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 21 entries in each of the rate and state variable arrays.
   There are a total of 72 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[0] is V in component membrane (millivolt).
 * CONSTANTS[0] is R in component membrane (joule_per_kilomole_kelvin).
 * CONSTANTS[1] is T in component membrane (kelvin).
 * CONSTANTS[2] is F in component membrane (coulomb_per_mole).
 * CONSTANTS[3] is Cm in component membrane (microF).
 * ALGEBRAIC[6] is i_K1 in component time_independent_potassium_current (nanoA).
 * ALGEBRAIC[35] is i_to in component transient_outward_current (nanoA).
 * ALGEBRAIC[7] is i_Kr in component rapid_delayed_rectifier_potassium_current (nanoA).
 * ALGEBRAIC[10] is i_Ks in component slow_delayed_rectifier_potassium_current (nanoA).
 * ALGEBRAIC[22] is i_Ca_L_K_cyt in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[25] is i_Ca_L_K_ds in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[38] is i_NaK in component sodium_potassium_pump (nanoA).
 * ALGEBRAIC[13] is i_Na in component fast_sodium_current (nanoA).
 * ALGEBRAIC[20] is i_b_Na in component sodium_background_current (nanoA).
 * ALGEBRAIC[19] is i_p_Na in component persistent_sodium_current (nanoA).
 * ALGEBRAIC[23] is i_Ca_L_Na_cyt in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[26] is i_Ca_L_Na_ds in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[39] is i_NaCa_cyt in component sodium_calcium_exchanger (nanoA).
 * ALGEBRAIC[40] is i_NaCa_ds in component sodium_calcium_exchanger (nanoA).
 * ALGEBRAIC[21] is i_Ca_L_Ca_cyt in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[24] is i_Ca_L_Ca_ds in component L_type_Ca_channel (nanoA).
 * ALGEBRAIC[34] is i_b_Ca in component calcium_background_current (nanoA).
 * ALGEBRAIC[0] is i_Stim in component membrane (nanoA).
 * CONSTANTS[4] is stim_start in component membrane (second).
 * CONSTANTS[5] is stim_end in component membrane (second).
 * CONSTANTS[6] is stim_period in component membrane (second).
 * CONSTANTS[7] is stim_duration in component membrane (second).
 * CONSTANTS[8] is stim_amplitude in component membrane (nanoA).
 * ALGEBRAIC[1] is E_Na in component reversal_potentials (millivolt).
 * ALGEBRAIC[2] is E_K in component reversal_potentials (millivolt).
 * ALGEBRAIC[3] is E_Ks in component reversal_potentials (millivolt).
 * ALGEBRAIC[4] is E_Ca in component reversal_potentials (millivolt).
 * ALGEBRAIC[5] is E_mh in component reversal_potentials (millivolt).
 * CONSTANTS[9] is P_kna in component reversal_potentials (dimensionless).
 * CONSTANTS[10] is K_o in component extracellular_potassium_concentration (millimolar).
 * CONSTANTS[11] is Na_o in component extracellular_sodium_concentration (millimolar).
 * STATES[1] is K_i in component intracellular_potassium_concentration (millimolar).
 * STATES[2] is Na_i in component intracellular_sodium_concentration (millimolar).
 * CONSTANTS[12] is Ca_o in component extracellular_calcium_concentration (millimolar).
 * STATES[3] is Ca_i in component intracellular_calcium_concentration (millimolar).
 * CONSTANTS[13] is K_mk1 in component time_independent_potassium_current (millimolar).
 * CONSTANTS[14] is g_K1 in component time_independent_potassium_current (microS).
 * CONSTANTS[65] is g_Kr in component rapid_delayed_rectifier_potassium_current (microS).
 * STATES[4] is xr in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless).
 * ALGEBRAIC[8] is xr_inf in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless).
 * ALGEBRAIC[9] is tau_xr in component rapid_delayed_rectifier_potassium_current_xr_gate (second).
 * CONSTANTS[66] is g_Ks in component slow_delayed_rectifier_potassium_current (microS).
 * STATES[5] is xs in component slow_delayed_rectifier_potassium_current_xs_gate (dimensionless).
 * ALGEBRAIC[11] is xs_inf in component slow_delayed_rectifier_potassium_current_xs_gate (dimensionless).
 * ALGEBRAIC[12] is tau_xs in component slow_delayed_rectifier_potassium_current_xs_gate (second).
 * CONSTANTS[67] is g_Na in component fast_sodium_current (microS).
 * CONSTANTS[15] is nachanneldensity in component fast_sodium_current (per_microF).
 * CONSTANTS[16] is gnachannel in component fast_sodium_current (microS).
 * STATES[6] is m in component fast_sodium_current_m_gate (dimensionless).
 * STATES[7] is h in component fast_sodium_current_h_gate (dimensionless).
 * CONSTANTS[17] is proton in component fast_sodium_current_h_gate (dimensionless).
 * ALGEBRAIC[15] is alpha_m in component fast_sodium_current_m_gate (per_second).
 * ALGEBRAIC[16] is beta_m in component fast_sodium_current_m_gate (per_second).
 * CONSTANTS[18] is delta_m in component fast_sodium_current_m_gate (millivolt).
 * ALGEBRAIC[14] is E0_m in component fast_sodium_current_m_gate (millivolt).
 * ALGEBRAIC[17] is alpha_h in component fast_sodium_current_h_gate (per_second).
 * ALGEBRAIC[18] is beta_h in component fast_sodium_current_h_gate (per_second).
 * CONSTANTS[68] is shifth in component fast_sodium_current_h_gate (millivolt).
 * CONSTANTS[19] is g_pna in component persistent_sodium_current (microS).
 * CONSTANTS[20] is g_bna in component sodium_background_current (microS).
 * ALGEBRAIC[27] is i_Ca_L in component L_type_Ca_channel (nanoA).
 * CONSTANTS[21] is P_Ca_L in component L_type_Ca_channel (nanoA_per_millimolar).
 * CONSTANTS[22] is P_CaK in component L_type_Ca_channel (dimensionless).
 * CONSTANTS[23] is P_CaNa in component L_type_Ca_channel (dimensionless).
 * STATES[8] is Ca_ds in component intracellular_calcium_concentration (millimolar).
 * STATES[9] is d in component L_type_Ca_channel_d_gate (dimensionless).
 * STATES[10] is f in component L_type_Ca_channel_f_gate (dimensionless).
 * STATES[11] is f2 in component L_type_Ca_channel_f2_gate (dimensionless).
 * STATES[12] is f2ds in component L_type_Ca_channel_f2ds_gate (dimensionless).
 * CONSTANTS[24] is Km_f2 in component L_type_Ca_channel (millimolar).
 * CONSTANTS[25] is Km_f2ds in component L_type_Ca_channel (millimolar).
 * CONSTANTS[26] is R_decay in component L_type_Ca_channel (per_second).
 * CONSTANTS[27] is FrICa in component L_type_Ca_channel (dimensionless).
 * ALGEBRAIC[29] is alpha_d in component L_type_Ca_channel_d_gate (per_second).
 * ALGEBRAIC[30] is beta_d in component L_type_Ca_channel_d_gate (per_second).
 * ALGEBRAIC[28] is E0_d in component L_type_Ca_channel_d_gate (millivolt).
 * CONSTANTS[28] is speed_d in component L_type_Ca_channel_d_gate (dimensionless).
 * ALGEBRAIC[32] is alpha_f in component L_type_Ca_channel_f_gate (per_second).
 * ALGEBRAIC[33] is beta_f in component L_type_Ca_channel_f_gate (per_second).
 * CONSTANTS[29] is speed_f in component L_type_Ca_channel_f_gate (dimensionless).
 * CONSTANTS[30] is delta_f in component L_type_Ca_channel_f_gate (millivolt).
 * ALGEBRAIC[31] is E0_f in component L_type_Ca_channel_f_gate (millivolt).
 * CONSTANTS[31] is g_bca in component calcium_background_current (microS).
 * CONSTANTS[32] is g_to in component transient_outward_current (microS).
 * CONSTANTS[33] is g_tos in component transient_outward_current (dimensionless).
 * STATES[13] is s in component transient_outward_current_s_gate (dimensionless).
 * STATES[14] is r in component transient_outward_current_r_gate (dimensionless).
 * ALGEBRAIC[36] is alpha_s in component transient_outward_current_s_gate (per_second).
 * ALGEBRAIC[37] is beta_s in component transient_outward_current_s_gate (per_second).
 * CONSTANTS[34] is i_NaK_max in component sodium_potassium_pump (nanoA).
 * CONSTANTS[35] is K_mK in component sodium_potassium_pump (millimolar).
 * CONSTANTS[36] is K_mNa in component sodium_potassium_pump (millimolar).
 * ALGEBRAIC[41] is i_NaCa in component sodium_calcium_exchanger (nanoA).
 * CONSTANTS[37] is k_NaCa in component sodium_calcium_exchanger (nanoA).
 * CONSTANTS[38] is n_NaCa in component sodium_calcium_exchanger (dimensionless).
 * CONSTANTS[39] is d_NaCa in component sodium_calcium_exchanger (dimensionless).
 * CONSTANTS[40] is gamma in component sodium_calcium_exchanger (dimensionless).
 * CONSTANTS[41] is FRiNaCa in component sodium_calcium_exchanger (dimensionless).
 * ALGEBRAIC[43] is i_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second).
 * CONSTANTS[69] is K_1 in component sarcoplasmic_reticulum_calcium_pump (dimensionless).
 * ALGEBRAIC[42] is K_2 in component sarcoplasmic_reticulum_calcium_pump (millimolar).
 * CONSTANTS[42] is K_cyca in component sarcoplasmic_reticulum_calcium_pump (millimolar).
 * CONSTANTS[43] is K_xcs in component sarcoplasmic_reticulum_calcium_pump (dimensionless).
 * CONSTANTS[44] is K_srca in component sarcoplasmic_reticulum_calcium_pump (millimolar).
 * CONSTANTS[45] is alpha_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second).
 * CONSTANTS[46] is beta_up in component sarcoplasmic_reticulum_calcium_pump (millimolar_per_second).
 * STATES[15] is Ca_up in component intracellular_calcium_concentration (millimolar).
 * ALGEBRAIC[44] is i_trans in component calcium_translocation (millimolar_per_second).
 * STATES[16] is Ca_rel in component intracellular_calcium_concentration (millimolar).
 * ALGEBRAIC[53] is i_rel in component calcium_release (millimolar_per_second).
 * ALGEBRAIC[45] is VoltDep in component calcium_release (dimensionless).
 * ALGEBRAIC[48] is RegBindSite in component calcium_release (dimensionless).
 * ALGEBRAIC[46] is CaiReg in component calcium_release (dimensionless).
 * ALGEBRAIC[47] is CadsReg in component calcium_release (dimensionless).
 * ALGEBRAIC[49] is ActRate in component calcium_release (per_second).
 * ALGEBRAIC[50] is InactRate in component calcium_release (per_second).
 * CONSTANTS[47] is K_leak_rate in component calcium_release (per_second).
 * CONSTANTS[48] is K_m_rel in component calcium_release (per_second).
 * CONSTANTS[49] is K_m_Ca_cyt in component calcium_release (millimolar).
 * CONSTANTS[50] is K_m_Ca_ds in component calcium_release (millimolar).
 * ALGEBRAIC[52] is PrecFrac in component calcium_release (dimensionless).
 * STATES[17] is ActFrac in component calcium_release (dimensionless).
 * STATES[18] is ProdFrac in component calcium_release (dimensionless).
 * ALGEBRAIC[51] is SpeedRel in component calcium_release (dimensionless).
 * CONSTANTS[71] is V_i in component intracellular_calcium_concentration (micrometre3).
 * STATES[19] is Ca_Calmod in component intracellular_calcium_concentration (millimolar).
 * STATES[20] is Ca_Trop in component intracellular_calcium_concentration (millimolar).
 * CONSTANTS[51] is Calmod in component intracellular_calcium_concentration (millimolar).
 * CONSTANTS[52] is Trop in component intracellular_calcium_concentration (millimolar).
 * CONSTANTS[53] is alpha_Calmod in component intracellular_calcium_concentration (per_millimolar_second).
 * CONSTANTS[54] is beta_Calmod in component intracellular_calcium_concentration (per_second).
 * CONSTANTS[55] is alpha_Trop in component intracellular_calcium_concentration (per_millimolar_second).
 * CONSTANTS[56] is beta_Trop in component intracellular_calcium_concentration (per_second).
 * CONSTANTS[57] is radius in component intracellular_calcium_concentration (micrometre).
 * CONSTANTS[58] is length in component intracellular_calcium_concentration (micrometre).
 * CONSTANTS[64] is V_Cell in component intracellular_calcium_concentration (micrometre3).
 * CONSTANTS[70] is V_i_ratio in component intracellular_calcium_concentration (dimensionless).
 * CONSTANTS[59] is V_ds_ratio in component intracellular_calcium_concentration (dimensionless).
 * CONSTANTS[60] is V_rel_ratio in component intracellular_calcium_concentration (dimensionless).
 * CONSTANTS[61] is V_e_ratio in component intracellular_calcium_concentration (dimensionless).
 * CONSTANTS[62] is V_up_ratio in component intracellular_calcium_concentration (dimensionless).
 * CONSTANTS[63] is Kdecay in component intracellular_calcium_concentration (per_second).
 * RATES[0] is d/dt V in component membrane (millivolt).
 * RATES[4] is d/dt xr in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless).
 * RATES[5] is d/dt xs in component slow_delayed_rectifier_potassium_current_xs_gate (dimensionless).
 * RATES[6] is d/dt m in component fast_sodium_current_m_gate (dimensionless).
 * RATES[7] is d/dt h in component fast_sodium_current_h_gate (dimensionless).
 * RATES[9] is d/dt d in component L_type_Ca_channel_d_gate (dimensionless).
 * RATES[10] is d/dt f in component L_type_Ca_channel_f_gate (dimensionless).
 * RATES[11] is d/dt f2 in component L_type_Ca_channel_f2_gate (dimensionless).
 * RATES[12] is d/dt f2ds in component L_type_Ca_channel_f2ds_gate (dimensionless).
 * RATES[13] is d/dt s in component transient_outward_current_s_gate (dimensionless).
 * RATES[14] is d/dt r in component transient_outward_current_r_gate (dimensionless).
 * RATES[17] is d/dt ActFrac in component calcium_release (dimensionless).
 * RATES[18] is d/dt ProdFrac in component calcium_release (dimensionless).
 * RATES[2] is d/dt Na_i in component intracellular_sodium_concentration (millimolar).
 * RATES[1] is d/dt K_i in component intracellular_potassium_concentration (millimolar).
 * RATES[3] is d/dt Ca_i in component intracellular_calcium_concentration (millimolar).
 * RATES[19] is d/dt Ca_Calmod in component intracellular_calcium_concentration (millimolar).
 * RATES[20] is d/dt Ca_Trop in component intracellular_calcium_concentration (millimolar).
 * RATES[8] is d/dt Ca_ds in component intracellular_calcium_concentration (millimolar).
 * RATES[15] is d/dt Ca_up in component intracellular_calcium_concentration (millimolar).
 * RATES[16] is d/dt Ca_rel in component intracellular_calcium_concentration (millimolar).
 * There are a total of 8 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -89.1374183;
CONSTANTS[0] = 8314.472;
CONSTANTS[1] = 310;
CONSTANTS[2] = 96485.3415;
CONSTANTS[3] = 0.000121;
CONSTANTS[4] = 0.1;
CONSTANTS[5] = 9;
CONSTANTS[6] = 1;
CONSTANTS[7] = 0.003;
CONSTANTS[8] = -2;
CONSTANTS[9] = 0.03;
CONSTANTS[10] = 4;
CONSTANTS[11] = 140;
STATES[1] = 138.7963753;
STATES[2] = 5.6633707;
CONSTANTS[12] = 2;
STATES[3] = 5.44e-5;
CONSTANTS[13] = 10;
CONSTANTS[14] = 0.2;
STATES[4] = 1.98e-5;
STATES[5] = 0.0381477;
CONSTANTS[15] = 1075;
CONSTANTS[16] = 20;
STATES[6] = 0.0026891;
STATES[7] = 0.9873107;
CONSTANTS[17] = 3.98e-5;
CONSTANTS[18] = 1e-5;
CONSTANTS[19] = 0.005;
CONSTANTS[20] = 0.0006;
CONSTANTS[21] = 0.11;
CONSTANTS[22] = 0.002;
CONSTANTS[23] = 0.01;
STATES[8] = 0.0018991;
STATES[9] = 1.44e-4;
STATES[10] = 0.9999993;
STATES[11] = 0.254433;
STATES[12] = 0.9292189;
CONSTANTS[24] = 100000;
CONSTANTS[25] = 0.001;
CONSTANTS[26] = 20;
CONSTANTS[27] = 1;
CONSTANTS[28] = 3;
CONSTANTS[29] = 0.3;
CONSTANTS[30] = 0.0001;
CONSTANTS[31] = 0.00025;
CONSTANTS[32] = 0.005;
CONSTANTS[33] = 0;
STATES[13] = 0.7352365;
STATES[14] = 0;
CONSTANTS[34] = 0.7;
CONSTANTS[35] = 1;
CONSTANTS[36] = 40;
CONSTANTS[37] = 0.00012;
CONSTANTS[38] = 3;
CONSTANTS[39] = 0;
CONSTANTS[40] = 0.5;
CONSTANTS[41] = 0.001;
CONSTANTS[42] = 0.0003;
CONSTANTS[43] = 0.4;
CONSTANTS[44] = 0.5;
CONSTANTS[45] = 0.4;
CONSTANTS[46] = 0.03;
STATES[15] = 0.7625025;
STATES[16] = 0.7368094;
CONSTANTS[47] = 0.05;
CONSTANTS[48] = 250;
CONSTANTS[49] = 0.0005;
CONSTANTS[50] = 0.01;
STATES[17] = 0.0101647;
STATES[18] = 0.9584464;
STATES[19] = 0.0018544;
STATES[20] = 0.0012852;
CONSTANTS[51] = 0.02;
CONSTANTS[52] = 0.05;
CONSTANTS[53] = 100000;
CONSTANTS[54] = 50;
CONSTANTS[55] = 100000;
CONSTANTS[56] = 200;
CONSTANTS[57] = 12;
CONSTANTS[58] = 74;
CONSTANTS[59] = 0.1;
CONSTANTS[60] = 0.1;
CONSTANTS[61] = 0.4;
CONSTANTS[62] = 0.01;
CONSTANTS[63] = 10;
CONSTANTS[64] = ( 3.14159*pow(CONSTANTS[57]/1000.00, 2.00000)*CONSTANTS[58])/1000.00;
CONSTANTS[65] =  CONSTANTS[3]*7.70000* pow((CONSTANTS[10]/5.40000), 1.0 / 2);
CONSTANTS[66] =  CONSTANTS[3]*26.6000;
CONSTANTS[67] = ( CONSTANTS[15]*CONSTANTS[3]*CONSTANTS[16]*(1.26000/(1.00000+CONSTANTS[17]/( 1000.00*2.51190e-06))+0.340000))/1.58000;
CONSTANTS[68] = 32.7000/(1.00000+(CONSTANTS[17]/1000.00)/2.51190e-06) - 32.1800;
CONSTANTS[69] = ( CONSTANTS[42]*CONSTANTS[43])/CONSTANTS[44];
CONSTANTS[70] = ((1.00000 - CONSTANTS[61]) - CONSTANTS[62]) - CONSTANTS[60];
CONSTANTS[71] =  CONSTANTS[64]*CONSTANTS[70];
RATES[0] = 0.1001;
RATES[4] = 0.1001;
RATES[5] = 0.1001;
RATES[6] = 0.1001;
RATES[7] = 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[17] = 0.1001;
RATES[18] = 0.1001;
RATES[2] = 0.1001;
RATES[1] = 0.1001;
RATES[3] = 0.1001;
RATES[19] = 0.1001;
RATES[20] = 0.1001;
RATES[8] = 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] -  (- 1.00000/CONSTANTS[3])*(ALGEBRAIC[0]+ALGEBRAIC[6]+ALGEBRAIC[35]+ALGEBRAIC[7]+ALGEBRAIC[10]+ALGEBRAIC[38]+ALGEBRAIC[13]+ALGEBRAIC[20]+ALGEBRAIC[19]+ALGEBRAIC[23]+ALGEBRAIC[26]+ALGEBRAIC[39]+ALGEBRAIC[40]+ALGEBRAIC[21]+ALGEBRAIC[24]+ALGEBRAIC[22]+ALGEBRAIC[25]+ALGEBRAIC[34]);
resid[1] = RATES[4] - (ALGEBRAIC[8] - STATES[4])/ALGEBRAIC[9];
resid[2] = RATES[5] - (ALGEBRAIC[11] - STATES[5])/ALGEBRAIC[12];
resid[3] = RATES[6] -  ALGEBRAIC[15]*(1.00000 - STATES[6]) -  ALGEBRAIC[16]*STATES[6];
resid[4] = RATES[7] -  ALGEBRAIC[17]*(1.00000 - STATES[7]) -  ALGEBRAIC[18]*STATES[7];
resid[5] = RATES[9] -  CONSTANTS[28]*( ALGEBRAIC[29]*(1.00000 - STATES[9]) -  ALGEBRAIC[30]*STATES[9]);
resid[6] = RATES[10] -  CONSTANTS[29]*( ALGEBRAIC[32]*(1.00000 - STATES[10]) -  ALGEBRAIC[33]*STATES[10]);
resid[7] = RATES[11] - 1.00000 -  1.00000*(STATES[3]/(CONSTANTS[24]+STATES[3])+STATES[11]);
resid[8] = RATES[12] -  CONSTANTS[26]*(1.00000 - (STATES[8]/(CONSTANTS[25]+STATES[8])+STATES[12]));
resid[9] = RATES[13] -  ALGEBRAIC[36]*(1.00000 - STATES[13]) -  ALGEBRAIC[37]*STATES[13];
resid[10] = RATES[14] -  333.000*(1.00000/(1.00000+exp(- (STATES[0]+4.00000)/5.00000)) - STATES[14]);
resid[11] = RATES[17] -  ALGEBRAIC[52]*ALGEBRAIC[51]*ALGEBRAIC[49] -  STATES[17]*ALGEBRAIC[51]*ALGEBRAIC[50];
resid[12] = RATES[18] -  STATES[17]*ALGEBRAIC[51]*ALGEBRAIC[50] -  ALGEBRAIC[51]*1.00000*STATES[18];
resid[13] = RATES[2] -  (- 1.00000/( 1.00000*CONSTANTS[71]*CONSTANTS[2]))*(ALGEBRAIC[13]+ALGEBRAIC[19]+ALGEBRAIC[20]+ 3.00000*ALGEBRAIC[38]+ 3.00000*ALGEBRAIC[39]+ALGEBRAIC[23]+ALGEBRAIC[26]);
resid[14] = RATES[1] -  (- 1.00000/( 1.00000*CONSTANTS[71]*CONSTANTS[2]))*((ALGEBRAIC[6]+ALGEBRAIC[7]+ALGEBRAIC[10]+ALGEBRAIC[22]+ALGEBRAIC[25]+ALGEBRAIC[35]) -  2.00000*ALGEBRAIC[38]);
resid[15] = RATES[3] - ((( (- 1.00000/( 2.00000*1.00000*CONSTANTS[71]*CONSTANTS[2]))*((ALGEBRAIC[21]+ALGEBRAIC[34]) -  2.00000*ALGEBRAIC[39])+ STATES[8]*CONSTANTS[59]*CONSTANTS[63]+( ALGEBRAIC[53]*CONSTANTS[60])/CONSTANTS[70]) - RATES[19]) - RATES[20]) - ALGEBRAIC[43];
resid[16] = RATES[8] - ( - 1.00000*ALGEBRAIC[24])/( 2.00000*1.00000*CONSTANTS[59]*CONSTANTS[71]*CONSTANTS[2]) -  STATES[8]*CONSTANTS[63];
resid[17] = RATES[15] -  (CONSTANTS[70]/CONSTANTS[62])*ALGEBRAIC[43] - ALGEBRAIC[44];
resid[18] = RATES[16] -  (CONSTANTS[62]/CONSTANTS[60])*ALGEBRAIC[44] - ALGEBRAIC[53];
resid[19] = RATES[19] -  CONSTANTS[53]*STATES[3]*(CONSTANTS[51] - STATES[19]) -  CONSTANTS[54]*STATES[19];
resid[20] = RATES[20] -  CONSTANTS[55]*STATES[3]*(CONSTANTS[52] - STATES[20]) -  CONSTANTS[56]*STATES[20];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[27] = ALGEBRAIC[21]+ALGEBRAIC[22]+ALGEBRAIC[23]+ALGEBRAIC[24]+ALGEBRAIC[25]+ALGEBRAIC[26];
ALGEBRAIC[41] = ALGEBRAIC[39]+ALGEBRAIC[40];
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONDVAR[0]>=0.00000&&CONDVAR[1]<=0.00000&&CONDVAR[2]<=0.00000 ? CONSTANTS[8] : 0.00000);
ALGEBRAIC[2] =  (( CONSTANTS[0]*CONSTANTS[1])/CONSTANTS[2])*log(CONSTANTS[10]/STATES[1]);
ALGEBRAIC[6] = ( (( CONSTANTS[14]*CONSTANTS[10])/(CONSTANTS[10]+CONSTANTS[13]))*(STATES[0] - ALGEBRAIC[2]))/(1.00000+exp(( ((STATES[0] - ALGEBRAIC[2]) - 10.0000)*CONSTANTS[2]*1.50000)/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[7] =  (( CONSTANTS[65]*STATES[4]*1.00000)/(1.00000+exp((STATES[0]+9.00000)/22.4000)))*(STATES[0] - ALGEBRAIC[2]);
ALGEBRAIC[8] = 1.00000/(1.00000+exp(- (STATES[0]+21.5000)/7.50000));
ALGEBRAIC[9] = 0.00100000/(( 0.00138000*(STATES[0]+14.2000))/(1.00000 - exp( - 0.123000*(STATES[0]+14.2000)))+( 0.000610000*(STATES[0]+38.9000))/(exp( 0.145000*(STATES[0]+38.9000)) - 1.00000));
ALGEBRAIC[3] =  (( CONSTANTS[0]*CONSTANTS[1])/CONSTANTS[2])*log((CONSTANTS[10]+ CONSTANTS[9]*CONSTANTS[11])/(STATES[1]+ CONSTANTS[9]*STATES[2]));
ALGEBRAIC[10] =  CONSTANTS[66]*pow(STATES[5], 2.00000)*(STATES[0] - ALGEBRAIC[3]);
ALGEBRAIC[11] = 1.00000/(1.00000+exp(- (STATES[0] - 1.50000)/16.7000));
ALGEBRAIC[12] = 0.00100000/(( 7.19000e-05*(STATES[0]+30.0000))/(1.00000 - exp( - 0.148000*(STATES[0]+30.0000)))+( 0.000131000*(STATES[0]+30.0000))/(exp( 0.0687000*(STATES[0]+30.0000)) - 1.00000));
ALGEBRAIC[5] =  (( CONSTANTS[0]*CONSTANTS[1])/CONSTANTS[2])*log((CONSTANTS[11]+ 0.120000*CONSTANTS[10])/(STATES[2]+ 0.120000*STATES[1]));
ALGEBRAIC[13] =  CONSTANTS[67]*pow(STATES[6], 3.00000)*STATES[7]*(STATES[0] - ALGEBRAIC[5]);
ALGEBRAIC[14] = STATES[0]+41.0000;
ALGEBRAIC[15] = (CONDVAR[3]<0.00000 ? 2000.00 : ( 200.000*ALGEBRAIC[14])/(1.00000 - exp( - 0.100000*ALGEBRAIC[14])));
ALGEBRAIC[16] =  8000.00*exp( - 0.0560000*(STATES[0]+66.0000));
ALGEBRAIC[17] =  20.0000*exp( - 0.125000*((STATES[0]+75.0000) - CONSTANTS[68]));
ALGEBRAIC[18] = 2000.00/(1.00000+ 320.000*exp( - 0.100000*((STATES[0]+75.0000) - CONSTANTS[68])));
ALGEBRAIC[19] = (( CONSTANTS[3]*1.00000e+06*CONSTANTS[19]*(STATES[0] - 51.5397))/(1.00000+exp(- (STATES[0]+58.0111)/7.03320)))/1000.00;
ALGEBRAIC[1] =  (( CONSTANTS[0]*CONSTANTS[1])/CONSTANTS[2])*log(CONSTANTS[11]/STATES[2]);
ALGEBRAIC[20] =  CONSTANTS[20]*(STATES[0] - ALGEBRAIC[1]);
ALGEBRAIC[21] =  ((( (1.00000 - CONSTANTS[27])*4.00000*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[11]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2]*2.00000)/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[3]*exp(( 100.000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[12]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2]*2.00000)/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[22] =  ((( (1.00000 - CONSTANTS[27])*CONSTANTS[22]*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[11]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[1]*exp(( 50.0000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[10]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[23] =  ((( (1.00000 - CONSTANTS[27])*CONSTANTS[23]*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[11]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[2]*exp(( 50.0000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[11]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[24] =  ((( CONSTANTS[27]*4.00000*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[12]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2]*2.00000)/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[3]*exp(( 100.000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[12]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2]*2.00000)/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[25] =  ((( CONSTANTS[27]*CONSTANTS[22]*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[12]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[1]*exp(( 50.0000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[10]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[26] =  ((( CONSTANTS[27]*CONSTANTS[23]*CONSTANTS[21]*STATES[9]*STATES[10]*STATES[12]*(STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))/(1.00000 - exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))))*( STATES[2]*exp(( 50.0000*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])) -  CONSTANTS[11]*exp(( - (STATES[0] - 50.0000)*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[28] = (STATES[0]+24.0000) - 5.00000;
ALGEBRAIC[29] = (CONDVAR[4]<0.00000 ? 120.000 : ( 30.0000*ALGEBRAIC[28])/(1.00000 - exp(- ALGEBRAIC[28]/7.20000)));
ALGEBRAIC[30] = (CONDVAR[5]<0.00000 ? 120.000 : ( 12.0000*ALGEBRAIC[28])/(exp(ALGEBRAIC[28]/( 2.50000*7.20000)) - 1.00000));
ALGEBRAIC[31] = STATES[0]+34.0000;
ALGEBRAIC[32] = (CONDVAR[6]<0.00000 ? 25.0000 : ( 6.25000*ALGEBRAIC[31])/(exp(ALGEBRAIC[31]/5.10000) - 1.00000));
ALGEBRAIC[33] = 12.0000/(1.00000+exp(( - 1.00000*(STATES[0]+34.0000))/5.10000));
ALGEBRAIC[4] =  (( 0.500000*CONSTANTS[0]*CONSTANTS[1])/CONSTANTS[2])*log(CONSTANTS[12]/STATES[3]);
ALGEBRAIC[34] =  CONSTANTS[31]*(STATES[0] - ALGEBRAIC[4]);
ALGEBRAIC[35] =  CONSTANTS[32]*(CONSTANTS[33]+ STATES[13]*(1.00000 - CONSTANTS[33]))*STATES[14]*(STATES[0] - ALGEBRAIC[2]);
ALGEBRAIC[36] =  0.0330000*exp(- STATES[0]/17.0000);
ALGEBRAIC[37] = 33.0000/(1.00000+exp( - 0.125000*(STATES[0]+10.0000)));
ALGEBRAIC[38] = ( (( CONSTANTS[34]*CONSTANTS[10])/(CONSTANTS[35]+CONSTANTS[10]))*STATES[2])/(CONSTANTS[36]+STATES[2]);
ALGEBRAIC[39] = ( (1.00000 - CONSTANTS[41])*CONSTANTS[37]*( exp(( CONSTANTS[40]*(CONSTANTS[38] - 2.00000)*STATES[0]*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))*pow(STATES[2], CONSTANTS[38])*CONSTANTS[12] -  exp(( (CONSTANTS[40] - 1.00000)*(CONSTANTS[38] - 2.00000)*STATES[0]*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))*pow(CONSTANTS[11], CONSTANTS[38])*STATES[3]))/( (1.00000+ CONSTANTS[39]*( STATES[3]*pow(CONSTANTS[11], CONSTANTS[38])+ CONSTANTS[12]*pow(STATES[2], CONSTANTS[38])))*(1.00000+STATES[3]/0.00690000));
ALGEBRAIC[40] = ( CONSTANTS[41]*CONSTANTS[37]*( exp(( CONSTANTS[40]*(CONSTANTS[38] - 2.00000)*STATES[0]*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))*pow(STATES[2], CONSTANTS[38])*CONSTANTS[12] -  exp(( (CONSTANTS[40] - 1.00000)*(CONSTANTS[38] - 2.00000)*STATES[0]*CONSTANTS[2])/( CONSTANTS[0]*CONSTANTS[1]))*pow(CONSTANTS[11], CONSTANTS[38])*STATES[8]))/( (1.00000+ CONSTANTS[39]*( STATES[8]*pow(CONSTANTS[11], CONSTANTS[38])+ CONSTANTS[12]*pow(STATES[2], CONSTANTS[38])))*(1.00000+STATES[8]/0.00690000));
ALGEBRAIC[42] = STATES[3]+ STATES[15]*CONSTANTS[69]+ CONSTANTS[42]*CONSTANTS[43]+CONSTANTS[42];
ALGEBRAIC[43] =  (STATES[3]/ALGEBRAIC[42])*CONSTANTS[45] -  (( STATES[15]*CONSTANTS[69])/ALGEBRAIC[42])*CONSTANTS[46];
ALGEBRAIC[44] =  50.0000*(STATES[15] - STATES[16]);
ALGEBRAIC[45] = exp( 0.0800000*(STATES[0] - 40.0000));
ALGEBRAIC[46] = STATES[3]/(STATES[3]+CONSTANTS[49]);
ALGEBRAIC[47] = STATES[8]/(STATES[8]+CONSTANTS[50]);
ALGEBRAIC[48] = ALGEBRAIC[46]+ (1.00000 - ALGEBRAIC[46])*ALGEBRAIC[47];
ALGEBRAIC[49] =  0.00000*ALGEBRAIC[45]+ 500.000*pow(ALGEBRAIC[48], 2.00000);
ALGEBRAIC[50] = 60.0000+ 500.000*pow(ALGEBRAIC[48], 2.00000);
ALGEBRAIC[51] = (CONDVAR[7]<0.00000 ? 5.00000 : 1.00000);
ALGEBRAIC[52] = (1.00000 - STATES[17]) - STATES[18];
ALGEBRAIC[53] =  ( pow(STATES[17]/(STATES[17]+0.250000), 2.00000)*CONSTANTS[48]+CONSTANTS[47])*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;
SI[17] = 1.0;
SI[18] = 1.0;
SI[19] = 1.0;
SI[20] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - CONSTANTS[4];
CONDVAR[1] = VOI - CONSTANTS[5];
CONDVAR[2] = ((VOI - CONSTANTS[4]) -  floor((VOI - CONSTANTS[4])/CONSTANTS[6])*CONSTANTS[6]) - CONSTANTS[7];
CONDVAR[3] = fabs(ALGEBRAIC[14]) - CONSTANTS[18];
CONDVAR[4] = fabs(ALGEBRAIC[28]) - 0.000100000;
CONDVAR[5] = fabs(ALGEBRAIC[28]) - 0.000100000;
CONDVAR[6] = fabs(ALGEBRAIC[31]) - CONSTANTS[30];
CONDVAR[7] = STATES[0] - - 50.0000;
}