@@ -167,7 +167,6 @@ namespace reaction
167
167
168
168
return 0 ;
169
169
}
170
-
171
170
void extendModelWithDynamicReactions (cadet::JsonParameterProvider& jpp, UnitOpIdx unit, bool bulk, bool particle, bool particleModifiers)
172
171
{
173
172
auto gs = util::makeModelGroupScope (jpp, unit);
@@ -179,10 +178,12 @@ namespace reaction
179
178
180
179
if (!isLRM && bulk)
181
180
{
182
- char const * const scopeName = " " ;
181
+ char const * const scopeName = " liquid_reaction_000 " ;
183
182
jpp.addScope (scopeName);
184
183
auto gs2 = util::makeGroupScope (jpp, scopeName);
185
184
185
+ jpp.set (" TYPE" , " MASS_ACTION_LAW" );
186
+
186
187
const int nReactions = 4 ;
187
188
188
189
std::vector<double > stoichMat (nReactions * nComp, 0.0 );
@@ -204,27 +205,27 @@ namespace reaction
204
205
jpp.set (" MAL_KBWD" , rateBwd);
205
206
}
206
207
208
+ if (!jpp.exists (" NPARTYPE" ))
209
+ return ;
210
+
211
+ const int nParType = jpp.getInt (" NPARTYPE" );
212
+
207
213
if ((!isLRM && particle) || (isLRM && bulk))
208
214
{
209
215
const int nReactions = 3 ;
210
216
211
217
for (int i = 0 ; i < nParType; ++i)
212
218
{
213
- const int nBoundParType = std::accumulate (nBound.begin () + i * nComp, nBound.begin () + (i + 1 ) * nComp, 0 );
219
+
220
+ jpp.pushScope (" particle_type_" + std::string (3 - std::to_string (i).length (), ' 0' ) + std::to_string (i)); // particle_type_xxx
214
221
215
- std::ostringstream oss;
216
- if (isLRM)
217
- oss << " reaction" ;
218
- else
219
- oss << " particle_type_" << std::setfill (' 0' ) << std::setw (3 ) << std::setprecision (0 ) << i;
220
-
221
- jpp.addScope (oss.str ());
222
- auto gs2 = util::makeGroupScope (jpp, oss.str ());
222
+ std::vector<int > nBound = jpp.getIntArray (" NBOUND" );
223
+ const int nTotalBound = std::accumulate (nBound.begin (), nBound.end (), 0 );
223
224
224
225
int nReac = 1 ;
225
226
jpp.set (" NREAC_CROSS_PHASE" , nReac);
226
227
227
- jpp.addScope (" cross_phase_reaction_000" );
228
+ jpp.addScope (" cross_phase_reaction_000" ); // particle_type_xxx//cross_phase_reaction_000
228
229
auto gs3 = util::makeGroupScope (jpp, " cross_phase_reaction_000" );
229
230
230
231
jpp.set (" TYPE" , " MASS_ACTION_LAW_CROSS_PHASE" );
@@ -235,9 +236,9 @@ namespace reaction
235
236
std::vector<double > rateFwdLiquid (nReactions, 0.0 );
236
237
std::vector<double > rateBwdLiquid (nReactions, 0.0 );
237
238
238
- std::vector<double > stoichMatSolid (nReactions * nBoundParType , 0.0 );
239
- std::vector<double > expFwdSolid (nReactions * nBoundParType , 0.0 );
240
- std::vector<double > expBwdSolid (nReactions * nBoundParType , 0.0 );
239
+ std::vector<double > stoichMatSolid (nReactions * nTotalBound , 0.0 );
240
+ std::vector<double > expFwdSolid (nReactions * nTotalBound , 0.0 );
241
+ std::vector<double > expBwdSolid (nReactions * nTotalBound , 0.0 );
241
242
std::vector<double > rateFwdSolid (nReactions, 0.0 );
242
243
std::vector<double > rateBwdSolid (nReactions, 0.0 );
243
244
@@ -267,8 +268,8 @@ namespace reaction
267
268
268
269
if (particleModifiers)
269
270
{
270
- std::vector<double > expFwdLiquidModSolid (nReactions * nBoundParType , 0.0 );
271
- std::vector<double > expBwdLiquidModSolid (nReactions * nBoundParType , 0.0 );
271
+ std::vector<double > expFwdLiquidModSolid (nReactions * nTotalBound , 0.0 );
272
+ std::vector<double > expBwdLiquidModSolid (nReactions * nTotalBound , 0.0 );
272
273
std::vector<double > expFwdSolidModLiquid (nReactions * nComp, 0.0 );
273
274
std::vector<double > expBwdSolidModLiquid (nReactions * nComp, 0.0 );
274
275
@@ -282,6 +283,9 @@ namespace reaction
282
283
jpp.set (" MAL_EXPONENTS_SOLID_FWD_MODLIQUID" , expFwdSolidModLiquid);
283
284
jpp.set (" MAL_EXPONENTS_SOLID_BWD_MODLIQUID" , expBwdSolidModLiquid);
284
285
}
286
+
287
+ if (!isCSTR)
288
+ jpp.popScope ();
285
289
}
286
290
}
287
291
}
0 commit comments