Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Split out to have ii infusions taken care of with DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Jan 18, 2024
1 parent 868046f commit 6316844
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 160 deletions.
54 changes: 47 additions & 7 deletions src/comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,61 @@ void solveSSinf_lin(double *yp,
lin_context_c_t *lin = (lin_context_c_t*)(ctx);
int linCmt = ind->linCmt;
rx_solve *rx=(&rx_global);
int central = 0;
if (rx->linKa) {
// has depot
if (isSameTime(lin->rate[0], 0.0)) {
// lin->rate[0]; assume central infusion
central = 1;
yp[0] = 0.0;
lin->rate[0] = 0.0;
} else {
// depot infusion
switch(rx->linNcmt) {
case 3:
comp3ssInfDepot(yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21),
&(lin->k13), &(lin->k31));
break;
case 2:
comp2ssInfDepot(yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21));
break;
case 1:
comp1ssInfDepot(yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10));
break;
}
double lag = ind->linCmtLag[0];
if (lag + *dur < *curIi) {
lin->rate[0] = 0.0;
}
lin->rate[1] = 0.0;
return;
}
}
// central
switch(rx->linNcmt) {
case 3:
comp3ssInf(ind, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21),
&(lin->k13), &(lin->k31));
comp3ssInfCentral(&central, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21),
&(lin->k13), &(lin->k31));
break;
case 2:
comp2ssInf(ind, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21));
comp2ssInfCentral(&central, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10), &(lin->k12), &(lin->k21));
break;
case 1:
comp1ssInf(ind, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10));
comp1ssInfCentral(&central, yp + linCmt, dur, curIi, lin->rate,
&(lin->ka), &(lin->k10));
break;
}
double lag = ind->linCmtLag[central];
// lag + dur < ii
if (lag + *dur < *curIi) {
// should be off
lin->rate[central] = 0.0;
}
}

void solveSSinf8_lin(double *yp,
Expand Down
Loading

0 comments on commit 6316844

Please sign in to comment.