Skip to content

Commit 090107a

Browse files
committed
fixup! Add multi-substrate Michaelis Menten
1 parent e5c748a commit 090107a

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/libcadet/model/reaction/MichaelisMentenReaction.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
217217
for (int idxSubstrateReaction_r : idxSubstrateReaction_r)
218218
{
219219
if(std::find(idxInhibitorReaction_r.begin(), idxInhibitorReaction_r.end(), idxSubstrateReaction_r) != idxInhibitorReaction_r.end())
220-
throw InvalidParameterException("Inhibitor is also substrate in reaction " + std::to_string(r) + "this is not supportet yet");
220+
throw InvalidParameterException("Michaelis-Menten reaction: Inhibitor is also substrate in reaction " + std::to_string(r) + "this is not supported yet");
221221
}
222222
}
223223

@@ -322,7 +322,7 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
322322

323323
double sFlux = y[s] / ((kMM_rs + y[s]) * (1 + inhSum));
324324
flux *= sFlux;
325-
// save flux and inhibitor sum for each substrat
325+
// save flux and inhibitor sum for each substrate
326326
substratFlux[sIdx] = sFlux;
327327
inhSumOfSub[sIdx] = inhSum;
328328
}
@@ -360,13 +360,13 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
360360

361361
double dvdy = 0.0;
362362

363-
// case 1: comp is a substrat and not an inhibitor
363+
// case 1: comp is a substrate and not an inhibitor
364364
// dvds = vmax * prod_i!=s (y[i]/(kMM_rs + y[i])*(1+inhSum)) * df/ds
365365
// df/ds = ((kMM_rs + y[i])*(1+inhSum)) - y[i](1+inhSum) / ((kMM_rs + y[i])*(1+inhSum))^2
366366
// = (kMM_rs) / ((kMM_rs + y[i])*(1+inhSum)^2)
367367
if (isSubstrate && !isInhibitor)
368368
{
369-
int s = comp; // comp is a substrat
369+
int s = comp; // comp is a substrate
370370
double kMM_rs = static_cast<double>(p->kMM[r]);
371371
if (!_oldInterface)
372372
kMM_rs = static_cast<double>(p->kMM[_nComp * r + s]);
@@ -381,7 +381,7 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
381381

382382
}
383383

384-
//case 2: comp is a inhibitor and not a substrat
384+
//case 2: comp is a inhibitor and not a substrate
385385
// dvdI = vmax * sum_L(prod_!i=l (y[i]/(kMM_rs + y[i])*(1+inhSum)) * df/dI
386386
// L is the set of all substrates which are inhibited by I
387387
// df/dI = - ((kMM_rs+y[s])/kI_ri)/((kMM_rs + y[s])*(1+inhSum))^2
@@ -396,8 +396,8 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
396396
int s = _idxSubstrate[r][sIdx];
397397
double kMM_rs = static_cast<double>(p->kMM[r]);
398398
if (!_oldInterface)
399-
// kMM_rs = kMM[r][s]
400399
kMM_rs = static_cast<double>(p->kMM[_nComp * r + s]);
400+
401401
double inhSum = inhSumOfSub[sIdx];
402402

403403
double denom = (kMM_rs + y[s])*(1+inhSum)* (1 + inhSum);
@@ -406,12 +406,11 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
406406

407407
dvdy += factor * dinhFluxdi;
408408
}
409-
410409
}
411410

412411
if (isInhibitor && isSubstrate)
413412
{
414-
throw(InvalidParameterException("Inhibitor and substrat in the same reaction is not supported yet"));
413+
throw(InvalidParameterException("Michaelis-Menten reaction: Inhibitor and substrate in the same reaction is not supported yet"));
415414
}
416415

417416
if (std::abs(dvdy) < 1e-18)
@@ -424,9 +423,7 @@ class MichaelisMentenReactionBase : public DynamicReactionModelBase
424423
const double colFactor = static_cast<double>(_stoichiometryBulk.native(row, r)) * factor;
425424
curJac[comp - static_cast<int>(row)] += colFactor * dvdy;
426425
}
427-
428426
}
429-
430427
}
431428
}
432429

test/ReactionModels.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ TEST_CASE("MichaelisMenten kinetic and specific mass action law micro-kinetics y
8383
const std::string& configFilePath1 = std::string("/data/configuration_CSTR_MichaelisMenten_benchmark1.json");
8484
const std::string& configFilePath2 = std::string("/data/configuration_CSTR_MicroKineticsSMA_benchmark1.json");
8585

86-
const double absTol = 1e-6;
86+
const double absTol = 1e-12;
8787
const double relTol = 5e-4;
8888

8989
cadet::test::reaction::testMichaelisMentenToSMAMicroKinetic(configFilePath1, configFilePath2, absTol, relTol);
@@ -100,7 +100,7 @@ TEST_CASE("MichaelisMenten kinetic with two inhibitors and specific mass action
100100
cadet::test::reaction::testMichaelisMentenToSMAInhibitionMicroKinetic(configFilePath1, configFilePath2, absTol, relTol);
101101
}
102102

103-
TEST_CASE("MichaelisMenten kinetic and numerical reference with Crank-Nicolson yield same result", "[MichaelisMenten],[ReactionModel],[Simulation],[Reference],[CI]") // todo fails due to wrong size of km
103+
TEST_CASE("MichaelisMenten kinetic and numerical reference with Crank-Nicolson yield same result", "[MichaelisMenten],[ReactionModel],[Simulation],[Reference],[CI]")
104104
{
105105
const std::string& configFileRelPath = std::string("/data/configuration_CSTR_MichaelisMenten_benchmark2.json");
106106
const std::string& refFileRelPath = std::string("/data/ref_CSTR_MichaelisMenten_benchmark2.h5");
@@ -145,7 +145,7 @@ TEST_CASE("MichaelisMenten kinetic analytic Jacobian vs AD with inhibition", "[M
145145
);
146146
}
147147

148-
TEST_CASE("Multi Substrat MichaelisMenten kinetic analytic Jacobian vs AD with inhibition", "[MichaelisMenten],[ReactionModel],[Jacobian],[AD]")
148+
TEST_CASE("Multi Substrate MichaelisMenten kinetic analytic Jacobian vs AD with inhibition", "[MichaelisMenten],[ReactionModel],[Jacobian],[AD]")
149149
{
150150
const unsigned int nBound[] = { 1, 2, 1 };
151151
const double point[] = { 1.0, 2.0, 1.4, 2.1, 0.2, 1.1, 1.8 };

0 commit comments

Comments
 (0)