Skip to content

Commit ea61fa8

Browse files
committed
Add FV particle diffusion operator (#465)
Also makes field `SPATIAL_METHOD` in particle discretization mandatory
1 parent d7fe6b9 commit ea61fa8

14 files changed

+1319
-64
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ jobs:
224224
${BUILD_DIR}/test/testRunner [CI_sens22]
225225
${BUILD_DIR}/test/testRunner [CI_sens23]
226226
${BUILD_DIR}/test/testRunner [CI_sens24]
227+
${BUILD_DIR}/test/testRunner [CI_sens25]
227228
- name: Run CI test set III - crystallization
228229
run: |
229230
set -e

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
${BUILD_DIR}/test/testRunner [CI_sens22]
8888
${BUILD_DIR}/test/testRunner [CI_sens23]
8989
${BUILD_DIR}/test/testRunner [CI_sens24]
90+
${BUILD_DIR}/test/testRunner [CI_sens25]
9091
- name: Run CI test set III - crystallization
9192
run: |
9293
${BUILD_DIR}/test/testRunner [CI_cry1]

src/libcadet/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ if (ENABLE_DG)
221221
${CMAKE_SOURCE_DIR}/src/libcadet/model/particle/HomogeneousParticle.cpp
222222
${CMAKE_SOURCE_DIR}/src/libcadet/model/parts/ParticleDiffusionOperatorBase.cpp
223223
${CMAKE_SOURCE_DIR}/src/libcadet/model/parts/ParticleDiffusionOperatorDG.cpp
224+
${CMAKE_SOURCE_DIR}/src/libcadet/model/parts/ParticleDiffusionOperatorFV.cpp
224225
${CMAKE_SOURCE_DIR}/src/libcadet/model/LumpedRateModelWithoutPoresDG.cpp
225226
${CMAKE_SOURCE_DIR}/src/libcadet/model/ColumnModel1D.cpp
226227
)

src/libcadet/model/particle/GeneralRateParticle.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "model/particle/GeneralRateParticle.hpp"
1414
#include "model/parts/ParticleDiffusionOperatorDG.hpp"
15+
#include "model/parts/ParticleDiffusionOperatorFV.hpp"
1516

1617
#include "cadet/Exceptions.hpp"
1718
#include "BindingModelFactory.hpp"
@@ -115,16 +116,13 @@ namespace model
115116

116117
paramProvider.pushScope("discretization");
117118

118-
if (paramProvider.exists("SPATIAL_METHOD"))
119-
{
120-
const std::string parSpatialMethod = paramProvider.getString("SPATIAL_METHOD");
121-
if (parSpatialMethod != "DG")
122-
throw InvalidParameterException("Unsupported SPATIAL_METHOD '" + parSpatialMethod + "' for GeneralRateParticle. Only 'DG' is supported for now.");
123-
119+
const std::string parSpatialMethod = paramProvider.getString("SPATIAL_METHOD");
120+
if (parSpatialMethod == "DG")
124121
_parDiffOp = new parts::ParticleDiffusionOperatorDG();
125-
}
122+
else if (parSpatialMethod == "FV")
123+
_parDiffOp = new parts::ParticleDiffusionOperatorFV();
126124
else
127-
_parDiffOp = new parts::ParticleDiffusionOperatorDG();
125+
throw InvalidParameterException("Unsupported SPATIAL_METHOD '" + parSpatialMethod + "' for GeneralRateParticle. Only 'DG' and 'FV' are supported.");
128126

129127
paramProvider.popScope();
130128

@@ -330,7 +328,7 @@ namespace model
330328
// Add flux to column void / bulk volume
331329
for (unsigned int comp = 0; comp < _nComp; ++comp)
332330
{
333-
// + 1/Beta_c * (surfaceToVolumeRatio_{p,j}) * d_j * (k_f * [c_l - c_p])
331+
// + 1/Beta^c * (surfaceToVolumeRatio^p_j) * d_j * (k_f * [c^b - c^p])
334332
resBulk[comp] += static_cast<ParamType>(filmDiff[comp]) * jacCF_val * static_cast<ParamType>(packing.parTypeVolFrac) * (yBulk[comp] - yPar[(nDiscPoints() - 1) * stridePoint() + comp]);
335333
}
336334
}

src/libcadet/model/parts/ParticleDiffusionOperatorDG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,7 +1610,7 @@ namespace parts
16101610
jacCl[0] += static_cast<double>(filmDiff[comp]) * (1.0 - colPorosity) / colPorosity
16111611
* _parGeomSurfToVol / static_cast<double>(_parRadius)
16121612
* static_cast<double>(parTypeVolFrac[_parTypeIdx + blk * nParType]);
1613-
// add Cl on Cp entries (added since these entries are also touched by bulk jacobian)
1613+
// add Cl on Cp entries
16141614
// row: already at bulk phase. already at current node and component.
16151615
// col: go to current particle phase entry.
16161616
jacCl[jacCp.row() - jacCl.row()] = -static_cast<double>(filmDiff[comp]) * (1.0 - colPorosity) / colPorosity
@@ -1622,7 +1622,7 @@ namespace parts
16221622
for (int node = _parPolyDeg; node >= 0; node--, jacCp -= strideParNode()) {
16231623
// row: already at particle. Already at current node and liquid state.
16241624
// col: original entry at outer node.
1625-
if (!outliersOnly) // Cp on Cb
1625+
if (!outliersOnly) // Cp on Cp
16261626
jacCp[entry - jacCp.row()]
16271627
+= static_cast<double>(filmDiff[comp]) * 2.0 / static_cast<double>(_deltaR[0]) * _parInvMM[_nParElem - 1](node, _nParNode - 1) * exIntLiftContribution / static_cast<double>(_parPorosity) / static_cast<double>(_poreAccessFactor[comp]);
16281628
// row: already at particle. Already at current node and liquid state.

src/libcadet/model/parts/ParticleDiffusionOperatorDG.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ namespace parts
200200

201201
/* DG specific operators */
202202

203-
active* _deltaR; //!< equidistant particle element spacing
203+
active* _deltaR; //!< particle element spacing
204204
Eigen::VectorXd _parNodes; //!< Array with positions of nodes in radial reference element for each particle
205205
Eigen::MatrixXd _parPolyDerM; //!< Array with polynomial derivative Matrix for each particle
206206
Eigen::MatrixXd* _minus_InvMM_ST; //!< equals minus inverse mass matrix times transposed stiffness matrix.

0 commit comments

Comments
 (0)