Skip to content

Commit 28ce635

Browse files
committed
Handle 0 linear repair rate
Somehow I missed this possibility...
1 parent 6338ccc commit 28ce635

File tree

1 file changed

+27
-41
lines changed

1 file changed

+27
-41
lines changed

addons/PhysiPKPD/src/PhysiPKPD_PD.cpp

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -299,28 +299,40 @@ void setup_pd_model_auc(Pharmacodynamics_Model *pPD, pugi::xml_node substrate_no
299299
<< std::endl;
300300
exit(-1);
301301
}
302+
double metabolism_rate = substrate_node.child("metabolism_rate").text().as_double();
303+
double linear_repair_rate = substrate_node.child("linear_repair_rate").text().as_double();
304+
double constant_repair_rate = substrate_node.child("constant_repair_rate").text().as_double();
302305

303306
// internalized drug amount (or concentration) simply decreases as A(dt) = A0 * exp(-metabolism_rate * dt);
304-
pPD->metabolism_reduction_factor = exp(-substrate_node.child("metabolism_rate").text().as_double() * pPD->dt);
307+
pPD->metabolism_reduction_factor = exp(-metabolism_rate * pPD->dt);
305308

306-
// Damage (D) follows D' = A - linear_rate * D - constant_rate ==> D(dt) = d_00 + d_10 * A0 + d_01 * D0; defining d_00, d_10, and d_01 here
307-
pPD->initial_damage_coefficient = exp(-substrate_node.child("linear_repair_rate").text().as_double() * pPD->dt); // d_01
308-
309-
pPD->damage_constant = substrate_node.child("constant_repair_rate").text().as_double();
310-
pPD->damage_constant /= substrate_node.child("linear_repair_rate").text().as_double();
311-
pPD->damage_constant *= pPD->initial_damage_coefficient - 1; // d_00
312-
313-
// if the metabolism and repair rates are equal, then the system has repeated eigenvalues and the analytic solution is qualitatively different; notice the division by the difference of these rates in the first case
314-
if (substrate_node.child("metabolism_rate").text().as_double() != substrate_node.child("linear_repair_rate").text().as_double())
309+
if (linear_repair_rate == 0)
315310
{
316-
pPD->initial_substrate_coefficient = pPD->metabolism_reduction_factor;
317-
pPD->initial_substrate_coefficient -= pPD->initial_damage_coefficient; // d_10
318-
pPD->initial_substrate_coefficient /= substrate_node.child("linear_repair_rate").text().as_double() - substrate_node.child("metabolism_rate").text().as_double(); // this would be bad if these rates were equal!
311+
// Damage (D) follows D' = A - constant_rate ==> D(dt) = d_00 + d_10 * A0 + 1 * D0; defining d_00 and d_01 here
312+
pPD->damage_constant = -constant_repair_rate * pPD->dt; // d_00
313+
pPD->initial_substrate_coefficient = (1 - exp(-metabolism_rate * pPD->dt)) / metabolism_rate; // d_10
314+
pPD->initial_damage_coefficient = 1.0; // d_01
319315
}
320316
else
321317
{
322-
pPD->initial_substrate_coefficient = pPD->dt;
323-
pPD->initial_substrate_coefficient *= pPD->initial_damage_coefficient; // d_10
318+
// Damage (D) follows D' = A - linear_rate * D - constant_rate ==> D(dt) = d_00 + d_10 * A0 + d_01 * D0; defining d_00, d_10, and d_01 here
319+
pPD->initial_damage_coefficient = exp(-linear_repair_rate * pPD->dt); // d_01
320+
321+
pPD->damage_constant = constant_repair_rate;
322+
pPD->damage_constant /= linear_repair_rate;
323+
pPD->damage_constant *= pPD->initial_damage_coefficient - 1; // d_00
324+
325+
// if the metabolism and repair rates are equal, then the system has repeated eigenvalues and the analytic solution is qualitatively different; notice the division by the difference of these rates in the first case
326+
if (metabolism_rate != linear_repair_rate)
327+
{
328+
pPD->initial_substrate_coefficient = pPD->metabolism_reduction_factor;
329+
pPD->initial_substrate_coefficient -= pPD->initial_damage_coefficient; // d_10
330+
pPD->initial_substrate_coefficient /= linear_repair_rate - metabolism_rate; // this would be bad if these rates were equal!
331+
}
332+
else
333+
{
334+
pPD->initial_substrate_coefficient = pPD->initial_damage_coefficient * pPD->dt; // d_10
335+
}
324336
}
325337
}
326338
}
@@ -356,32 +368,6 @@ void single_pd_model(Pharmacodynamics_Model *pPD, double current_time)
356368
<< "\tWe anticipate the main reason to not use precomputation is for heterogeneity of PD parameters within a cell_definition." << std::endl
357369
<< "\tWe need to discuss how best to move PD parameters into custom_data for this to work, we think." << std::endl;
358370
exit(-1);
359-
/*
360-
double metabolism_reduction_factor = exp(-pC->custom_data[pPD->substrate_name + "_metabolism_rate"] * dt);
361-
double initial_damage_coefficient = exp(-pC->custom_data[pPD->substrate_name + "_repair_rate_linear"] * dt);
362-
double damage_constant = pC->custom_data[pPD->substrate_name + "_repair_rate_constant"] / pC->custom_data[pPD->substrate_name + "_repair_rate_linear"] * (initial_damage_coefficient - 1); // +d_00...
363-
double initial_substrate_coefficient;
364-
if (pC->custom_data[pPD->substrate_name + "_metabolism_rate"] != pC->custom_data[pPD->substrate_name + "_repair_rate_linear"]) // +d_10*A0 (but the analytic form depends on whether the repair and metabolism rates are equal)
365-
{
366-
initial_substrate_coefficient = (metabolism_reduction_factor - initial_damage_coefficient) / (pC->custom_data[pPD->substrate_name + "_repair_rate_linear"] - pC->custom_data[pPD->substrate_name + "_metabolism_rate"]);
367-
}
368-
else
369-
{
370-
initial_substrate_coefficient = dt * metabolism_reduction_factor;
371-
}
372-
if (!pPD->use_internalized_amount)
373-
{
374-
initial_substrate_coefficient /= pC->phenotype.volume.total; // use concentration of internalized substrate to cause damage rather than internalized amount
375-
}
376-
pC->custom_data[pPD->damage_index] *= initial_damage_coefficient; // D(dt) = d_01 * D(0)...
377-
pC->custom_data[pPD->damage_index] += damage_constant; // + d_00 ...
378-
pC->custom_data[pPD->damage_index] += initial_substrate_coefficient * p.molecular.internalized_total_substrates[pPD->substrate_index]; // + d_10*A(0) or + d_10*C(0) if using concentration
379-
if (pC->custom_data[pPD->damage_index] <= 0)
380-
{
381-
pC->custom_data[pPD->damage_index] = 0; // very likely that cells will end up with negative damage without this because the repair rate is assumed constant (not proportional to amount of damage)
382-
}
383-
p.molecular.internalized_total_substrates[pPD->substrate_index] *= metabolism_reduction_factor;
384-
*/
385371
}
386372
else
387373
{

0 commit comments

Comments
 (0)