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 4 entries in the algebraic variable array.
   There are a total of 5 entries in each of the rate and state variable arrays.
   There are a total of 22 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (day).
 * STATES[0] is R in component R (nanomolar).
 * CONSTANTS[0] is delta_R in component R (first_order_rate_constant).
 * ALGEBRAIC[1] is f1 in component f1 (flux).
 * STATES[1] is U in component U (nanomolar).
 * CONSTANTS[1] is delta_U in component U (first_order_rate_constant).
 * CONSTANTS[2] is alpha0 in component model_parameters (per_nanomolar_day).
 * CONSTANTS[3] is alpha1 in component model_parameters (per_nanomolar_day).
 * CONSTANTS[4] is d01 in component model_parameters (first_order_rate_constant).
 * CONSTANTS[5] is d12 in component model_parameters (first_order_rate_constant).
 * STATES[2] is B1 in component B1 (nanomolar).
 * STATES[3] is B2 in component B2 (nanomolar).
 * ALGEBRAIC[3] is P in component P (nanomolar).
 * ALGEBRAIC[2] is f2 in component f2 (flux).
 * CONSTANTS[6] is delta_b1 in component B1 (first_order_rate_constant).
 * CONSTANTS[7] is delta_b2 in component B2 (first_order_rate_constant).
 * CONSTANTS[8] is PE in component P (nanomolar).
 * ALGEBRAIC[0] is q in component P (dimensionless).
 * CONSTANTS[9] is G in component P (first_order_rate_constant).
 * CONSTANTS[10] is ti in component P (day).
 * CONSTANTS[11] is T in component P (day).
 * CONSTANTS[12] is P0 in component model_parameters (nanomolar).
 * CONSTANTS[13] is a in component f1 (flux).
 * CONSTANTS[14] is a0 in component f1 (flux).
 * CONSTANTS[15] is b in component f1 (nanomolar).
 * CONSTANTS[16] is b0 in component f1 (nanomolar).
 * STATES[4] is x in component x (flux).
 * CONSTANTS[17] is P1 in component x (nanomolar).
 * CONSTANTS[18] is s in component x (nanomolar_day2).
 * CONSTANTS[19] is delta_x in component x (first_order_rate_constant).
 * CONSTANTS[20] is kappa in component f2 (flux).
 * CONSTANTS[21] is kappa0 in component f2 (nanomolar).
 * RATES[0] is d/dt R in component R (nanomolar).
 * RATES[1] is d/dt U in component U (nanomolar).
 * RATES[2] is d/dt B1 in component B1 (nanomolar).
 * RATES[3] is d/dt B2 in component B2 (nanomolar).
 * RATES[4] is d/dt x in component x (flux).
 * There are a total of 3 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 1.0;
CONSTANTS[0] = 1.905;
STATES[1] = 1.0;
CONSTANTS[1] = 7.5;
CONSTANTS[2] = 4.15;
CONSTANTS[3] = 3.02;
CONSTANTS[4] = 13.0;
CONSTANTS[5] = 4.72E3;
STATES[2] = 1.0;
STATES[3] = 1.0;
CONSTANTS[6] = 7.5;
CONSTANTS[7] = 50.0;
CONSTANTS[8] = 20.55;
CONSTANTS[9] = 35.6;
CONSTANTS[10] = 1.0;
CONSTANTS[11] = 9.0;
CONSTANTS[12] = 0.25;
CONSTANTS[13] = 3.58E5;
CONSTANTS[14] = 2.33E4;
CONSTANTS[15] = 100.0;
CONSTANTS[16] = 263.0;
STATES[4] = 1.0;
CONSTANTS[17] = 20.0;
CONSTANTS[18] = 3.71E5;
CONSTANTS[19] = 0.207;
CONSTANTS[20] = 2.4E5;
CONSTANTS[21] = 6.55E3;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[3] = 0.1001;
RATES[4] = 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] -  CONSTANTS[0]*STATES[0];
resid[1] = RATES[1] - (ALGEBRAIC[2]+ CONSTANTS[4]*STATES[2]+ CONSTANTS[5]*STATES[3]) - ( CONSTANTS[1]*STATES[1]+ CONSTANTS[2]*ALGEBRAIC[3]*STATES[1]+ CONSTANTS[3]*STATES[2]*STATES[1]);
resid[2] = RATES[2] - ( CONSTANTS[2]*ALGEBRAIC[3]*STATES[1]+ CONSTANTS[5]*STATES[3]) - ( CONSTANTS[4]*STATES[2]+ CONSTANTS[6]*STATES[2]+ CONSTANTS[3]*STATES[2]*STATES[1]);
resid[3] = RATES[3] -  CONSTANTS[3]*STATES[2]*STATES[1] - ( CONSTANTS[5]*STATES[3]+ CONSTANTS[7]*STATES[3]);
resid[4] = RATES[4] - ( CONSTANTS[18]*(ALGEBRAIC[3] - CONSTANTS[12]))/(ALGEBRAIC[3]+CONSTANTS[17]) -  CONSTANTS[19]*STATES[4];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] =  CONSTANTS[14]*(1.00000 - STATES[3]/(CONSTANTS[15]+STATES[3]))+( STATES[4]*(1.00000 - exp(- STATES[4]/CONSTANTS[13]))*STATES[3])/(CONSTANTS[16]+STATES[3]);
ALGEBRAIC[2] = ( CONSTANTS[20]*STATES[0])/(CONSTANTS[21]+STATES[0]);
ALGEBRAIC[0] = (CONDVAR[0]<0.00000 ? 0.00000 : CONDVAR[1]<0.00000&&CONDVAR[2]>=0.00000 ? 1.00000 - exp( - CONSTANTS[9]*(VOI - CONSTANTS[10])) :  exp( CONSTANTS[9]*CONSTANTS[11] - 1.00000)*exp( CONSTANTS[9]*(VOI - CONSTANTS[10])));
ALGEBRAIC[3] = CONSTANTS[12]+ CONSTANTS[8]*ALGEBRAIC[0];
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
SI[4] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - CONSTANTS[10];
CONDVAR[1] = VOI - (CONSTANTS[11]+CONSTANTS[10]);
CONDVAR[2] = VOI - CONSTANTS[10];
}