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 16 entries in the algebraic variable array.
   There are a total of 3 entries in each of the rate and state variable arrays.
   There are a total of 37 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (hour).
 * CONSTANTS[0] is T_a in component model_parameters (celsius).
 * CONSTANTS[1] is T_b in component model_parameters (celsius).
 * CONSTANTS[2] is delta_T in component model_parameters (celsius).
 * CONSTANTS[3] is kinc in component model_parameters (W_per_kg_C2).
 * CONSTANTS[4] is tdose1 in component model_parameters (hour).
 * CONSTANTS[5] is tdose2 in component model_parameters (hour).
 * CONSTANTS[6] is tdose3 in component model_parameters (hour).
 * ALGEBRAIC[5] is M_c in component M_c (W_per_kg).
 * CONSTANTS[7] is t_day in component M_c (hour).
 * CONSTANTS[8] is t_night in component M_c (hour).
 * ALGEBRAIC[1] is tprime in component M_c (second).
 * CONSTANTS[9] is day_length in component M_c (second).
 * CONSTANTS[35] is M_day in component M_day (W_per_kg).
 * ALGEBRAIC[3] is M_night in component M_night (W_per_kg).
 * STATES[0] is M in component M (W_per_kg).
 * CONSTANTS[10] is km in component M (per_hour).
 * STATES[1] is T in component T (celsius).
 * CONSTANTS[11] is c in component T (kJ_per_kg_C).
 * ALGEBRAIC[0] is k in component k (W_per_kg_C).
 * STATES[2] is BR in component k (dimensionless).
 * CONSTANTS[12] is pEtot in component k (dimensionless).
 * CONSTANTS[13] is kR in component k (per_day).
 * CONSTANTS[14] is AMT_dose in component k (mg_per_kg).
 * CONSTANTS[15] is pEf1 in component k (per_day).
 * CONSTANTS[16] is pEs1 in component k (kg_per_day_mg).
 * CONSTANTS[17] is pEf2 in component k (per_day).
 * CONSTANTS[18] is pEs2 in component k (kg_per_day_mg).
 * CONSTANTS[19] is pEf3 in component k (per_day).
 * CONSTANTS[20] is pEs3 in component k (kg_per_day_mg).
 * ALGEBRAIC[13] is E_slow in component k (per_day).
 * ALGEBRAIC[15] is E_fast in component k (per_day).
 * CONSTANTS[30] is f2_drug in component k (W_per_kg_C).
 * CONSTANTS[34] is kb in component kb (W_per_kg_C).
 * ALGEBRAIC[2] is f_prime in component M_night (dimensionless).
 * ALGEBRAIC[6] is gNsTs1 in component gNT (dimensionless).
 * ALGEBRAIC[9] is gNsTs2 in component gNT (dimensionless).
 * ALGEBRAIC[12] is gNsTs3 in component gNT (dimensionless).
 * ALGEBRAIC[7] is gNfTf1 in component gNT (dimensionless).
 * ALGEBRAIC[10] is gNfTf2 in component gNT (dimensionless).
 * ALGEBRAIC[14] is gNfTf3 in component gNT (dimensionless).
 * CONSTANTS[29] is T_day in component T_day (celsius).
 * CONSTANTS[32] is T_night in component T_night (celsius).
 * CONSTANTS[21] is M_b in component kb (W_per_kg).
 * CONSTANTS[22] is t_prime in component M_night (hour).
 * CONSTANTS[23] is alpha in component M_night (per_hour).
 * CONSTANTS[24] is delta_high_dose in component M_night (dimensionless).
 * CONSTANTS[36] is M_night_baseline in component M_night (W_per_kg).
 * CONSTANTS[25] is Ns in component gNT (dimensionless).
 * CONSTANTS[26] is Nf in component gNT (dimensionless).
 * CONSTANTS[27] is Ts in component gNT (day).
 * CONSTANTS[28] is Tf in component gNT (day).
 * ALGEBRAIC[4] is X1 in component gNT (day).
 * ALGEBRAIC[8] is X2 in component gNT (day).
 * ALGEBRAIC[11] is X3 in component gNT (day).
 * CONSTANTS[31] is Kf in component gNT (per_day).
 * CONSTANTS[33] is Ks in component gNT (per_day).
 * RATES[0] is d/dt M in component M (W_per_kg).
 * RATES[1] is d/dt T in component T (celsius).
 * RATES[2] is d/dt BR in component k (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 21.0;
CONSTANTS[1] = 38.0;
CONSTANTS[2] = 1.57;
CONSTANTS[3] = 0.0258;
CONSTANTS[4] = 24.0;
CONSTANTS[5] = 72.0;
CONSTANTS[6] = 120.0;
CONSTANTS[7] = 17.5;
CONSTANTS[8] = 6.73;
CONSTANTS[9] = 86400;
STATES[0] = 3.5;
CONSTANTS[10] = 1.1375;
STATES[1] = 38.785;
CONSTANTS[11] = 3.47;
STATES[2] = 0.0;
CONSTANTS[12] = 0.144;
CONSTANTS[13] = 5.35;
CONSTANTS[14] = 3.0;
CONSTANTS[15] = 1.0;
CONSTANTS[16] = 0.2;
CONSTANTS[17] = 3.57;
CONSTANTS[18] = 2.43;
CONSTANTS[19] = 8.0;
CONSTANTS[20] = 50.0;
CONSTANTS[21] = 3.0;
CONSTANTS[22] = 45.12;
CONSTANTS[23] = 0.2229166;
CONSTANTS[24] = 1.0;
CONSTANTS[25] = 4.0;
CONSTANTS[26] = 4.0;
CONSTANTS[27] = 2.45;
CONSTANTS[28] = 0.368;
CONSTANTS[29] = CONSTANTS[1]+CONSTANTS[2]/2.00000;
CONSTANTS[30] = 0.00000;
CONSTANTS[31] = CONSTANTS[26]/CONSTANTS[28];
CONSTANTS[32] = CONSTANTS[1] - CONSTANTS[2]/2.00000;
CONSTANTS[33] = CONSTANTS[25]/CONSTANTS[27];
CONSTANTS[34] = CONSTANTS[21]/(CONSTANTS[1] - CONSTANTS[0]);
CONSTANTS[35] =  (CONSTANTS[34]+ CONSTANTS[3]*(CONSTANTS[29] - CONSTANTS[1]))*(CONSTANTS[29] - CONSTANTS[0]);
CONSTANTS[36] =  (CONSTANTS[34]+ CONSTANTS[3]*(CONSTANTS[32] - CONSTANTS[1]))*(CONSTANTS[32] - CONSTANTS[0]);
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = CONSTANTS[34]+ CONSTANTS[3]*(STATES[1] -  CONSTANTS[1]*(1.00000+ CONSTANTS[12]*STATES[2]))+CONSTANTS[30];
RATES[1] =  pow(CONSTANTS[11], -1.00000)*(STATES[0] -  ALGEBRAIC[0]*(STATES[1] - CONSTANTS[0]));
ALGEBRAIC[1] =  (int)( VOI*3600.00*1.00000) % (int)(CONSTANTS[9]);
ALGEBRAIC[2] =  CONSTANTS[24]*pow(1.00000+exp( - CONSTANTS[23]*(VOI - (CONSTANTS[4]+CONSTANTS[22]))), -1.00000);
ALGEBRAIC[3] =  (1.00000 - ALGEBRAIC[2])*CONSTANTS[36]+ ALGEBRAIC[2]*CONSTANTS[35];
ALGEBRAIC[5] = (ALGEBRAIC[1]/3600.00>=CONSTANTS[8]&&ALGEBRAIC[1]/3600.00<CONSTANTS[7] ? ALGEBRAIC[3] : CONSTANTS[35]);
RATES[0] =  - CONSTANTS[10]*(STATES[0] - ALGEBRAIC[5]);
ALGEBRAIC[4] = (VOI - CONSTANTS[4])/24.0000;
ALGEBRAIC[6] = (ALGEBRAIC[4]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[4])*pow(ALGEBRAIC[4], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[8] = (VOI - CONSTANTS[5])/24.0000;
ALGEBRAIC[9] = (ALGEBRAIC[8]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[8])*pow(ALGEBRAIC[8], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[11] = (VOI - CONSTANTS[6])/24.0000;
ALGEBRAIC[12] = (ALGEBRAIC[11]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[11])*pow(ALGEBRAIC[11], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[13] =  CONSTANTS[14]*CONSTANTS[18]*(ALGEBRAIC[6]+ALGEBRAIC[9]+ALGEBRAIC[12]);
ALGEBRAIC[7] = (ALGEBRAIC[4]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[4])*pow(ALGEBRAIC[4], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[10] = (ALGEBRAIC[8]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[8])*pow(ALGEBRAIC[8], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[14] = (ALGEBRAIC[11]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[11])*pow(ALGEBRAIC[11], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[15] =  CONSTANTS[17]*(ALGEBRAIC[7]+ALGEBRAIC[10]+ALGEBRAIC[14]);
RATES[2] =  ( ALGEBRAIC[2]*(ALGEBRAIC[13]+ALGEBRAIC[15]))*(1.00000 - STATES[2]) -  CONSTANTS[13]*STATES[2];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = CONSTANTS[34]+ CONSTANTS[3]*(STATES[1] -  CONSTANTS[1]*(1.00000+ CONSTANTS[12]*STATES[2]))+CONSTANTS[30];
ALGEBRAIC[1] =  (int)( VOI*3600.00*1.00000) % (int)(CONSTANTS[9]);
ALGEBRAIC[2] =  CONSTANTS[24]*pow(1.00000+exp( - CONSTANTS[23]*(VOI - (CONSTANTS[4]+CONSTANTS[22]))), -1.00000);
ALGEBRAIC[3] =  (1.00000 - ALGEBRAIC[2])*CONSTANTS[36]+ ALGEBRAIC[2]*CONSTANTS[35];
ALGEBRAIC[5] = (ALGEBRAIC[1]/3600.00>=CONSTANTS[8]&&ALGEBRAIC[1]/3600.00<CONSTANTS[7] ? ALGEBRAIC[3] : CONSTANTS[35]);
ALGEBRAIC[4] = (VOI - CONSTANTS[4])/24.0000;
ALGEBRAIC[6] = (ALGEBRAIC[4]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[4])*pow(ALGEBRAIC[4], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[8] = (VOI - CONSTANTS[5])/24.0000;
ALGEBRAIC[9] = (ALGEBRAIC[8]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[8])*pow(ALGEBRAIC[8], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[11] = (VOI - CONSTANTS[6])/24.0000;
ALGEBRAIC[12] = (ALGEBRAIC[11]>0.00000 ?  (pow(CONSTANTS[33], CONSTANTS[25])/6.00000)*exp( - CONSTANTS[33]*ALGEBRAIC[11])*pow(ALGEBRAIC[11], CONSTANTS[25] - 1.00000) : 0.00000);
ALGEBRAIC[13] =  CONSTANTS[14]*CONSTANTS[18]*(ALGEBRAIC[6]+ALGEBRAIC[9]+ALGEBRAIC[12]);
ALGEBRAIC[7] = (ALGEBRAIC[4]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[4])*pow(ALGEBRAIC[4], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[10] = (ALGEBRAIC[8]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[8])*pow(ALGEBRAIC[8], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[14] = (ALGEBRAIC[11]>0.00000 ?  (pow(CONSTANTS[31], CONSTANTS[26])/6.00000)*exp( - CONSTANTS[31]*ALGEBRAIC[11])*pow(ALGEBRAIC[11], CONSTANTS[26] - 1.00000) : 0.00000);
ALGEBRAIC[15] =  CONSTANTS[17]*(ALGEBRAIC[7]+ALGEBRAIC[10]+ALGEBRAIC[14]);
}