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 6 entries in each of the rate and state variable arrays. There are a total of 11 entries in the constant variable array. */ /* * VOI is t in component main (second). * CONSTANTS[0] is RT in component main (J_per_mol). * 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_e0 in component main (mole). * STATES[5] is q_e1 in component main (mole). * ALGEBRAIC[14] is v_1 in component main (mol_per_s). * ALGEBRAIC[15] is v_2 in component main (mol_per_s). * ALGEBRAIC[0] is u_1 in component main (J_per_mol). * ALGEBRAIC[2] is u_2 in component main (J_per_mol). * ALGEBRAIC[4] is u_3 in component main (J_per_mol). * ALGEBRAIC[6] is u_4 in component main (J_per_mol). * ALGEBRAIC[8] is u_e0 in component main (J_per_mol). * ALGEBRAIC[11] is u_e1 in component main (J_per_mol). * ALGEBRAIC[9] is u_f_1 in component main (J_per_mol). * ALGEBRAIC[12] is u_r_1 in component main (J_per_mol). * ALGEBRAIC[13] is u_f_2 in component main (J_per_mol). * ALGEBRAIC[10] is u_r_2 in component main (J_per_mol). * CONSTANTS[1] is K_q_1 in component main (per_mol). * CONSTANTS[2] is K_q_2 in component main (per_mol). * CONSTANTS[3] is K_q_3 in component main (per_mol). * CONSTANTS[4] is K_q_4 in component main (per_mol). * CONSTANTS[5] is K_q_e0 in component main (per_mol). * CONSTANTS[6] is K_q_e1 in component main (per_mol). * CONSTANTS[7] is kappa_1 in component main (mol_per_s). * CONSTANTS[8] is kappa_2 in component main (mol_per_s). * ALGEBRAIC[1] is q_e_tot in component main (mole). * ALGEBRAIC[3] is A_f in component main (per_mol3_per_s). * ALGEBRAIC[5] is A_r in component main (per_mol3_per_s). * CONSTANTS[9] is B_f in component main (per_mol3). * CONSTANTS[10] is B_r in component main (per_mol3). * ALGEBRAIC[7] is v_SS 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_e0 in component main (mole). * RATES[5] is d/dt q_e1 in component main (mole). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 2578.73058; STATES[0] = 3; STATES[1] = 1; STATES[2] = 0; STATES[3] = 0; STATES[4] = 1; STATES[5] = 1; CONSTANTS[1] = 2; CONSTANTS[2] = 2; CONSTANTS[3] = 2; CONSTANTS[4] = 2; CONSTANTS[5] = 2; CONSTANTS[6] = 2; CONSTANTS[7] = 0.20; CONSTANTS[8] = 0.1; CONSTANTS[9] = (( (CONSTANTS[5]/CONSTANTS[6])*CONSTANTS[7])/(CONSTANTS[7]+CONSTANTS[8]))*CONSTANTS[1]*pow(CONSTANTS[2], 2.00000); CONSTANTS[10] = (( (CONSTANTS[5]/CONSTANTS[6])*CONSTANTS[7])/(CONSTANTS[7]+CONSTANTS[8]))*CONSTANTS[3]*pow(CONSTANTS[4], 2.00000); } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[0]*log( CONSTANTS[1]*STATES[0]); ALGEBRAIC[2] = CONSTANTS[0]*log( CONSTANTS[2]*STATES[1]); ALGEBRAIC[8] = CONSTANTS[0]*log( CONSTANTS[5]*STATES[4]); ALGEBRAIC[9] = ALGEBRAIC[0]+ 2.00000*ALGEBRAIC[2]+ALGEBRAIC[8]; ALGEBRAIC[11] = CONSTANTS[0]*log( CONSTANTS[6]*STATES[5]); ALGEBRAIC[12] = ALGEBRAIC[11]; ALGEBRAIC[14] = CONSTANTS[7]*(exp(ALGEBRAIC[9]/CONSTANTS[0]) - exp(ALGEBRAIC[12]/CONSTANTS[0])); RATES[0] = - ALGEBRAIC[14]; RATES[1] = - 2.00000*ALGEBRAIC[14]; ALGEBRAIC[13] = ALGEBRAIC[11]; ALGEBRAIC[4] = CONSTANTS[0]*log( CONSTANTS[3]*STATES[2]); ALGEBRAIC[6] = CONSTANTS[0]*log( CONSTANTS[4]*STATES[3]); ALGEBRAIC[10] = ALGEBRAIC[4]+ 2.00000*ALGEBRAIC[6]+ALGEBRAIC[8]; ALGEBRAIC[15] = CONSTANTS[8]*(exp(ALGEBRAIC[13]/CONSTANTS[0]) - exp(ALGEBRAIC[10]/CONSTANTS[0])); RATES[2] = ALGEBRAIC[15]; RATES[3] = 2.00000*ALGEBRAIC[15]; RATES[4] = ALGEBRAIC[15] - ALGEBRAIC[14]; RATES[5] = ALGEBRAIC[14] - ALGEBRAIC[15]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[0]*log( CONSTANTS[1]*STATES[0]); ALGEBRAIC[2] = CONSTANTS[0]*log( CONSTANTS[2]*STATES[1]); ALGEBRAIC[8] = CONSTANTS[0]*log( CONSTANTS[5]*STATES[4]); ALGEBRAIC[9] = ALGEBRAIC[0]+ 2.00000*ALGEBRAIC[2]+ALGEBRAIC[8]; ALGEBRAIC[11] = CONSTANTS[0]*log( CONSTANTS[6]*STATES[5]); ALGEBRAIC[12] = ALGEBRAIC[11]; ALGEBRAIC[14] = CONSTANTS[7]*(exp(ALGEBRAIC[9]/CONSTANTS[0]) - exp(ALGEBRAIC[12]/CONSTANTS[0])); ALGEBRAIC[13] = ALGEBRAIC[11]; ALGEBRAIC[4] = CONSTANTS[0]*log( CONSTANTS[3]*STATES[2]); ALGEBRAIC[6] = CONSTANTS[0]*log( CONSTANTS[4]*STATES[3]); ALGEBRAIC[10] = ALGEBRAIC[4]+ 2.00000*ALGEBRAIC[6]+ALGEBRAIC[8]; ALGEBRAIC[15] = CONSTANTS[8]*(exp(ALGEBRAIC[13]/CONSTANTS[0]) - exp(ALGEBRAIC[10]/CONSTANTS[0])); ALGEBRAIC[1] = STATES[4]+STATES[5]; ALGEBRAIC[3] = (( ALGEBRAIC[1]*CONSTANTS[5]*CONSTANTS[7]*CONSTANTS[8])/(CONSTANTS[7]+CONSTANTS[8]))*CONSTANTS[1]*pow(CONSTANTS[2], 2.00000); ALGEBRAIC[5] = (( ALGEBRAIC[1]*CONSTANTS[5]*CONSTANTS[7]*CONSTANTS[8])/(CONSTANTS[7]+CONSTANTS[8]))*CONSTANTS[3]*pow(CONSTANTS[4], 2.00000); ALGEBRAIC[7] = ( ALGEBRAIC[3]*STATES[0]*pow(STATES[1], 2.00000) - ALGEBRAIC[5]*STATES[2]*pow(STATES[3], 2.00000))/(1.00000+ CONSTANTS[9]*STATES[0]*pow(STATES[1], 2.00000)+ CONSTANTS[10]*STATES[2]*pow(STATES[3], 2.00000)); }