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 9 entries in the algebraic variable array.
   There are a total of 7 entries in each of the rate and state variable arrays.
   There are a total of 26 entries in the constant variable array.
 */
/*
 * VOI is time in component Environment (second).
 * ALGEBRAIC[0] is P_L in component PluralPressureFunction (mmHg).
 * ALGEBRAIC[1] is dP_Ldt in component PluralPressureFunction (mmHg_per_second).
 * CONSTANTS[0] is P_m in component PluralPressureFunction (mmHg).
 * CONSTANTS[23] is R in component PluralPressureFunction (mmHg_second_per_litre).
 * CONSTANTS[1] is omega in component PluralPressureFunction (radian_per_second).
 * CONSTANTS[2] is V_T in component PluralPressureFunction (litre).
 * CONSTANTS[3] is E in component PluralPressureFunction (mmHg_per_second).
 * CONSTANTS[4] is P_m in component lungMechanics (mmHg).
 * STATES[0] is V_A in component lungMechanics (litre).
 * CONSTANTS[5] is E in component lungMechanics (mmHg_per_second).
 * STATES[1] is P_A in component lungMechanics (mmHg).
 * CONSTANTS[6] is R in component lungMechanics (mmHg_second_per_litre).
 * ALGEBRAIC[6] is Q_A in component gasExchange (litre_per_second).
 * ALGEBRAIC[3] is q in component lungMechanics (litre_per_second).
 * CONSTANTS[7] is D_o in component gasExchange (mole_per_second_mmHg).
 * STATES[2] is f_o in component gasExchange (dimensionless).
 * ALGEBRAIC[7] is f_oi in component gasExchange (dimensionless).
 * CONSTANTS[8] is D_c in component gasExchange (mole_per_second_mmHg).
 * STATES[3] is f_c in component gasExchange (dimensionless).
 * ALGEBRAIC[8] is f_ci in component gasExchange (dimensionless).
 * CONSTANTS[9] is P_w in component gasExchange (mmHg).
 * ALGEBRAIC[4] is p_ao in component gasExchange (mmHg).
 * STATES[4] is p_o in component gasTransport (mmHg).
 * ALGEBRAIC[5] is p_ac in component gasExchange (mmHg).
 * CONSTANTS[10] is f_om in component gasExchange (dimensionless).
 * CONSTANTS[11] is f_cm in component gasExchange (dimensionless).
 * STATES[5] is p_c in component gasTransport (mmHg).
 * CONSTANTS[12] is V_D in component gasExchange (litre).
 * CONSTANTS[13] is V_T in component gasExchange (litre).
 * ALGEBRAIC[2] is df_satdp in component gasTransport (dimensionless).
 * CONSTANTS[14] is L in component gasTransport (dimensionless).
 * CONSTANTS[15] is K_T in component gasTransport (litre_per_mole).
 * CONSTANTS[16] is K_R in component gasTransport (litre_per_mole).
 * CONSTANTS[17] is sigma in component gasTransport (mole_per_litre_mmHg).
 * CONSTANTS[18] is V_c in component gasTransport (litre).
 * CONSTANTS[19] is T_h in component gasTransport (mole_per_litre).
 * CONSTANTS[24] is delta in component gasTransport (dimensionless).
 * CONSTANTS[25] is h in component gasTransport (mole_per_litre).
 * CONSTANTS[20] is l_2 in component gasTransport (litre_per_second_mole).
 * CONSTANTS[21] is r_2 in component gasTransport (per_second).
 * CONSTANTS[22] is sigma_c in component gasTransport (mole_per_litre_mmHg).
 * STATES[6] is z in component gasTransport (dimensionless).
 * RATES[1] is d/dt P_A in component lungMechanics (mmHg).
 * RATES[0] is d/dt V_A in component lungMechanics (litre).
 * RATES[2] is d/dt f_o in component gasExchange (dimensionless).
 * RATES[3] is d/dt f_c in component gasExchange (dimensionless).
 * RATES[4] is d/dt p_o in component gasTransport (mmHg).
 * RATES[5] is d/dt p_c in component gasTransport (mmHg).
 * RATES[6] is d/dt z in component gasTransport (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 760;
CONSTANTS[1] = 1.256637;
CONSTANTS[2] = 0.41;
CONSTANTS[3] = 2.5;
CONSTANTS[4] = 760;
STATES[0] = 1;
CONSTANTS[5] = 2.5;
STATES[1] = 760;
CONSTANTS[6] = 1;
CONSTANTS[7] = 0.0000156;
STATES[2] = 0.1368;
CONSTANTS[8] = 0.0000316;
STATES[3] = 0.05263;
CONSTANTS[9] = 47;
STATES[4] = 40;
CONSTANTS[10] = 0.21;
CONSTANTS[11] = 0;
STATES[5] = 46;
CONSTANTS[12] = 0.151;
CONSTANTS[13] = 0.41;
CONSTANTS[14] = 171200000;
CONSTANTS[15] = 10000;
CONSTANTS[16] = 3600000;
CONSTANTS[17] = 0.0000014;
CONSTANTS[18] = 0.071;
CONSTANTS[19] = 0.002;
CONSTANTS[20] = 164000;
CONSTANTS[21] = 0.12;
CONSTANTS[22] = 0.000033;
STATES[6] = 0.00000044219;
CONSTANTS[23] = ( 2.00000* 3.14159265358979*1.00000)/5.00000;
CONSTANTS[24] = pow(10.0000, 1.90000);
CONSTANTS[25] =  1.00000*pow(10.0000, - 7.40000);
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[6] = ( CONSTANTS[24]*CONSTANTS[21]*CONSTANTS[22]*STATES[5])/1.00000 -  CONSTANTS[24]*CONSTANTS[20]*CONSTANTS[25]*STATES[6];
ALGEBRAIC[0] = (CONSTANTS[0] -  (( CONSTANTS[23]*CONSTANTS[1]*CONSTANTS[2])/2.00000)* sin(( CONSTANTS[1]*VOI)/1.00000)) -  CONSTANTS[3]*(2.50000 -  (( CONSTANTS[2]*1.00000)/2.00000)*cos(( CONSTANTS[1]*VOI)/1.00000));
RATES[0] = ((CONSTANTS[4] - ALGEBRAIC[0]) - ( STATES[0]*CONSTANTS[5])/1.00000)/CONSTANTS[6];
ALGEBRAIC[2] = ( ( CONSTANTS[14]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 4.00000)+pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 4.00000))*( 3.00000*CONSTANTS[14]*pow(CONSTANTS[15], 2.00000)*pow(CONSTANTS[17], 2.00000)*STATES[4]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 2.00000)+ CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ 3.00000*pow(CONSTANTS[16], 2.00000)*pow(CONSTANTS[17], 2.00000)*STATES[4]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 2.00000)+ CONSTANTS[16]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000)) -  ( CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*STATES[4]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ CONSTANTS[16]*CONSTANTS[17]*STATES[4]*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000))*( 4.00000*CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ 4.00000*CONSTANTS[16]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000)))/pow( CONSTANTS[14]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 4.00000)+pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 4.00000), 2.00000);
RATES[4] =  (CONSTANTS[7]/( CONSTANTS[17]*CONSTANTS[18]))*pow(1.00000+ (( 4.00000*CONSTANTS[19])/CONSTANTS[17])*ALGEBRAIC[2], - 1.00000)*( STATES[2]*(STATES[1] - CONSTANTS[9]) - STATES[4]);
ALGEBRAIC[5] =  STATES[3]*(STATES[1] - CONSTANTS[9]);
RATES[5] = ( (CONSTANTS[8]/( CONSTANTS[22]*CONSTANTS[18]))*(ALGEBRAIC[5] - STATES[5])+ (( 1.00000*CONSTANTS[24]*CONSTANTS[20])/CONSTANTS[22])*CONSTANTS[25]*STATES[6]) -  CONSTANTS[24]*CONSTANTS[21]*STATES[5];
ALGEBRAIC[1] =  (( - CONSTANTS[23]*pow(CONSTANTS[1], 2.00000)*CONSTANTS[2])/( 2.00000*1.00000))*cos(( CONSTANTS[1]*VOI)/1.00000) -  CONSTANTS[3]*(2.50000 -  (CONSTANTS[2]/2.00000)* sin(( CONSTANTS[1]*VOI)/1.00000));
ALGEBRAIC[3] = (CONSTANTS[4] - STATES[1])/CONSTANTS[6];
ALGEBRAIC[4] =  STATES[2]*(STATES[1] - CONSTANTS[9]);
ALGEBRAIC[6] = ALGEBRAIC[3]+ 1.00000*CONSTANTS[8]*(STATES[5] - ALGEBRAIC[5])+ 1.00000*CONSTANTS[7]*(STATES[4] - ALGEBRAIC[4]);
RATES[1] = ( CONSTANTS[4]*CONSTANTS[5]*ALGEBRAIC[6])/( STATES[1]*1.00000)+ALGEBRAIC[1];
ALGEBRAIC[7] = (CONSTANTS[13]>=CONSTANTS[12] ? ( STATES[2]*CONSTANTS[12]+ CONSTANTS[10]*(CONSTANTS[13] - CONSTANTS[12]))/CONSTANTS[13] : STATES[2]);
RATES[2] =  (1.00000/STATES[0])*(( 1.00000*CONSTANTS[7]*(STATES[4] - ALGEBRAIC[4])+ (ALGEBRAIC[7] - STATES[2])*ALGEBRAIC[3]) -  STATES[2]*( 1.00000*CONSTANTS[8]*(STATES[5] - ALGEBRAIC[5])+ 1.00000*CONSTANTS[7]*(STATES[4] - ALGEBRAIC[4])));
ALGEBRAIC[8] = (CONSTANTS[13]>=CONSTANTS[12] ? ( STATES[3]*CONSTANTS[12]+ CONSTANTS[11]*(CONSTANTS[13] - CONSTANTS[12]))/CONSTANTS[13] : STATES[3]);
RATES[3] =  (1.00000/STATES[0])*(( 1.00000*CONSTANTS[8]*(STATES[5] - ALGEBRAIC[5])+ (ALGEBRAIC[8] - STATES[3])*ALGEBRAIC[3]) -  STATES[3]*( 1.00000*CONSTANTS[7]*(STATES[4] - ALGEBRAIC[4])+ 1.00000*CONSTANTS[8]*(STATES[5] - ALGEBRAIC[5])));
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONSTANTS[0] -  (( CONSTANTS[23]*CONSTANTS[1]*CONSTANTS[2])/2.00000)* sin(( CONSTANTS[1]*VOI)/1.00000)) -  CONSTANTS[3]*(2.50000 -  (( CONSTANTS[2]*1.00000)/2.00000)*cos(( CONSTANTS[1]*VOI)/1.00000));
ALGEBRAIC[2] = ( ( CONSTANTS[14]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 4.00000)+pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 4.00000))*( 3.00000*CONSTANTS[14]*pow(CONSTANTS[15], 2.00000)*pow(CONSTANTS[17], 2.00000)*STATES[4]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 2.00000)+ CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ 3.00000*pow(CONSTANTS[16], 2.00000)*pow(CONSTANTS[17], 2.00000)*STATES[4]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 2.00000)+ CONSTANTS[16]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000)) -  ( CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*STATES[4]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ CONSTANTS[16]*CONSTANTS[17]*STATES[4]*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000))*( 4.00000*CONSTANTS[14]*CONSTANTS[15]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 3.00000)+ 4.00000*CONSTANTS[16]*CONSTANTS[17]*1.00000*pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 3.00000)))/pow( CONSTANTS[14]*pow(1.00000+ CONSTANTS[15]*CONSTANTS[17]*STATES[4], 4.00000)+pow(1.00000+ CONSTANTS[16]*CONSTANTS[17]*STATES[4], 4.00000), 2.00000);
ALGEBRAIC[5] =  STATES[3]*(STATES[1] - CONSTANTS[9]);
ALGEBRAIC[1] =  (( - CONSTANTS[23]*pow(CONSTANTS[1], 2.00000)*CONSTANTS[2])/( 2.00000*1.00000))*cos(( CONSTANTS[1]*VOI)/1.00000) -  CONSTANTS[3]*(2.50000 -  (CONSTANTS[2]/2.00000)* sin(( CONSTANTS[1]*VOI)/1.00000));
ALGEBRAIC[3] = (CONSTANTS[4] - STATES[1])/CONSTANTS[6];
ALGEBRAIC[4] =  STATES[2]*(STATES[1] - CONSTANTS[9]);
ALGEBRAIC[6] = ALGEBRAIC[3]+ 1.00000*CONSTANTS[8]*(STATES[5] - ALGEBRAIC[5])+ 1.00000*CONSTANTS[7]*(STATES[4] - ALGEBRAIC[4]);
ALGEBRAIC[7] = (CONSTANTS[13]>=CONSTANTS[12] ? ( STATES[2]*CONSTANTS[12]+ CONSTANTS[10]*(CONSTANTS[13] - CONSTANTS[12]))/CONSTANTS[13] : STATES[2]);
ALGEBRAIC[8] = (CONSTANTS[13]>=CONSTANTS[12] ? ( STATES[3]*CONSTANTS[12]+ CONSTANTS[11]*(CONSTANTS[13] - CONSTANTS[12]))/CONSTANTS[13] : STATES[3]);
}