@@ -375,22 +375,6 @@ bool GeneralRateModelDG::configure(IParameterProvider& paramProvider)
375
375
}
376
376
377
377
// Read vectorial parameters (which may also be section dependent; transport)
378
- _filmDiffusionMode = readAndRegisterMultiplexCompTypeSecParam (paramProvider, _parameters, _filmDiffusion, " FILM_DIFFUSION" , _disc.nParType , _disc.nComp , _unitOpIdx);
379
-
380
- if ((_filmDiffusion.size () < _disc.nComp * _disc.nParType ) || (_filmDiffusion.size () % (_disc.nComp * _disc.nParType ) != 0 ))
381
- throw InvalidParameterException (" Number of elements in field FILM_DIFFUSION is not a positive multiple of NCOMP * NPARTYPE (" + std::to_string (_disc.nComp * _disc.nParType ) + " )" );
382
-
383
- if (paramProvider.exists (" PORE_ACCESSIBILITY" ))
384
- _poreAccessFactorMode = readAndRegisterMultiplexCompTypeSecParam (paramProvider, _parameters, _poreAccessFactor, " PORE_ACCESSIBILITY" , _disc.nParType , _disc.nComp , _unitOpIdx);
385
- else
386
- {
387
- _poreAccessFactorMode = MultiplexMode::ComponentType;
388
- _poreAccessFactor = std::vector<cadet::active>(_disc.nComp * _disc.nParType , 1.0 );
389
- }
390
-
391
- if (_disc.nComp * _disc.nParType != _poreAccessFactor.size ())
392
- throw InvalidParameterException (" Number of elements in field PORE_ACCESSIBILITY differs from NCOMP * NPARTYPE (" + std::to_string (_disc.nComp * _disc.nParType ) + " )" );
393
-
394
378
// Add parameters to map
395
379
_parameters[makeParamId (hashString (" COL_POROSITY" ), _unitOpIdx, CompIndep, ParTypeIndep, BoundStateIndep, ReactionIndep, SectionIndep)] = &_colPorosity;
396
380
@@ -552,7 +536,7 @@ void GeneralRateModelDG::notifyDiscontinuousSectionTransition(double t, unsigned
552
536
553
537
for (int parType = 0 ; parType < _disc.nParType ; parType++)
554
538
{
555
- _particle[parType].notifyDiscontinuousSectionTransition (t, secIdx, getSectionDependentSlice (_filmDiffusion, _disc. nComp * _disc. nParType , secIdx), &_poreAccessFactor[ 0 ] );
539
+ _particle[parType].notifyDiscontinuousSectionTransition (t, secIdx);
556
540
}
557
541
558
542
_disc.curSection = secIdx;
@@ -886,14 +870,20 @@ int GeneralRateModelDG::residualImpl(double t, unsigned int secIdx, StateType co
886
870
const unsigned int colNode = pblk % _disc.nPoints ;
887
871
888
872
linalg::BandedEigenSparseRowIterator jacIt (_globalJac, idxr.offsetCp (ParticleTypeIndex{ parType }, ParticleIndex{ colNode }));
889
- ColumnPosition colPos{ _convDispOp.relativeCoordinate (colNode), 0.0 , 0.0 }; // Relative position of current node - needed in externally dependent adsorption kinetic
873
+ model::columnPackingParameters packing
874
+ {
875
+ _parTypeVolFrac[parType + _disc.nParType * colNode],
876
+ _colPorosity,
877
+ ColumnPosition{ _convDispOp.relativeCoordinate (colNode), 0.0 , 0.0 }
878
+ };
890
879
891
880
_particle[parType].residual (t, secIdx,
892
881
y + idxr.offsetCp (ParticleTypeIndex{ parType }, ParticleIndex{ colNode }),
893
882
y + idxr.offsetC () + colNode * idxr.strideColNode (),
894
883
yDot ? yDot + idxr.offsetCp (ParticleTypeIndex{ parType }, ParticleIndex{ colNode }) : nullptr ,
895
884
res ? res + idxr.offsetCp (ParticleTypeIndex{ parType }, ParticleIndex{ colNode }) : nullptr ,
896
- colPos, jacIt, tlmAlloc,
885
+ res ? res + idxr.offsetC () + colNode * idxr.strideColNode () : nullptr ,
886
+ packing, jacIt, tlmAlloc,
897
887
typename cadet::ParamSens<ParamType>::enabled ()
898
888
);
899
889
}
@@ -903,8 +893,6 @@ int GeneralRateModelDG::residualImpl(double t, unsigned int secIdx, StateType co
903
893
904
894
BENCH_STOP (_timerResidualPar);
905
895
906
- residualFlux<StateType, ResidualType, ParamType>(t, secIdx, y, yDot, res);
907
-
908
896
// Handle inlet DOFs, which are simply copied to the residual
909
897
for (unsigned int i = 0 ; i < _disc.nComp ; ++i)
910
898
{
@@ -964,51 +952,6 @@ int GeneralRateModelDG::residualBulk(double t, unsigned int secIdx, StateType co
964
952
return 0 ;
965
953
}
966
954
967
- template <typename StateType, typename ResidualType, typename ParamType>
968
- int GeneralRateModelDG::residualFlux (double t, unsigned int secIdx, StateType const * yBase, double const * yDotBase, ResidualType* resBase)
969
- {
970
- Indexer idxr (_disc);
971
-
972
- const ParamType invBetaC = 1.0 / static_cast <ParamType>(_colPorosity) - 1.0 ;
973
-
974
- // Get offsets
975
- ResidualType* const resCol = resBase + idxr.offsetC ();
976
- StateType const * const yCol = yBase + idxr.offsetC ();
977
-
978
- for (unsigned int type = 0 ; type < _disc.nParType ; ++type)
979
- {
980
- ResidualType* const resParType = resBase + idxr.offsetCp (ParticleTypeIndex{type});
981
- StateType const * const yParType = yBase + idxr.offsetCp (ParticleTypeIndex{type});
982
-
983
- const ParamType epsP = static_cast <ParamType>(_particle[type].getPorosity ());
984
-
985
- // Ordering of diffusion:
986
- // sec0type0comp0, sec0type0comp1, sec0type0comp2, sec0type1comp0, sec0type1comp1, sec0type1comp2,
987
- // sec1type0comp0, sec1type0comp1, sec1type0comp2, sec1type1comp0, sec1type1comp1, sec1type1comp2, ...
988
- active const * const filmDiff = getSectionDependentSlice (_filmDiffusion, _disc.nComp * _disc.nParType , secIdx) + type * _disc.nComp ;
989
-
990
- const ParamType surfaceToVolumeRatio = static_cast <ParamType>(_particle[type].surfaceToVolumeRatio ());
991
-
992
- const ParamType jacCF_val = invBetaC * surfaceToVolumeRatio;
993
- const ParamType jacPF_val = -1.0 / epsP;
994
-
995
- // Add flux to column void / bulk volume
996
- for (unsigned int i = 0 ; i < _disc.nPoints * _disc.nComp ; ++i)
997
- {
998
- const unsigned int colNode = i / _disc.nComp ;
999
- const unsigned int comp = i - colNode * _disc.nComp ;
1000
- // + 1/Beta_c * (surfaceToVolumeRatio_{p,j}) * d_j * (k_f * [c_l - c_p])
1001
- resCol[i] += static_cast <ParamType>(filmDiff[comp]) * jacCF_val * static_cast <ParamType>(_parTypeVolFrac[type + colNode * _disc.nParType ])
1002
- * (yCol[i] - yParType[colNode * idxr.strideParBlock (type) + (_disc.nParPoints [type] - 1 ) * idxr.strideParNode (type) + comp]);
1003
- }
1004
-
1005
- // Bead boundary condition is computed in particle residual.
1006
-
1007
- }
1008
-
1009
- return 0 ;
1010
- }
1011
-
1012
955
parts::cell::CellParameters GeneralRateModelDG::makeCellResidualParams (unsigned int parType, int const * qsReaction) const
1013
956
{
1014
957
return parts::cell::CellParameters
@@ -1019,7 +962,7 @@ parts::cell::CellParameters GeneralRateModelDG::makeCellResidualParams(unsigned
1019
962
_disc.strideBound [parType],
1020
963
qsReaction,
1021
964
_particle[parType].getPorosity (),
1022
- _poreAccessFactor. data () + _disc. nComp * parType ,
965
+ _particle[parType]. getPoreAccessfactor () ,
1023
966
_binding[parType],
1024
967
(_dynReaction[parType] && (_dynReaction[parType]->numReactionsCombined () > 0 )) ? _dynReaction[parType] : nullptr
1025
968
};
@@ -1214,10 +1157,6 @@ bool GeneralRateModelDG::setParameter(const ParameterId& pId, double value)
1214
1157
{
1215
1158
if (pId.unitOperation == _unitOpIdx)
1216
1159
{
1217
- if (multiplexCompTypeSecParameterValue (pId, hashString (" PORE_ACCESSIBILITY" ), _poreAccessFactorMode, _poreAccessFactor, _disc.nParType , _disc.nComp , value, nullptr ))
1218
- return true ;
1219
- if (multiplexCompTypeSecParameterValue (pId, hashString (" FILM_DIFFUSION" ), _filmDiffusionMode, _filmDiffusion, _disc.nParType , _disc.nComp , value, nullptr ))
1220
- return true ;
1221
1160
const int mpIc = multiplexInitialConditions (pId, value, false );
1222
1161
if (mpIc > 0 )
1223
1162
return true ;
@@ -1241,7 +1180,12 @@ bool GeneralRateModelDG::setParameter(const ParameterId& pId, double value)
1241
1180
for (int parType = 0 ; parType < _disc.nParType ; parType++)
1242
1181
{
1243
1182
if (_particle[parType].setParameter (pId, value))
1244
- return true ;
1183
+ { // continue loop for particle type independent parameters to set the respective parameter sensitivity in all particle types
1184
+ if ((pId.particleType != ParTypeIndep && parType == pId.particleType ) || (pId.particleType == ParTypeIndep && parType == _disc.nParType - 1 ))
1185
+ {
1186
+ return true ;
1187
+ }
1188
+ }
1245
1189
}
1246
1190
1247
1191
if (_convDispOp.setParameter (pId, value))
@@ -1273,7 +1217,12 @@ bool GeneralRateModelDG::setParameter(const ParameterId& pId, int value)
1273
1217
for (int parType = 0 ; parType < _disc.nParType ; parType++)
1274
1218
{
1275
1219
if (_particle[parType].setParameter (pId, value))
1276
- return true ;
1220
+ { // continue loop for particle type independent parameters to set the respective parameter sensitivity in all particle types
1221
+ if ((pId.particleType != ParTypeIndep && parType == pId.particleType ) || (pId.particleType == ParTypeIndep && parType == _disc.nParType - 1 ))
1222
+ {
1223
+ return true ;
1224
+ }
1225
+ }
1277
1226
}
1278
1227
1279
1228
if (pId.unitOperation == _unitOpIdx)
@@ -1293,7 +1242,12 @@ bool GeneralRateModelDG::setParameter(const ParameterId& pId, bool value)
1293
1242
for (int parType = 0 ; parType < _disc.nParType ; parType++)
1294
1243
{
1295
1244
if (_particle[parType].setParameter (pId, value))
1296
- return true ;
1245
+ { // continue loop for particle type independent parameters to set the respective parameter sensitivity in all particle types
1246
+ if ((pId.particleType != ParTypeIndep && parType == pId.particleType ) || (pId.particleType == ParTypeIndep && parType == _disc.nParType - 1 ))
1247
+ {
1248
+ return true ;
1249
+ }
1250
+ }
1297
1251
}
1298
1252
1299
1253
if (pId.unitOperation == _unitOpIdx)
@@ -1309,10 +1263,6 @@ void GeneralRateModelDG::setSensitiveParameterValue(const ParameterId& pId, doub
1309
1263
{
1310
1264
if (pId.unitOperation == _unitOpIdx)
1311
1265
{
1312
- if (multiplexCompTypeSecParameterValue (pId, hashString (" PORE_ACCESSIBILITY" ), _poreAccessFactorMode, _poreAccessFactor, _disc.nParType , _disc.nComp , value, &_sensParams))
1313
- return ;
1314
- if (multiplexCompTypeSecParameterValue (pId, hashString (" FILM_DIFFUSION" ), _filmDiffusionMode, _filmDiffusion, _disc.nParType , _disc.nComp , value, &_sensParams))
1315
- return ;
1316
1266
if (multiplexInitialConditions (pId, value, true ) != 0 )
1317
1267
return ;
1318
1268
@@ -1336,7 +1286,12 @@ void GeneralRateModelDG::setSensitiveParameterValue(const ParameterId& pId, doub
1336
1286
for (int parType = 0 ; parType < _disc.nParType ; parType++)
1337
1287
{
1338
1288
if (_particle[parType].setSensitiveParameterValue (_sensParams, pId, value))
1339
- return ;
1289
+ { // continue loop for particle type independent parameters to set the respective parameter sensitivity in all particle types
1290
+ if ((pId.particleType != ParTypeIndep && parType == pId.particleType ) || (pId.particleType == ParTypeIndep && parType == _disc.nParType - 1 ))
1291
+ {
1292
+ return ;
1293
+ }
1294
+ }
1340
1295
}
1341
1296
1342
1297
if (_convDispOp.setSensitiveParameterValue (_sensParams, pId, value))
@@ -1362,18 +1317,6 @@ bool GeneralRateModelDG::setSensitiveParameter(const ParameterId& pId, unsigned
1362
1317
{
1363
1318
if (pId.unitOperation == _unitOpIdx)
1364
1319
{
1365
- if (multiplexCompTypeSecParameterAD (pId, hashString (" PORE_ACCESSIBILITY" ), _poreAccessFactorMode, _poreAccessFactor, _disc.nParType , _disc.nComp , adDirection, adValue, _sensParams))
1366
- {
1367
- LOG (Debug) << " Found parameter " << pId << " : Dir " << adDirection << " is set to " << adValue;
1368
- return true ;
1369
- }
1370
-
1371
- if (multiplexCompTypeSecParameterAD (pId, hashString (" FILM_DIFFUSION" ), _filmDiffusionMode, _filmDiffusion, _disc.nParType , _disc.nComp , adDirection, adValue, _sensParams))
1372
- {
1373
- LOG (Debug) << " Found parameter " << pId << " : Dir " << adDirection << " is set to " << adValue;
1374
- return true ;
1375
- }
1376
-
1377
1320
const int mpIc = multiplexInitialConditions (pId, adDirection, adValue);
1378
1321
if (mpIc > 0 )
1379
1322
{
@@ -1405,6 +1348,7 @@ bool GeneralRateModelDG::setSensitiveParameter(const ParameterId& pId, unsigned
1405
1348
{
1406
1349
if (_particle[parType].setSensitiveParameter (_sensParams, pId, adDirection, adValue))
1407
1350
{
1351
+ // continue loop for particle type independent parameters to set the respective parameter sensitivity in all particle types
1408
1352
if ((pId.particleType != ParTypeIndep && parType == pId.particleType ) || (pId.particleType == ParTypeIndep && parType == _disc.nParType - 1 ))
1409
1353
{
1410
1354
LOG (Debug) << " Found parameter " << pId << " : Dir " << adDirection << " is set to " << adValue;
0 commit comments