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 8 entries in the algebraic variable array.
   There are a total of 6 entries in each of the rate and state variable arrays.
   There are a total of 21 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (min).
 * CONSTANTS[0] is Vp in component environment (l).
 * CONSTANTS[1] is Vi in component environment (l).
 * CONSTANTS[2] is Vg in component environment (l).
 * CONSTANTS[3] is E in component environment (l_per_min).
 * STATES[0] is Ip in component plasma_insulin (mU).
 * ALGEBRAIC[0] is Ip_conc in component plasma_insulin (mU_per_l).
 * CONSTANTS[4] is tp in component plasma_insulin (min).
 * ALGEBRAIC[1] is f1_G in component plasma_insulin (mU_per_min).
 * CONSTANTS[5] is Rm in component plasma_insulin (mU_per_min).
 * CONSTANTS[6] is C1 in component plasma_insulin (mg_per_l).
 * CONSTANTS[7] is a1 in component plasma_insulin (mg_per_l).
 * STATES[1] is Ii in component intercellular_insulin (mU).
 * STATES[2] is G in component glucose (mg).
 * ALGEBRAIC[2] is Ii_conc in component intercellular_insulin (mU_per_l).
 * CONSTANTS[8] is ti in component intercellular_insulin (min).
 * ALGEBRAIC[3] is G_conc in component glucose (mg_per_dl).
 * CONSTANTS[9] is Gin in component glucose (mg_per_min).
 * ALGEBRAIC[4] is f2_G in component glucose (mg_per_min).
 * ALGEBRAIC[5] is f3_G in component glucose (dimensionless).
 * ALGEBRAIC[6] is f4_Ii in component glucose (mg_per_min).
 * ALGEBRAIC[7] is f5_x3 in component glucose (mg_per_min).
 * CONSTANTS[10] is C2 in component glucose (mg_per_l).
 * CONSTANTS[11] is C3 in component glucose (mg_per_l).
 * CONSTANTS[12] is C4 in component glucose (mU_per_l).
 * CONSTANTS[13] is C5 in component glucose (mU_per_l).
 * CONSTANTS[14] is U0 in component glucose (mg_per_min).
 * CONSTANTS[15] is Um in component glucose (mg_per_min).
 * CONSTANTS[16] is Ub in component glucose (mg_per_min).
 * CONSTANTS[17] is beta in component glucose (dimensionless).
 * CONSTANTS[18] is Rg in component glucose (mg_per_min).
 * CONSTANTS[19] is alpha in component glucose (l_per_mU).
 * STATES[3] is x3 in component delay (min).
 * CONSTANTS[20] is td in component delay (min).
 * STATES[4] is x1 in component delay (min).
 * STATES[5] is x2 in component delay (min).
 * RATES[0] is d/dt Ip in component plasma_insulin (mU).
 * RATES[1] is d/dt Ii in component intercellular_insulin (mU).
 * RATES[2] is d/dt G in component glucose (mg).
 * RATES[4] is d/dt x1 in component delay (min).
 * RATES[5] is d/dt x2 in component delay (min).
 * RATES[3] is d/dt x3 in component delay (min).
 * There are a total of 0 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 3;
CONSTANTS[1] = 11;
CONSTANTS[2] = 10;
CONSTANTS[3] = 0.2;
STATES[0] = 93.36441699;
CONSTANTS[4] = 6;
CONSTANTS[5] = 210;
CONSTANTS[6] = 2000;
CONSTANTS[7] = 300;
STATES[1] = 243.2865183;
STATES[2] = 12342.61665;
CONSTANTS[8] = 100;
CONSTANTS[9] = 216;
CONSTANTS[10] = 144;
CONSTANTS[11] = 1000;
CONSTANTS[12] = 80;
CONSTANTS[13] = 26;
CONSTANTS[14] = 40;
CONSTANTS[15] = 940;
CONSTANTS[16] = 72;
CONSTANTS[17] = 1.77;
CONSTANTS[18] = 180;
CONSTANTS[19] = 0.29;
STATES[3] = 104.5878705;
CONSTANTS[20] = 36;
STATES[4] = 110.420253;
STATES[5] = 112.7601171;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[4] = 0.1001;
RATES[5] = 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] - ( CONSTANTS[3]*(STATES[0]/CONSTANTS[0] - STATES[1]/CONSTANTS[1])+STATES[0]/CONSTANTS[4]);
resid[1] = RATES[1] -  CONSTANTS[3]*(STATES[0]/CONSTANTS[0] - STATES[1]/CONSTANTS[1]) - STATES[1]/CONSTANTS[8];
resid[2] = RATES[2] - CONSTANTS[9]+ALGEBRAIC[7]+- (ALGEBRAIC[4]+ ALGEBRAIC[5]*ALGEBRAIC[6]);
resid[3] = RATES[4] -  (3.00000/CONSTANTS[20])*(STATES[0]/1.00000 - STATES[4]);
resid[4] = RATES[5] -  (3.00000/CONSTANTS[20])*(STATES[4] - STATES[5]);
resid[5] = RATES[3] -  (3.00000/CONSTANTS[20])*(STATES[5] - STATES[3]);
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[0]/CONSTANTS[0];
ALGEBRAIC[2] = STATES[1]/CONSTANTS[1];
ALGEBRAIC[3] = STATES[2]/( CONSTANTS[2]*10.0000);
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = CONSTANTS[5]/(1.00000+exp((CONSTANTS[6] - STATES[2]/CONSTANTS[2])/CONSTANTS[7]));
ALGEBRAIC[4] =  CONSTANTS[16]*(1.00000 - exp(- STATES[2]/( CONSTANTS[10]*CONSTANTS[2])));
ALGEBRAIC[5] = STATES[2]/( CONSTANTS[11]*CONSTANTS[2]);
ALGEBRAIC[6] = CONSTANTS[14]+(CONSTANTS[15] - CONSTANTS[14])/(1.00000+exp( - CONSTANTS[17]*log( (STATES[1]/CONSTANTS[12])*(1.00000/CONSTANTS[1]+1.00000/( CONSTANTS[3]*CONSTANTS[8])))));
ALGEBRAIC[7] = CONSTANTS[18]/(1.00000+exp( CONSTANTS[19]*(( STATES[3]*1.00000)/CONSTANTS[0] - CONSTANTS[13])));
}
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;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}