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 54 entries in the algebraic variable array.
   There are a total of 7 entries in each of the rate and state variable arrays.
   There are a total of 46 entries in the constant variable array.
 */
/*
 * VOI is t in component params_BG (second).
 * CONSTANTS[0] is R in component params_BG (J_per_K_mol).
 * CONSTANTS[1] is T in component params_BG (kelvin).
 * CONSTANTS[2] is F in component params_BG (C_per_mol).
 * CONSTANTS[3] is K_Nai in component params_BG (per_fmol).
 * CONSTANTS[38] is q_Nai in component params_BG (fmol).
 * CONSTANTS[4] is K_Nao in component params_BG (per_fmol).
 * CONSTANTS[40] is q_Nao in component params_BG (fmol).
 * CONSTANTS[5] is K_Glci in component params_BG (per_fmol).
 * CONSTANTS[42] is q_Glci in component params_BG (fmol).
 * CONSTANTS[6] is K_Glco in component params_BG (per_fmol).
 * CONSTANTS[44] is q_Glco in component params_BG (fmol).
 * CONSTANTS[7] is K_1 in component params_BG (per_fmol).
 * CONSTANTS[8] is q_init_1 in component params_BG (fmol).
 * CONSTANTS[9] is K_2 in component params_BG (per_fmol).
 * CONSTANTS[10] is q_init_2 in component params_BG (fmol).
 * CONSTANTS[11] is K_3 in component params_BG (per_fmol).
 * CONSTANTS[12] is q_init_3 in component params_BG (fmol).
 * CONSTANTS[13] is K_4 in component params_BG (per_fmol).
 * CONSTANTS[14] is q_init_4 in component params_BG (fmol).
 * CONSTANTS[15] is K_5 in component params_BG (per_fmol).
 * CONSTANTS[16] is q_init_5 in component params_BG (fmol).
 * CONSTANTS[17] is K_6 in component params_BG (per_fmol).
 * CONSTANTS[18] is q_init_6 in component params_BG (fmol).
 * ALGEBRAIC[16] is V0_Vm in component params_BG (volt).
 * CONSTANTS[19] is z_zf1 in component params_BG (dimensionless).
 * CONSTANTS[20] is z_zr1 in component params_BG (dimensionless).
 * CONSTANTS[21] is z_zf6 in component params_BG (dimensionless).
 * CONSTANTS[22] is z_zr6 in component params_BG (dimensionless).
 * CONSTANTS[23] is kappa_r1 in component params_BG (fmol_per_s).
 * CONSTANTS[24] is kappa_r2 in component params_BG (fmol_per_s).
 * CONSTANTS[25] is kappa_r3 in component params_BG (fmol_per_s).
 * CONSTANTS[26] is kappa_r4 in component params_BG (fmol_per_s).
 * CONSTANTS[27] is kappa_r5 in component params_BG (fmol_per_s).
 * CONSTANTS[28] is kappa_r6 in component params_BG (fmol_per_s).
 * CONSTANTS[29] is kappa_r7 in component params_BG (fmol_per_s).
 * CONSTANTS[39] is mu_Nai in component SGLT1_BG (J_per_mol).
 * CONSTANTS[41] is mu_Nao in component SGLT1_BG (J_per_mol).
 * CONSTANTS[43] is mu_Glci in component SGLT1_BG (J_per_mol).
 * CONSTANTS[45] is mu_Glco in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[0] is mu_1 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[41] is v_1 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[1] is mu_2 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[42] is v_2 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[2] is mu_3 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[24] is v_3 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[3] is mu_4 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[25] is v_4 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[4] is mu_5 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[26] is v_5 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[5] is mu_6 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[43] is v_6 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[18] is V_Vm in component SGLT1_BG (volt).
 * ALGEBRAIC[27] is V_zf1 in component SGLT1_BG (volt).
 * ALGEBRAIC[49] is I_zf1 in component SGLT1_BG (fA).
 * ALGEBRAIC[31] is mu_zf1 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[44] is v_zf1 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[28] is V_zr1 in component SGLT1_BG (volt).
 * ALGEBRAIC[50] is I_zr1 in component SGLT1_BG (fA).
 * ALGEBRAIC[32] is mu_zr1 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[45] is v_zr1 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[29] is V_zf6 in component SGLT1_BG (volt).
 * ALGEBRAIC[51] is I_zf6 in component SGLT1_BG (fA).
 * ALGEBRAIC[33] is mu_zf6 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[46] is v_zf6 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[30] is V_zr6 in component SGLT1_BG (volt).
 * ALGEBRAIC[52] is I_zr6 in component SGLT1_BG (fA).
 * ALGEBRAIC[34] is mu_zr6 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[47] is v_zr6 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[35] is A_f_r1 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[39] is v_r1 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[36] is A_r_r1 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[6] is A_f_r2 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[19] is v_r2 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[7] is A_r_r2 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[8] is A_f_r3 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[20] is v_r3 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[9] is A_r_r3 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[10] is A_f_r4 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[21] is v_r4 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[11] is A_r_r4 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[12] is A_f_r5 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[22] is v_r5 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[13] is A_r_r5 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[37] is A_f_r6 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[40] is v_r6 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[38] is A_r_r6 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[14] is A_f_r7 in component SGLT1_BG (J_per_mol).
 * ALGEBRAIC[23] is v_r7 in component SGLT1_BG (fmol_per_s).
 * ALGEBRAIC[15] is A_r_r7 in component SGLT1_BG (J_per_mol).
 * STATES[0] is q_1 in component SGLT1_BG (fmol).
 * STATES[1] is q_2 in component SGLT1_BG (fmol).
 * STATES[2] is q_3 in component SGLT1_BG (fmol).
 * STATES[3] is q_4 in component SGLT1_BG (fmol).
 * STATES[4] is q_5 in component SGLT1_BG (fmol).
 * STATES[5] is q_6 in component SGLT1_BG (fmol).
 * ALGEBRAIC[53] is Ii in component SGLT1_BG (fA).
 * ALGEBRAIC[48] is I_ss in component SGLT1_BG (fA).
 * CONSTANTS[30] is Nai in component params_BG (mM).
 * CONSTANTS[31] is Nao in component params_BG (mM).
 * CONSTANTS[32] is Glci in component params_BG (mM).
 * CONSTANTS[33] is Glco in component params_BG (mM).
 * CONSTANTS[34] is V_i in component params_BG (pL).
 * CONSTANTS[35] is V_o in component params_BG (pL).
 * STATES[6] is V_E in component params_BG (volt).
 * CONSTANTS[36] is test_volt in component params_BG (volt).
 * ALGEBRAIC[17] is rate_VE in component params_BG (volt_per_s).
 * CONSTANTS[37] is dt in component params_BG (second).
 * RATES[0] is d/dt q_1 in component SGLT1_BG (fmol).
 * RATES[1] is d/dt q_2 in component SGLT1_BG (fmol).
 * RATES[2] is d/dt q_3 in component SGLT1_BG (fmol).
 * RATES[3] is d/dt q_4 in component SGLT1_BG (fmol).
 * RATES[4] is d/dt q_5 in component SGLT1_BG (fmol).
 * RATES[5] is d/dt q_6 in component SGLT1_BG (fmol).
 * RATES[6] is d/dt V_E in component params_BG (volt).
 * There are a total of 7 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 8.31;
CONSTANTS[1] = 293;
CONSTANTS[2] = 96485;
CONSTANTS[3] = 3.216e-08;
CONSTANTS[4] = 3.216e-08;
CONSTANTS[5] = 4.848e-06;
CONSTANTS[6] = 4.848e-06;
CONSTANTS[7] = 2.235;
CONSTANTS[8] = 13.7727015449461;
CONSTANTS[9] = 10.437;
CONSTANTS[10] = 72.295598813025;
CONSTANTS[11] = 8.602;
CONSTANTS[12] = 0.16701061319503;
CONSTANTS[13] = 8.602;
CONSTANTS[14] = 0.233806833618937;
CONSTANTS[15] = 28.628;
CONSTANTS[16] = 1.73527350102727;
CONSTANTS[17] = 0.192;
CONSTANTS[18] = 11.4302815603453;
CONSTANTS[19] = 0.3;
CONSTANTS[20] = 0.3;
CONSTANTS[21] = 0.7;
CONSTANTS[22] = 0.7;
CONSTANTS[23] = 47.905;
CONSTANTS[24] = 2.325;
CONSTANTS[25] = 5.812;
CONSTANTS[26] = 92.998;
CONSTANTS[27] = 0.349;
CONSTANTS[28] = 15.661;
CONSTANTS[29] = 0.029;
CONSTANTS[30] = 20;
CONSTANTS[31] = 100;
CONSTANTS[32] = 10e-3;
CONSTANTS[33] = 1e-12;
CONSTANTS[34] = 8.5e5;
CONSTANTS[35] = 8.5e5;
STATES[6] = -0.05;
CONSTANTS[36] = 0;
CONSTANTS[37] = 1e-3;
CONSTANTS[38] =  CONSTANTS[30]*CONSTANTS[34];
CONSTANTS[39] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[3]*CONSTANTS[38]);
CONSTANTS[40] =  CONSTANTS[31]*CONSTANTS[35];
CONSTANTS[41] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[4]*CONSTANTS[40]);
CONSTANTS[42] =  CONSTANTS[32]*CONSTANTS[34];
CONSTANTS[43] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[5]*CONSTANTS[42]);
CONSTANTS[44] =  CONSTANTS[33]*CONSTANTS[35];
CONSTANTS[45] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[6]*CONSTANTS[44]);
STATES[0] = CONSTANTS[8];
STATES[1] = CONSTANTS[10];
STATES[2] = CONSTANTS[12];
STATES[3] = CONSTANTS[14];
STATES[4] = CONSTANTS[16];
STATES[5] = CONSTANTS[18];
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;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - ALGEBRAIC[41];
resid[1] = RATES[1] - ALGEBRAIC[42];
resid[2] = RATES[2] - ALGEBRAIC[24];
resid[3] = RATES[3] - ALGEBRAIC[25];
resid[4] = RATES[4] - ALGEBRAIC[26];
resid[5] = RATES[5] - ALGEBRAIC[43];
resid[6] = RATES[6] - ALGEBRAIC[17];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[44] = ALGEBRAIC[39];
ALGEBRAIC[45] = ALGEBRAIC[39];
ALGEBRAIC[46] = ALGEBRAIC[40];
ALGEBRAIC[47] = ALGEBRAIC[40];
ALGEBRAIC[48] =  2.00000*CONSTANTS[2]*- ALGEBRAIC[40];
ALGEBRAIC[49] =  CONSTANTS[19]*CONSTANTS[2]*ALGEBRAIC[44];
ALGEBRAIC[50] =  CONSTANTS[20]*CONSTANTS[2]*ALGEBRAIC[45];
ALGEBRAIC[51] =  CONSTANTS[21]*CONSTANTS[2]*ALGEBRAIC[46];
ALGEBRAIC[52] =  CONSTANTS[22]*CONSTANTS[2]*ALGEBRAIC[47];
ALGEBRAIC[53] = ALGEBRAIC[49]+ALGEBRAIC[50]+ALGEBRAIC[51]+ALGEBRAIC[52];
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[17] = (CONDVAR[0]<0.00000 ? 0.00000 : CONDVAR[1]>=0.00000&&CONDVAR[2]<0.00000 ? (CONSTANTS[36]+0.0500000)/CONSTANTS[37] : CONDVAR[3]>=0.00000&&CONDVAR[4]<0.00000 ? 0.00000 : CONDVAR[5]>=0.00000&&CONDVAR[6]<0.00000 ? - (CONSTANTS[36]+0.0500000)/CONSTANTS[37] : 0.00000);
ALGEBRAIC[1] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[9]*STATES[1]);
ALGEBRAIC[6] = CONSTANTS[45]+ALGEBRAIC[1];
ALGEBRAIC[2] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[11]*STATES[2]);
ALGEBRAIC[7] = ALGEBRAIC[2];
ALGEBRAIC[19] =  CONSTANTS[24]*(exp(ALGEBRAIC[6]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[7]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[8] = ALGEBRAIC[2];
ALGEBRAIC[3] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[13]*STATES[3]);
ALGEBRAIC[9] = ALGEBRAIC[3];
ALGEBRAIC[20] =  CONSTANTS[25]*(exp(ALGEBRAIC[8]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[9]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[24] = ALGEBRAIC[19] - ALGEBRAIC[20];
ALGEBRAIC[10] = ALGEBRAIC[3];
ALGEBRAIC[4] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[15]*STATES[4]);
ALGEBRAIC[11] = CONSTANTS[43]+ALGEBRAIC[4];
ALGEBRAIC[21] =  CONSTANTS[26]*(exp(ALGEBRAIC[10]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[11]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[25] = ALGEBRAIC[20] - ALGEBRAIC[21];
ALGEBRAIC[12] = ALGEBRAIC[4];
ALGEBRAIC[5] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[17]*STATES[5]);
ALGEBRAIC[13] =  2.00000*CONSTANTS[39]+ALGEBRAIC[5];
ALGEBRAIC[22] =  CONSTANTS[27]*(exp(ALGEBRAIC[12]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[13]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[14] = ALGEBRAIC[1];
ALGEBRAIC[15] = ALGEBRAIC[4];
ALGEBRAIC[23] =  CONSTANTS[29]*(exp(ALGEBRAIC[14]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[15]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[26] = (ALGEBRAIC[21] - ALGEBRAIC[22])+ALGEBRAIC[23];
ALGEBRAIC[0] =  CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[7]*STATES[0]);
ALGEBRAIC[16] = STATES[6];
ALGEBRAIC[18] = ALGEBRAIC[16];
ALGEBRAIC[27] = ALGEBRAIC[18];
ALGEBRAIC[31] =  CONSTANTS[19]*CONSTANTS[2]*ALGEBRAIC[27];
ALGEBRAIC[35] = ( 2.00000*CONSTANTS[41]+ALGEBRAIC[0]) - ALGEBRAIC[31];
ALGEBRAIC[28] = ALGEBRAIC[18];
ALGEBRAIC[32] =  CONSTANTS[20]*CONSTANTS[2]*ALGEBRAIC[28];
ALGEBRAIC[36] = ALGEBRAIC[1]+ALGEBRAIC[32];
ALGEBRAIC[39] =  CONSTANTS[23]*(exp(ALGEBRAIC[35]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[36]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[29] = ALGEBRAIC[18];
ALGEBRAIC[33] =  CONSTANTS[21]*CONSTANTS[2]*ALGEBRAIC[29];
ALGEBRAIC[37] = ALGEBRAIC[5] - ALGEBRAIC[33];
ALGEBRAIC[30] = ALGEBRAIC[18];
ALGEBRAIC[34] =  CONSTANTS[22]*CONSTANTS[2]*ALGEBRAIC[30];
ALGEBRAIC[38] = ALGEBRAIC[0]+ALGEBRAIC[34];
ALGEBRAIC[40] =  CONSTANTS[28]*(exp(ALGEBRAIC[37]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[38]/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[41] = - ALGEBRAIC[39]+ALGEBRAIC[40];
ALGEBRAIC[42] = (ALGEBRAIC[39] - ALGEBRAIC[19]) - ALGEBRAIC[23];
ALGEBRAIC[43] = ALGEBRAIC[22] - ALGEBRAIC[40];
}
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;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - 1.20475;
CONDVAR[1] = VOI - 1.20475;
CONDVAR[2] = VOI - (1.20475+CONSTANTS[37]);
CONDVAR[3] = VOI - (1.20475+CONSTANTS[37]);
CONDVAR[4] = VOI - 2.98475;
CONDVAR[5] = VOI - 2.98475;
CONDVAR[6] = VOI - (2.98475+CONSTANTS[37]);
}