Generated Code

The following is c code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

/*
   There are a total of 2 entries in the algebraic variable array.
   There are a total of 9 entries in each of the rate and state variable arrays.
   There are a total of 38 entries in the constant variable array.
 */
/*
 * CONSTANTS[0] is BW in component main (kilogram).
 * CONSTANTS[1] is Qcc in component main (litre_per_hr_kg).
 * CONSTANTS[2] is Qliv in component main (dimensionless).
 * CONSTANTS[3] is Qfat in component main (dimensionless).
 * CONSTANTS[4] is Qbrain in component main (dimensionless).
 * CONSTANTS[5] is Qslow in component main (dimensionless).
 * CONSTANTS[20] is Qc in component main (litre_per_hr).
 * CONSTANTS[28] is Ql in component main (litre_per_hr).
 * CONSTANTS[33] is Qf in component main (litre_per_hr).
 * CONSTANTS[35] is Qbr in component main (litre_per_hr).
 * CONSTANTS[36] is Qs in component main (litre_per_hr).
 * CONSTANTS[37] is Qr in component main (litre_per_hr).
 * CONSTANTS[6] is Vblood in component main (dimensionless).
 * CONSTANTS[7] is Vbrain in component main (dimensionless).
 * CONSTANTS[8] is Vliver in component main (dimensionless).
 * CONSTANTS[21] is Vfat in component main (dimensionless).
 * CONSTANTS[9] is Vslow in component main (dimensionless).
 * CONSTANTS[29] is Vrap in component main (dimensionless).
 * CONSTANTS[30] is Vf in component main (litre).
 * CONSTANTS[22] is Vs in component main (litre).
 * CONSTANTS[23] is Vl in component main (litre).
 * CONSTANTS[34] is Vr in component main (litre).
 * CONSTANTS[24] is Vbr in component main (litre).
 * CONSTANTS[25] is Vb in component main (litre).
 * CONSTANTS[31] is Vven in component main (litre).
 * CONSTANTS[32] is Vart in component main (litre).
 * CONSTANTS[10] is Pfat_bl in component main (dimensionless).
 * CONSTANTS[11] is Pslow_bl in component main (dimensionless).
 * CONSTANTS[12] is Pliv_bl in component main (dimensionless).
 * CONSTANTS[13] is Prapid_bl in component main (dimensionless).
 * CONSTANTS[14] is Pbrain_bl in component main (dimensionless).
 * CONSTANTS[15] is dose in component main (mg_per_kg).
 * CONSTANTS[16] is F in component main (dimensionless).
 * CONSTANTS[26] is D0 in component main (mg).
 * CONSTANTS[17] is Ka in component main (per_hr).
 * CONSTANTS[18] is Kfc in component main (per_hr).
 * CONSTANTS[27] is KF in component main (per_hr_kg).
 * VOI is t in component main (hr).
 * STATES[0] is A_fat in component main (mg).
 * STATES[1] is A_slow in component main (mg).
 * STATES[2] is A_liv in component main (mg).
 * STATES[3] is A_rapid in component main (mg).
 * STATES[4] is A_brain in component main (mg).
 * CONSTANTS[19] is A_blood in component main (mg).
 * STATES[5] is A_stomach in component main (mg).
 * STATES[6] is A_ven in component main (mg).
 * STATES[7] is A_art in component main (mg).
 * STATES[8] is A_liv_CL in component main (mg).
 * ALGEBRAIC[0] is C_art in component main (mg_per_litre).
 * ALGEBRAIC[1] is C_brain in component main (mg_per_litre).
 * RATES[6] is d/dt A_ven in component main (mg).
 * RATES[7] is d/dt A_art in component main (mg).
 * RATES[0] is d/dt A_fat in component main (mg).
 * RATES[1] is d/dt A_slow in component main (mg).
 * RATES[4] is d/dt A_brain in component main (mg).
 * RATES[3] is d/dt A_rapid in component main (mg).
 * RATES[5] is d/dt A_stomach in component main (mg).
 * RATES[2] is d/dt A_liv in component main (mg).
 * RATES[8] is d/dt A_liv_CL in component main (mg).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 0.1615;
CONSTANTS[1] = 14;
CONSTANTS[2] = 0.25;
CONSTANTS[3] = 0.09;
CONSTANTS[4] = 0.03;
CONSTANTS[5] = 0.278;
CONSTANTS[6] = 0.05;
CONSTANTS[7] = 0.0116;
CONSTANTS[8] = 0.04;
CONSTANTS[9] = 0.63;
CONSTANTS[10] = 186;
CONSTANTS[11] = 3.4;
CONSTANTS[12] = 6.1;
CONSTANTS[13] = 6.1;
CONSTANTS[14] = 3;
CONSTANTS[15] = 60;
CONSTANTS[16] = 0.8;
CONSTANTS[17] = 0.1;
CONSTANTS[18] = 6;
STATES[0] = 0;
STATES[1] = 0;
STATES[2] = 0;
STATES[3] = 0;
STATES[4] = 0;
CONSTANTS[19] = 0;
STATES[6] = 0;
STATES[7] = 0;
STATES[8] = 0;
CONSTANTS[20] =  CONSTANTS[1]*pow(CONSTANTS[0], 0.740000);
CONSTANTS[21] =  0.0100000*( 20.0000*CONSTANTS[0]+1.66400);
CONSTANTS[22] =  CONSTANTS[9]*CONSTANTS[0];
CONSTANTS[23] =  CONSTANTS[8]*CONSTANTS[0];
CONSTANTS[24] =  CONSTANTS[7]*CONSTANTS[0];
CONSTANTS[25] =  CONSTANTS[6]*CONSTANTS[0];
CONSTANTS[26] =  CONSTANTS[16]*CONSTANTS[15]*CONSTANTS[0];
CONSTANTS[27] = CONSTANTS[18]/pow(CONSTANTS[0], 0.300000);
CONSTANTS[28] =  CONSTANTS[2]*CONSTANTS[20];
CONSTANTS[29] = (((1.00000 - CONSTANTS[6]) - CONSTANTS[8]) - CONSTANTS[21]) - CONSTANTS[9];
CONSTANTS[30] =  CONSTANTS[21]*CONSTANTS[0];
CONSTANTS[31] =  0.750000*CONSTANTS[25];
CONSTANTS[32] =  0.250000*CONSTANTS[25];
CONSTANTS[33] =  CONSTANTS[3]*CONSTANTS[20];
CONSTANTS[34] =  CONSTANTS[29]*CONSTANTS[0];
CONSTANTS[35] =  CONSTANTS[4]*CONSTANTS[20];
CONSTANTS[36] =  CONSTANTS[5]*CONSTANTS[20];
CONSTANTS[37] = (((CONSTANTS[20] - CONSTANTS[28]) - CONSTANTS[33]) - CONSTANTS[35]) - CONSTANTS[36];
STATES[5] = CONSTANTS[26];
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[6] = (( CONSTANTS[33]*STATES[0])/CONSTANTS[30])/CONSTANTS[10]+(( CONSTANTS[35]*STATES[4])/CONSTANTS[24])/CONSTANTS[14]+(( CONSTANTS[36]*STATES[1])/CONSTANTS[22])/CONSTANTS[11]+(( CONSTANTS[28]*STATES[2])/CONSTANTS[23])/CONSTANTS[12]+(( CONSTANTS[37]*STATES[3])/CONSTANTS[34])/CONSTANTS[13];
RATES[0] =  CONSTANTS[33]*(STATES[7]/CONSTANTS[25] - (STATES[0]/CONSTANTS[30])/CONSTANTS[10]);
RATES[1] =  CONSTANTS[36]*(STATES[7]/CONSTANTS[25] - (STATES[1]/CONSTANTS[22])/CONSTANTS[11]);
RATES[4] =  CONSTANTS[35]*(STATES[7]/CONSTANTS[25] - (STATES[4]/CONSTANTS[24])/CONSTANTS[14]);
RATES[3] =  CONSTANTS[37]*(STATES[7]/CONSTANTS[25] - (STATES[3]/CONSTANTS[34])/CONSTANTS[13]);
RATES[5] =  - CONSTANTS[17]*STATES[5];
RATES[2] = ( CONSTANTS[28]*(STATES[7]/CONSTANTS[25] - (STATES[2]/CONSTANTS[23])/CONSTANTS[12]) - (( CONSTANTS[27]*CONSTANTS[23]*STATES[2])/CONSTANTS[23])/CONSTANTS[12])+ CONSTANTS[17]*STATES[5];
RATES[8] = (( CONSTANTS[27]*CONSTANTS[23]*STATES[2])/CONSTANTS[23])/CONSTANTS[12];
RATES[7] = RATES[6] - ( CONSTANTS[20]*STATES[7])/CONSTANTS[25];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[7]/CONSTANTS[25];
ALGEBRAIC[1] = STATES[4]/CONSTANTS[24];
}