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 2 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 8 entries in the constant variable array.
*/
/*
* CONSTANTS[6] is k2 in component moussa (per_sec).
* CONSTANTS[7] is k1 in component moussa (per_sec).
* STATES[0] is X1 in component moussa (conc).
* STATES[1] is X2 in component moussa (conc).
* VOI is time in component moussa (second).
* ALGEBRAIC[0] is A in component moussa (conc).
* ALGEBRAIC[1] is D in component moussa (conc).
* CONSTANTS[0] is R in component moussa (gas_constant).
* CONSTANTS[1] is E1 in component moussa (J_per_mole).
* CONSTANTS[2] is E2 in component moussa (J_per_mole).
* CONSTANTS[3] is A1 in component moussa (per_sec).
* CONSTANTS[4] is A2 in component moussa (per_sec).
* CONSTANTS[5] is T in component moussa (kelvin).
* RATES[0] is d/dt X1 in component moussa (conc).
* RATES[1] is d/dt X2 in component moussa (conc).
*/
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 1;
STATES[1] = 0;
CONSTANTS[0] = 8.3;
CONSTANTS[1] = 2.5E5;
CONSTANTS[2] = 1.28E5;
CONSTANTS[3] = 0.0683E38;
CONSTANTS[4] = 0.0283E19;
CONSTANTS[5] = 325;
CONSTANTS[6] = CONSTANTS[4]*exp(- CONSTANTS[2]/( CONSTANTS[0]*CONSTANTS[5]));
CONSTANTS[7] = CONSTANTS[3]*exp(- CONSTANTS[1]/( CONSTANTS[0]*CONSTANTS[5]));
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[0] = - CONSTANTS[7]*STATES[0];
RATES[1] = CONSTANTS[7]*STATES[0] - CONSTANTS[6]*STATES[1];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[0]+STATES[1];
ALGEBRAIC[1] = 1.00000 - ALGEBRAIC[0];
}
