Generated Code

The following is python code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

# Size of variable arrays:
sizeAlgebraic = 90
sizeStates = 33
sizeConstants = 104
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_voi = "time in component environment (second)"
    legend_constants[0] = "R in component Membrane (joule_per_kilomole_kelvin)"
    legend_constants[1] = "T in component Membrane (kelvin)"
    legend_constants[2] = "F in component Membrane (coulomb_per_mole)"
    legend_constants[3] = "C in component Membrane (microF)"
    legend_constants[85] = "RTONF in component Membrane (millivolt)"
    legend_algebraic[51] = "i_f in component i_f (nanoA)"
    legend_algebraic[52] = "i_NaK in component i_NaK (nanoA)"
    legend_algebraic[66] = "i_NaCa in component i_NaCa (nanoA)"
    legend_algebraic[68] = "i_Na in component i_Na (nanoA)"
    legend_algebraic[76] = "i_Kr in component i_Kr (nanoA)"
    legend_algebraic[80] = "i_Ks in component i_Ks (nanoA)"
    legend_algebraic[74] = "i_to in component i_to (nanoA)"
    legend_algebraic[72] = "i_CaL in component i_CaL (nanoA)"
    legend_algebraic[73] = "i_CaT in component i_CaT (nanoA)"
    legend_algebraic[83] = "i_KACh in component i_KACh (nanoA)"
    legend_algebraic[7] = "V in component Membrane (millivolt)"
    legend_constants[4] = "clamp_mode in component Membrane (dimensionless)"
    legend_algebraic[3] = "V_clamp in component Voltage_clamp (millivolt)"
    legend_states[0] = "V_ode in component Membrane (millivolt)"
    legend_algebraic[86] = "i_tot in component Membrane (nanoA)"
    legend_constants[5] = "t_holding in component Voltage_clamp (second)"
    legend_constants[6] = "t_test in component Voltage_clamp (second)"
    legend_constants[7] = "V_test in component Voltage_clamp (millivolt)"
    legend_constants[8] = "V_holding in component Voltage_clamp (millivolt)"
    legend_constants[9] = "Iva_3_uM in component Rate_modulation_experiments (dimensionless)"
    legend_constants[10] = "Cs_5_mM in component Rate_modulation_experiments (dimensionless)"
    legend_constants[11] = "ACh in component Rate_modulation_experiments (millimolar)"
    legend_constants[12] = "Iso_1_uM in component Rate_modulation_experiments (dimensionless)"
    legend_constants[13] = "BAPTA_10_mM in component Rate_modulation_experiments (dimensionless)"
    legend_algebraic[16] = "Nai in component Nai_concentration (millimolar)"
    legend_constants[14] = "Nao in component Ionic_values (millimolar)"
    legend_constants[15] = "Ki in component Ionic_values (millimolar)"
    legend_constants[16] = "Ko in component Ionic_values (millimolar)"
    legend_states[1] = "Ca_sub in component Ca_dynamics (millimolar)"
    legend_constants[17] = "Cao in component Ionic_values (millimolar)"
    legend_algebraic[32] = "E_Na in component Ionic_values (millivolt)"
    legend_constants[87] = "E_K in component Ionic_values (millivolt)"
    legend_algebraic[0] = "E_Ca in component Ionic_values (millivolt)"
    legend_constants[98] = "V_sub in component Cell_parameters (millimetre3)"
    legend_constants[100] = "V_i in component Cell_parameters (millimetre3)"
    legend_algebraic[46] = "i_fNa in component i_f (nanoA)"
    legend_algebraic[71] = "i_siNa in component i_CaL (nanoA)"
    legend_states[2] = "Nai_ in component Nai_concentration (millimolar)"
    legend_algebraic[42] = "ICs_on_Icontrol in component i_f (dimensionless)"
    legend_algebraic[49] = "i_fK in component i_f (nanoA)"
    legend_constants[82] = "g_f_Na in component i_f (microS)"
    legend_constants[83] = "g_f_K in component i_f (microS)"
    legend_constants[18] = "Km_f in component i_f (millimolar)"
    legend_states[3] = "y in component i_f_y_gate (dimensionless)"
    legend_algebraic[8] = "tau_y in component i_f_y_gate (second)"
    legend_algebraic[25] = "y_infinity in component i_f_y_gate (dimensionless)"
    legend_constants[89] = "ACh_shift in component i_f_y_gate (millivolt)"
    legend_constants[90] = "Iso_shift in component i_f_y_gate (millivolt)"
    legend_constants[19] = "Km_Kp in component i_NaK (millimolar)"
    legend_constants[20] = "Km_Nap in component i_NaK (millimolar)"
    legend_constants[21] = "i_NaK_max in component i_NaK (nanoA)"
    legend_constants[91] = "Iso_increase in component i_NaK (dimensionless)"
    legend_constants[22] = "K_NaCa in component i_NaCa (nanoA)"
    legend_algebraic[63] = "x1 in component i_NaCa (dimensionless)"
    legend_algebraic[59] = "x2 in component i_NaCa (dimensionless)"
    legend_algebraic[64] = "x3 in component i_NaCa (dimensionless)"
    legend_algebraic[65] = "x4 in component i_NaCa (dimensionless)"
    legend_algebraic[54] = "k41 in component i_NaCa (dimensionless)"
    legend_constants[92] = "k34 in component i_NaCa (dimensionless)"
    legend_algebraic[62] = "k23 in component i_NaCa (dimensionless)"
    legend_algebraic[61] = "k21 in component i_NaCa (dimensionless)"
    legend_algebraic[58] = "k32 in component i_NaCa (dimensionless)"
    legend_algebraic[53] = "k43 in component i_NaCa (dimensionless)"
    legend_algebraic[56] = "k12 in component i_NaCa (dimensionless)"
    legend_algebraic[57] = "k14 in component i_NaCa (dimensionless)"
    legend_constants[23] = "Qci in component i_NaCa (dimensionless)"
    legend_constants[24] = "Qn in component i_NaCa (dimensionless)"
    legend_constants[25] = "Qco in component i_NaCa (dimensionless)"
    legend_constants[26] = "K3ni in component i_NaCa (millimolar)"
    legend_constants[27] = "Kci in component i_NaCa (millimolar)"
    legend_constants[28] = "K1ni in component i_NaCa (millimolar)"
    legend_constants[29] = "K2ni in component i_NaCa (millimolar)"
    legend_constants[30] = "Kcni in component i_NaCa (millimolar)"
    legend_constants[31] = "K3no in component i_NaCa (millimolar)"
    legend_constants[32] = "K1no in component i_NaCa (millimolar)"
    legend_constants[33] = "K2no in component i_NaCa (millimolar)"
    legend_constants[34] = "Kco in component i_NaCa (millimolar)"
    legend_algebraic[60] = "do in component i_NaCa (dimensionless)"
    legend_algebraic[55] = "di in component i_NaCa (dimensionless)"
    legend_constants[35] = "g_Na in component i_Na (microS)"
    legend_algebraic[67] = "E_mh in component i_Na (millivolt)"
    legend_states[4] = "m in component i_Na_m_gate (dimensionless)"
    legend_states[5] = "h in component i_Na_h_gate (dimensionless)"
    legend_algebraic[26] = "alpha_m in component i_Na_m_gate (per_second)"
    legend_algebraic[40] = "beta_m in component i_Na_m_gate (per_second)"
    legend_constants[36] = "delta_m in component i_Na_m_gate (millivolt)"
    legend_algebraic[9] = "E0_m in component i_Na_m_gate (millivolt)"
    legend_algebraic[10] = "alpha_h in component i_Na_h_gate (per_second)"
    legend_algebraic[27] = "beta_h in component i_Na_h_gate (per_second)"
    legend_algebraic[69] = "i_siCa in component i_CaL (nanoA)"
    legend_algebraic[70] = "i_siK in component i_CaL (nanoA)"
    legend_constants[94] = "ACh_block in component i_CaL (dimensionless)"
    legend_constants[37] = "P_CaL in component i_CaL (nanoA_per_millimolar)"
    legend_states[6] = "dL in component i_CaL_dL_gate (dimensionless)"
    legend_states[7] = "fL in component i_CaL_fL_gate (dimensionless)"
    legend_states[8] = "fCa in component i_CaL_fCa_gate (dimensionless)"
    legend_constants[93] = "Iso_increase in component i_CaL (dimensionless)"
    legend_algebraic[11] = "dL_infinity in component i_CaL_dL_gate (dimensionless)"
    legend_algebraic[50] = "tau_dL in component i_CaL_dL_gate (second)"
    legend_algebraic[41] = "alpha_dL in component i_CaL_dL_gate (per_second)"
    legend_algebraic[48] = "beta_dL in component i_CaL_dL_gate (per_second)"
    legend_algebraic[28] = "adVm in component i_CaL_dL_gate (millivolt)"
    legend_algebraic[45] = "bdVm in component i_CaL_dL_gate (millivolt)"
    legend_constants[95] = "Iso_shift in component i_CaL_dL_gate (millivolt)"
    legend_constants[96] = "Iso_slope in component i_CaL_dL_gate (dimensionless)"
    legend_algebraic[12] = "fL_infinity in component i_CaL_fL_gate (dimensionless)"
    legend_algebraic[29] = "tau_fL in component i_CaL_fL_gate (second)"
    legend_constants[38] = "alpha_fCa in component i_CaL_fCa_gate (per_second)"
    legend_algebraic[1] = "fCa_infinity in component i_CaL_fCa_gate (dimensionless)"
    legend_algebraic[5] = "tau_fCa in component i_CaL_fCa_gate (second)"
    legend_constants[39] = "Km_fCa in component i_CaL_fCa_gate (millimolar)"
    legend_constants[40] = "P_CaT in component i_CaT (nanoA_per_millimolar)"
    legend_states[9] = "dT in component i_CaT_dT_gate (dimensionless)"
    legend_states[10] = "fT in component i_CaT_fT_gate (dimensionless)"
    legend_algebraic[13] = "dT_infinity in component i_CaT_dT_gate (dimensionless)"
    legend_algebraic[30] = "tau_dT in component i_CaT_dT_gate (second)"
    legend_algebraic[14] = "fT_infinity in component i_CaT_fT_gate (dimensionless)"
    legend_algebraic[31] = "tau_fT in component i_CaT_fT_gate (second)"
    legend_algebraic[75] = "j_SRCarel in component Ca_SR_release (millimolar_per_second)"
    legend_states[11] = "R in component Ca_SR_release (dimensionless)"
    legend_states[12] = "O in component Ca_SR_release (dimensionless)"
    legend_states[13] = "I in component Ca_SR_release (dimensionless)"
    legend_states[14] = "RI in component Ca_SR_release (dimensionless)"
    legend_constants[41] = "ks in component Ca_SR_release (per_second)"
    legend_constants[42] = "MaxSR in component Ca_SR_release (dimensionless)"
    legend_constants[43] = "MinSR in component Ca_SR_release (dimensionless)"
    legend_constants[44] = "EC50_SR in component Ca_SR_release (millimolar)"
    legend_constants[45] = "HSR in component Ca_SR_release (dimensionless)"
    legend_algebraic[6] = "koSRCa in component Ca_SR_release (per_millimolar2_second)"
    legend_algebraic[15] = "kiSRCa in component Ca_SR_release (per_millimolar_second)"
    legend_constants[46] = "koCa in component Ca_SR_release (per_millimolar2_second)"
    legend_constants[47] = "kiCa in component Ca_SR_release (per_millimolar_second)"
    legend_algebraic[2] = "kCaSR in component Ca_SR_release (dimensionless)"
    legend_constants[48] = "kim in component Ca_SR_release (per_second)"
    legend_constants[49] = "kom in component Ca_SR_release (per_second)"
    legend_states[15] = "Ca_jsr in component Ca_dynamics (millimolar)"
    legend_algebraic[77] = "j_Ca_dif in component Ca_intracellular_fluxes (millimolar_per_second)"
    legend_algebraic[79] = "j_up in component Ca_intracellular_fluxes (millimolar_per_second)"
    legend_algebraic[82] = "j_tr in component Ca_intracellular_fluxes (millimolar_per_second)"
    legend_constants[50] = "tau_dif_Ca in component Ca_intracellular_fluxes (second)"
    legend_constants[51] = "tau_tr in component Ca_intracellular_fluxes (second)"
    legend_constants[88] = "P_up in component Ca_intracellular_fluxes (millimolar_per_second)"
    legend_constants[52] = "P_up_basal in component Ca_intracellular_fluxes (millimolar_per_second)"
    legend_constants[84] = "b_up in component Ca_intracellular_fluxes (dimensionless)"
    legend_constants[53] = "K_up in component Ca_intracellular_fluxes (millimolar)"
    legend_states[16] = "Ca_nsr in component Ca_dynamics (millimolar)"
    legend_states[17] = "Cai in component Ca_dynamics (millimolar)"
    legend_constants[54] = "TC_tot in component Ca_buffering (millimolar)"
    legend_constants[55] = "TMC_tot in component Ca_buffering (millimolar)"
    legend_constants[56] = "CM_tot in component Ca_buffering (millimolar)"
    legend_constants[57] = "CQ_tot in component Ca_buffering (millimolar)"
    legend_algebraic[81] = "delta_fTC in component Ca_buffering (per_second)"
    legend_algebraic[84] = "delta_fTMC in component Ca_buffering (per_second)"
    legend_algebraic[88] = "delta_fCMs in component Ca_buffering (per_second)"
    legend_algebraic[87] = "delta_fCMi in component Ca_buffering (per_second)"
    legend_algebraic[85] = "delta_fCQ in component Ca_buffering (per_second)"
    legend_algebraic[4] = "delta_fTMM in component Ca_buffering (per_second)"
    legend_states[18] = "fTMM in component Ca_buffering (dimensionless)"
    legend_states[19] = "fCMi in component Ca_buffering (dimensionless)"
    legend_states[20] = "fCMs in component Ca_buffering (dimensionless)"
    legend_states[21] = "fTC in component Ca_buffering (dimensionless)"
    legend_states[22] = "fTMC in component Ca_buffering (dimensionless)"
    legend_states[23] = "fCQ in component Ca_buffering (dimensionless)"
    legend_constants[58] = "kf_TC in component Ca_buffering (per_millimolar_second)"
    legend_constants[59] = "kf_TMM in component Ca_buffering (per_millimolar_second)"
    legend_constants[60] = "kf_TMC in component Ca_buffering (per_millimolar_second)"
    legend_constants[61] = "kf_CM in component Ca_buffering (per_millimolar_second)"
    legend_constants[62] = "kf_CQ in component Ca_buffering (per_millimolar_second)"
    legend_constants[63] = "kb_TC in component Ca_buffering (per_second)"
    legend_constants[64] = "kb_TMC in component Ca_buffering (per_second)"
    legend_constants[65] = "kb_TMM in component Ca_buffering (per_second)"
    legend_constants[66] = "kb_CM in component Ca_buffering (per_second)"
    legend_constants[67] = "kb_CQ in component Ca_buffering (per_second)"
    legend_constants[68] = "Mgi in component Ca_buffering (millimolar)"
    legend_constants[99] = "V_jsr in component Cell_parameters (millimetre3)"
    legend_constants[101] = "V_nsr in component Cell_parameters (millimetre3)"
    legend_algebraic[89] = "BAPTA in component Ca_dynamics (millimolar)"
    legend_constants[69] = "kfBAPTA in component Ca_dynamics (per_millimolar_second)"
    legend_constants[70] = "kbBAPTA in component Ca_dynamics (per_second)"
    legend_states[24] = "fBAPTA in component Ca_dynamics (millimolar)"
    legend_states[25] = "fBAPTA_sub in component Ca_dynamics (millimolar)"
    legend_constants[71] = "T in component Ca_dynamics (second)"
    legend_constants[97] = "V_cell in component Cell_parameters (millimetre3)"
    legend_constants[72] = "V_jsr_part in component Cell_parameters (dimensionless)"
    legend_constants[73] = "V_i_part in component Cell_parameters (dimensionless)"
    legend_constants[74] = "V_nsr_part in component Cell_parameters (dimensionless)"
    legend_constants[75] = "R_cell in component Cell_parameters (micrometre)"
    legend_constants[76] = "L_cell in component Cell_parameters (micrometre)"
    legend_constants[77] = "L_sub in component Cell_parameters (micrometre)"
    legend_constants[78] = "g_to in component i_to (microS)"
    legend_states[26] = "q in component i_to_q_gate (dimensionless)"
    legend_states[27] = "r in component i_to_r_gate (dimensionless)"
    legend_algebraic[17] = "q_infinity in component i_to_q_gate (dimensionless)"
    legend_algebraic[33] = "tau_q in component i_to_q_gate (second)"
    legend_algebraic[18] = "r_infinity in component i_to_r_gate (dimensionless)"
    legend_algebraic[34] = "tau_r in component i_to_r_gate (second)"
    legend_constants[79] = "g_Kr in component i_Kr (microS)"
    legend_states[28] = "paS in component i_Kr_pa_gate (dimensionless)"
    legend_states[29] = "paF in component i_Kr_pa_gate (dimensionless)"
    legend_states[30] = "piy in component i_Kr_pi_gate (dimensionless)"
    legend_algebraic[19] = "pa_infinity in component i_Kr_pa_gate (dimensionless)"
    legend_algebraic[20] = "alfapaF in component i_Kr_pa_gate (per_second)"
    legend_algebraic[21] = "betapaF in component i_Kr_pa_gate (per_second)"
    legend_algebraic[35] = "tau_paS in component i_Kr_pa_gate (second)"
    legend_algebraic[36] = "tau_paF in component i_Kr_pa_gate (second)"
    legend_algebraic[37] = "pi_infinity in component i_Kr_pi_gate (dimensionless)"
    legend_algebraic[22] = "tau_pi in component i_Kr_pi_gate (second)"
    legend_constants[86] = "g_Ks in component i_Ks (microS)"
    legend_algebraic[78] = "E_Ks in component i_Ks (millivolt)"
    legend_states[31] = "n in component i_Ks_n_gate (dimensionless)"
    legend_algebraic[23] = "n_infinity in component i_Ks_n_gate (dimensionless)"
    legend_algebraic[47] = "tau_n in component i_Ks_n_gate (second)"
    legend_constants[102] = "Iso_shift in component i_Ks_n_gate (millivolt)"
    legend_constants[80] = "shift in component i_Ks_n_gate (millivolt)"
    legend_algebraic[38] = "alpha_n in component i_Ks_n_gate (per_second)"
    legend_algebraic[43] = "beta_n in component i_Ks_n_gate (per_second)"
    legend_constants[81] = "g_KACh in component i_KACh (microS)"
    legend_states[32] = "a in component i_KACh_a_gate (dimensionless)"
    legend_constants[103] = "alpha_a in component i_KACh_a_gate (per_second)"
    legend_algebraic[24] = "beta_a in component i_KACh_a_gate (per_second)"
    legend_algebraic[39] = "a_infinity in component i_KACh_a_gate (dimensionless)"
    legend_algebraic[44] = "tau_a in component i_KACh_a_gate (second)"
    legend_rates[0] = "d/dt V_ode in component Membrane (millivolt)"
    legend_rates[2] = "d/dt Nai_ in component Nai_concentration (millimolar)"
    legend_rates[3] = "d/dt y in component i_f_y_gate (dimensionless)"
    legend_rates[4] = "d/dt m in component i_Na_m_gate (dimensionless)"
    legend_rates[5] = "d/dt h in component i_Na_h_gate (dimensionless)"
    legend_rates[6] = "d/dt dL in component i_CaL_dL_gate (dimensionless)"
    legend_rates[7] = "d/dt fL in component i_CaL_fL_gate (dimensionless)"
    legend_rates[8] = "d/dt fCa in component i_CaL_fCa_gate (dimensionless)"
    legend_rates[9] = "d/dt dT in component i_CaT_dT_gate (dimensionless)"
    legend_rates[10] = "d/dt fT in component i_CaT_fT_gate (dimensionless)"
    legend_rates[11] = "d/dt R in component Ca_SR_release (dimensionless)"
    legend_rates[12] = "d/dt O in component Ca_SR_release (dimensionless)"
    legend_rates[13] = "d/dt I in component Ca_SR_release (dimensionless)"
    legend_rates[14] = "d/dt RI in component Ca_SR_release (dimensionless)"
    legend_rates[21] = "d/dt fTC in component Ca_buffering (dimensionless)"
    legend_rates[22] = "d/dt fTMC in component Ca_buffering (dimensionless)"
    legend_rates[18] = "d/dt fTMM in component Ca_buffering (dimensionless)"
    legend_rates[19] = "d/dt fCMi in component Ca_buffering (dimensionless)"
    legend_rates[20] = "d/dt fCMs in component Ca_buffering (dimensionless)"
    legend_rates[23] = "d/dt fCQ in component Ca_buffering (dimensionless)"
    legend_rates[17] = "d/dt Cai in component Ca_dynamics (millimolar)"
    legend_rates[24] = "d/dt fBAPTA in component Ca_dynamics (millimolar)"
    legend_rates[1] = "d/dt Ca_sub in component Ca_dynamics (millimolar)"
    legend_rates[25] = "d/dt fBAPTA_sub in component Ca_dynamics (millimolar)"
    legend_rates[16] = "d/dt Ca_nsr in component Ca_dynamics (millimolar)"
    legend_rates[15] = "d/dt Ca_jsr in component Ca_dynamics (millimolar)"
    legend_rates[26] = "d/dt q in component i_to_q_gate (dimensionless)"
    legend_rates[27] = "d/dt r in component i_to_r_gate (dimensionless)"
    legend_rates[28] = "d/dt paS in component i_Kr_pa_gate (dimensionless)"
    legend_rates[29] = "d/dt paF in component i_Kr_pa_gate (dimensionless)"
    legend_rates[30] = "d/dt piy in component i_Kr_pi_gate (dimensionless)"
    legend_rates[31] = "d/dt n in component i_Ks_n_gate (dimensionless)"
    legend_rates[32] = "d/dt a in component i_KACh_a_gate (dimensionless)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 8314.472
    constants[1] = 310
    constants[2] = 96485.3415
    constants[3] = 3.2e-5
    constants[4] = 0
    states[0] = -52
    constants[5] = 0.5
    constants[6] = 0.5
    constants[7] = -35
    constants[8] = -45
    constants[9] = 0
    constants[10] = 0
    constants[11] = 0
    constants[12] = 0
    constants[13] = 0
    constants[14] = 140
    constants[15] = 140
    constants[16] = 5.4
    states[1] = 1e-5
    constants[17] = 1.8
    states[2] = 7.5
    constants[18] = 45
    states[3] = 0.181334538702451
    constants[19] = 1.4
    constants[20] = 14
    constants[21] = 0.063
    constants[22] = 4
    constants[23] = 0.1369
    constants[24] = 0.4315
    constants[25] = 0
    constants[26] = 26.44
    constants[27] = 0.0207
    constants[28] = 395.3
    constants[29] = 2.289
    constants[30] = 26.44
    constants[31] = 4.663
    constants[32] = 1628
    constants[33] = 561.4
    constants[34] = 3.663
    constants[35] = 0.0125
    states[4] = 0.440131579215766
    states[5] = 1.3676940140066e-5
    constants[36] = 1e-5
    constants[37] = 0.2
    states[6] = 0
    states[7] = 0.497133507285601
    states[8] = 0.697998543259722
    constants[38] = 0.01
    constants[39] = 0.00035
    constants[40] = 0.02
    states[9] = 0
    states[10] = 0
    states[11] = 0.912317231017262
    states[12] = 1.7340201253e-7
    states[13] = 7.86181717518e-8
    states[14] = 0.211148145512825
    constants[41] = 250000000
    constants[42] = 15
    constants[43] = 1
    constants[44] = 0.45
    constants[45] = 2.5
    constants[46] = 10000
    constants[47] = 500
    constants[48] = 5
    constants[49] = 60
    states[15] = 0.316762674605
    constants[50] = 4e-5
    constants[51] = 0.04
    constants[52] = 12
    constants[53] = 0.0006
    states[16] = 1.05386465080816
    states[17] = 1e-5
    constants[54] = 0.031
    constants[55] = 0.062
    constants[56] = 0.045
    constants[57] = 10
    states[18] = 0.501049376634
    states[19] = 0.0373817991524254
    states[20] = 0.054381370046
    states[21] = 0.0180519400676086
    states[22] = 0.281244308217086
    states[23] = 0.299624275428735
    constants[58] = 88800
    constants[59] = 2277
    constants[60] = 227700
    constants[61] = 227700
    constants[62] = 534
    constants[63] = 446
    constants[64] = 7.51
    constants[65] = 751
    constants[66] = 542
    constants[67] = 445
    constants[68] = 2.5
    constants[69] = 940000
    constants[70] = 119.38
    states[24] = 0
    states[25] = 0
    constants[71] = 6.928
    constants[72] = 0.0012
    constants[73] = 0.46
    constants[74] = 0.0116
    constants[75] = 4
    constants[76] = 70
    constants[77] = 0.02
    constants[78] = 0.002
    states[26] = 0.506139850982478
    states[27] = 0.0144605370597924
    constants[79] = 0.0021637
    states[28] = 0.322999177802891
    states[29] = 0.0990510403258968
    states[30] = 0.705410877258545
    states[31] = 0
    constants[80] = 0
    constants[81] = 0.00864
    states[32] = 0
    constants[82] = custom_piecewise([greater_equal(constants[9] , 1.00000), 0.0300000*(1.00000-0.660000) , True, 0.0300000])
    constants[83] = custom_piecewise([greater_equal(constants[9] , 1.00000), 0.0300000*(1.00000-0.660000) , True, 0.0300000])
    constants[84] = custom_piecewise([greater(constants[12] , 0.00000), -0.250000 , greater(constants[11] , 0.00000), (0.700000*constants[11])/(9.00000e-05+constants[11]) , True, 0.00000])
    constants[85] = (constants[0]*constants[1])/constants[2]
    constants[86] = custom_piecewise([greater(constants[12] , 0.00000), 1.20000*0.00165760 , True, 0.00165760])
    constants[87] = constants[85]*log(constants[16]/constants[15])
    constants[88] = constants[52]*(1.00000-constants[84])
    constants[89] = custom_piecewise([greater(constants[11] , 0.00000), -1.00000-(9.89800*(power(1.00000*constants[11], 0.618000)))/(power(1.00000*constants[11], 0.618000)+0.00122423) , True, 0.00000])
    constants[90] = custom_piecewise([greater(constants[12] , 0.00000), 7.50000 , True, 0.00000])
    constants[91] = custom_piecewise([greater(constants[12] , 0.00000), 1.20000 , True, 1.00000])
    constants[92] = constants[14]/(constants[31]+constants[14])
    constants[93] = custom_piecewise([greater(constants[12] , 0.00000), 1.23000 , True, 1.00000])
    constants[94] = (0.310000*constants[11])/(constants[11]+9.00000e-05)
    constants[95] = custom_piecewise([greater(constants[12] , 0.00000), -8.00000 , True, 0.00000])
    constants[96] = custom_piecewise([greater(constants[12] , 0.00000), 0.690000 , True, 1.00000])
    constants[97] = 1.00000e-09* pi*(power(constants[75], 2.00000))*constants[76]
    constants[98] = 1.00000e-09*2.00000* pi*constants[77]*(constants[75]-constants[77]/2.00000)*constants[76]
    constants[99] = constants[72]*constants[97]
    constants[100] = constants[73]*constants[97]-constants[98]
    constants[101] = constants[74]*constants[97]
    constants[102] = custom_piecewise([greater(constants[12] , 0.00000), -14.0000 , True, 0.00000])
    constants[103] = (3.59880-0.0256410)/(1.00000+1.21550e-06/(power(1.00000*constants[11], 1.69510)))+0.0256410
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[4] = constants[59]*constants[68]*(1.00000-(states[22]+states[18]))-constants[65]*states[18]
    rates[18] = algebraic[4]
    algebraic[1] = constants[39]/(constants[39]+states[1])
    algebraic[5] = (0.00100000*algebraic[1])/constants[38]
    rates[8] = (algebraic[1]-states[8])/algebraic[5]
    algebraic[2] = constants[42]-(constants[42]-constants[43])/(1.00000+power(constants[44]/states[15], constants[45]))
    algebraic[6] = constants[46]/algebraic[2]
    algebraic[15] = constants[47]*algebraic[2]
    rates[11] = (constants[48]*states[14]-algebraic[15]*states[1]*states[11])-(algebraic[6]*(power(states[1], 2.00000))*states[11]-constants[49]*states[12])
    rates[12] = (algebraic[6]*(power(states[1], 2.00000))*states[11]-constants[49]*states[12])-(algebraic[15]*states[1]*states[12]-constants[48]*states[13])
    rates[13] = (algebraic[15]*states[1]*states[12]-constants[48]*states[13])-(constants[49]*states[13]-algebraic[6]*(power(states[1], 2.00000))*states[14])
    rates[14] = (constants[49]*states[13]-algebraic[6]*(power(states[1], 2.00000))*states[14])-(constants[48]*states[14]-algebraic[15]*states[1]*states[11])
    algebraic[3] = custom_piecewise([greater(voi , constants[5]) & less(voi , constants[5]+constants[6]), constants[7] , True, constants[8]])
    algebraic[7] = custom_piecewise([greater_equal(constants[4] , 1.00000), algebraic[3] , True, states[0]])
    algebraic[8] = 0.716653/(0.0708000*exp(-(((algebraic[7]+5.00000)-constants[89])-constants[90])/20.2791)+10.6000*exp(((algebraic[7]-constants[89])-constants[90])/18.0000))
    algebraic[25] = 1.00000/(1.00000+exp((((algebraic[7]+52.5000)-constants[89])-constants[90])/9.00000))
    rates[3] = (algebraic[25]-states[3])/algebraic[8]
    algebraic[10] = 20.0000*exp(-0.125000*(algebraic[7]+75.0000))
    algebraic[27] = 2000.00/(320.000*exp(-0.100000*(algebraic[7]+75.0000))+1.00000)
    rates[5] = algebraic[10]*(1.00000-states[5])-algebraic[27]*states[5]
    algebraic[12] = 1.00000/(1.00000+exp((algebraic[7]+37.4000)/5.30000))
    algebraic[29] = 0.00100000*(44.3000+230.000*exp(-(power((algebraic[7]+36.0000)/10.0000, 2.00000))))
    rates[7] = (algebraic[12]-states[7])/algebraic[29]
    algebraic[13] = 1.00000/(1.00000+exp(-(algebraic[7]+38.3000)/5.50000))
    algebraic[30] = 0.00100000/(1.06800*exp((algebraic[7]+38.3000)/30.0000)+1.06800*exp(-(algebraic[7]+38.3000)/30.0000))
    rates[9] = (algebraic[13]-states[9])/algebraic[30]
    algebraic[14] = 1.00000/(1.00000+exp((algebraic[7]+58.7000)/3.80000))
    algebraic[31] = 1.00000/(16.6700*exp(-(algebraic[7]+75.0000)/83.3000)+16.6700*exp((algebraic[7]+75.0000)/15.3800))
    rates[10] = (algebraic[14]-states[10])/algebraic[31]
    algebraic[17] = 1.00000/(1.00000+exp((algebraic[7]+49.0000)/13.0000))
    algebraic[33] = 0.00100000*0.600000*(65.1700/(0.570000*exp(-0.0800000*(algebraic[7]+44.0000))+0.0650000*exp(0.100000*(algebraic[7]+45.9300)))+10.1000)
    rates[26] = (algebraic[17]-states[26])/algebraic[33]
    algebraic[18] = 1.00000/(1.00000+exp(-(algebraic[7]-19.3000)/15.0000))
    algebraic[34] = 0.00100000*0.660000*1.40000*(15.5900/(1.03700*exp(0.0900000*(algebraic[7]+30.6100))+0.369000*exp(-0.120000*(algebraic[7]+23.8400)))+2.98000)
    rates[27] = (algebraic[18]-states[27])/algebraic[34]
    algebraic[19] = 1.00000/(1.00000+exp(-(algebraic[7]+14.8000)/8.50000))
    algebraic[35] = 0.846554/(4.20000*exp(algebraic[7]/17.0000)+0.150000*exp(-algebraic[7]/21.6000))
    rates[28] = (algebraic[19]-states[28])/algebraic[35]
    algebraic[36] = 1.00000/(30.0000*exp(algebraic[7]/10.0000)+exp(-algebraic[7]/12.0000))
    rates[29] = (algebraic[19]-states[29])/algebraic[36]
    algebraic[37] = 1.00000/(1.00000+exp((algebraic[7]+28.6000)/17.1000))
    algebraic[22] = 1.00000/(100.000*exp(-algebraic[7]/54.6450)+656.000*exp(algebraic[7]/106.157))
    rates[30] = (algebraic[37]-states[30])/algebraic[22]
    algebraic[9] = algebraic[7]+41.0000
    algebraic[26] = custom_piecewise([less(fabs(algebraic[9]) , constants[36]), 2000.00 , True, (200.000*algebraic[9])/(1.00000-exp(-0.100000*algebraic[9]))])
    algebraic[40] = 8000.00*exp(-0.0560000*(algebraic[7]+66.0000))
    rates[4] = algebraic[26]*(1.00000-states[4])-algebraic[40]*states[4]
    algebraic[24] = 10.0000*exp(0.0133000*(algebraic[7]+40.0000))
    algebraic[39] = constants[103]/(constants[103]+algebraic[24])
    algebraic[44] = 1.00000/(constants[103]+algebraic[24])
    rates[32] = (algebraic[39]-states[32])/algebraic[44]
    algebraic[23] = (14.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/12.0000)))/(14.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/12.0000))+1.00000*exp(-(algebraic[7]-constants[102])/45.0000))
    algebraic[38] = 28.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/3.00000))
    algebraic[43] = 1.00000*exp(-(((algebraic[7]-constants[102])-constants[80])-5.00000)/25.0000)
    algebraic[47] = 1.00000/(algebraic[38]+algebraic[43])
    rates[31] = (algebraic[23]-states[31])/algebraic[47]
    algebraic[11] = 1.00000/(1.00000+exp(-((algebraic[7]+20.3000)-constants[95])/(constants[96]*4.20000)))
    algebraic[28] = custom_piecewise([equal(algebraic[7] , -41.8000), -41.8000 , equal(algebraic[7] , 0.00000), 0.00000 , equal(algebraic[7] , -6.80000), -6.80001 , True, algebraic[7]])
    algebraic[41] = (-0.0283900*((algebraic[28]+41.8000)-constants[95]))/(exp(-((algebraic[28]+41.8000)-constants[95])/2.50000)-1.00000)-(0.0849000*((algebraic[28]+6.80000)-constants[95]))/(exp(-((algebraic[28]+6.80000)-constants[95])/4.80000)-1.00000)
    algebraic[45] = custom_piecewise([equal(algebraic[7] , -1.80000), -1.80001 , True, algebraic[7]])
    algebraic[48] = (0.0114300*((algebraic[45]+1.80000)-constants[95]))/(exp(((algebraic[45]+1.80000)-constants[95])/2.50000)-1.00000)
    algebraic[50] = 0.00100000/(algebraic[41]+algebraic[48])
    rates[6] = (algebraic[11]-states[6])/algebraic[50]
    algebraic[16] = custom_piecewise([greater(constants[13] , 0.00000), 7.50000 , True, states[2]])
    algebraic[32] = constants[85]*log(constants[14]/algebraic[16])
    algebraic[52] = constants[91]*constants[21]*(power(1.00000+power(constants[19]/constants[16], 1.20000), -1.00000))*(power(1.00000+power(constants[20]/algebraic[16], 1.30000), -1.00000))*(power(1.00000+exp(-((algebraic[7]-algebraic[32])+110.000)/20.0000), -1.00000))
    algebraic[54] = exp((-constants[24]*algebraic[7])/(2.00000*constants[85]))
    algebraic[60] = 1.00000+(constants[17]/constants[34])*(1.00000+exp((constants[25]*algebraic[7])/constants[85]))+(constants[14]/constants[32])*(1.00000+(constants[14]/constants[33])*(1.00000+constants[14]/constants[31]))
    algebraic[62] = ((((constants[14]/constants[32])*constants[14])/constants[33])*(1.00000+constants[14]/constants[31])*exp((-constants[24]*algebraic[7])/(2.00000*constants[85])))/algebraic[60]
    algebraic[61] = ((constants[17]/constants[34])*exp((constants[25]*algebraic[7])/constants[85]))/algebraic[60]
    algebraic[58] = exp((constants[24]*algebraic[7])/(2.00000*constants[85]))
    algebraic[53] = algebraic[16]/(constants[26]+algebraic[16])
    algebraic[63] = algebraic[54]*constants[92]*(algebraic[62]+algebraic[61])+algebraic[61]*algebraic[58]*(algebraic[53]+algebraic[54])
    algebraic[55] = 1.00000+(states[1]/constants[27])*(1.00000+exp((-constants[23]*algebraic[7])/constants[85])+algebraic[16]/constants[30])+(algebraic[16]/constants[28])*(1.00000+(algebraic[16]/constants[29])*(1.00000+algebraic[16]/constants[26]))
    algebraic[56] = ((states[1]/constants[27])*exp((-constants[23]*algebraic[7])/constants[85]))/algebraic[55]
    algebraic[57] = ((((algebraic[16]/constants[28])*algebraic[16])/constants[29])*(1.00000+algebraic[16]/constants[26])*exp((constants[24]*algebraic[7])/(2.00000*constants[85])))/algebraic[55]
    algebraic[59] = algebraic[58]*algebraic[53]*(algebraic[57]+algebraic[56])+algebraic[54]*algebraic[56]*(constants[92]+algebraic[58])
    algebraic[64] = algebraic[57]*algebraic[53]*(algebraic[62]+algebraic[61])+algebraic[56]*algebraic[62]*(algebraic[53]+algebraic[54])
    algebraic[65] = algebraic[62]*constants[92]*(algebraic[57]+algebraic[56])+algebraic[57]*algebraic[61]*(constants[92]+algebraic[58])
    algebraic[66] = (constants[22]*(algebraic[59]*algebraic[61]-algebraic[63]*algebraic[56]))/(algebraic[63]+algebraic[59]+algebraic[64]+algebraic[65])
    algebraic[67] = constants[85]*log((constants[14]+0.120000*constants[16])/(algebraic[16]+0.120000*constants[15]))
    algebraic[68] = constants[35]*(power(states[4], 3.00000))*states[5]*(algebraic[7]-algebraic[67])
    algebraic[42] = custom_piecewise([greater_equal(constants[10] , 1.00000), (10.6015/5.00000)/(10.6015/5.00000+exp((-0.710000*algebraic[7])/25.0000)) , True, 1.00000])
    algebraic[46] = (((power(states[3], 2.00000))*constants[16])/(constants[16]+constants[18]))*constants[82]*(algebraic[7]-algebraic[32])*algebraic[42]
    algebraic[71] = ((1.85000e-05*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))))*(algebraic[16]-constants[14]*exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    rates[2] = (-1.00000*(algebraic[68]+algebraic[46]+algebraic[71]+3.00000*algebraic[52]+3.00000*algebraic[66]))/(1.00000*(constants[100]+constants[98])*constants[2])
    algebraic[81] = constants[58]*states[17]*(1.00000-states[21])-constants[63]*states[21]
    rates[21] = algebraic[81]
    algebraic[79] = constants[88]/(1.00000+constants[53]/states[17])
    algebraic[82] = (states[16]-states[15])/constants[51]
    rates[16] = algebraic[79]-(algebraic[82]*constants[99])/constants[101]
    algebraic[84] = constants[60]*states[17]*(1.00000-(states[22]+states[18]))-constants[64]*states[22]
    rates[22] = algebraic[84]
    algebraic[85] = constants[62]*states[15]*(1.00000-states[23])-constants[67]*states[23]
    rates[23] = algebraic[85]
    algebraic[75] = constants[41]*states[12]*(states[15]-states[1])
    rates[15] = algebraic[82]-(algebraic[75]+constants[57]*algebraic[85])
    algebraic[49] = (((power(states[3], 2.00000))*constants[16])/(constants[16]+constants[18]))*constants[83]*(algebraic[7]-constants[87])*algebraic[42]
    algebraic[51] = algebraic[46]+algebraic[49]
    algebraic[76] = constants[79]*(algebraic[7]-constants[87])*(0.900000*states[29]+0.100000*states[28])*states[30]
    algebraic[78] = constants[85]*log((constants[16]+0.00000*constants[14])/(constants[15]+0.00000*algebraic[16]))
    algebraic[80] = constants[86]*(algebraic[7]-algebraic[78])*(power(states[31], 2.00000))
    algebraic[74] = constants[78]*(algebraic[7]-constants[87])*states[26]*states[27]
    algebraic[69] = ((2.00000*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000)*2.00000)/constants[85]))))*(states[1]-constants[17]*exp((-2.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    algebraic[70] = ((0.000365000*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))))*(constants[15]-constants[16]*exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    algebraic[72] = (algebraic[69]+algebraic[70]+algebraic[71])*(1.00000-constants[94])*1.00000*constants[93]
    algebraic[73] = ((2.00000*constants[40]*algebraic[7])/(constants[85]*(1.00000-exp((-1.00000*algebraic[7]*2.00000)/constants[85]))))*(states[1]-constants[17]*exp((-2.00000*algebraic[7])/constants[85]))*states[9]*states[10]
    algebraic[83] = custom_piecewise([greater(constants[11] , 0.00000), constants[81]*(algebraic[7]-constants[87])*(1.00000+exp((algebraic[7]+20.0000)/20.0000))*states[32] , True, 0.00000])
    algebraic[86] = algebraic[51]+algebraic[76]+algebraic[80]+algebraic[74]+algebraic[52]+algebraic[66]+algebraic[68]+algebraic[72]+algebraic[73]+algebraic[83]
    rates[0] = -algebraic[86]/constants[3]
    algebraic[87] = constants[61]*states[17]*(1.00000-states[19])-constants[66]*states[19]
    rates[19] = algebraic[87]
    algebraic[88] = constants[61]*states[1]*(1.00000-states[20])-constants[66]*states[20]
    rates[20] = algebraic[88]
    algebraic[77] = (states[1]-states[17])/constants[50]
    algebraic[89] = custom_piecewise([greater(constants[13] , 0.00000) & greater(voi , constants[71]), 10.0000 , True, 0.00000])
    rates[17] = ((1.00000*(algebraic[77]*constants[98]-algebraic[79]*constants[101]))/constants[100]-(constants[56]*algebraic[87]+constants[54]*algebraic[81]+constants[55]*algebraic[84]))-(constants[69]*states[17]*(algebraic[89]-states[24])-constants[70]*states[24])
    rates[24] = constants[69]*states[17]*(algebraic[89]-states[24])-constants[70]*states[24]
    rates[1] = ((algebraic[75]*constants[99])/constants[98]-(((algebraic[69]+algebraic[73])-2.00000*algebraic[66])/(2.00000*constants[2]*constants[98])+algebraic[77]+constants[56]*algebraic[88]))-(constants[69]*states[1]*(algebraic[89]-states[25])-constants[70]*states[25])
    rates[25] = constants[69]*states[1]*(algebraic[89]-states[25])-constants[70]*states[25]
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[4] = constants[59]*constants[68]*(1.00000-(states[22]+states[18]))-constants[65]*states[18]
    algebraic[1] = constants[39]/(constants[39]+states[1])
    algebraic[5] = (0.00100000*algebraic[1])/constants[38]
    algebraic[2] = constants[42]-(constants[42]-constants[43])/(1.00000+power(constants[44]/states[15], constants[45]))
    algebraic[6] = constants[46]/algebraic[2]
    algebraic[15] = constants[47]*algebraic[2]
    algebraic[3] = custom_piecewise([greater(voi , constants[5]) & less(voi , constants[5]+constants[6]), constants[7] , True, constants[8]])
    algebraic[7] = custom_piecewise([greater_equal(constants[4] , 1.00000), algebraic[3] , True, states[0]])
    algebraic[8] = 0.716653/(0.0708000*exp(-(((algebraic[7]+5.00000)-constants[89])-constants[90])/20.2791)+10.6000*exp(((algebraic[7]-constants[89])-constants[90])/18.0000))
    algebraic[25] = 1.00000/(1.00000+exp((((algebraic[7]+52.5000)-constants[89])-constants[90])/9.00000))
    algebraic[10] = 20.0000*exp(-0.125000*(algebraic[7]+75.0000))
    algebraic[27] = 2000.00/(320.000*exp(-0.100000*(algebraic[7]+75.0000))+1.00000)
    algebraic[12] = 1.00000/(1.00000+exp((algebraic[7]+37.4000)/5.30000))
    algebraic[29] = 0.00100000*(44.3000+230.000*exp(-(power((algebraic[7]+36.0000)/10.0000, 2.00000))))
    algebraic[13] = 1.00000/(1.00000+exp(-(algebraic[7]+38.3000)/5.50000))
    algebraic[30] = 0.00100000/(1.06800*exp((algebraic[7]+38.3000)/30.0000)+1.06800*exp(-(algebraic[7]+38.3000)/30.0000))
    algebraic[14] = 1.00000/(1.00000+exp((algebraic[7]+58.7000)/3.80000))
    algebraic[31] = 1.00000/(16.6700*exp(-(algebraic[7]+75.0000)/83.3000)+16.6700*exp((algebraic[7]+75.0000)/15.3800))
    algebraic[17] = 1.00000/(1.00000+exp((algebraic[7]+49.0000)/13.0000))
    algebraic[33] = 0.00100000*0.600000*(65.1700/(0.570000*exp(-0.0800000*(algebraic[7]+44.0000))+0.0650000*exp(0.100000*(algebraic[7]+45.9300)))+10.1000)
    algebraic[18] = 1.00000/(1.00000+exp(-(algebraic[7]-19.3000)/15.0000))
    algebraic[34] = 0.00100000*0.660000*1.40000*(15.5900/(1.03700*exp(0.0900000*(algebraic[7]+30.6100))+0.369000*exp(-0.120000*(algebraic[7]+23.8400)))+2.98000)
    algebraic[19] = 1.00000/(1.00000+exp(-(algebraic[7]+14.8000)/8.50000))
    algebraic[35] = 0.846554/(4.20000*exp(algebraic[7]/17.0000)+0.150000*exp(-algebraic[7]/21.6000))
    algebraic[36] = 1.00000/(30.0000*exp(algebraic[7]/10.0000)+exp(-algebraic[7]/12.0000))
    algebraic[37] = 1.00000/(1.00000+exp((algebraic[7]+28.6000)/17.1000))
    algebraic[22] = 1.00000/(100.000*exp(-algebraic[7]/54.6450)+656.000*exp(algebraic[7]/106.157))
    algebraic[9] = algebraic[7]+41.0000
    algebraic[26] = custom_piecewise([less(fabs(algebraic[9]) , constants[36]), 2000.00 , True, (200.000*algebraic[9])/(1.00000-exp(-0.100000*algebraic[9]))])
    algebraic[40] = 8000.00*exp(-0.0560000*(algebraic[7]+66.0000))
    algebraic[24] = 10.0000*exp(0.0133000*(algebraic[7]+40.0000))
    algebraic[39] = constants[103]/(constants[103]+algebraic[24])
    algebraic[44] = 1.00000/(constants[103]+algebraic[24])
    algebraic[23] = (14.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/12.0000)))/(14.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/12.0000))+1.00000*exp(-(algebraic[7]-constants[102])/45.0000))
    algebraic[38] = 28.0000/(1.00000+exp(-((algebraic[7]-40.0000)-constants[102])/3.00000))
    algebraic[43] = 1.00000*exp(-(((algebraic[7]-constants[102])-constants[80])-5.00000)/25.0000)
    algebraic[47] = 1.00000/(algebraic[38]+algebraic[43])
    algebraic[11] = 1.00000/(1.00000+exp(-((algebraic[7]+20.3000)-constants[95])/(constants[96]*4.20000)))
    algebraic[28] = custom_piecewise([equal(algebraic[7] , -41.8000), -41.8000 , equal(algebraic[7] , 0.00000), 0.00000 , equal(algebraic[7] , -6.80000), -6.80001 , True, algebraic[7]])
    algebraic[41] = (-0.0283900*((algebraic[28]+41.8000)-constants[95]))/(exp(-((algebraic[28]+41.8000)-constants[95])/2.50000)-1.00000)-(0.0849000*((algebraic[28]+6.80000)-constants[95]))/(exp(-((algebraic[28]+6.80000)-constants[95])/4.80000)-1.00000)
    algebraic[45] = custom_piecewise([equal(algebraic[7] , -1.80000), -1.80001 , True, algebraic[7]])
    algebraic[48] = (0.0114300*((algebraic[45]+1.80000)-constants[95]))/(exp(((algebraic[45]+1.80000)-constants[95])/2.50000)-1.00000)
    algebraic[50] = 0.00100000/(algebraic[41]+algebraic[48])
    algebraic[16] = custom_piecewise([greater(constants[13] , 0.00000), 7.50000 , True, states[2]])
    algebraic[32] = constants[85]*log(constants[14]/algebraic[16])
    algebraic[52] = constants[91]*constants[21]*(power(1.00000+power(constants[19]/constants[16], 1.20000), -1.00000))*(power(1.00000+power(constants[20]/algebraic[16], 1.30000), -1.00000))*(power(1.00000+exp(-((algebraic[7]-algebraic[32])+110.000)/20.0000), -1.00000))
    algebraic[54] = exp((-constants[24]*algebraic[7])/(2.00000*constants[85]))
    algebraic[60] = 1.00000+(constants[17]/constants[34])*(1.00000+exp((constants[25]*algebraic[7])/constants[85]))+(constants[14]/constants[32])*(1.00000+(constants[14]/constants[33])*(1.00000+constants[14]/constants[31]))
    algebraic[62] = ((((constants[14]/constants[32])*constants[14])/constants[33])*(1.00000+constants[14]/constants[31])*exp((-constants[24]*algebraic[7])/(2.00000*constants[85])))/algebraic[60]
    algebraic[61] = ((constants[17]/constants[34])*exp((constants[25]*algebraic[7])/constants[85]))/algebraic[60]
    algebraic[58] = exp((constants[24]*algebraic[7])/(2.00000*constants[85]))
    algebraic[53] = algebraic[16]/(constants[26]+algebraic[16])
    algebraic[63] = algebraic[54]*constants[92]*(algebraic[62]+algebraic[61])+algebraic[61]*algebraic[58]*(algebraic[53]+algebraic[54])
    algebraic[55] = 1.00000+(states[1]/constants[27])*(1.00000+exp((-constants[23]*algebraic[7])/constants[85])+algebraic[16]/constants[30])+(algebraic[16]/constants[28])*(1.00000+(algebraic[16]/constants[29])*(1.00000+algebraic[16]/constants[26]))
    algebraic[56] = ((states[1]/constants[27])*exp((-constants[23]*algebraic[7])/constants[85]))/algebraic[55]
    algebraic[57] = ((((algebraic[16]/constants[28])*algebraic[16])/constants[29])*(1.00000+algebraic[16]/constants[26])*exp((constants[24]*algebraic[7])/(2.00000*constants[85])))/algebraic[55]
    algebraic[59] = algebraic[58]*algebraic[53]*(algebraic[57]+algebraic[56])+algebraic[54]*algebraic[56]*(constants[92]+algebraic[58])
    algebraic[64] = algebraic[57]*algebraic[53]*(algebraic[62]+algebraic[61])+algebraic[56]*algebraic[62]*(algebraic[53]+algebraic[54])
    algebraic[65] = algebraic[62]*constants[92]*(algebraic[57]+algebraic[56])+algebraic[57]*algebraic[61]*(constants[92]+algebraic[58])
    algebraic[66] = (constants[22]*(algebraic[59]*algebraic[61]-algebraic[63]*algebraic[56]))/(algebraic[63]+algebraic[59]+algebraic[64]+algebraic[65])
    algebraic[67] = constants[85]*log((constants[14]+0.120000*constants[16])/(algebraic[16]+0.120000*constants[15]))
    algebraic[68] = constants[35]*(power(states[4], 3.00000))*states[5]*(algebraic[7]-algebraic[67])
    algebraic[42] = custom_piecewise([greater_equal(constants[10] , 1.00000), (10.6015/5.00000)/(10.6015/5.00000+exp((-0.710000*algebraic[7])/25.0000)) , True, 1.00000])
    algebraic[46] = (((power(states[3], 2.00000))*constants[16])/(constants[16]+constants[18]))*constants[82]*(algebraic[7]-algebraic[32])*algebraic[42]
    algebraic[71] = ((1.85000e-05*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))))*(algebraic[16]-constants[14]*exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    algebraic[81] = constants[58]*states[17]*(1.00000-states[21])-constants[63]*states[21]
    algebraic[79] = constants[88]/(1.00000+constants[53]/states[17])
    algebraic[82] = (states[16]-states[15])/constants[51]
    algebraic[84] = constants[60]*states[17]*(1.00000-(states[22]+states[18]))-constants[64]*states[22]
    algebraic[85] = constants[62]*states[15]*(1.00000-states[23])-constants[67]*states[23]
    algebraic[75] = constants[41]*states[12]*(states[15]-states[1])
    algebraic[49] = (((power(states[3], 2.00000))*constants[16])/(constants[16]+constants[18]))*constants[83]*(algebraic[7]-constants[87])*algebraic[42]
    algebraic[51] = algebraic[46]+algebraic[49]
    algebraic[76] = constants[79]*(algebraic[7]-constants[87])*(0.900000*states[29]+0.100000*states[28])*states[30]
    algebraic[78] = constants[85]*log((constants[16]+0.00000*constants[14])/(constants[15]+0.00000*algebraic[16]))
    algebraic[80] = constants[86]*(algebraic[7]-algebraic[78])*(power(states[31], 2.00000))
    algebraic[74] = constants[78]*(algebraic[7]-constants[87])*states[26]*states[27]
    algebraic[69] = ((2.00000*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000)*2.00000)/constants[85]))))*(states[1]-constants[17]*exp((-2.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    algebraic[70] = ((0.000365000*constants[37]*(algebraic[7]-0.00000))/(constants[85]*(1.00000-exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))))*(constants[15]-constants[16]*exp((-1.00000*(algebraic[7]-0.00000))/constants[85]))*states[6]*states[7]*states[8]
    algebraic[72] = (algebraic[69]+algebraic[70]+algebraic[71])*(1.00000-constants[94])*1.00000*constants[93]
    algebraic[73] = ((2.00000*constants[40]*algebraic[7])/(constants[85]*(1.00000-exp((-1.00000*algebraic[7]*2.00000)/constants[85]))))*(states[1]-constants[17]*exp((-2.00000*algebraic[7])/constants[85]))*states[9]*states[10]
    algebraic[83] = custom_piecewise([greater(constants[11] , 0.00000), constants[81]*(algebraic[7]-constants[87])*(1.00000+exp((algebraic[7]+20.0000)/20.0000))*states[32] , True, 0.00000])
    algebraic[86] = algebraic[51]+algebraic[76]+algebraic[80]+algebraic[74]+algebraic[52]+algebraic[66]+algebraic[68]+algebraic[72]+algebraic[73]+algebraic[83]
    algebraic[87] = constants[61]*states[17]*(1.00000-states[19])-constants[66]*states[19]
    algebraic[88] = constants[61]*states[1]*(1.00000-states[20])-constants[66]*states[20]
    algebraic[77] = (states[1]-states[17])/constants[50]
    algebraic[89] = custom_piecewise([greater(constants[13] , 0.00000) & greater(voi , constants[71]), 10.0000 , True, 0.00000])
    algebraic[0] = 0.500000*constants[85]*log(constants[17]/states[1])
    algebraic[20] = (1.00000/(1.00000+exp(-(algebraic[7]+23.2000)/6.60000)))/(0.846554/(37.2000*exp(algebraic[7]/11.9000)+0.960000*exp(-algebraic[7]/18.5000)))
    algebraic[21] = 4.00000*((37.2000*exp(algebraic[7]/15.9000)+0.960000*exp(-algebraic[7]/22.5000))/0.846554-(1.00000/(1.00000+exp(-(algebraic[7]+23.2000)/10.6000)))/(0.846554/(37.2000*exp(algebraic[7]/15.9000)+0.960000*exp(-algebraic[7]/22.5000))))
    return algebraic

def custom_piecewise(cases):
    """Compute result of a piecewise function"""
    return select(cases[0::2],cases[1::2])

def solve_model():
    """Solve model with ODE solver"""
    from scipy.integrate import ode
    # Initialise constants and state variables
    (init_states, constants) = initConsts()

    # Set timespan to solve over
    voi = linspace(0, 10, 500)

    # Construct ODE object to solve
    r = ode(computeRates)
    r.set_integrator('vode', method='bdf', atol=1e-06, rtol=1e-06, max_step=1)
    r.set_initial_value(init_states, voi[0])
    r.set_f_params(constants)

    # Solve model
    states = array([[0.0] * len(voi)] * sizeStates)
    states[:,0] = init_states
    for (i,t) in enumerate(voi[1:]):
        if r.successful():
            r.integrate(t)
            states[:,i+1] = r.y
        else:
            break

    # Compute algebraic variables
    algebraic = computeAlgebraic(constants, states, voi)
    return (voi, states, algebraic)

def plot_model(voi, states, algebraic):
    """Plot variables against variable of integration"""
    import pylab
    (legend_states, legend_algebraic, legend_voi, legend_constants) = createLegends()
    pylab.figure(1)
    pylab.plot(voi,vstack((states,algebraic)).T)
    pylab.xlabel(legend_voi)
    pylab.legend(legend_states + legend_algebraic, loc='best')
    pylab.show()

if __name__ == "__main__":
    (voi, states, algebraic) = solve_model()
    plot_model(voi, states, algebraic)
Source
Derived from workspace severi_fantini_charawi_difrancesco_2012 at changeset 1acf719d8f4b.
This exposure was expired.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License
The terms of use/license for this work is unspecified.