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 13 entries in the algebraic variable array.
   There are a total of 14 entries in each of the rate and state variable arrays.
   There are a total of 18 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[0] is O2 in component O2 (molar).
 * ALGEBRAIC[0] is v1 in component v1 (flux).
 * ALGEBRAIC[4] is v5 in component v5 (flux).
 * ALGEBRAIC[6] is v7 in component v7 (flux).
 * ALGEBRAIC[10] is v11 in component v11 (flux).
 * ALGEBRAIC[12] is v13_back in component v13_back (flux).
 * CONSTANTS[17] is v13 in component v13 (flux).
 * STATES[1] is O2_radical in component O2_radical (molar).
 * ALGEBRAIC[5] is v6 in component v6 (flux).
 * STATES[2] is NADH in component NADH (molar).
 * CONSTANTS[16] is v12 in component v12 (flux).
 * ALGEBRAIC[11] is v14 in component v14 (flux).
 * STATES[3] is NAD in component NAD (molar).
 * ALGEBRAIC[7] is v8 in component v8 (flux).
 * ALGEBRAIC[9] is v10 in component v10 (flux).
 * STATES[4] is NAD_radical in component NAD_radical (molar).
 * ALGEBRAIC[8] is v9 in component v9 (flux).
 * STATES[5] is NAD2 in component NAD2 (molar).
 * STATES[6] is H2O2 in component H2O2 (molar).
 * ALGEBRAIC[1] is v2 in component v2 (flux).
 * STATES[7] is Per3 in component Per3 (molar).
 * ALGEBRAIC[3] is v4 in component v4 (flux).
 * STATES[8] is Per2 in component Per2 (molar).
 * STATES[9] is coI in component coI (molar).
 * ALGEBRAIC[2] is v3 in component v3 (flux).
 * STATES[10] is coII in component coII (molar).
 * STATES[11] is coIII in component coIII (molar).
 * STATES[12] is Ar_radical in component Ar_radical (molar).
 * STATES[13] is ArH in component ArH (molar).
 * CONSTANTS[0] is k1 in component v1 (second_order_rate_constant).
 * CONSTANTS[1] is k2 in component v2 (second_order_rate_constant).
 * CONSTANTS[2] is k3 in component v3 (second_order_rate_constant).
 * CONSTANTS[3] is k4 in component v4 (second_order_rate_constant).
 * CONSTANTS[4] is k5 in component v5 (second_order_rate_constant).
 * CONSTANTS[5] is k6 in component v6 (second_order_rate_constant).
 * CONSTANTS[6] is k7 in component v7 (second_order_rate_constant).
 * CONSTANTS[7] is k8 in component v8 (second_order_rate_constant).
 * CONSTANTS[8] is k9 in component v9 (second_order_rate_constant).
 * CONSTANTS[9] is k10 in component v10 (second_order_rate_constant).
 * CONSTANTS[10] is k11 in component v11 (second_order_rate_constant).
 * CONSTANTS[11] is k12 in component v12 (flux).
 * CONSTANTS[12] is O2eq in component v13 (molar).
 * CONSTANTS[13] is k13 in component v13 (first_order_rate_constant).
 * CONSTANTS[14] is k13_ in component v13_back (first_order_rate_constant).
 * CONSTANTS[15] is k14 in component v14 (second_order_rate_constant).
 * RATES[0] is d/dt O2 in component O2 (molar).
 * RATES[1] is d/dt O2_radical in component O2_radical (molar).
 * RATES[2] is d/dt NADH in component NADH (molar).
 * RATES[3] is d/dt NAD in component NAD (molar).
 * RATES[4] is d/dt NAD_radical in component NAD_radical (molar).
 * RATES[5] is d/dt NAD2 in component NAD2 (molar).
 * RATES[6] is d/dt H2O2 in component H2O2 (molar).
 * RATES[7] is d/dt Per3 in component Per3 (molar).
 * RATES[8] is d/dt Per2 in component Per2 (molar).
 * RATES[9] is d/dt coI in component coI (molar).
 * RATES[10] is d/dt coII in component coII (molar).
 * RATES[11] is d/dt coIII in component coIII (molar).
 * RATES[12] is d/dt Ar_radical in component Ar_radical (molar).
 * RATES[13] is d/dt ArH in component ArH (molar).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 5.33e-6;
STATES[1] = 0.026e-6;
STATES[2] = 0.95e-6;
STATES[3] = 558e-6;
STATES[4] = 5e-10;
STATES[5] = 0.12e-6;
STATES[6] = 0.013e-6;
STATES[7] = 0.059e-6;
STATES[8] = 1e-10;
STATES[9] = 8.9e-10;
STATES[10] = 0.026e-6;
STATES[11] = 1.31e-6;
STATES[12] = 0.12e-6;
STATES[13] = 299.88e-6;
CONSTANTS[0] = 3;
CONSTANTS[1] = 1.8e7;
CONSTANTS[2] = 1.5e5;
CONSTANTS[3] = 5.2e3;
CONSTANTS[4] = 2e7;
CONSTANTS[5] = 1.7e7;
CONSTANTS[6] = 2e7;
CONSTANTS[7] = 4e7;
CONSTANTS[8] = 6e7;
CONSTANTS[9] = 1.8e6;
CONSTANTS[10] = 1e5;
CONSTANTS[11] = 0.08e-6;
CONSTANTS[12] = 1.2e-5;
CONSTANTS[13] = 6e-3;
CONSTANTS[14] = 6e-3;
CONSTANTS[15] = 7e5;
CONSTANTS[16] = CONSTANTS[11];
CONSTANTS[17] =  CONSTANTS[13]*CONSTANTS[12];
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[3] =  CONSTANTS[3]*STATES[10]*STATES[13];
ALGEBRAIC[2] =  CONSTANTS[2]*STATES[9]*STATES[13];
RATES[10] = ALGEBRAIC[2] - ALGEBRAIC[3];
ALGEBRAIC[4] =  CONSTANTS[4]*STATES[4]*STATES[0];
ALGEBRAIC[6] =  CONSTANTS[6]*pow(STATES[1], 2.00000);
ALGEBRAIC[5] =  CONSTANTS[5]*STATES[1]*STATES[7];
RATES[1] = (ALGEBRAIC[4] - ALGEBRAIC[5]) -  2.00000*ALGEBRAIC[6];
ALGEBRAIC[0] =  CONSTANTS[0]*STATES[2]*STATES[0];
ALGEBRAIC[1] =  CONSTANTS[1]*STATES[6]*STATES[7];
RATES[6] = (ALGEBRAIC[0] - ALGEBRAIC[1]) - ALGEBRAIC[6];
ALGEBRAIC[7] =  CONSTANTS[7]*STATES[11]*STATES[4];
RATES[9] = (ALGEBRAIC[1] - ALGEBRAIC[2])+ALGEBRAIC[7];
ALGEBRAIC[8] =  CONSTANTS[8]*pow(STATES[4], 2.00000);
RATES[5] = ALGEBRAIC[8];
ALGEBRAIC[9] =  CONSTANTS[9]*STATES[7]*STATES[4];
RATES[3] = ALGEBRAIC[0]+ALGEBRAIC[4]+ALGEBRAIC[7]+ALGEBRAIC[9];
RATES[7] = ((- ALGEBRAIC[1]+ALGEBRAIC[3]) - ALGEBRAIC[5]) - ALGEBRAIC[9];
ALGEBRAIC[11] =  CONSTANTS[15]*STATES[12]*STATES[2];
RATES[2] = (- ALGEBRAIC[0]+CONSTANTS[16]) - ALGEBRAIC[11];
RATES[4] = ((( - 2.00000*ALGEBRAIC[8] - ALGEBRAIC[4]) - ALGEBRAIC[7]) - ALGEBRAIC[9])+ALGEBRAIC[11];
ALGEBRAIC[10] =  CONSTANTS[10]*STATES[8]*STATES[0];
RATES[8] = - ALGEBRAIC[10]+ALGEBRAIC[9];
RATES[11] = (ALGEBRAIC[5] - ALGEBRAIC[7])+ALGEBRAIC[10];
RATES[12] = (ALGEBRAIC[2]+ALGEBRAIC[3]) - ALGEBRAIC[11];
RATES[13] = (- ALGEBRAIC[2] - ALGEBRAIC[3])+ALGEBRAIC[11];
ALGEBRAIC[12] =  CONSTANTS[14]*STATES[0];
RATES[0] = ((((- ALGEBRAIC[0] - ALGEBRAIC[4])+ALGEBRAIC[6]) - ALGEBRAIC[10])+CONSTANTS[17]) - ALGEBRAIC[12];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[3] =  CONSTANTS[3]*STATES[10]*STATES[13];
ALGEBRAIC[2] =  CONSTANTS[2]*STATES[9]*STATES[13];
ALGEBRAIC[4] =  CONSTANTS[4]*STATES[4]*STATES[0];
ALGEBRAIC[6] =  CONSTANTS[6]*pow(STATES[1], 2.00000);
ALGEBRAIC[5] =  CONSTANTS[5]*STATES[1]*STATES[7];
ALGEBRAIC[0] =  CONSTANTS[0]*STATES[2]*STATES[0];
ALGEBRAIC[1] =  CONSTANTS[1]*STATES[6]*STATES[7];
ALGEBRAIC[7] =  CONSTANTS[7]*STATES[11]*STATES[4];
ALGEBRAIC[8] =  CONSTANTS[8]*pow(STATES[4], 2.00000);
ALGEBRAIC[9] =  CONSTANTS[9]*STATES[7]*STATES[4];
ALGEBRAIC[11] =  CONSTANTS[15]*STATES[12]*STATES[2];
ALGEBRAIC[10] =  CONSTANTS[10]*STATES[8]*STATES[0];
ALGEBRAIC[12] =  CONSTANTS[14]*STATES[0];
}