Generated Code

The following is c_ida code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

/*
   There are a total of 6 entries in the algebraic variable array.
   There are a total of 4 entries in each of the rate and state variable arrays.
   There are a total of 7 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).
 * ALGEBRAIC[1] is v_1 in component main (mol_per_s).
 * ALGEBRAIC[2] is v_2 in component main (mol_per_s).
 * ALGEBRAIC[3] is v_SS in component main (mol_per_s).
 * ALGEBRAIC[5] is v_MM in component main (mol_per_s).
 * CONSTANTS[0] is K_1 in component main (per_mol).
 * CONSTANTS[1] is K_2 in component main (per_mol).
 * CONSTANTS[2] is K_3 in component main (per_mol).
 * CONSTANTS[3] is K_4 in component main (per_mol).
 * CONSTANTS[4] is kappa_1 in component main (mol_per_s).
 * CONSTANTS[5] is kappa_2 in component main (mol_per_s).
 * ALGEBRAIC[0] is E_0 in component main (mole).
 * CONSTANTS[6] is k_m in component main (mole).
 * ALGEBRAIC[4] is v_max 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).
 * There are a total of 0 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 30;
STATES[1] = 0;
STATES[2] = 10;
STATES[3] = 0;
CONSTANTS[0] = 0.1;
CONSTANTS[1] = 0.1;
CONSTANTS[2] = 0.1;
CONSTANTS[3] = 0.1;
CONSTANTS[4] = 10;
CONSTANTS[5] = 10;
CONSTANTS[6] = ( (CONSTANTS[4]+CONSTANTS[5])*CONSTANTS[3])/( CONSTANTS[4]*CONSTANTS[0]*CONSTANTS[2]);
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[3] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - - ALGEBRAIC[1];
resid[1] = RATES[1] - ALGEBRAIC[2];
resid[2] = RATES[2] - ALGEBRAIC[2] - ALGEBRAIC[1];
resid[3] = RATES[3] - ALGEBRAIC[1] - ALGEBRAIC[2];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[2]+STATES[3];
ALGEBRAIC[3] = ( ALGEBRAIC[0]*CONSTANTS[4]*CONSTANTS[5]*CONSTANTS[2]*CONSTANTS[3]*( CONSTANTS[0]*STATES[0] -  CONSTANTS[1]*STATES[1]))/( CONSTANTS[3]*(CONSTANTS[4]+CONSTANTS[5])+ CONSTANTS[4]*CONSTANTS[0]*CONSTANTS[2]*STATES[0]+ CONSTANTS[5]*CONSTANTS[1]*CONSTANTS[2]*STATES[1]);
ALGEBRAIC[4] =  ALGEBRAIC[0]*CONSTANTS[5]*CONSTANTS[3];
ALGEBRAIC[5] =  ALGEBRAIC[4]*(STATES[0]/(CONSTANTS[6]+STATES[0]));
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] =  CONSTANTS[4]*( CONSTANTS[0]*STATES[0]*CONSTANTS[2]*STATES[2] -  CONSTANTS[3]*STATES[3]);
ALGEBRAIC[2] =  CONSTANTS[5]*( CONSTANTS[3]*STATES[3] -  CONSTANTS[1]*STATES[1]*CONSTANTS[2]*STATES[2]);
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}