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 7 entries in the algebraic variable array.
   There are a total of 5 entries in each of the rate and state variable arrays.
   There are a total of 23 entries in the constant variable array.
 */
/*
 * VOI is t in component main (second).
 * STATES[0] is q_1 in component main (mole).
 * STATES[1] is q_2 in component main (mole).
 * STATES[2] is q_3 in component main (mole).
 * STATES[3] is q_4 in component main (mole).
 * STATES[4] is q_5 in component main (mole).
 * ALGEBRAIC[0] is q_6 in component main (mole).
 * CONSTANTS[0] is q_tot in component main (mole).
 * ALGEBRAIC[3] is v_1 in component main (mol_per_s).
 * ALGEBRAIC[4] is v_2 in component main (mol_per_s).
 * ALGEBRAIC[5] is v_3 in component main (mol_per_s).
 * ALGEBRAIC[6] is v_4 in component main (mol_per_s).
 * CONSTANTS[1] is kappa_1 in component main (mol_per_s).
 * CONSTANTS[2] is kappa_2 in component main (mol_per_s).
 * CONSTANTS[3] is kappa_3 in component main (mol_per_s).
 * CONSTANTS[4] is kappa_4 in component main (mol_per_s).
 * CONSTANTS[5] is K_1 in component main (per_mol).
 * CONSTANTS[6] is K_2 in component main (per_mol).
 * CONSTANTS[7] is K_s in component main (per_mol).
 * CONSTANTS[8] is K_3 in component main (per_mol).
 * CONSTANTS[9] is K_4 in component main (per_mol).
 * CONSTANTS[10] is K_5 in component main (per_mol).
 * CONSTANTS[11] is K_6 in component main (per_mol).
 * CONSTANTS[12] is K_m in component main (per_mol).
 * CONSTANTS[13] is k_m in component main (mole).
 * CONSTANTS[14] is v_max in component main (mol_per_s).
 * CONSTANTS[15] is k_f_1 in component main (per_mol_per_s).
 * CONSTANTS[16] is k_r_1 in component main (per_s).
 * CONSTANTS[17] is k_f_2 in component main (per_s).
 * CONSTANTS[18] is k_r_2 in component main (per_mol_per_s).
 * CONSTANTS[19] is k_f_3 in component main (per_s).
 * CONSTANTS[20] is k_r_3 in component main (per_s).
 * CONSTANTS[21] is k_f_4 in component main (per_s).
 * CONSTANTS[22] is k_r_4 in component main (per_s).
 * ALGEBRAIC[1] is v_SF in component main (mol_per_s).
 * ALGEBRAIC[2] is v_MM in component main (mol_per_s).
 * RATES[0] is d/dt q_1 in component main (mole).
 * RATES[1] is d/dt q_2 in component main (mole).
 * RATES[2] is d/dt q_3 in component main (mole).
 * RATES[3] is d/dt q_4 in component main (mole).
 * RATES[4] is d/dt q_5 in component main (mole).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 100;
STATES[1] = 0;
STATES[2] = 0;
STATES[3] = 0;
STATES[4] = 0;
CONSTANTS[0] = 1;
CONSTANTS[1] = 100;
CONSTANTS[2] = 100;
CONSTANTS[3] = 1;
CONSTANTS[4] = 0.1;
CONSTANTS[5] = 0.1;
CONSTANTS[6] = 0.1;
CONSTANTS[7] = 0.1;
CONSTANTS[8] = 1;
CONSTANTS[9] = 1;
CONSTANTS[10] = 1;
CONSTANTS[11] = 1;
CONSTANTS[12] = 1;
CONSTANTS[13] = 2.00000/( CONSTANTS[7]*(1.00000+CONSTANTS[3]/CONSTANTS[4]));
CONSTANTS[14] = ( CONSTANTS[0]*CONSTANTS[3]*CONSTANTS[12])/(1.00000+CONSTANTS[3]/CONSTANTS[4]);
CONSTANTS[15] =  CONSTANTS[1]*CONSTANTS[5]*CONSTANTS[11];
CONSTANTS[16] =  CONSTANTS[1]*CONSTANTS[8];
CONSTANTS[17] =  CONSTANTS[2]*CONSTANTS[9];
CONSTANTS[18] =  CONSTANTS[2]*CONSTANTS[6]*CONSTANTS[10];
CONSTANTS[19] =  CONSTANTS[3]*CONSTANTS[8];
CONSTANTS[20] =  CONSTANTS[3]*CONSTANTS[9];
CONSTANTS[21] =  CONSTANTS[4]*CONSTANTS[10];
CONSTANTS[22] =  CONSTANTS[4]*CONSTANTS[11];
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = ((CONSTANTS[0] - STATES[2]) - STATES[3]) - STATES[4];
ALGEBRAIC[3] =  CONSTANTS[15]*STATES[0]*ALGEBRAIC[0] -  CONSTANTS[16]*STATES[2];
RATES[0] = - ALGEBRAIC[3];
ALGEBRAIC[4] =  CONSTANTS[17]*STATES[3] -  CONSTANTS[18]*STATES[1]*STATES[4];
RATES[1] = ALGEBRAIC[4] -  1000.00*STATES[1];
ALGEBRAIC[5] =  CONSTANTS[19]*STATES[2] -  CONSTANTS[20]*STATES[3];
RATES[2] = ALGEBRAIC[3] - ALGEBRAIC[5];
RATES[3] = ALGEBRAIC[5] - ALGEBRAIC[4];
ALGEBRAIC[6] =  CONSTANTS[21]*STATES[4] -  CONSTANTS[22]*ALGEBRAIC[0];
RATES[4] = ALGEBRAIC[4] - ALGEBRAIC[6];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = ((CONSTANTS[0] - STATES[2]) - STATES[3]) - STATES[4];
ALGEBRAIC[3] =  CONSTANTS[15]*STATES[0]*ALGEBRAIC[0] -  CONSTANTS[16]*STATES[2];
ALGEBRAIC[4] =  CONSTANTS[17]*STATES[3] -  CONSTANTS[18]*STATES[1]*STATES[4];
ALGEBRAIC[5] =  CONSTANTS[19]*STATES[2] -  CONSTANTS[20]*STATES[3];
ALGEBRAIC[6] =  CONSTANTS[21]*STATES[4] -  CONSTANTS[22]*ALGEBRAIC[0];
ALGEBRAIC[1] = ( CONSTANTS[0]*CONSTANTS[3]*CONSTANTS[4]*CONSTANTS[12]*CONSTANTS[7]*(STATES[0] - STATES[1]))/( 2.00000*CONSTANTS[4]+ (CONSTANTS[3]+CONSTANTS[4])*CONSTANTS[7]*(STATES[0]+STATES[1])+ 2.00000*CONSTANTS[3]*CONSTANTS[7]*CONSTANTS[7]*STATES[0]*STATES[1]);
ALGEBRAIC[2] = ( CONSTANTS[14]*STATES[0])/(CONSTANTS[13]+STATES[0]);
}