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 2 entries in each of the rate and state variable arrays. There are a total of 13 entries in the constant variable array. */ /* * VOI is t in component main (second). * CONSTANTS[0] is V_m in component main (J_per_C). * CONSTANTS[1] is RTF in component main (J_per_C). * CONSTANTS[10] is epsilon in component main (dimensionless). * STATES[0] is TA_i in component main (mol_per_m3). * ALGEBRAIC[0] is CO2_o in component main (mol_per_m3). * ALGEBRAIC[5] is CO2_i in component main (mol_per_m3). * ALGEBRAIC[7] is HCO3_i in component main (mol_per_m3). * ALGEBRAIC[1] is HCO3_o in component main (mol_per_m3). * STATES[1] is H_i in component main (mol_per_m3). * CONSTANTS[2] is H_o in component main (mol_per_m3). * CONSTANTS[3] is H_Lim in component main (mol_per_m3). * ALGEBRAIC[6] is M_CO2 in component main (mol_per_m2_s). * ALGEBRAIC[8] is M_HCO3 in component main (mol_per_m2_s). * ALGEBRAIC[3] is M_H in component main (mol_per_m2_s). * ALGEBRAIC[2] is pH_i in component main (dimensionless). * CONSTANTS[11] is pH_o in component main (dimensionless). * CONSTANTS[12] is pH_Lim in component main (dimensionless). * CONSTANTS[4] is P_CO2 in component main (m_per_s). * CONSTANTS[5] is P_HCO3 in component main (m_per_s). * CONSTANTS[6] is k in component main (m_per_s). * CONSTANTS[7] is K_A in component main (mol_per_m3). * CONSTANTS[8] is rho in component main (per_m). * ALGEBRAIC[4] is alpha_i in component main (dimensionless). * CONSTANTS[9] is beta in component main (mol_per_m3). * RATES[0] is d/dt TA_i in component main (mol_per_m3). * RATES[1] is d/dt H_i in component main (mol_per_m3). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = -0.057; CONSTANTS[1] = 0.0256796; STATES[0] = 0.0; STATES[1] = 3.981071705534970e-05; CONSTANTS[2] = 1.995262314968879e-05; CONSTANTS[3] = 3.981071705534970e-05; CONSTANTS[4] = 6e-5; CONSTANTS[5] = 5e-9; CONSTANTS[6] = 0.0375; CONSTANTS[7] = 1e-3; CONSTANTS[8] = 8000; CONSTANTS[9] = -26; CONSTANTS[10] = exp(- CONSTANTS[0]/CONSTANTS[1]); CONSTANTS[11] = - arbitrary_log( 0.00100000*CONSTANTS[2], 10); CONSTANTS[12] = - arbitrary_log( 0.00100000*CONSTANTS[3], 10); } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = (VOI<100.000 ? 0.00000 : VOI<2800.00 ? 1.18770 : 0.00000); ALGEBRAIC[4] = STATES[1]/(STATES[1]+CONSTANTS[7]); ALGEBRAIC[5] = ALGEBRAIC[4]*STATES[0]; ALGEBRAIC[6] = CONSTANTS[4]*(ALGEBRAIC[0] - ALGEBRAIC[5]); ALGEBRAIC[7] = (1.00000 - ALGEBRAIC[4])*STATES[0]; ALGEBRAIC[1] = ( CONSTANTS[7]*ALGEBRAIC[0])/CONSTANTS[2]; ALGEBRAIC[8] = ( (( CONSTANTS[5]*CONSTANTS[0])/CONSTANTS[1])*(ALGEBRAIC[1] - ALGEBRAIC[7]*CONSTANTS[10]))/(1.00000 - CONSTANTS[10]); RATES[0] = CONSTANTS[8]*(ALGEBRAIC[6]+ALGEBRAIC[8]); ALGEBRAIC[2] = - arbitrary_log( 0.00100000*STATES[1], 10); ALGEBRAIC[3] = (ALGEBRAIC[2]<CONSTANTS[12] ? CONSTANTS[6]*(STATES[1] - CONSTANTS[3]) : 0.00000); RATES[1] = (( - 2.30300*STATES[1])/CONSTANTS[9])*CONSTANTS[8]*(( (1.00000 - ALGEBRAIC[4])*ALGEBRAIC[6] - ALGEBRAIC[4]*ALGEBRAIC[8]) - ALGEBRAIC[3]); } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = (VOI<100.000 ? 0.00000 : VOI<2800.00 ? 1.18770 : 0.00000); ALGEBRAIC[4] = STATES[1]/(STATES[1]+CONSTANTS[7]); ALGEBRAIC[5] = ALGEBRAIC[4]*STATES[0]; ALGEBRAIC[6] = CONSTANTS[4]*(ALGEBRAIC[0] - ALGEBRAIC[5]); ALGEBRAIC[7] = (1.00000 - ALGEBRAIC[4])*STATES[0]; ALGEBRAIC[1] = ( CONSTANTS[7]*ALGEBRAIC[0])/CONSTANTS[2]; ALGEBRAIC[8] = ( (( CONSTANTS[5]*CONSTANTS[0])/CONSTANTS[1])*(ALGEBRAIC[1] - ALGEBRAIC[7]*CONSTANTS[10]))/(1.00000 - CONSTANTS[10]); ALGEBRAIC[2] = - arbitrary_log( 0.00100000*STATES[1], 10); ALGEBRAIC[3] = (ALGEBRAIC[2]<CONSTANTS[12] ? CONSTANTS[6]*(STATES[1] - CONSTANTS[3]) : 0.00000); }