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 19 entries in the algebraic variable array.
   There are a total of 17 entries in each of the rate and state variable arrays.
   There are a total of 18 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[0] is A in component differentials (molar).
 * STATES[1] is G in component differentials (molar).
 * STATES[2] is GA in component differentials (molar).
 * STATES[3] is T in component differentials (molar).
 * STATES[4] is R in component differentials (molar).
 * STATES[5] is GT in component differentials (molar).
 * STATES[6] is GD in component differentials (molar).
 * STATES[7] is Pi_ in component differentials (molar).
 * STATES[8] is D in component differentials (molar).
 * STATES[9] is RG in component differentials (molar).
 * STATES[10] is RGT in component differentials (molar).
 * STATES[11] is GAT in component differentials (molar).
 * STATES[12] is GAD in component differentials (molar).
 * STATES[13] is RGD in component differentials (molar).
 * STATES[14] is RGA in component differentials (molar).
 * STATES[15] is RGAT in component differentials (molar).
 * STATES[16] is RGAD in component differentials (molar).
 * ALGEBRAIC[7] is A2 in component A2 (molar_per_second).
 * ALGEBRAIC[8] is A3 in component A3 (molar_per_second).
 * ALGEBRAIC[16] is A5 in component A5 (molar_per_second).
 * ALGEBRAIC[6] is R2 in component R2 (molar_per_second).
 * ALGEBRAIC[9] is R3 in component R3 (molar_per_second).
 * ALGEBRAIC[14] is R4 in component R4 (molar_per_second).
 * ALGEBRAIC[2] is T1 in component T1 (molar_per_second).
 * ALGEBRAIC[5] is T3 in component T3 (molar_per_second).
 * ALGEBRAIC[15] is T4 in component T4 (molar_per_second).
 * ALGEBRAIC[3] is P1 in component P1 (molar_per_second).
 * ALGEBRAIC[12] is P2 in component P2 (molar_per_second).
 * ALGEBRAIC[10] is P3 in component P3 (molar_per_second).
 * ALGEBRAIC[17] is P4 in component P4 (molar_per_second).
 * ALGEBRAIC[4] is D1 in component D1 (molar_per_second).
 * ALGEBRAIC[13] is D2 in component D2 (molar_per_second).
 * ALGEBRAIC[11] is D3 in component D3 (molar_per_second).
 * ALGEBRAIC[18] is D4 in component D4 (molar_per_second).
 * ALGEBRAIC[0] is Z in component output (dimensionless).
 * ALGEBRAIC[1] is v in component output (per_second).
 * CONSTANTS[0] is G_tot in component output (molar).
 * CONSTANTS[1] is k1 in component P1 (per_second).
 * CONSTANTS[2] is k1 in component P2 (per_second).
 * CONSTANTS[3] is k1 in component P3 (per_second).
 * CONSTANTS[4] is k1 in component P4 (per_second).
 * CONSTANTS[5] is k1 in component T1 (per_molar_per_second).
 * CONSTANTS[6] is k1 in component D1 (per_second).
 * CONSTANTS[7] is k1 in component T3 (per_molar_per_second).
 * CONSTANTS[8] is k2 in component R2 (per_second).
 * CONSTANTS[9] is k1 in component A2 (per_molar_per_second).
 * CONSTANTS[10] is k2 in component A3 (per_second).
 * CONSTANTS[11] is k1 in component R3 (per_molar_per_second).
 * CONSTANTS[12] is k1 in component D3 (per_second).
 * CONSTANTS[13] is k1 in component D2 (per_second).
 * CONSTANTS[14] is k1 in component R4 (per_molar_per_second).
 * CONSTANTS[15] is k1 in component T4 (per_molar_per_second).
 * CONSTANTS[16] is k1 in component A5 (per_molar_per_second).
 * CONSTANTS[17] is k1 in component D4 (per_second).
 * RATES[0] is d/dt A in component differentials (molar).
 * RATES[1] is d/dt G in component differentials (molar).
 * RATES[2] is d/dt GA in component differentials (molar).
 * RATES[3] is d/dt T in component differentials (molar).
 * RATES[4] is d/dt R in component differentials (molar).
 * RATES[5] is d/dt GT in component differentials (molar).
 * RATES[6] is d/dt GD in component differentials (molar).
 * RATES[7] is d/dt Pi_ in component differentials (molar).
 * RATES[8] is d/dt D in component differentials (molar).
 * RATES[9] is d/dt RG in component differentials (molar).
 * RATES[10] is d/dt RGT in component differentials (molar).
 * RATES[11] is d/dt GAT in component differentials (molar).
 * RATES[12] is d/dt GAD in component differentials (molar).
 * RATES[13] is d/dt RGD in component differentials (molar).
 * RATES[14] is d/dt RGA in component differentials (molar).
 * RATES[15] is d/dt RGAT in component differentials (molar).
 * RATES[16] is d/dt RGAD in component differentials (molar).
 * There are a total of 0 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 0;
STATES[1] = 0;
STATES[2] = 0;
STATES[3] = 0.000468;
STATES[4] = 0;
STATES[5] = 0;
STATES[6] = 1e-8;
STATES[7] = 0.0044;
STATES[8] = 0.000149;
STATES[9] = 0;
STATES[10] = 0;
STATES[11] = 0;
STATES[12] = 0;
STATES[13] = 0;
STATES[14] = 0;
STATES[15] = 0;
STATES[16] = 0;
CONSTANTS[0] = 1e-8;
CONSTANTS[1] = 0.013;
CONSTANTS[2] = 25;
CONSTANTS[3] = 0.013;
CONSTANTS[4] = 25;
CONSTANTS[5] = 529000;
CONSTANTS[6] = 0.0001;
CONSTANTS[7] = 853000;
CONSTANTS[8] = 1.28;
CONSTANTS[9] = 386000;
CONSTANTS[10] = 0.95;
CONSTANTS[11] = 94700000;
CONSTANTS[12] = 2;
CONSTANTS[13] = 0.0001;
CONSTANTS[14] = 22800000;
CONSTANTS[15] = 1620000;
CONSTANTS[16] = 6300000;
CONSTANTS[17] = 2.75;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[3] = 0.1001;
RATES[4] = 0.1001;
RATES[5] = 0.1001;
RATES[6] = 0.1001;
RATES[7] = 0.1001;
RATES[8] = 0.1001;
RATES[9] = 0.1001;
RATES[10] = 0.1001;
RATES[11] = 0.1001;
RATES[12] = 0.1001;
RATES[13] = 0.1001;
RATES[14] = 0.1001;
RATES[15] = 0.1001;
RATES[16] = 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[7]+ALGEBRAIC[8]+ALGEBRAIC[16]);
resid[1] = RATES[1] - ALGEBRAIC[4] - ALGEBRAIC[2];
resid[2] = RATES[2] - ALGEBRAIC[13] - ALGEBRAIC[14];
resid[3] = RATES[3] - - (ALGEBRAIC[2]+ALGEBRAIC[5]+ALGEBRAIC[15]);
resid[4] = RATES[4] - - (ALGEBRAIC[6]+ALGEBRAIC[9]+ALGEBRAIC[14]);
resid[5] = RATES[5] - ((ALGEBRAIC[2] - ALGEBRAIC[3]) - ALGEBRAIC[6]) - ALGEBRAIC[7];
resid[6] = RATES[6] - ((ALGEBRAIC[3] - ALGEBRAIC[4]) - ALGEBRAIC[8]) - ALGEBRAIC[9];
resid[7] = RATES[7] - ALGEBRAIC[3]+ALGEBRAIC[10]+ALGEBRAIC[12]+ALGEBRAIC[17];
resid[8] = RATES[8] - ALGEBRAIC[4]+ALGEBRAIC[11]+ALGEBRAIC[13]+ALGEBRAIC[18];
resid[9] = RATES[9] - - ALGEBRAIC[5]+ALGEBRAIC[11];
resid[10] = RATES[10] - ((ALGEBRAIC[5]+ALGEBRAIC[6]) - ALGEBRAIC[10]) - ALGEBRAIC[16];
resid[11] = RATES[11] - ALGEBRAIC[7] - ALGEBRAIC[12];
resid[12] = RATES[12] - (ALGEBRAIC[8]+ALGEBRAIC[12]) - ALGEBRAIC[13];
resid[13] = RATES[13] - (ALGEBRAIC[9]+ALGEBRAIC[10]) - ALGEBRAIC[11];
resid[14] = RATES[14] - (ALGEBRAIC[14] - ALGEBRAIC[15])+ALGEBRAIC[18];
resid[15] = RATES[15] - (ALGEBRAIC[15]+ALGEBRAIC[16]) - ALGEBRAIC[17];
resid[16] = RATES[16] - ALGEBRAIC[17] - ALGEBRAIC[18];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (STATES[5]+STATES[10]+STATES[15]+STATES[11])/CONSTANTS[0];
ALGEBRAIC[1] = ( CONSTANTS[4]*STATES[15]+ CONSTANTS[2]*STATES[11]+ CONSTANTS[3]*STATES[10]+ CONSTANTS[1]*STATES[5])/CONSTANTS[0];
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[2] =  CONSTANTS[5]*STATES[1]*STATES[3];
ALGEBRAIC[3] =  CONSTANTS[1]*STATES[5];
ALGEBRAIC[4] =  CONSTANTS[6]*STATES[6];
ALGEBRAIC[5] =  CONSTANTS[7]*STATES[9]*STATES[3];
ALGEBRAIC[6] =  - CONSTANTS[8]*STATES[10];
ALGEBRAIC[7] =  CONSTANTS[9]*STATES[5]*STATES[0];
ALGEBRAIC[8] =  - CONSTANTS[10]*STATES[12];
ALGEBRAIC[9] =  CONSTANTS[11]*STATES[6]*STATES[4];
ALGEBRAIC[10] =  CONSTANTS[3]*STATES[10];
ALGEBRAIC[11] =  CONSTANTS[12]*STATES[13];
ALGEBRAIC[12] =  CONSTANTS[2]*STATES[11];
ALGEBRAIC[13] =  CONSTANTS[13]*STATES[12];
ALGEBRAIC[14] =  CONSTANTS[14]*STATES[2]*STATES[4];
ALGEBRAIC[15] =  CONSTANTS[15]*STATES[14]*STATES[3];
ALGEBRAIC[16] =  CONSTANTS[16]*STATES[10]*STATES[0];
ALGEBRAIC[17] =  CONSTANTS[4]*STATES[15];
ALGEBRAIC[18] =  CONSTANTS[17]*STATES[16];
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
SI[4] = 1.0;
SI[5] = 1.0;
SI[6] = 1.0;
SI[7] = 1.0;
SI[8] = 1.0;
SI[9] = 1.0;
SI[10] = 1.0;
SI[11] = 1.0;
SI[12] = 1.0;
SI[13] = 1.0;
SI[14] = 1.0;
SI[15] = 1.0;
SI[16] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}