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 1 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 6 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (hour).
 * ALGEBRAIC[0] is GnRH in component GnRH (nanomolar).
 * STATES[0] is F in component F (dimensionless).
 * CONSTANTS[0] is kfb in component model_parameters (second_order_rate_constant).
 * CONSTANTS[1] is kdf in component model_parameters (first_order_rate_constant).
 * STATES[1] is D in component D (dimensionless).
 * CONSTANTS[2] is kbd in component model_parameters (first_order_rate_constant).
 * STATES[2] is B in component B (dimensionless).
 * STATES[3] is R in component R (dimensionless).
 * CONSTANTS[3] is s in component model_parameters (first_order_rate_constant).
 * CONSTANTS[4] is a1 in component model_parameters (first_order_rate_constant).
 * CONSTANTS[5] is a2 in component model_parameters (first_order_rate_constant).
 * STATES[4] is C in component C (dimensionless).
 * RATES[0] is d/dt F in component F (dimensionless).
 * RATES[1] is d/dt D in component D (dimensionless).
 * RATES[2] is d/dt B in component B (dimensionless).
 * RATES[3] is d/dt R in component R (dimensionless).
 * RATES[4] is d/dt C in component C (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 1.0;
CONSTANTS[0] = 19.35;
CONSTANTS[1] = 2.52;
STATES[1] = 0.0;
CONSTANTS[2] = 9.91;
STATES[2] = 0.0;
STATES[3] = 2115.0;
CONSTANTS[3] = 6.80;
CONSTANTS[4] = 0.0328;
CONSTANTS[5] = 0.0830;
STATES[4] = 0.0;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[1] =  CONSTANTS[2]*STATES[2] -  CONSTANTS[1]*STATES[1];
RATES[3] = CONSTANTS[3] -  (CONSTANTS[4]+ CONSTANTS[5]*STATES[2])*STATES[3];
RATES[4] =  (CONSTANTS[4]+ CONSTANTS[5]*STATES[2])*STATES[3];
ALGEBRAIC[0] = (VOI>=0.00000&&VOI<0.0666667 ? 0.500000 : VOI>=0.0666667&&VOI<0.400000 ? 0.00000 : VOI>=0.400000&&VOI<0.466667 ? 0.500000 : VOI>=0.466667&&VOI<2.46667 ? 0.00000 : VOI>=2.46667&&VOI<2.53333 ? 0.500000 : VOI>=2.53333&&VOI<2.61667 ? 0.00000 : VOI>=2.61667&&VOI<2.68333 ? 0.500000 : VOI>=2.68333&&VOI<4.68333 ? 0.00000 : VOI>=4.68333&&VOI<4.75000 ? 0.500000 : VOI>=4.75000&&VOI<4.91667 ? 0.00000 : VOI>=4.91667&&VOI<4.98333 ? 0.500000 : VOI>=4.98333&&VOI<6.98333 ? 0.00000 : VOI>=6.98333&&VOI<7.06667 ? 0.500000 : VOI>=7.06667&&VOI<7.73333 ? 0.00000 : VOI>=7.73333&&VOI<7.80000 ? 0.500000 : VOI>=7.80000&&VOI<9.80000 ? 0.00000 : 0.0/0.0);
RATES[0] =  CONSTANTS[1]*STATES[1] -  CONSTANTS[0]*STATES[0]*ALGEBRAIC[0];
RATES[2] =  CONSTANTS[0]*STATES[0]*ALGEBRAIC[0] -  CONSTANTS[2]*STATES[2];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (VOI>=0.00000&&VOI<0.0666667 ? 0.500000 : VOI>=0.0666667&&VOI<0.400000 ? 0.00000 : VOI>=0.400000&&VOI<0.466667 ? 0.500000 : VOI>=0.466667&&VOI<2.46667 ? 0.00000 : VOI>=2.46667&&VOI<2.53333 ? 0.500000 : VOI>=2.53333&&VOI<2.61667 ? 0.00000 : VOI>=2.61667&&VOI<2.68333 ? 0.500000 : VOI>=2.68333&&VOI<4.68333 ? 0.00000 : VOI>=4.68333&&VOI<4.75000 ? 0.500000 : VOI>=4.75000&&VOI<4.91667 ? 0.00000 : VOI>=4.91667&&VOI<4.98333 ? 0.500000 : VOI>=4.98333&&VOI<6.98333 ? 0.00000 : VOI>=6.98333&&VOI<7.06667 ? 0.500000 : VOI>=7.06667&&VOI<7.73333 ? 0.00000 : VOI>=7.73333&&VOI<7.80000 ? 0.500000 : VOI>=7.80000&&VOI<9.80000 ? 0.00000 : 0.0/0.0);
}