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 2 entries in the algebraic variable array.
   There are a total of 3 entries in each of the rate and state variable arrays.
   There are a total of 13 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (day).
 * STATES[0] is x1 in component x1 (cell).
 * CONSTANTS[0] is alpha1 in component model_parameters (flux).
 * CONSTANTS[1] is beta1 in component model_parameters (first_order_rate_constant).
 * CONSTANTS[2] is g11 in component model_parameters (dimensionless).
 * CONSTANTS[3] is g21 in component model_parameters (dimensionless).
 * STATES[1] is x2 in component x2 (cell).
 * CONSTANTS[4] is alpha2 in component model_parameters (first_order_rate_constant).
 * CONSTANTS[5] is beta2 in component model_parameters (first_order_rate_constant).
 * CONSTANTS[6] is g12 in component model_parameters (dimensionless).
 * CONSTANTS[7] is g22 in component model_parameters (dimensionless).
 * STATES[2] is z in component z (percent).
 * CONSTANTS[8] is k1 in component model_parameters (percent_per_cell_per_day).
 * CONSTANTS[9] is k2 in component model_parameters (percent_per_cell_per_day).
 * ALGEBRAIC[0] is y1 in component y1 (cell).
 * ALGEBRAIC[1] is y2 in component y2 (cell).
 * CONSTANTS[11] is x1_bar in component x1_bar (cell).
 * CONSTANTS[12] is x2_bar in component x2_bar (cell).
 * CONSTANTS[10] is gamma in component model_parameters (dimensionless).
 * RATES[0] is d/dt x1 in component x1 (cell).
 * RATES[1] is d/dt x2 in component x2 (cell).
 * RATES[2] is d/dt z in component z (percent).
 * There are a total of 2 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 10.06066;
CONSTANTS[0] = 3;
CONSTANTS[1] = 0.2;
CONSTANTS[2] = 0.5;
CONSTANTS[3] = -0.5;
STATES[1] = 212.132;
CONSTANTS[4] = 4;
CONSTANTS[5] = 0.02;
CONSTANTS[6] = 1;
CONSTANTS[7] = 0;
STATES[2] = 100.0;
CONSTANTS[8] = 0.24;
CONSTANTS[9] = 0.0017;
CONSTANTS[10] =  CONSTANTS[6]*CONSTANTS[3] -  (1.00000 - CONSTANTS[2])*(1.00000 - CONSTANTS[7]);
CONSTANTS[11] =  pow(CONSTANTS[1]/CONSTANTS[0], (1.00000 - CONSTANTS[7])/CONSTANTS[10])*pow(CONSTANTS[5]/CONSTANTS[4], CONSTANTS[3]/CONSTANTS[10]);
CONSTANTS[12] =  pow(CONSTANTS[1]/CONSTANTS[0], CONSTANTS[6]/CONSTANTS[10])*pow(CONSTANTS[5]/CONSTANTS[4], (1.00000 - CONSTANTS[2])/CONSTANTS[10]);
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] -  CONSTANTS[0]*pow(STATES[0], CONSTANTS[2])*pow(STATES[1], CONSTANTS[3]) -  CONSTANTS[1]*STATES[0];
resid[1] = RATES[1] -  CONSTANTS[4]*pow(STATES[0], CONSTANTS[6])*pow(STATES[1], CONSTANTS[7]) -  CONSTANTS[5]*STATES[1];
resid[2] = RATES[2] -  CONSTANTS[9]*ALGEBRAIC[1] -  CONSTANTS[8]*ALGEBRAIC[0];
}
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[0] = (CONDVAR[0]>0.00000 ? STATES[0] - CONSTANTS[11] : 0.00000);
ALGEBRAIC[1] = (CONDVAR[1]>0.00000 ? STATES[1] - CONSTANTS[12] : 0.00000);
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = STATES[0] - CONSTANTS[11];
CONDVAR[1] = STATES[1] - CONSTANTS[12];
}