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 5 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 4 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). * ALGEBRAIC[4] is v_r 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[1] is u_f in component main (J_per_mol). * ALGEBRAIC[3] is u_r 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 kappa_r 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). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 2578.73058; STATES[0] = 1; STATES[1] = 0; CONSTANTS[1] = 1; CONSTANTS[2] = 1; CONSTANTS[3] = 0.1; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[0]*log( CONSTANTS[1]*STATES[0]); ALGEBRAIC[1] = ALGEBRAIC[0]; ALGEBRAIC[2] = CONSTANTS[0]*log( CONSTANTS[2]*STATES[1]); ALGEBRAIC[3] = ALGEBRAIC[2]; ALGEBRAIC[4] = CONSTANTS[3]*(exp(ALGEBRAIC[1]/CONSTANTS[0]) - exp(ALGEBRAIC[3]/CONSTANTS[0])); RATES[0] = - ALGEBRAIC[4]; RATES[1] = ALGEBRAIC[4]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[0]*log( CONSTANTS[1]*STATES[0]); ALGEBRAIC[1] = ALGEBRAIC[0]; ALGEBRAIC[2] = CONSTANTS[0]*log( CONSTANTS[2]*STATES[1]); ALGEBRAIC[3] = ALGEBRAIC[2]; ALGEBRAIC[4] = CONSTANTS[3]*(exp(ALGEBRAIC[1]/CONSTANTS[0]) - exp(ALGEBRAIC[3]/CONSTANTS[0])); }