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 = 145
sizeStates = 73
sizeConstants = 188
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] = "F in component Parameters (sec_A_per_mol)"
    legend_constants[1] = "vol_cyt in component Parameters (cubic_Meter)"
    legend_constants[2] = "vol_md in component Parameters (cubic_Meter)"
    legend_constants[3] = "vol_SR in component Parameters (cubic_Meter)"
    legend_constants[4] = "vol_cyt_Ca in component Parameters (cubic_Meter)"
    legend_constants[5] = "K_mr in component Parameters (Molar)"
    legend_constants[6] = "n_H in component Parameters (dimensionless)"
    legend_constants[7] = "v_RyR in component Parameters (per_sec)"
    legend_constants[8] = "K_a in component Parameters (Molar)"
    legend_constants[9] = "K_b in component Parameters (Molar)"
    legend_constants[10] = "K_c in component Parameters (Molar)"
    legend_constants[11] = "K_c_rate in component Parameters (per_sec)"
    legend_constants[12] = "v_IP3R in component Parameters (per_sec)"
    legend_constants[13] = "v_IP3 in component Parameters (per_sec)"
    legend_constants[14] = "conc_IP3_ref in component Parameters (Molar)"
    legend_constants[15] = "alpha_4 in component Parameters (dimensionless)"
    legend_constants[16] = "k4 in component Parameters (Molar)"
    legend_constants[17] = "I_r in component Parameters (per_sec)"
    legend_constants[18] = "d1 in component Parameters (Molar)"
    legend_constants[19] = "a4 in component Parameters (per_M_sec)"
    legend_constants[20] = "d4 in component Parameters (Molar)"
    legend_constants[21] = "a5 in component Parameters (per_M_sec)"
    legend_constants[22] = "d5 in component Parameters (Molar)"
    legend_constants[23] = "G_CaSOC_max in component Parameters (siemens2)"
    legend_constants[24] = "K_SOC in component Parameters (Molar)"
    legend_constants[25] = "delta_CT in component Parameters (volt)"
    legend_constants[26] = "J_NaCl_max in component Parameters (mol_per_sec)"
    legend_constants[27] = "J_KCl_max in component Parameters (mol_per_sec)"
    legend_constants[28] = "J_NKCC_max in component Parameters (mol_per_sec)"
    legend_constants[29] = "K_NKCC_Na in component Parameters (Molar)"
    legend_constants[30] = "K_NKCC_K in component Parameters (Molar)"
    legend_constants[31] = "K_NKCC_Cl1 in component Parameters (Molar)"
    legend_constants[32] = "K_NKCC_Cl2 in component Parameters (Molar)"
    legend_constants[33] = "k_on in component Parameters (per_M_sec)"
    legend_constants[34] = "k_off in component Parameters (per_sec)"
    legend_constants[35] = "alpha1 in component Parameters (per_sec)"
    legend_constants[36] = "alpha2 in component Parameters (per_sec)"
    legend_constants[37] = "alpha3 in component Parameters (per_sec)"
    legend_constants[38] = "G_ClCa_max in component Parameters (siemens2)"
    legend_constants[39] = "G_K_b in component Parameters (siemens2)"
    legend_constants[40] = "G_Na_b in component Parameters (siemens2)"
    legend_constants[41] = "G_Ca_b in component Parameters (siemens2)"
    legend_constants[42] = "G_Cl_b in component Parameters (siemens2)"
    legend_constants[43] = "G_Kir_max in component Parameters (siemens2)"
    legend_constants[44] = "conc_K_ref in component Parameters (Molar)"
    legend_constants[45] = "G_Kv_max in component Parameters (siemens2)"
    legend_constants[46] = "n_ATP in component Parameters (dimensionless)"
    legend_constants[47] = "G_KATP_max in component Parameters (siemens2)"
    legend_constants[48] = "G_KCa_max in component Parameters (siemens2)"
    legend_constants[49] = "Tau_PF in component Parameters (second)"
    legend_constants[50] = "Tau_PS in component Parameters (second)"
    legend_constants[51] = "K_m_K in component Parameters (Molar)"
    legend_constants[52] = "K_m_Na_alpha1 in component Parameters (Molar)"
    legend_constants[53] = "K_m_Na_alpha2 in component Parameters (Molar)"
    legend_constants[54] = "I_NaCa_max in component Parameters (ampere)"
    legend_constants[55] = "K_m_Cai in component Parameters (Molar)"
    legend_constants[56] = "K_m_Cao in component Parameters (Molar)"
    legend_constants[57] = "K_m_Nai in component Parameters (Molar)"
    legend_constants[58] = "K_m_Nao in component Parameters (Molar)"
    legend_constants[59] = "k_sat in component Parameters (dimensionless)"
    legend_constants[60] = "gamma in component Parameters (dimensionless)"
    legend_constants[61] = "K_mCa_act in component Parameters (Molar)"
    legend_constants[62] = "G_VONa_max in component Parameters (siemens2)"
    legend_constants[63] = "Tau_m in component Parameters (second)"
    legend_constants[64] = "Tau_h in component Parameters (second)"
    legend_constants[65] = "K_m_CaP in component Parameters (Molar)"
    legend_constants[66] = "G_CaL_max in component Parameters (siemens2)"
    legend_constants[67] = "conc_Bf_tot in component Parameters (Molar)"
    legend_constants[68] = "k_Bf_on in component Parameters (per_M_sec)"
    legend_constants[69] = "k_Bf_off in component Parameters (per_sec)"
    legend_constants[70] = "conc_Calseq_SR_tot in component Parameters (Molar)"
    legend_constants[71] = "k_Calseq_on in component Parameters (per_M_sec)"
    legend_constants[72] = "k_Calseq_off in component Parameters (per_sec)"
    legend_constants[73] = "f_cyt in component Parameters (dimensionless)"
    legend_constants[74] = "f_md in component Parameters (dimensionless)"
    legend_constants[75] = "R in component Parameters (J_per_mol_K)"
    legend_constants[76] = "T in component Parameters (kelvin)"
    legend_constants[77] = "Area in component Parameters (sq_meter)"
    legend_constants[78] = "L in component Parameters (meter)"
    legend_constants[79] = "hcon in component Parameters (dimensionless)"
    legend_constants[80] = "D_Ca in component Parameters (sq_m_per_sec)"
    legend_constants[176] = "D_K in component Parameters (sq_m_per_sec)"
    legend_constants[177] = "D_Na in component Parameters (sq_m_per_sec)"
    legend_constants[81] = "D_Cl in component Parameters (sq_m_per_sec)"
    legend_states[0] = "conc_K_cyt in component Potassium_Conc_cyt (Molar)"
    legend_algebraic[37] = "I_K_cyt_b in component Background_Currents (ampere)"
    legend_algebraic[87] = "I_K_cyt_ir in component K_Inward_Rectifier_Current (ampere)"
    legend_algebraic[95] = "I_K_cyt_ATP in component K_ATP_Current (ampere)"
    legend_algebraic[92] = "I_K_cyt_v in component K_Delayed_Rectifier_Current (ampere)"
    legend_algebraic[98] = "I_K_cyt_Ca in component K_Ca_Current (ampere)"
    legend_algebraic[140] = "I_NaK_cyt_alpha1 in component NaK_alpha_Current (ampere)"
    legend_algebraic[77] = "J_cyt_KCl in component Cl_flux_KCl (mol_per_sec)"
    legend_algebraic[79] = "J_cyt_NKCC in component Cl_flux_NKCC (mol_per_sec)"
    legend_algebraic[115] = "J_Kdiff in component Md_Cyt_Flux_K (mol_per_sec)"
    legend_states[1] = "conc_K_md in component Potassium_Conc_md (Molar)"
    legend_algebraic[41] = "I_K_md_b in component Background_Currents (ampere)"
    legend_algebraic[90] = "I_K_md_ir in component K_Inward_Rectifier_Current (ampere)"
    legend_algebraic[96] = "I_K_md_ATP in component K_ATP_Current (ampere)"
    legend_algebraic[94] = "I_K_md_v in component K_Delayed_Rectifier_Current (ampere)"
    legend_algebraic[100] = "I_K_md_Ca in component K_Ca_Current (ampere)"
    legend_algebraic[141] = "I_NaK_md_alpha2 in component NaK_alpha_Current (ampere)"
    legend_algebraic[78] = "J_md_KCl in component Cl_flux_KCl (mol_per_sec)"
    legend_algebraic[80] = "J_md_NKCC in component Cl_flux_NKCC (mol_per_sec)"
    legend_states[2] = "conc_Na_cyt in component Sodium_Conc_cyt (Molar)"
    legend_algebraic[43] = "I_Na_cyt_b in component Background_Currents (ampere)"
    legend_algebraic[108] = "I_VONa_cyt in component VONa_Current (ampere)"
    legend_algebraic[73] = "I_Na_cyt_SOC in component SOC_Current_Na (ampere)"
    legend_algebraic[75] = "J_cyt_NaCl in component Cl_flux_NaCl (mol_per_sec)"
    legend_algebraic[117] = "J_Nadiff in component Md_Cyt_Flux_Na (mol_per_sec)"
    legend_states[3] = "conc_Na_md in component Sodium_Conc_md (Molar)"
    legend_algebraic[45] = "I_Na_md_b in component Background_Currents (ampere)"
    legend_algebraic[109] = "I_VONa_md in component VONa_Current (ampere)"
    legend_algebraic[74] = "I_Na_md_SOC in component SOC_Current_Na (ampere)"
    legend_algebraic[76] = "J_md_NaCl in component Cl_flux_NaCl (mol_per_sec)"
    legend_algebraic[107] = "I_NaCa_md in component NCX_Current (ampere)"
    legend_states[4] = "conc_Cl_cyt in component Chloride_Conc_cyt (Molar)"
    legend_algebraic[47] = "I_Cl_cyt_b in component Background_Currents (ampere)"
    legend_algebraic[81] = "I_Cl_cyt_Ca in component ClCa_Current (ampere)"
    legend_algebraic[121] = "J_Cldiff in component Md_Cyt_Flux_Cl (mol_per_sec)"
    legend_states[5] = "conc_Cl_md in component Chloride_Conc_md (Molar)"
    legend_algebraic[49] = "I_Cl_md_b in component Background_Currents (ampere)"
    legend_algebraic[82] = "I_Cl_md_Ca in component ClCa_Current (ampere)"
    legend_states[6] = "conc_Ca_cyt in component Calcium_Conc_cyt (Molar)"
    legend_algebraic[51] = "I_Ca_cyt_b in component Background_Currents (ampere)"
    legend_algebraic[126] = "I_Ca_cyt_P in component Ca_Pump_Current (ampere)"
    legend_algebraic[71] = "I_Ca_cyt_SOC in component SOC_Current_Ca (ampere)"
    legend_algebraic[111] = "I_Ca_cyt_L in component CaL_Current (ampere)"
    legend_algebraic[131] = "I_cyt_SERCa_IP3R in component SERCA_Currents_IP3R (ampere)"
    legend_algebraic[55] = "I_cyt_RyR in component RyR_Currents (ampere)"
    legend_algebraic[119] = "J_Cadiff in component Md_Cyt_Flux_Ca (mol_per_sec)"
    legend_algebraic[63] = "I_cyt_IP3R in component IP3R_Currents (ampere)"
    legend_states[7] = "conc_CaMN__ in component MLCK_Activation_CaM (Molar)"
    legend_states[8] = "conc_BfCa_cyt in component Bf_Kinetics (Molar)"
    legend_algebraic[133] = "I_cyt_SERCa_RyR in component SERCA_Currents_RyR (ampere)"
    legend_states[9] = "conc_CaM_C_ in component MLCK_Activation_CaM (Molar)"
    legend_states[10] = "conc_CaM_CM in component MLCK_Activation_CaM (Molar)"
    legend_states[11] = "conc_CaMNCM in component MLCK_Activation_CaM (Molar)"
    legend_states[12] = "conc_CaM___ in component MLCK_Activation_CaM (Molar)"
    legend_states[13] = "conc_BfCa_md in component Bf_Kinetics (Molar)"
    legend_states[14] = "conc_Ca_md in component Calcium_Conc_md (Molar)"
    legend_algebraic[53] = "I_Ca_md_b in component Background_Currents (ampere)"
    legend_algebraic[127] = "I_Ca_md_P in component Ca_Pump_Current (ampere)"
    legend_algebraic[72] = "I_Ca_md_SOC in component SOC_Current_Ca (ampere)"
    legend_algebraic[113] = "I_Ca_md_L in component CaL_Current (ampere)"
    legend_algebraic[134] = "I_md_SERCa_RyR in component SERCA_Currents_RyR (ampere)"
    legend_algebraic[57] = "I_md_RyR in component RyR_Currents (ampere)"
    legend_algebraic[67] = "I_md_IP3R in component IP3R_Currents (ampere)"
    legend_algebraic[132] = "I_md_SERCa_IP3R in component SERCA_Currents_IP3R (ampere)"
    legend_states[15] = "conc_CaMN__ in component MLCK_Activation_CaM_md (Molar)"
    legend_states[16] = "conc_CaM_C_ in component MLCK_Activation_CaM_md (Molar)"
    legend_states[17] = "conc_CaM_CM in component MLCK_Activation_CaM_md (Molar)"
    legend_states[18] = "conc_CaMNCM in component MLCK_Activation_CaM_md (Molar)"
    legend_states[19] = "conc_Ca_IP3R in component Calcium_Conc_SR (Molar)"
    legend_states[20] = "conc_Ca_RyR in component Calcium_Conc_SR (Molar)"
    legend_states[21] = "conc_CalseqCa_IP3R in component Calseq_Kinetics (Molar)"
    legend_states[22] = "conc_CalseqCa_RyR in component Calseq_Kinetics (Molar)"
    legend_states[23] = "V_m_cyt in component Membrane_Voltage (volt)"
    legend_states[24] = "V_m_md in component Membrane_Voltage (volt)"
    legend_algebraic[34] = "E_K_cyt in component Nernst_Potentials (volt)"
    legend_algebraic[39] = "E_K_md in component Nernst_Potentials (volt)"
    legend_algebraic[42] = "E_Na_cyt in component Nernst_Potentials (volt)"
    legend_algebraic[44] = "E_Na_md in component Nernst_Potentials (volt)"
    legend_algebraic[46] = "E_Cl_cyt in component Nernst_Potentials (volt)"
    legend_algebraic[48] = "E_Cl_md in component Nernst_Potentials (volt)"
    legend_algebraic[50] = "E_Ca_cyt in component Nernst_Potentials (volt)"
    legend_algebraic[52] = "E_Ca_md in component Nernst_Potentials (volt)"
    legend_constants[82] = "conc_K_out in component Nernst_Potentials (Molar)"
    legend_constants[83] = "conc_Na_out in component Nernst_Potentials (Molar)"
    legend_constants[84] = "conc_Cl_out in component Nernst_Potentials (Molar)"
    legend_constants[85] = "conc_Ca_out in component Nernst_Potentials (Molar)"
    legend_constants[86] = "z_K in component Nernst_Potentials (dimensionless)"
    legend_constants[87] = "z_Na in component Nernst_Potentials (dimensionless)"
    legend_constants[88] = "z_Cl in component Nernst_Potentials (dimensionless)"
    legend_constants[89] = "z_Ca in component Nernst_Potentials (dimensionless)"
    legend_constants[178] = "RTF in component Nernst_Potentials (volt)"
    legend_algebraic[130] = "I_SERCA_max in component ROS_SERCA_Interaction (ampere)"
    legend_algebraic[124] = "K_mf in component SERCA_Activation (Molar)"
    legend_algebraic[54] = "P_cyt_RyR in component RyR_Currents (dimensionless)"
    legend_algebraic[56] = "P_md_RyR in component RyR_Currents (dimensionless)"
    legend_states[25] = "w_cyt in component RyR_Currents (dimensionless)"
    legend_states[26] = "w_md in component RyR_Currents (dimensionless)"
    legend_algebraic[0] = "w_inf_cyt in component RyR_Currents (dimensionless)"
    legend_algebraic[1] = "w_inf_md in component RyR_Currents (dimensionless)"
    legend_algebraic[62] = "x110_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[66] = "x110_md in component IP3R_Binding_Sites (dimensionless)"
    legend_states[27] = "conc_IP3_cyt in component IP3R_Currents (Molar)"
    legend_states[28] = "conc_IP3_md in component IP3R_Currents (Molar)"
    legend_states[29] = "x000_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_states[30] = "x000_md in component IP3R_Binding_Sites (dimensionless)"
    legend_states[31] = "x001_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_states[32] = "x001_md in component IP3R_Binding_Sites (dimensionless)"
    legend_states[33] = "x010_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_states[34] = "x010_md in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[64] = "x011_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[68] = "x011_md in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[60] = "x101_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[61] = "x101_md in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[65] = "x111_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[69] = "x111_md in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[58] = "x100_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_algebraic[59] = "x100_md in component IP3R_Binding_Sites (dimensionless)"
    legend_constants[90] = "d3 in component IP3R_Binding_Sites (Molar)"
    legend_algebraic[70] = "conc_Ca_SR in component SOC_Current_Ca (Molar)"
    legend_constants[91] = "z_Na in component SOC_Current_Na (dimensionless)"
    legend_constants[92] = "z_Ca in component SOC_Current_Na (dimensionless)"
    legend_constants[93] = "P_SOC_ratio in component SOC_Current_Na (dimensionless)"
    legend_states[35] = "y_C1_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[36] = "y_C2_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[37] = "y_C3_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[38] = "y_O1_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[39] = "y_O2_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[40] = "y_O3_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_algebraic[19] = "Beta_cyt in component Cl_Channel_Rates (per_sec)"
    legend_algebraic[2] = "y_C0_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_states[41] = "y_C1_md in component Cl_Channels_md (dimensionless)"
    legend_states[42] = "y_C2_md in component Cl_Channels_md (dimensionless)"
    legend_states[43] = "y_C3_md in component Cl_Channels_md (dimensionless)"
    legend_states[44] = "y_O1_md in component Cl_Channels_md (dimensionless)"
    legend_states[45] = "y_O2_md in component Cl_Channels_md (dimensionless)"
    legend_states[46] = "y_O3_md in component Cl_Channels_md (dimensionless)"
    legend_algebraic[20] = "Beta_md in component Cl_Channel_Rates (per_sec)"
    legend_algebraic[3] = "y_C0_md in component Cl_Channels_md (dimensionless)"
    legend_constants[94] = "V1 in component Cl_Channel_Rates (dimensionless)"
    legend_constants[95] = "V2 in component Cl_Channel_Rates (per_V)"
    legend_constants[96] = "Lambda_Beta in component Cl_Channel_Rates (per_sec)"
    legend_algebraic[86] = "x_Kir_cyt in component K_Inward_Rectifier_Current (dimensionless)"
    legend_algebraic[89] = "x_Kir_md in component K_Inward_Rectifier_Current (dimensionless)"
    legend_algebraic[83] = "alpha_Kir_cyt in component K_ir_Rates (per_sec)"
    legend_algebraic[84] = "alpha_Kir_md in component K_ir_Rates (per_sec)"
    legend_algebraic[85] = "Beta_Kir_cyt in component K_ir_Rates (per_sec)"
    legend_algebraic[88] = "Beta_Kir_md in component K_ir_Rates (per_sec)"
    legend_algebraic[91] = "P_Kv_cyt in component Kv_Activations (dimensionless)"
    legend_algebraic[93] = "P_Kv_md in component Kv_Activations (dimensionless)"
    legend_states[47] = "P1_cyt in component Kv_Activations (dimensionless)"
    legend_states[48] = "P1_md in component Kv_Activations (dimensionless)"
    legend_states[49] = "P2_cyt in component Kv_Activations (dimensionless)"
    legend_states[50] = "P2_md in component Kv_Activations (dimensionless)"
    legend_algebraic[4] = "P_bar_Kv_cyt in component Kv_Activations (dimensionless)"
    legend_algebraic[5] = "P_bar_Kv_md in component Kv_Activations (dimensionless)"
    legend_algebraic[21] = "Tau_P1_cyt in component Kv_Time_Constants (second)"
    legend_algebraic[22] = "Tau_P1_md in component Kv_Time_Constants (second)"
    legend_algebraic[23] = "Tau_P2_cyt in component Kv_Time_Constants (second)"
    legend_algebraic[24] = "Tau_P2_md in component Kv_Time_Constants (second)"
    legend_algebraic[97] = "P_KCa_cyt in component KCa_Activations (dimensionless)"
    legend_algebraic[99] = "P_KCa_md in component KCa_Activations (dimensionless)"
    legend_states[51] = "PF_cyt in component KCa_Activations (dimensionless)"
    legend_states[52] = "PF_md in component KCa_Activations (dimensionless)"
    legend_states[53] = "PS_cyt in component KCa_Activations (dimensionless)"
    legend_states[54] = "PS_md in component KCa_Activations (dimensionless)"
    legend_algebraic[25] = "P_bar_KCa_cyt in component KCa_Activations (dimensionless)"
    legend_algebraic[26] = "P_bar_KCa_md in component KCa_Activations (dimensionless)"
    legend_algebraic[6] = "V_KCa_cyt in component cGMP_Ca_Interaction (volt)"
    legend_algebraic[7] = "V_KCa_md in component cGMP_Ca_Interaction (volt)"
    legend_algebraic[138] = "I_NaK_alpha1_max in component ROS_NaK_Interaction (ampere)"
    legend_algebraic[142] = "I_NaK_alpha2_max in component NaK_alpha_Current (ampere)"
    legend_algebraic[101] = "Psi_NaK_cyt in component NaK_alpha_Waveform (dimensionless)"
    legend_algebraic[102] = "Psi_NaK_md in component NaK_alpha_Waveform (dimensionless)"
    legend_constants[179] = "Sigma in component NaK_alpha_Waveform (dimensionless)"
    legend_algebraic[103] = "K_a_NaCa in component NCX_Waveform (dimensionless)"
    legend_algebraic[104] = "Psi_F in component NCX_Waveform (dimensionless)"
    legend_algebraic[105] = "Psi_R in component NCX_Waveform (dimensionless)"
    legend_algebraic[106] = "G in component NCX_Waveform (M_fourpow)"
    legend_states[55] = "m_VONa_cyt in component VONa_Channels (dimensionless)"
    legend_states[56] = "m_VONa_md in component VONa_Channels (dimensionless)"
    legend_states[57] = "h_VONa_cyt in component VONa_Channels (dimensionless)"
    legend_states[58] = "h_VONa_md in component VONa_Channels (dimensionless)"
    legend_algebraic[8] = "m_bar_cyt in component VONa_Channels (dimensionless)"
    legend_algebraic[9] = "m_bar_md in component VONa_Channels (dimensionless)"
    legend_algebraic[10] = "h_bar_cyt in component VONa_Channels (dimensionless)"
    legend_algebraic[11] = "h_bar_md in component VONa_Channels (dimensionless)"
    legend_algebraic[125] = "I_CaP_max in component CaP_Current_Max (ampere)"
    legend_states[59] = "d_L_cyt in component CaL_Activations (dimensionless)"
    legend_states[60] = "d_L_md in component CaL_Activations (dimensionless)"
    legend_algebraic[110] = "f_L_cyt in component CaL_Activations (dimensionless)"
    legend_algebraic[112] = "f_L_md in component CaL_Activations (dimensionless)"
    legend_states[61] = "f_F_cyt in component CaL_Activations (dimensionless)"
    legend_states[62] = "f_F_md in component CaL_Activations (dimensionless)"
    legend_algebraic[12] = "d_bar_L_cyt in component CaL_Activations (dimensionless)"
    legend_algebraic[13] = "d_bar_L_md in component CaL_Activations (dimensionless)"
    legend_algebraic[14] = "f_bar_F_cyt in component CaL_Activations (dimensionless)"
    legend_algebraic[15] = "f_bar_F_md in component CaL_Activations (dimensionless)"
    legend_algebraic[27] = "Tau_d_cyt in component CaL_Time_Constants (second)"
    legend_algebraic[28] = "Tau_d_md in component CaL_Time_Constants (second)"
    legend_algebraic[29] = "Tau_f_cyt in component CaL_Time_Constants (second)"
    legend_algebraic[30] = "Tau_f_md in component CaL_Time_Constants (second)"
    legend_algebraic[114] = "Xi_K in component Md_Cyt_Flux_K (dimensionless)"
    legend_constants[182] = "P_K_diff in component Md_Cyt_Flux_K (m_per_sec)"
    legend_constants[97] = "z_K in component Md_Cyt_Flux_K (dimensionless)"
    legend_constants[186] = "Volsec in component Md_Cyt_Flux_K (cubic_m_per_sec)"
    legend_constants[98] = "DiffArea in component Md_Cyt_Flux_K (sq_meter)"
    legend_algebraic[116] = "Xi_Na in component Md_Cyt_Flux_Na (dimensionless)"
    legend_constants[183] = "P_Na_diff in component Md_Cyt_Flux_Na (m_per_sec)"
    legend_constants[99] = "z_Na in component Md_Cyt_Flux_Na (dimensionless)"
    legend_constants[187] = "Volsec in component Md_Cyt_Flux_Na (cubic_m_per_sec)"
    legend_constants[100] = "DiffArea in component Md_Cyt_Flux_Na (sq_meter)"
    legend_algebraic[118] = "Xi_Ca in component Md_Cyt_Flux_Ca (dimensionless)"
    legend_constants[180] = "P_Ca_diff in component Md_Cyt_Flux_Ca (m_per_sec)"
    legend_constants[101] = "z_Ca in component Md_Cyt_Flux_Ca (dimensionless)"
    legend_constants[184] = "Volsec in component Md_Cyt_Flux_Ca (cubic_m_per_sec)"
    legend_constants[102] = "DiffArea in component Md_Cyt_Flux_Ca (sq_meter)"
    legend_algebraic[120] = "Xi_Cl in component Md_Cyt_Flux_Cl (dimensionless)"
    legend_constants[181] = "P_Cl_diff in component Md_Cyt_Flux_Cl (m_per_sec)"
    legend_constants[103] = "z_Cl in component Md_Cyt_Flux_Cl (dimensionless)"
    legend_constants[185] = "Volsec in component Md_Cyt_Flux_Cl (cubic_m_per_sec)"
    legend_constants[104] = "DiffArea in component Md_Cyt_Flux_Cl (sq_meter)"
    legend_algebraic[143] = "I_cyt_tot in component Membrane_Potential_Cyt (ampere)"
    legend_algebraic[135] = "I_cyt_up in component Membrane_Potential_Cyt (ampere)"
    legend_algebraic[144] = "I_md_tot in component Membrane_Potential_md (ampere)"
    legend_constants[105] = "C_m in component Membrane_Voltage (farad2)"
    legend_algebraic[137] = "I_md_up in component Membrane_Potential_md (ampere)"
    legend_constants[106] = "k_NO_O2 in component Parameters_VR (per_M_sec)"
    legend_constants[107] = "k_NO_cons in component Parameters_VR (per_sec)"
    legend_constants[108] = "k_SOD_O2 in component Parameters_VR (per_M_sec)"
    legend_constants[109] = "k_cat in component Parameters_VR (per_M_sec)"
    legend_constants[110] = "conc_SOD in component Parameters_VR (Molar)"
    legend_constants[111] = "conc_CAT in component Parameters_VR (Molar)"
    legend_constants[112] = "J_NO in component Parameters_VR (mol_per_sq_m_sec)"
    legend_constants[113] = "G_O2 in component Parameters_VR (M_per_sec)"
    legend_constants[114] = "J_H2O2 in component Parameters_VR (mol_per_sq_m_sec)"
    legend_constants[115] = "P_NO in component Parameters_VR (m_per_sec)"
    legend_constants[116] = "P_O2 in component Parameters_VR (m_per_sec)"
    legend_constants[117] = "P_H2O2 in component Parameters_VR (m_per_sec)"
    legend_constants[118] = "k_sGC_for in component Parameters_VR (per_M_sec)"
    legend_constants[119] = "k_sGC_back in component Parameters_VR (per_sec)"
    legend_constants[120] = "k2_sGC_for in component Parameters_VR (per_sec)"
    legend_constants[121] = "k3_sCG_for in component Parameters_VR (per_M_sec)"
    legend_constants[122] = "K4_sGC_for in component Parameters_VR (per_M_sec)"
    legend_constants[123] = "V_sGC_max in component Parameters_VR (M_per_sec)"
    legend_constants[124] = "k_PDE in component Parameters_VR (per_sec)"
    legend_constants[125] = "K_M_PDE in component Parameters_VR (Molar)"
    legend_constants[126] = "K_MLCP in component Parameters_VR (Molar)"
    legend_constants[127] = "K_SERCA in component Parameters_VR (Molar)"
    legend_constants[128] = "K_PMCA in component Parameters_VR (Molar)"
    legend_constants[129] = "K_KCa_cGMP in component Parameters_VR (Molar)"
    legend_constants[130] = "V_KCa_cGMP in component Parameters_VR (volt)"
    legend_constants[131] = "K_KCa_NO in component Parameters_VR (Molar)"
    legend_constants[132] = "V_KCa_NO in component Parameters_VR (volt)"
    legend_constants[133] = "V_Ca in component Parameters_VR (volt)"
    legend_constants[134] = "V_B in component Parameters_VR (volt)"
    legend_constants[135] = "k_KCa in component Parameters_VR (volt)"
    legend_constants[136] = "K_SERCA_O2 in component Parameters_VR (Molar)"
    legend_constants[137] = "K_SERCA_H2O2 in component Parameters_VR (Molar)"
    legend_constants[138] = "K_NaK_O2 in component Parameters_VR (Molar)"
    legend_constants[139] = "K_NaK_H202 in component Parameters_VR (Molar)"
    legend_constants[140] = "K_MLCP_H2O2 in component Parameters_VR (Molar)"
    legend_constants[141] = "alpha_MLCP in component Parameters_VR (dimensionless)"
    legend_constants[142] = "k1_CAM_on in component Parameters_VR (per_sq_M_sec)"
    legend_constants[143] = "k1_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[144] = "k2_CAM_on in component Parameters_VR (per_sq_M_sec)"
    legend_constants[145] = "k2_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[146] = "k3_CAM_on in component Parameters_VR (per_sq_M_sec)"
    legend_constants[147] = "k3_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[148] = "k4_CAM_on in component Parameters_VR (per_sq_M_sec)"
    legend_constants[149] = "k4_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[150] = "k5_CAM_on in component Parameters_VR (per_M_sec)"
    legend_constants[151] = "k5_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[152] = "k6_CAM_on in component Parameters_VR (per_sq_M_sec)"
    legend_constants[153] = "k6_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[154] = "k7_CAM_on in component Parameters_VR (per_M_sec)"
    legend_constants[155] = "k7_CAM_off in component Parameters_VR (per_sec)"
    legend_constants[156] = "k_Myo_MLCK in component Parameters_VR (per_M_sec)"
    legend_constants[157] = "k_Myo_MLCP in component Parameters_VR (per_sec)"
    legend_constants[158] = "k3_Myo in component Parameters_VR (per_sec)"
    legend_constants[159] = "k4_Myo in component Parameters_VR (per_sec)"
    legend_constants[160] = "k7_Myo in component Parameters_VR (per_sec)"
    legend_constants[161] = "conc_CaM_tot in component Parameters_VR (Molar)"
    legend_constants[162] = "conc_MLCK_tot in component Parameters_VR (Molar)"
    legend_constants[163] = "conc_Myo_tot in component Parameters_VR (Molar)"
    legend_constants[164] = "K_mf_rest in component Parameters_VR (Molar)"
    legend_constants[165] = "I_PMCA_rest_max in component Parameters_VR (ampere)"
    legend_constants[166] = "I_SERCA_rest_max in component Parameters_VR (ampere)"
    legend_constants[167] = "I_NaK_alpha1_rest_max in component Parameters_VR (ampere)"
    legend_constants[168] = "I_NaK_alpha2_rest_max in component Parameters_VR (ampere)"
    legend_algebraic[122] = "conc_CaMNC_ in component MLCK_Activation_CaM (Molar)"
    legend_algebraic[123] = "conc_MLCK_free in component MLCK_Activation_CaM (Molar)"
    legend_states[63] = "conc_Myo in component MLCK_Phospho_Myosin (Molar)"
    legend_states[64] = "conc_MyoP in component MLCK_Phospho_Myosin (Molar)"
    legend_states[65] = "conc_AMyo in component MLCK_Phospho_Myosin (Molar)"
    legend_algebraic[16] = "conc_AMyoP in component MLCK_Phospho_Myosin (Molar)"
    legend_algebraic[31] = "k1_6_Myo in component MLCP_Rate_Constants (per_sec)"
    legend_algebraic[38] = "k2_Myo in component MLCP_Rate_Constants (per_sec)"
    legend_algebraic[40] = "k5_Myo in component MLCP_Rate_Constants (per_sec)"
    legend_constants[169] = "K_M_cGMP in component MLCP_Rate_Constants (Molar)"
    legend_states[66] = "conc_cGMP in component cGMP_Kinetics (Molar)"
    legend_algebraic[35] = "R_MLCP in component MLCP_Rate_Constants (dimensionless)"
    legend_states[67] = "conc_H2O2_cyt in component H2O2_Kinetics (Molar)"
    legend_states[68] = "conc_NO_cyt in component NO_Kinetics (Molar)"
    legend_states[69] = "conc_O2_cyt in component O2_Kinetics (Molar)"
    legend_algebraic[17] = "zeta in component Zeta (dimensionless)"
    legend_states[70] = "conc_Eb in component sGC_Activation (dimensionless)"
    legend_algebraic[18] = "conc_E6c in component sGC_Activation (dimensionless)"
    legend_states[71] = "conc_E5c in component sGC_Activation (dimensionless)"
    legend_algebraic[32] = "k4_sGC_for in component sGC_Activation (per_sec)"
    legend_constants[170] = "convert in component cGMP_Ca_Interaction (dimensionless)"
    legend_constants[171] = "K_mod in component SERCA_Activation (dimensionless)"
    legend_algebraic[128] = "theta_SERCA_O2 in component ROS_SERCA_Interaction (dimensionless)"
    legend_algebraic[129] = "theta_SERCA_H2O2 in component ROS_SERCA_Interaction (dimensionless)"
    legend_states[72] = "conc_CaM___ in component MLCK_Activation_CaM_md (Molar)"
    legend_algebraic[136] = "conc_CaMNC_ in component MLCK_Activation_CaM_md (Molar)"
    legend_algebraic[139] = "conc_MLCK_free in component MLCK_Activation_CaM_md (Molar)"
    legend_algebraic[33] = "f_p in component Contractile_Force (dimensionless)"
    legend_algebraic[36] = "F_contract in component Contractile_Force (dimensionless)"
    legend_constants[172] = "a in component Contractile_Force (dimensionless)"
    legend_constants[173] = "b in component Contractile_Force (dimensionless)"
    legend_constants[174] = "c in component Contractile_Force (dimensionless)"
    legend_constants[175] = "d in component Contractile_Force (dimensionless)"
    legend_rates[0] = "d/dt conc_K_cyt in component Potassium_Conc_cyt (Molar)"
    legend_rates[1] = "d/dt conc_K_md in component Potassium_Conc_md (Molar)"
    legend_rates[2] = "d/dt conc_Na_cyt in component Sodium_Conc_cyt (Molar)"
    legend_rates[3] = "d/dt conc_Na_md in component Sodium_Conc_md (Molar)"
    legend_rates[4] = "d/dt conc_Cl_cyt in component Chloride_Conc_cyt (Molar)"
    legend_rates[5] = "d/dt conc_Cl_md in component Chloride_Conc_md (Molar)"
    legend_rates[6] = "d/dt conc_Ca_cyt in component Calcium_Conc_cyt (Molar)"
    legend_rates[7] = "d/dt conc_CaMN__ in component MLCK_Activation_CaM (Molar)"
    legend_rates[9] = "d/dt conc_CaM_C_ in component MLCK_Activation_CaM (Molar)"
    legend_rates[10] = "d/dt conc_CaM_CM in component MLCK_Activation_CaM (Molar)"
    legend_rates[8] = "d/dt conc_BfCa_cyt in component Bf_Kinetics (Molar)"
    legend_rates[13] = "d/dt conc_BfCa_md in component Bf_Kinetics (Molar)"
    legend_rates[14] = "d/dt conc_Ca_md in component Calcium_Conc_md (Molar)"
    legend_rates[15] = "d/dt conc_CaMN__ in component MLCK_Activation_CaM_md (Molar)"
    legend_rates[16] = "d/dt conc_CaM_C_ in component MLCK_Activation_CaM_md (Molar)"
    legend_rates[17] = "d/dt conc_CaM_CM in component MLCK_Activation_CaM_md (Molar)"
    legend_rates[19] = "d/dt conc_Ca_IP3R in component Calcium_Conc_SR (Molar)"
    legend_rates[21] = "d/dt conc_CalseqCa_IP3R in component Calseq_Kinetics (Molar)"
    legend_rates[20] = "d/dt conc_Ca_RyR in component Calcium_Conc_SR (Molar)"
    legend_rates[22] = "d/dt conc_CalseqCa_RyR in component Calseq_Kinetics (Molar)"
    legend_rates[25] = "d/dt w_cyt in component RyR_Currents (dimensionless)"
    legend_rates[26] = "d/dt w_md in component RyR_Currents (dimensionless)"
    legend_rates[27] = "d/dt conc_IP3_cyt in component IP3R_Currents (Molar)"
    legend_rates[28] = "d/dt conc_IP3_md in component IP3R_Currents (Molar)"
    legend_rates[29] = "d/dt x000_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[30] = "d/dt x000_md in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[31] = "d/dt x001_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[32] = "d/dt x001_md in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[33] = "d/dt x010_cyt in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[34] = "d/dt x010_md in component IP3R_Binding_Sites (dimensionless)"
    legend_rates[35] = "d/dt y_C1_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[36] = "d/dt y_C2_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[37] = "d/dt y_C3_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[38] = "d/dt y_O1_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[39] = "d/dt y_O2_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[40] = "d/dt y_O3_cyt in component Cl_Channels_cyt (dimensionless)"
    legend_rates[41] = "d/dt y_C1_md in component Cl_Channels_md (dimensionless)"
    legend_rates[42] = "d/dt y_C2_md in component Cl_Channels_md (dimensionless)"
    legend_rates[43] = "d/dt y_C3_md in component Cl_Channels_md (dimensionless)"
    legend_rates[44] = "d/dt y_O1_md in component Cl_Channels_md (dimensionless)"
    legend_rates[45] = "d/dt y_O2_md in component Cl_Channels_md (dimensionless)"
    legend_rates[46] = "d/dt y_O3_md in component Cl_Channels_md (dimensionless)"
    legend_rates[47] = "d/dt P1_cyt in component Kv_Activations (dimensionless)"
    legend_rates[48] = "d/dt P1_md in component Kv_Activations (dimensionless)"
    legend_rates[49] = "d/dt P2_cyt in component Kv_Activations (dimensionless)"
    legend_rates[50] = "d/dt P2_md in component Kv_Activations (dimensionless)"
    legend_rates[51] = "d/dt PF_cyt in component KCa_Activations (dimensionless)"
    legend_rates[52] = "d/dt PF_md in component KCa_Activations (dimensionless)"
    legend_rates[53] = "d/dt PS_cyt in component KCa_Activations (dimensionless)"
    legend_rates[54] = "d/dt PS_md in component KCa_Activations (dimensionless)"
    legend_rates[55] = "d/dt m_VONa_cyt in component VONa_Channels (dimensionless)"
    legend_rates[56] = "d/dt m_VONa_md in component VONa_Channels (dimensionless)"
    legend_rates[57] = "d/dt h_VONa_cyt in component VONa_Channels (dimensionless)"
    legend_rates[58] = "d/dt h_VONa_md in component VONa_Channels (dimensionless)"
    legend_rates[59] = "d/dt d_L_cyt in component CaL_Activations (dimensionless)"
    legend_rates[60] = "d/dt d_L_md in component CaL_Activations (dimensionless)"
    legend_rates[61] = "d/dt f_F_cyt in component CaL_Activations (dimensionless)"
    legend_rates[62] = "d/dt f_F_md in component CaL_Activations (dimensionless)"
    legend_rates[23] = "d/dt V_m_cyt in component Membrane_Voltage (volt)"
    legend_rates[24] = "d/dt V_m_md in component Membrane_Voltage (volt)"
    legend_rates[12] = "d/dt conc_CaM___ in component MLCK_Activation_CaM (Molar)"
    legend_rates[11] = "d/dt conc_CaMNCM in component MLCK_Activation_CaM (Molar)"
    legend_rates[63] = "d/dt conc_Myo in component MLCK_Phospho_Myosin (Molar)"
    legend_rates[64] = "d/dt conc_MyoP in component MLCK_Phospho_Myosin (Molar)"
    legend_rates[65] = "d/dt conc_AMyo in component MLCK_Phospho_Myosin (Molar)"
    legend_rates[68] = "d/dt conc_NO_cyt in component NO_Kinetics (Molar)"
    legend_rates[69] = "d/dt conc_O2_cyt in component O2_Kinetics (Molar)"
    legend_rates[67] = "d/dt conc_H2O2_cyt in component H2O2_Kinetics (Molar)"
    legend_rates[70] = "d/dt conc_Eb in component sGC_Activation (dimensionless)"
    legend_rates[71] = "d/dt conc_E5c in component sGC_Activation (dimensionless)"
    legend_rates[66] = "d/dt conc_cGMP in component cGMP_Kinetics (Molar)"
    legend_rates[72] = "d/dt conc_CaM___ in component MLCK_Activation_CaM_md (Molar)"
    legend_rates[18] = "d/dt conc_CaMNCM in component MLCK_Activation_CaM_md (Molar)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 96487
    constants[1] = 5E-16
    constants[2] = 3E-18
    constants[3] = 7E-17
    constants[4] = 3.5E-16
    constants[5] = 1.7
    constants[6] = 2
    constants[7] = 12
    constants[8] = 3.7224E-4
    constants[9] = 6.3601E-4
    constants[10] = 5.71E-5
    constants[11] = 0.1
    constants[12] = 20
    constants[13] = 1.85
    constants[14] = 2.4E-4
    constants[15] = 0.5
    constants[16] = 1.1E-3
    constants[17] = 1
    constants[18] = 1.3E-4
    constants[19] = 2E2
    constants[20] = 1.445E-4
    constants[21] = 2E4
    constants[22] = 8.234E-5
    constants[23] = 7.5E-11
    constants[24] = 0.1
    constants[25] = 8.78E-2
    constants[26] = 6E-17
    constants[27] = 3.5E-18
    constants[28] = 6E-17
    constants[29] = 46
    constants[30] = 4.0
    constants[31] = 78
    constants[32] = 78
    constants[33] = 3.0E3
    constants[34] = 50
    constants[35] = 10
    constants[36] = 30
    constants[37] = 300
    constants[38] = 1.2E-8
    constants[39] = 1E-11
    constants[40] = 1E-11
    constants[41] = 1.2E-11
    constants[42] = 1E-11
    constants[43] = 3E-10
    constants[44] = 5.4
    constants[45] = 9.8325E-9
    constants[46] = 0.463
    constants[47] = 1.036E-9
    constants[48] = 5.00E-10
    constants[49] = 5E-4
    constants[50] = 1.15E-2
    constants[51] = 1.5
    constants[52] = 12
    constants[53] = 22
    constants[54] = 1.7097E-10
    constants[55] = 3.59E-3
    constants[56] = 1.3
    constants[57] = 12.29
    constants[58] = 87.5
    constants[59] = 0.27
    constants[60] = 0.35
    constants[61] = 1.25E-4
    constants[62] = 2.860E-9
    constants[63] = 0.0001
    constants[64] = 0.001
    constants[65] = 1.7E-4
    constants[66] = 1.4151E-9
    constants[67] = 4E-1
    constants[68] = 100E3
    constants[69] = 300
    constants[70] = 1.4E-1
    constants[71] = 1E5
    constants[72] = 8E4
    constants[73] = 0.8580
    constants[74] = 0.1420
    constants[75] = 8.3144621
    constants[76] = 298
    constants[77] = 1.21E-9
    constants[78] = 5E-7
    constants[79] = 0.001
    constants[80] = 3E-10
    constants[81] = 3E-10
    states[0] = 140.55
    states[1] = 131.37
    states[2] = 9.1964
    states[3] = 20.742
    states[4] = 23.257
    states[5] = 16.737
    states[6] = 1.0533E-4
    states[7] = 1.1023E-5
    states[8] = 1.3568E-2
    states[9] = 4.1154E-5
    states[10] = 1.9451E-3
    states[11] = 5.3950E-5
    states[12] = 7.9487E-3
    states[13] = 4.4109E-2
    states[14] = 3.7182E-4
    states[15] = 1.2766E-4
    states[16] = 4.7661E-4
    states[17] = 1.4863E-3
    states[18] = 5.1368E-4
    states[19] = 5.6334E-1
    states[20] = 4.9091E-1
    states[21] = 5.7849E-2
    states[22] = 5.3239E-2
    states[23] = -7.8960E-2
    states[24] = -7.6961E-2
    constants[82] = 5.4
    constants[83] = 140
    constants[84] = 110
    constants[85] = 2.0
    constants[86] = 1
    constants[87] = 1
    constants[88] = -1
    constants[89] = 2
    states[25] = 0.11187
    states[26] = 0.89971
    states[27] = 2.4140E-4
    states[28] = 2.7808E-4
    states[29] = 0.11631
    states[30] = 0.028019
    states[31] = 0.084779
    states[32] = 0.072097
    states[33] = 0.14878
    states[34] = 0.12652
    constants[90] = 9.434E-4
    constants[91] = 1
    constants[92] = 2
    constants[93] = 0.125
    states[35] = 0.0062437
    states[36] = 0.000039459
    states[37] = 0.00000024937
    states[38] = 0.0056570
    states[39] = 0.00010725
    states[40] = 0.0000067783
    states[41] = 2.1346E-2
    states[42] = 4.7620E-4
    states[43] = 1.0624E-5
    states[44] = 1.9731E-2
    states[45] = 1.3205E-3
    states[46] = 2.94594E-4
    constants[94] = -3.8
    constants[95] = -10.0
    constants[96] = 224
    states[47] = 0.0048876
    states[48] = 0.0056051
    states[49] = 0.0048876
    states[50] = 0.0056051
    states[51] = 0.94813
    states[52] = 0.67538
    states[53] = 0.94813
    states[54] = 0.67538
    states[55] = 1.0429E-5
    states[56] = 1.5817E-5
    states[57] = 0.87853
    states[58] = 0.84170
    states[59] = 3.7841E-5
    states[60] = 4.9277E-5
    states[61] = 1
    states[62] = 1
    constants[97] = 1
    constants[98] = 7.7598E-13
    constants[99] = 1
    constants[100] = 7.7598E-13
    constants[101] = 2
    constants[102] = 7.7598E-13
    constants[103] = -1
    constants[104] = 7.7598E-13
    constants[105] = 1.2100E-11
    constants[106] = 1.9E7
    constants[107] = 0.01
    constants[108] = 1.6E6
    constants[109] = 3.4E4
    constants[110] = 1E-3
    constants[111] = 20E-3
    constants[112] = 2.8E-8
    constants[113] = 4.5E-3
    constants[114] = 6E-8
    constants[115] = 3E-4
    constants[116] = 6E-4
    constants[117] = 6E-4
    constants[118] = 2E6
    constants[119] = 100
    constants[120] = 0.1
    constants[121] = 3E3
    constants[122] = 98
    constants[123] = 1.09E-3
    constants[124] = 0.032
    constants[125] = 2.0E-3
    constants[126] = 5.5E-3
    constants[127] = 5.0E-4
    constants[128] = 1.0E-3
    constants[129] = 5.5E-4
    constants[130] = 66.9
    constants[131] = 2E-1
    constants[132] = 100
    constants[133] = -53.7
    constants[134] = 283.7
    constants[135] = 30.8E-3
    constants[136] = 2.0E-2
    constants[137] = 6.6E-2
    constants[138] = 1.6E-3
    constants[139] = 0.56
    constants[140] = 1E-3
    constants[141] = 4.0
    constants[142] = 2.8E6
    constants[143] = 6
    constants[144] = 100E6
    constants[145] = 800
    constants[146] = 2.8E6
    constants[147] = 6.0
    constants[148] = 100E6
    constants[149] = 800
    constants[150] = 1000E3
    constants[151] = 20
    constants[152] = 12.5E6
    constants[153] = 5.0
    constants[154] = 1000E3
    constants[155] = 1
    constants[156] = 4E3
    constants[157] = 0.4
    constants[158] = 1.8
    constants[159] = 0.1
    constants[160] = 0.045
    constants[161] = 1.00E-2
    constants[162] = 2.0E-3
    constants[163] = 30E-3
    constants[164] = 3.0995E-4
    constants[165] = 2.853E-12
    constants[166] = 100E-12
    constants[167] = 2.7225E-11
    constants[168] = 2.7225E-11
    states[63] = 8.0265E-3
    states[64] = 6.3288E-4
    states[65] = 1.8089E-2
    constants[169] = 5.5E-3
    states[66] = 9.0341E-3
    states[67] = 5.0006E-5
    states[68] = 9.2798E-5
    states[69] = 8.3402E-7
    states[70] = 0.27479
    states[71] = 0.21715
    constants[170] = 1E-3
    constants[171] = 0.5263
    states[72] = 7.3876E-3
    constants[172] = 3.9796
    constants[173] = 97.35
    constants[174] = 522.25
    constants[175] = 329.81
    constants[176] = (constants[80]*1.96000)/0.790000
    constants[177] = (constants[80]*1.33000)/0.790000
    constants[178] = (constants[75]*constants[76])/constants[0]
    constants[179] = (1.00000/7.00000)*(exp(constants[83]/67.3000)-1.00000)
    constants[180] = (constants[79]*constants[80])/constants[78]
    constants[181] = (constants[79]*constants[81])/constants[78]
    constants[182] = (constants[79]*constants[176])/constants[78]
    constants[183] = (constants[79]*constants[177])/constants[78]
    constants[184] = constants[102]*constants[180]
    constants[185] = constants[104]*constants[181]
    constants[186] = constants[98]*constants[182]
    constants[187] = constants[100]*constants[183]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    rates[8] = constants[68]*states[6]*(constants[67]-states[8])-constants[69]*states[8]
    rates[27] = constants[13]*constants[14]*((states[6]+(1.00000-constants[15])*constants[16])/(states[6]+constants[16]))-constants[17]*states[27]
    rates[28] = constants[13]*constants[14]*((states[14]+(1.00000-constants[15])*constants[16])/(states[14]+constants[16]))-constants[17]*states[28]
    rates[29] = -constants[19]*(states[6]*states[29]-constants[20]*states[31])-constants[21]*(states[6]*states[29]-constants[22]*states[33])
    rates[30] = -constants[19]*(states[14]*states[30]-constants[20]*states[32])-constants[21]*(states[14]*states[30]-constants[22]*states[34])
    rates[12] = ((-constants[142]*(power(states[6], 2.00000))*states[12]+constants[143]*states[9])-constants[144]*(power(states[6], 2.00000))*states[12])+constants[145]*states[7]
    rates[68] = ((constants[77]/(2.00000*constants[1]))*(constants[112]-constants[115]*states[68])-constants[106]*states[68]*states[69])-constants[107]*states[68]
    rates[67] = ((constants[77]/(2.00000*constants[1]))*(constants[114]-constants[117]*states[67])+constants[108]*constants[110]*states[69])-constants[109]*states[67]*constants[111]
    rates[66] = constants[123]*states[71]-(constants[124]*(power(states[66], 2.00000)))/(constants[125]+states[66])
    rates[72] = ((-constants[142]*(power(states[14], 2.00000))*states[72]+constants[143]*states[16])-constants[144]*(power(states[14], 2.00000))*states[72])+constants[145]*states[15]
    rates[13] = constants[68]*states[14]*(constants[67]-states[13])-constants[69]*states[13]
    algebraic[0] = (1.00000+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))/(1.00000+1.00000/constants[10]+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))
    rates[25] = (constants[11]*(algebraic[0]-states[25]))/algebraic[0]
    algebraic[1] = (1.00000+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))/(1.00000+1.00000/constants[10]+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))
    rates[26] = (constants[11]*(algebraic[1]-states[26]))/algebraic[1]
    algebraic[8] = 1.00000/(1.00000+exp(-(states[23]+0.0239000)/0.00480000))
    rates[55] = (algebraic[8]-states[55])/constants[63]
    algebraic[9] = 1.00000/(1.00000+exp(-(states[24]+0.0239000)/0.00480000))
    rates[56] = (algebraic[9]-states[56])/constants[63]
    algebraic[10] = 1.00000/(1.00000+exp((states[23]+0.0661000)/0.00650000))
    rates[57] = (algebraic[10]-states[57])/constants[64]
    algebraic[11] = 1.00000/(1.00000+exp((states[24]+0.0661000)/0.00650000))
    rates[58] = (algebraic[11]-states[58])/constants[64]
    algebraic[17] = (-constants[0]*states[23])/(constants[75]*constants[76])
    rates[69] = ((constants[113]-(constants[77]/(2.00000*constants[1]))*constants[116]*states[69]*(algebraic[17]/(1.00000-exp(-algebraic[17]))))-constants[106]*states[68]*states[69])-constants[108]*constants[110]*states[69]
    algebraic[19] = constants[96]*exp(constants[94]+constants[95]*states[23])
    rootfind_0(voi, constants, rates, states, algebraic)
    rates[35] = ((-constants[33]*states[6]*(states[35]-algebraic[2])+constants[34]*(states[36]-states[35]))-constants[35]*states[35])+algebraic[19]*states[38]
    rates[36] = ((-constants[33]*states[6]*(states[36]-states[35])+constants[34]*(states[37]-states[36]))-constants[36]*states[36])+algebraic[19]*states[39]
    rates[37] = ((constants[33]*states[6]*states[36]-constants[34]*states[37])-constants[37]*states[37])+algebraic[19]*states[40]
    rates[38] = constants[35]*states[35]-algebraic[19]*states[38]
    rates[39] = constants[36]*states[36]-algebraic[19]*states[39]
    rates[40] = constants[37]*states[37]-algebraic[19]*states[40]
    algebraic[20] = constants[96]*exp(constants[94]+constants[95]*states[24])
    rootfind_1(voi, constants, rates, states, algebraic)
    rates[41] = ((-constants[33]*states[14]*(states[41]-algebraic[3])+constants[34]*(states[42]-states[41]))-constants[35]*states[41])+algebraic[20]*states[44]
    rates[42] = ((-constants[33]*states[14]*(states[42]-states[41])+constants[34]*(states[43]-states[42]))-constants[36]*states[42])+algebraic[20]*states[45]
    rates[43] = ((constants[33]*states[14]*states[42]-constants[34]*states[43])-constants[37]*states[43])+algebraic[20]*states[46]
    rates[44] = constants[35]*states[41]-algebraic[20]*states[44]
    rates[45] = constants[36]*states[42]-algebraic[20]*states[45]
    rates[46] = constants[37]*states[43]-algebraic[20]*states[46]
    algebraic[4] = 1.00000/(1.00000+exp(-(states[23]+0.00177000)/0.0145200))
    algebraic[21] = 0.210987*exp(-(power((states[23]+0.214340)/0.195350, 2.00000)))-0.0205900
    rates[47] = (algebraic[4]-states[47])/algebraic[21]
    algebraic[5] = 1.00000/(1.00000+exp(-(states[24]+0.00177000)/0.0145200))
    algebraic[22] = 0.210987*exp(-(power((states[24]+0.214340)/0.195350, 2.00000)))-0.0205900
    rates[48] = (algebraic[5]-states[48])/algebraic[22]
    algebraic[23] = 0.821390*exp(-(power((states[23]+0.0315900)/0.0274600, 2.00000)))+0.000190000
    rates[49] = (algebraic[4]-states[49])/algebraic[23]
    algebraic[24] = 0.821390*exp(-(power((states[24]+0.0315900)/0.0274600, 2.00000)))+0.000190000
    rates[50] = (algebraic[5]-states[50])/algebraic[24]
    algebraic[6] = (((constants[133]*log(states[6]/1.00000, 10)-constants[134])-constants[132]*(states[68]/(constants[131]+states[68])))-constants[130]*((power(states[66], 2.00000))/(power(constants[129], 2.00000)+power(states[66], 2.00000))))*constants[170]
    algebraic[25] = 1.00000/(1.00000+exp(-(states[23]-algebraic[6])/0.0308000))
    rates[51] = (algebraic[25]-states[51])/constants[49]
    algebraic[7] = (((constants[133]*log(states[14]/1.00000, 10)-constants[134])-constants[132]*(states[68]/(constants[131]+states[68])))-constants[130]*((power(states[66], 2.00000))/(power(constants[129], 2.00000)+power(states[66], 2.00000))))*constants[170]
    algebraic[26] = 1.00000/(1.00000+exp(-(states[24]-algebraic[7])/0.0308000))
    rates[52] = (algebraic[26]-states[52])/constants[49]
    rates[53] = (algebraic[25]-states[53])/constants[50]
    rates[54] = (algebraic[26]-states[54])/constants[50]
    algebraic[12] = 1.00000/(1.00000+exp(-(states[23]+0.00188000)/0.00757000))
    algebraic[27] = 0.00289000*exp(-(power((states[23]+0.00863000)/0.0123900, 2.00000)))+0.00243000
    rates[59] = (algebraic[12]-states[59])/algebraic[27]
    algebraic[13] = 1.00000/(1.00000+exp(-(states[24]+0.00188000)/0.00757000))
    algebraic[28] = 0.0289000*exp(-(power((states[24]+0.00863000)/0.0123900, 2.00000)))+0.00243000
    rates[60] = (algebraic[13]-states[60])/algebraic[28]
    algebraic[14] = 1.00000/(1.00000+exp((states[23]+0.0293200)/0.00154000))
    algebraic[29] = 0.295590*exp(-(power((states[23]-0.00472000)/0.112550, 2.00000)))+0.0231900
    rates[61] = (algebraic[14]-states[61])/algebraic[29]
    algebraic[15] = 1.00000/(1.00000+exp((states[24]+0.0293200)/0.00154000))
    algebraic[30] = 0.295590*exp(-(power((states[24]-0.00472000)/0.112550, 2.00000)))+0.0231900
    rates[62] = (algebraic[15]-states[62])/algebraic[30]
    algebraic[18] = 1.00000-(states[70]+states[71])
    algebraic[32] = constants[122]*states[66]
    rates[70] = -constants[118]*states[70]*states[68]+constants[119]*algebraic[18]+algebraic[32]*states[71]
    rates[71] = (constants[121]*algebraic[18]*states[68]+constants[120]*algebraic[18])-algebraic[32]*states[71]
    algebraic[31] = constants[156]*states[11]
    algebraic[35] = 1.00000+constants[141]*((power(states[67], 2.00000))/(power(constants[140], 2.00000)+power(states[67], 2.00000)))
    algebraic[38] = (constants[157]*(1.00000+3.65000*((power(states[66], 2.00000))/(power(constants[169], 2.00000)+power(states[66], 2.00000)))))/algebraic[35]
    rates[63] = -algebraic[31]*states[63]+algebraic[38]*states[64]+constants[160]*states[65]
    algebraic[16] = constants[163]-(states[63]+states[64]+states[65])
    rates[64] = ((algebraic[31]*states[63]-algebraic[38]*states[64])-constants[158]*states[64])+constants[159]*algebraic[16]
    algebraic[40] = algebraic[38]
    rates[65] = (-constants[160]*states[65]+algebraic[40]*algebraic[16])-algebraic[31]*states[65]
    algebraic[62] = (states[27]/constants[18])*states[33]
    algebraic[60] = (states[27]/constants[90])*states[31]
    algebraic[58] = (states[27]/constants[18])*states[29]
    rootfind_2(voi, constants, rates, states, algebraic)
    rates[31] = constants[19]*(states[6]*states[29]-constants[20]*states[31])-constants[21]*(states[6]*states[31]-constants[22]*algebraic[64])
    rates[33] = constants[21]*(states[6]*states[29]-constants[22]*states[33])-constants[19]*(states[6]*states[33]-constants[20]*algebraic[64])
    algebraic[66] = (states[28]/constants[18])*states[34]
    algebraic[61] = (states[28]/constants[90])*states[32]
    algebraic[59] = (states[28]/constants[18])*states[30]
    rootfind_3(voi, constants, rates, states, algebraic)
    rates[32] = constants[19]*(states[14]*states[30]-constants[20]*states[32])-constants[21]*(states[14]*states[32]-constants[22]*algebraic[68])
    rates[34] = constants[21]*(states[14]*states[30]-constants[22]*states[34])-constants[19]*(states[14]*states[34]-constants[20]*algebraic[68])
    rates[21] = constants[71]*states[19]*(constants[70]-states[21])-constants[72]*states[21]
    rates[22] = constants[71]*states[20]*(constants[70]-states[22])-constants[72]*states[22]
    algebraic[34] = (constants[178]/constants[86])*log(constants[82]/states[0])
    algebraic[46] = (constants[178]/constants[88])*log(constants[84]/states[4])
    algebraic[77] = constants[27]*constants[73]*((algebraic[34]-algebraic[46])/((algebraic[34]-algebraic[46])+constants[25]))
    algebraic[79] = constants[28]*constants[73]*(((constants[83]*constants[82]*(power(constants[84], 2.00000))-states[2]*states[0]*(power(states[4], 2.00000)))*constants[29]*constants[30]*constants[31]*constants[32])/((constants[83]+constants[29])*(constants[82]+constants[30])*(constants[84]+constants[31])*(constants[84]+constants[32])*(states[2]+constants[29])*(states[0]+constants[30])*(states[4]+constants[31])*(states[4]+constants[32])))
    algebraic[42] = (constants[178]/constants[87])*log(constants[83]/states[2])
    algebraic[75] = constants[26]*constants[73]*((power(algebraic[42]-algebraic[46], 4.00000))/(power(algebraic[42]-algebraic[46], 4.00000)+power(constants[25], 4.00000)))
    algebraic[47] = constants[42]*constants[73]*(states[23]-algebraic[46])
    algebraic[81] = constants[38]*constants[73]*(states[38]+states[39]+states[40])*(states[23]-algebraic[46])
    algebraic[120] = ((constants[103]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[121] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[185]*(states[5]-states[4]) , True, constants[185]*algebraic[120]*((states[5]-states[4]*exp(-algebraic[120]))/(1.00000-exp(-algebraic[120])))])
    rates[4] = (algebraic[47]+algebraic[81]+(constants[0]*algebraic[75]+constants[0]*(algebraic[77]+2.00000*algebraic[79]+algebraic[121])))/(constants[0]*constants[1])
    algebraic[39] = (constants[178]/constants[86])*log(constants[82]/states[1])
    algebraic[48] = (constants[178]/constants[88])*log(constants[84]/states[5])
    algebraic[78] = constants[27]*constants[74]*((algebraic[39]-algebraic[48])/((algebraic[39]-algebraic[48])+constants[25]))
    algebraic[80] = constants[28]*constants[74]*(((constants[83]*constants[82]*(power(constants[84], 2.00000))-states[3]*states[1]*(power(states[5], 2.00000)))*constants[29]*constants[30]*constants[31]*constants[32])/((constants[83]+constants[29])*(constants[82]+constants[30])*(constants[84]+constants[31])*(constants[84]+constants[32])*(states[3]+constants[29])*(states[1]+constants[30])*(states[5]+constants[31])*(states[5]+constants[32])))
    algebraic[44] = (constants[178]/constants[87])*log(constants[83]/states[3])
    algebraic[76] = constants[26]*constants[74]*((power(algebraic[44]-algebraic[48], 4.00000))/(power(algebraic[44]-algebraic[48], 4.00000)+power(constants[25], 4.00000)))
    algebraic[49] = constants[42]*constants[74]*(states[24]-algebraic[48])
    algebraic[82] = constants[38]*constants[74]*(states[44]+states[45]+states[46])*(states[24]-algebraic[48])
    rates[5] = (algebraic[49]+algebraic[82]+(constants[0]*algebraic[76]+constants[0]*((algebraic[78]+2.00000*algebraic[80])-algebraic[121])))/(constants[0]*constants[2])
    algebraic[122] = constants[161]-(states[12]+states[7]+states[9]+states[10]+states[11])
    rates[7] = ((constants[144]*(power(states[6], 2.00000))*states[12]-constants[145]*states[7])-constants[146]*(power(states[6], 2.00000))*states[7])+constants[147]*algebraic[122]
    algebraic[123] = constants[162]-(states[10]+states[11])
    rates[9] = ((((constants[142]*(power(states[6], 2.00000))*states[12]-constants[143]*states[9])-constants[148]*(power(states[6], 2.00000))*states[9])+constants[149]*algebraic[122])-constants[150]*algebraic[123]*states[9])+constants[151]*states[10]
    rates[11] = ((constants[152]*(power(states[6], 2.00000))*states[10]-constants[153]*states[11])+constants[154]*algebraic[123]*algebraic[122])-constants[155]*states[11]
    rates[10] = ((constants[150]*algebraic[123]*states[9]-constants[151]*states[10])-constants[152]*(power(states[6], 2.00000))*states[10])+constants[153]*states[11]
    algebraic[128] = (power(states[69], 1.0/2))/(power(constants[136], 1.0/2)+power(states[69], 1.0/2))
    algebraic[129] = states[67]/(constants[137]+states[67])
    algebraic[130] = constants[166]*(1.00000-algebraic[128])*(1.00000-algebraic[129])
    algebraic[124] = (constants[164]/constants[171])*(1.00000-states[66]/(2.00000*(constants[127]+states[66])))
    algebraic[131] = algebraic[130]*constants[73]*((power(states[6]/algebraic[124], constants[6])-power(states[19]/constants[5], constants[6]))/(1.00000+(power(states[6]/algebraic[124], constants[6])+power(states[19]/constants[5], constants[6]))))
    algebraic[63] = constants[12]*(power(algebraic[62], 3.00000))*(states[19]-states[6])*2.00000*constants[0]*constants[3]
    algebraic[67] = constants[12]*(power(algebraic[66], 3.00000))*(states[19]-states[14])*2.00000*constants[0]*constants[3]
    algebraic[132] = algebraic[130]*constants[74]*((power(states[14]/algebraic[124], constants[6])-power(states[19]/constants[5], constants[6]))/(1.00000+(power(states[14]/algebraic[124], constants[6])+power(states[19]/constants[5], constants[6]))))
    rates[19] = (((algebraic[131]-algebraic[63])+algebraic[132])-algebraic[67])/(constants[0]*constants[3])-rates[21]
    algebraic[50] = (constants[178]/constants[89])*log(constants[85]/states[6])
    algebraic[51] = constants[41]*constants[73]*(states[23]-algebraic[50])
    algebraic[125] = constants[165]*(1.00000+(3.60000*states[66])/(constants[128]+states[66]))
    algebraic[126] = algebraic[125]*constants[73]*(states[6]/(constants[65]+states[6]))
    algebraic[70] = (states[19]+states[20])/2.00000
    algebraic[71] = constants[23]*(constants[24]/(constants[24]+algebraic[70]))*(states[23]-algebraic[50])
    algebraic[110] = 0.740000*states[61]+0.260000
    algebraic[111] = constants[66]*constants[73]*states[59]*algebraic[110]*(states[23]-algebraic[50])
    algebraic[54] = (states[25]*(1.00000+power(states[6]/constants[9], 3.00000)))/(1.00000+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))
    algebraic[55] = constants[7]*algebraic[54]*(states[20]-states[6])*(2.00000*constants[0]*constants[3])
    algebraic[118] = ((constants[101]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[119] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[184]*(states[14]-states[6]) , True, constants[184]*algebraic[118]*((states[14]-states[6]*exp(-algebraic[118]))/(1.00000-exp(-algebraic[118])))])
    algebraic[133] = algebraic[130]*constants[73]*((power(states[6]/algebraic[124], constants[6])-power(states[20]/constants[5], constants[6]))/(1.00000+(power(states[6]/algebraic[124], constants[6])+power(states[20]/constants[5], constants[6]))))
    rates[6] = ((-(((algebraic[51]+algebraic[126]+algebraic[71]+algebraic[111]+algebraic[131]+algebraic[133])-algebraic[55])-algebraic[63])+2.00000*constants[0]*algebraic[119])/(2.00000*constants[0]*constants[4])-2.00000*(rates[7]+rates[9]+rates[10]))-rates[8]
    algebraic[134] = algebraic[130]*constants[74]*((power(states[14]/algebraic[124], constants[6])-power(states[20]/constants[5], constants[6]))/(1.00000+(power(states[14]/algebraic[124], constants[6])+power(states[20]/constants[5], constants[6]))))
    algebraic[56] = (states[26]*(1.00000+power(states[14]/constants[9], 3.00000)))/(1.00000+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))
    algebraic[57] = constants[7]*algebraic[56]*(states[20]-states[14])*(2.00000*constants[0]*constants[3])
    rates[20] = (((algebraic[133]-algebraic[55])+algebraic[134])-algebraic[57])/(constants[0]*constants[3])-rates[22]
    algebraic[136] = constants[161]-(states[72]+states[15]+states[16]+states[17]+states[18])
    rates[15] = ((constants[144]*(power(states[14], 2.00000))*states[72]-constants[145]*states[15])-constants[146]*(power(states[14], 2.00000))*states[15])+constants[147]*algebraic[136]
    algebraic[139] = constants[162]-(states[17]+states[18])
    rates[16] = ((((constants[142]*(power(states[14], 2.00000))*states[72]-constants[143]*states[16])-constants[148]*(power(states[14], 2.00000))*states[16])+constants[149]*algebraic[136])-constants[150]*algebraic[139]*states[16])+constants[151]*states[17]
    rates[18] = ((constants[152]*(power(states[14], 2.00000))*states[17]-constants[153]*states[18])+constants[154]*algebraic[139]*algebraic[136])-constants[155]*states[18]
    algebraic[37] = constants[39]*constants[73]*(states[23]-algebraic[34])
    algebraic[83] = 3.24100/(1.00000+exp(((states[23]-algebraic[34])-185.720)/1.59600))
    algebraic[85] = 1.00000*((0.0130000*exp(((states[23]-algebraic[34])+5.79220)/0.294000)+exp(((states[23]-algebraic[34])-653.733)/0.244000))/(1.00000+exp(-((states[23]-algebraic[34])-7.77750)/0.0928000)))
    algebraic[86] = algebraic[83]/(algebraic[83]+algebraic[85])
    algebraic[87] = constants[43]*constants[73]*algebraic[86]*(power(constants[82]/constants[44], 1.0/2))*(states[23]-algebraic[34])
    algebraic[95] = constants[47]*constants[73]*(power(constants[82]/constants[44], constants[46]))*(states[23]-algebraic[34])
    algebraic[91] = 0.580000*states[47]+0.420000*states[49]
    algebraic[92] = constants[45]*constants[73]*(power(algebraic[91], 2.00000))*(states[23]-algebraic[34])
    algebraic[97] = 0.650000*states[51]+0.350000*states[53]
    algebraic[98] = constants[48]*constants[73]*algebraic[97]*(states[23]-algebraic[34])
    algebraic[138] = constants[167]*(1.00000-states[69]/(constants[138]+states[69]))*(1.00000-states[67]/(constants[139]+states[67]))
    algebraic[101] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[23]*constants[0])/(constants[75]*constants[76]))+0.0365000*constants[179]*exp((-states[23]*constants[0])/(constants[75]*constants[76])))
    algebraic[140] = algebraic[138]*algebraic[101]*(constants[82]/(constants[82]+constants[51]))*((power(states[2], 1.50000))/(power(states[2], 1.50000)+power(constants[52], 1.50000)))
    algebraic[114] = ((constants[97]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[115] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[186]*(states[1]-states[0]) , True, constants[186]*algebraic[114]*((states[1]-states[0]*exp(-algebraic[114]))/(1.00000-exp(-algebraic[114])))])
    rates[0] = (-((algebraic[37]+algebraic[87]+algebraic[95]+algebraic[92]+algebraic[98])-2.00000*algebraic[140])+constants[0]*(algebraic[77]+algebraic[79]+algebraic[115]))/(constants[0]*constants[1])
    algebraic[41] = constants[39]*constants[74]*(states[24]-algebraic[39])
    algebraic[84] = 3.24100/(1.00000+exp(((states[24]-algebraic[39])-185.720)/1.59600))
    algebraic[88] = 1.00000*((0.0130000*exp(((states[24]-algebraic[39])+5.79220)/0.294000)+exp(((states[24]-algebraic[39])-653.733)/0.244000))/(1.00000+exp(-(((states[24]-algebraic[39])-7.77750)/0.0928000))))
    algebraic[89] = algebraic[84]/(algebraic[84]+algebraic[88])
    algebraic[90] = constants[43]*constants[74]*algebraic[89]*(power(constants[82]/constants[44], 1.0/2))*(states[24]-algebraic[39])
    algebraic[96] = constants[47]*constants[74]*(power(constants[82]/constants[44], constants[46]))*(states[24]-algebraic[39])
    algebraic[93] = 0.580000*states[48]+0.420000*states[50]
    algebraic[94] = constants[45]*constants[74]*(power(algebraic[93], 2.00000))*(states[24]-algebraic[39])
    algebraic[99] = 0.650000*states[52]+0.350000*states[54]
    algebraic[100] = constants[48]*constants[74]*algebraic[99]*(states[24]-algebraic[39])
    algebraic[102] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[24]*constants[0])/(constants[75]*constants[76]))+0.0365000*constants[179]*exp((-states[24]*constants[0])/(constants[75]*constants[76])))
    algebraic[141] = algebraic[138]*algebraic[102]*(constants[82]/(constants[82]+constants[51]))*((power(states[3], 1.50000))/(power(states[3], 1.50000)+power(constants[53], 1.50000)))
    rates[1] = (-((algebraic[41]+algebraic[90]+algebraic[96]+algebraic[94]+algebraic[100])-2.00000*algebraic[141])+constants[0]*((algebraic[78]+algebraic[80])-algebraic[115]))/(constants[0]*constants[2])
    algebraic[43] = constants[40]*constants[73]*(states[23]-algebraic[42])
    algebraic[108] = constants[62]*constants[73]*states[55]*states[57]*(states[23]-algebraic[42])
    algebraic[73] = algebraic[71]*(((power(constants[91], 2.00000))/(power(constants[92], 2.00000)))*constants[93])*((states[2]-constants[83]*exp((-constants[91]*constants[0]*states[23])/(constants[75]*constants[76])))/(states[6]-constants[85]*exp((-constants[92]*constants[0]*states[23])/(constants[75]*constants[76]))))*((1.00000-exp((-constants[92]*constants[0]*states[23])/(constants[75]*constants[76])))/(1.00000-exp((-constants[91]*constants[0]*states[23])/(constants[75]*constants[76]))))
    algebraic[116] = ((constants[99]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[117] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[187]*(states[3]-states[2]) , True, constants[187]*algebraic[116]*((states[3]-states[2]*exp(-algebraic[116]))/(1.00000-exp(-algebraic[116])))])
    rates[2] = (-(algebraic[43]+3.00000*algebraic[140]+algebraic[108]+algebraic[73])+constants[0]*(algebraic[75]+algebraic[79]+algebraic[117]))/(constants[0]*constants[1])
    algebraic[45] = constants[40]*constants[74]*(states[24]-algebraic[44])
    algebraic[109] = constants[62]*constants[74]*states[56]*states[58]*(states[24]-algebraic[44])
    algebraic[52] = (constants[178]/constants[89])*log(constants[85]/states[14])
    algebraic[72] = constants[23]*(constants[24]/(constants[24]+algebraic[70]))*(states[24]-algebraic[52])
    algebraic[74] = algebraic[72]*(((power(constants[91], 2.00000))/(power(constants[92], 2.00000)))*constants[93])*((states[3]-constants[83]*exp((-constants[91]*constants[0]*states[24])/(constants[75]*constants[76])))/(states[14]-constants[85]*exp((-constants[92]*constants[0]*states[24])/(constants[75]*constants[76]))))*((1.00000-exp((-constants[92]*constants[0]*states[24])/(constants[75]*constants[76])))/(1.00000-exp((-constants[91]*constants[0]*states[24])/(constants[75]*constants[76]))))
    algebraic[103] = 1.00000/(1.00000+power(constants[61]/states[14], 2.00000))
    algebraic[104] = exp((constants[60]*states[24]*constants[0])/(constants[75]*constants[76]))
    algebraic[105] = exp(((constants[60]-1.00000)*states[24]*constants[0])/(constants[75]*constants[76]))
    algebraic[106] = (power(constants[83], 3.00000))*states[14]+(power(states[3], 3.00000))*constants[85]+(power(constants[58], 3.00000))*states[14]+constants[56]*(power(states[3], 3.00000))+(power(constants[57], 3.00000))*constants[85]*(1.00000+states[14]/constants[55])+constants[55]*(power(constants[83], 3.00000))*(1.00000+power(states[3]/constants[57], 3.00000))
    algebraic[107] = constants[54]*algebraic[103]*((algebraic[104]*(power(states[3], 3.00000))*constants[85]-algebraic[105]*(power(constants[83], 3.00000))*states[14])/(algebraic[106]*(1.00000+constants[59]*algebraic[105])))
    rates[3] = (-(algebraic[45]+3.00000*algebraic[141]+algebraic[109]+algebraic[74]+3.00000*algebraic[107])+constants[0]*((algebraic[76]+algebraic[80])-algebraic[117]))/(constants[0]*constants[2])
    rates[17] = ((constants[150]*algebraic[139]*states[16]-constants[151]*states[17])-constants[152]*(power(states[14], 2.00000))*states[17])+constants[153]*states[18]
    algebraic[53] = constants[41]*constants[74]*(states[24]-algebraic[52])
    algebraic[127] = algebraic[125]*constants[74]*(states[14]/(constants[65]+states[14]))
    algebraic[112] = 0.740000*states[62]+0.260000
    algebraic[113] = constants[66]*constants[74]*states[60]*algebraic[112]*(states[24]-algebraic[52])
    rates[14] = ((-(((((algebraic[53]+algebraic[127]+algebraic[72]+algebraic[113])-2.00000*algebraic[107])+algebraic[134]+algebraic[132])-algebraic[57])-algebraic[67])-2.00000*constants[0]*algebraic[119])/(2.00000*constants[0]*constants[2])-2.00000*(rates[15]+rates[16]+rates[17]))-rates[13]
    algebraic[135] = algebraic[131]+algebraic[133]
    algebraic[143] = ((((((((algebraic[37]+algebraic[87]+algebraic[95]+algebraic[92]+algebraic[98])-constants[0]*algebraic[115])+algebraic[140]+algebraic[43]+algebraic[108]+algebraic[73])-constants[0]*algebraic[117])+algebraic[47]+algebraic[81]+constants[0]*algebraic[121]+algebraic[51]+algebraic[126]+algebraic[111]+algebraic[71])-2.00000*constants[0]*algebraic[119])+algebraic[135])-algebraic[55])-algebraic[63]
    rates[23] = -algebraic[143]/(constants[73]*constants[105])
    algebraic[137] = algebraic[132]+algebraic[134]
    algebraic[144] = ((((algebraic[41]+algebraic[90]+algebraic[96]+algebraic[94]+algebraic[100]+constants[0]*algebraic[115]+algebraic[141]+algebraic[45]+algebraic[109]+algebraic[74]+algebraic[107]+constants[0]*algebraic[117]+algebraic[49]+algebraic[82])-constants[0]*algebraic[121])+algebraic[53]+algebraic[127]+algebraic[113]+algebraic[72]+2.00000*constants[0]*algebraic[119]+algebraic[137])-algebraic[57])-algebraic[67]
    rates[24] = -algebraic[144]/(constants[74]*constants[105])
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[0] = (1.00000+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))/(1.00000+1.00000/constants[10]+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))
    algebraic[1] = (1.00000+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))/(1.00000+1.00000/constants[10]+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))
    algebraic[8] = 1.00000/(1.00000+exp(-(states[23]+0.0239000)/0.00480000))
    algebraic[9] = 1.00000/(1.00000+exp(-(states[24]+0.0239000)/0.00480000))
    algebraic[10] = 1.00000/(1.00000+exp((states[23]+0.0661000)/0.00650000))
    algebraic[11] = 1.00000/(1.00000+exp((states[24]+0.0661000)/0.00650000))
    algebraic[17] = (-constants[0]*states[23])/(constants[75]*constants[76])
    algebraic[19] = constants[96]*exp(constants[94]+constants[95]*states[23])
    algebraic[20] = constants[96]*exp(constants[94]+constants[95]*states[24])
    algebraic[4] = 1.00000/(1.00000+exp(-(states[23]+0.00177000)/0.0145200))
    algebraic[21] = 0.210987*exp(-(power((states[23]+0.214340)/0.195350, 2.00000)))-0.0205900
    algebraic[5] = 1.00000/(1.00000+exp(-(states[24]+0.00177000)/0.0145200))
    algebraic[22] = 0.210987*exp(-(power((states[24]+0.214340)/0.195350, 2.00000)))-0.0205900
    algebraic[23] = 0.821390*exp(-(power((states[23]+0.0315900)/0.0274600, 2.00000)))+0.000190000
    algebraic[24] = 0.821390*exp(-(power((states[24]+0.0315900)/0.0274600, 2.00000)))+0.000190000
    algebraic[6] = (((constants[133]*log(states[6]/1.00000, 10)-constants[134])-constants[132]*(states[68]/(constants[131]+states[68])))-constants[130]*((power(states[66], 2.00000))/(power(constants[129], 2.00000)+power(states[66], 2.00000))))*constants[170]
    algebraic[25] = 1.00000/(1.00000+exp(-(states[23]-algebraic[6])/0.0308000))
    algebraic[7] = (((constants[133]*log(states[14]/1.00000, 10)-constants[134])-constants[132]*(states[68]/(constants[131]+states[68])))-constants[130]*((power(states[66], 2.00000))/(power(constants[129], 2.00000)+power(states[66], 2.00000))))*constants[170]
    algebraic[26] = 1.00000/(1.00000+exp(-(states[24]-algebraic[7])/0.0308000))
    algebraic[12] = 1.00000/(1.00000+exp(-(states[23]+0.00188000)/0.00757000))
    algebraic[27] = 0.00289000*exp(-(power((states[23]+0.00863000)/0.0123900, 2.00000)))+0.00243000
    algebraic[13] = 1.00000/(1.00000+exp(-(states[24]+0.00188000)/0.00757000))
    algebraic[28] = 0.0289000*exp(-(power((states[24]+0.00863000)/0.0123900, 2.00000)))+0.00243000
    algebraic[14] = 1.00000/(1.00000+exp((states[23]+0.0293200)/0.00154000))
    algebraic[29] = 0.295590*exp(-(power((states[23]-0.00472000)/0.112550, 2.00000)))+0.0231900
    algebraic[15] = 1.00000/(1.00000+exp((states[24]+0.0293200)/0.00154000))
    algebraic[30] = 0.295590*exp(-(power((states[24]-0.00472000)/0.112550, 2.00000)))+0.0231900
    algebraic[18] = 1.00000-(states[70]+states[71])
    algebraic[32] = constants[122]*states[66]
    algebraic[31] = constants[156]*states[11]
    algebraic[35] = 1.00000+constants[141]*((power(states[67], 2.00000))/(power(constants[140], 2.00000)+power(states[67], 2.00000)))
    algebraic[38] = (constants[157]*(1.00000+3.65000*((power(states[66], 2.00000))/(power(constants[169], 2.00000)+power(states[66], 2.00000)))))/algebraic[35]
    algebraic[16] = constants[163]-(states[63]+states[64]+states[65])
    algebraic[40] = algebraic[38]
    algebraic[62] = (states[27]/constants[18])*states[33]
    algebraic[60] = (states[27]/constants[90])*states[31]
    algebraic[58] = (states[27]/constants[18])*states[29]
    algebraic[66] = (states[28]/constants[18])*states[34]
    algebraic[61] = (states[28]/constants[90])*states[32]
    algebraic[59] = (states[28]/constants[18])*states[30]
    algebraic[34] = (constants[178]/constants[86])*log(constants[82]/states[0])
    algebraic[46] = (constants[178]/constants[88])*log(constants[84]/states[4])
    algebraic[77] = constants[27]*constants[73]*((algebraic[34]-algebraic[46])/((algebraic[34]-algebraic[46])+constants[25]))
    algebraic[79] = constants[28]*constants[73]*(((constants[83]*constants[82]*(power(constants[84], 2.00000))-states[2]*states[0]*(power(states[4], 2.00000)))*constants[29]*constants[30]*constants[31]*constants[32])/((constants[83]+constants[29])*(constants[82]+constants[30])*(constants[84]+constants[31])*(constants[84]+constants[32])*(states[2]+constants[29])*(states[0]+constants[30])*(states[4]+constants[31])*(states[4]+constants[32])))
    algebraic[42] = (constants[178]/constants[87])*log(constants[83]/states[2])
    algebraic[75] = constants[26]*constants[73]*((power(algebraic[42]-algebraic[46], 4.00000))/(power(algebraic[42]-algebraic[46], 4.00000)+power(constants[25], 4.00000)))
    algebraic[47] = constants[42]*constants[73]*(states[23]-algebraic[46])
    algebraic[81] = constants[38]*constants[73]*(states[38]+states[39]+states[40])*(states[23]-algebraic[46])
    algebraic[120] = ((constants[103]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[121] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[185]*(states[5]-states[4]) , True, constants[185]*algebraic[120]*((states[5]-states[4]*exp(-algebraic[120]))/(1.00000-exp(-algebraic[120])))])
    algebraic[39] = (constants[178]/constants[86])*log(constants[82]/states[1])
    algebraic[48] = (constants[178]/constants[88])*log(constants[84]/states[5])
    algebraic[78] = constants[27]*constants[74]*((algebraic[39]-algebraic[48])/((algebraic[39]-algebraic[48])+constants[25]))
    algebraic[80] = constants[28]*constants[74]*(((constants[83]*constants[82]*(power(constants[84], 2.00000))-states[3]*states[1]*(power(states[5], 2.00000)))*constants[29]*constants[30]*constants[31]*constants[32])/((constants[83]+constants[29])*(constants[82]+constants[30])*(constants[84]+constants[31])*(constants[84]+constants[32])*(states[3]+constants[29])*(states[1]+constants[30])*(states[5]+constants[31])*(states[5]+constants[32])))
    algebraic[44] = (constants[178]/constants[87])*log(constants[83]/states[3])
    algebraic[76] = constants[26]*constants[74]*((power(algebraic[44]-algebraic[48], 4.00000))/(power(algebraic[44]-algebraic[48], 4.00000)+power(constants[25], 4.00000)))
    algebraic[49] = constants[42]*constants[74]*(states[24]-algebraic[48])
    algebraic[82] = constants[38]*constants[74]*(states[44]+states[45]+states[46])*(states[24]-algebraic[48])
    algebraic[122] = constants[161]-(states[12]+states[7]+states[9]+states[10]+states[11])
    algebraic[123] = constants[162]-(states[10]+states[11])
    algebraic[128] = (power(states[69], 1.0/2))/(power(constants[136], 1.0/2)+power(states[69], 1.0/2))
    algebraic[129] = states[67]/(constants[137]+states[67])
    algebraic[130] = constants[166]*(1.00000-algebraic[128])*(1.00000-algebraic[129])
    algebraic[124] = (constants[164]/constants[171])*(1.00000-states[66]/(2.00000*(constants[127]+states[66])))
    algebraic[131] = algebraic[130]*constants[73]*((power(states[6]/algebraic[124], constants[6])-power(states[19]/constants[5], constants[6]))/(1.00000+(power(states[6]/algebraic[124], constants[6])+power(states[19]/constants[5], constants[6]))))
    algebraic[63] = constants[12]*(power(algebraic[62], 3.00000))*(states[19]-states[6])*2.00000*constants[0]*constants[3]
    algebraic[67] = constants[12]*(power(algebraic[66], 3.00000))*(states[19]-states[14])*2.00000*constants[0]*constants[3]
    algebraic[132] = algebraic[130]*constants[74]*((power(states[14]/algebraic[124], constants[6])-power(states[19]/constants[5], constants[6]))/(1.00000+(power(states[14]/algebraic[124], constants[6])+power(states[19]/constants[5], constants[6]))))
    algebraic[50] = (constants[178]/constants[89])*log(constants[85]/states[6])
    algebraic[51] = constants[41]*constants[73]*(states[23]-algebraic[50])
    algebraic[125] = constants[165]*(1.00000+(3.60000*states[66])/(constants[128]+states[66]))
    algebraic[126] = algebraic[125]*constants[73]*(states[6]/(constants[65]+states[6]))
    algebraic[70] = (states[19]+states[20])/2.00000
    algebraic[71] = constants[23]*(constants[24]/(constants[24]+algebraic[70]))*(states[23]-algebraic[50])
    algebraic[110] = 0.740000*states[61]+0.260000
    algebraic[111] = constants[66]*constants[73]*states[59]*algebraic[110]*(states[23]-algebraic[50])
    algebraic[54] = (states[25]*(1.00000+power(states[6]/constants[9], 3.00000)))/(1.00000+power(constants[8]/states[6], 4.00000)+power(states[6]/constants[9], 3.00000))
    algebraic[55] = constants[7]*algebraic[54]*(states[20]-states[6])*(2.00000*constants[0]*constants[3])
    algebraic[118] = ((constants[101]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[119] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[184]*(states[14]-states[6]) , True, constants[184]*algebraic[118]*((states[14]-states[6]*exp(-algebraic[118]))/(1.00000-exp(-algebraic[118])))])
    algebraic[133] = algebraic[130]*constants[73]*((power(states[6]/algebraic[124], constants[6])-power(states[20]/constants[5], constants[6]))/(1.00000+(power(states[6]/algebraic[124], constants[6])+power(states[20]/constants[5], constants[6]))))
    algebraic[134] = algebraic[130]*constants[74]*((power(states[14]/algebraic[124], constants[6])-power(states[20]/constants[5], constants[6]))/(1.00000+(power(states[14]/algebraic[124], constants[6])+power(states[20]/constants[5], constants[6]))))
    algebraic[56] = (states[26]*(1.00000+power(states[14]/constants[9], 3.00000)))/(1.00000+power(constants[8]/states[14], 4.00000)+power(states[14]/constants[9], 3.00000))
    algebraic[57] = constants[7]*algebraic[56]*(states[20]-states[14])*(2.00000*constants[0]*constants[3])
    algebraic[136] = constants[161]-(states[72]+states[15]+states[16]+states[17]+states[18])
    algebraic[139] = constants[162]-(states[17]+states[18])
    algebraic[37] = constants[39]*constants[73]*(states[23]-algebraic[34])
    algebraic[83] = 3.24100/(1.00000+exp(((states[23]-algebraic[34])-185.720)/1.59600))
    algebraic[85] = 1.00000*((0.0130000*exp(((states[23]-algebraic[34])+5.79220)/0.294000)+exp(((states[23]-algebraic[34])-653.733)/0.244000))/(1.00000+exp(-((states[23]-algebraic[34])-7.77750)/0.0928000)))
    algebraic[86] = algebraic[83]/(algebraic[83]+algebraic[85])
    algebraic[87] = constants[43]*constants[73]*algebraic[86]*(power(constants[82]/constants[44], 1.0/2))*(states[23]-algebraic[34])
    algebraic[95] = constants[47]*constants[73]*(power(constants[82]/constants[44], constants[46]))*(states[23]-algebraic[34])
    algebraic[91] = 0.580000*states[47]+0.420000*states[49]
    algebraic[92] = constants[45]*constants[73]*(power(algebraic[91], 2.00000))*(states[23]-algebraic[34])
    algebraic[97] = 0.650000*states[51]+0.350000*states[53]
    algebraic[98] = constants[48]*constants[73]*algebraic[97]*(states[23]-algebraic[34])
    algebraic[138] = constants[167]*(1.00000-states[69]/(constants[138]+states[69]))*(1.00000-states[67]/(constants[139]+states[67]))
    algebraic[101] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[23]*constants[0])/(constants[75]*constants[76]))+0.0365000*constants[179]*exp((-states[23]*constants[0])/(constants[75]*constants[76])))
    algebraic[140] = algebraic[138]*algebraic[101]*(constants[82]/(constants[82]+constants[51]))*((power(states[2], 1.50000))/(power(states[2], 1.50000)+power(constants[52], 1.50000)))
    algebraic[114] = ((constants[97]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[115] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[186]*(states[1]-states[0]) , True, constants[186]*algebraic[114]*((states[1]-states[0]*exp(-algebraic[114]))/(1.00000-exp(-algebraic[114])))])
    algebraic[41] = constants[39]*constants[74]*(states[24]-algebraic[39])
    algebraic[84] = 3.24100/(1.00000+exp(((states[24]-algebraic[39])-185.720)/1.59600))
    algebraic[88] = 1.00000*((0.0130000*exp(((states[24]-algebraic[39])+5.79220)/0.294000)+exp(((states[24]-algebraic[39])-653.733)/0.244000))/(1.00000+exp(-(((states[24]-algebraic[39])-7.77750)/0.0928000))))
    algebraic[89] = algebraic[84]/(algebraic[84]+algebraic[88])
    algebraic[90] = constants[43]*constants[74]*algebraic[89]*(power(constants[82]/constants[44], 1.0/2))*(states[24]-algebraic[39])
    algebraic[96] = constants[47]*constants[74]*(power(constants[82]/constants[44], constants[46]))*(states[24]-algebraic[39])
    algebraic[93] = 0.580000*states[48]+0.420000*states[50]
    algebraic[94] = constants[45]*constants[74]*(power(algebraic[93], 2.00000))*(states[24]-algebraic[39])
    algebraic[99] = 0.650000*states[52]+0.350000*states[54]
    algebraic[100] = constants[48]*constants[74]*algebraic[99]*(states[24]-algebraic[39])
    algebraic[102] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[24]*constants[0])/(constants[75]*constants[76]))+0.0365000*constants[179]*exp((-states[24]*constants[0])/(constants[75]*constants[76])))
    algebraic[141] = algebraic[138]*algebraic[102]*(constants[82]/(constants[82]+constants[51]))*((power(states[3], 1.50000))/(power(states[3], 1.50000)+power(constants[53], 1.50000)))
    algebraic[43] = constants[40]*constants[73]*(states[23]-algebraic[42])
    algebraic[108] = constants[62]*constants[73]*states[55]*states[57]*(states[23]-algebraic[42])
    algebraic[73] = algebraic[71]*(((power(constants[91], 2.00000))/(power(constants[92], 2.00000)))*constants[93])*((states[2]-constants[83]*exp((-constants[91]*constants[0]*states[23])/(constants[75]*constants[76])))/(states[6]-constants[85]*exp((-constants[92]*constants[0]*states[23])/(constants[75]*constants[76]))))*((1.00000-exp((-constants[92]*constants[0]*states[23])/(constants[75]*constants[76])))/(1.00000-exp((-constants[91]*constants[0]*states[23])/(constants[75]*constants[76]))))
    algebraic[116] = ((constants[99]*constants[0])/(constants[75]*constants[76]))*(states[24]-states[23])
    algebraic[117] = custom_piecewise([equal(states[24]-states[23] , 0.00000), constants[187]*(states[3]-states[2]) , True, constants[187]*algebraic[116]*((states[3]-states[2]*exp(-algebraic[116]))/(1.00000-exp(-algebraic[116])))])
    algebraic[45] = constants[40]*constants[74]*(states[24]-algebraic[44])
    algebraic[109] = constants[62]*constants[74]*states[56]*states[58]*(states[24]-algebraic[44])
    algebraic[52] = (constants[178]/constants[89])*log(constants[85]/states[14])
    algebraic[72] = constants[23]*(constants[24]/(constants[24]+algebraic[70]))*(states[24]-algebraic[52])
    algebraic[74] = algebraic[72]*(((power(constants[91], 2.00000))/(power(constants[92], 2.00000)))*constants[93])*((states[3]-constants[83]*exp((-constants[91]*constants[0]*states[24])/(constants[75]*constants[76])))/(states[14]-constants[85]*exp((-constants[92]*constants[0]*states[24])/(constants[75]*constants[76]))))*((1.00000-exp((-constants[92]*constants[0]*states[24])/(constants[75]*constants[76])))/(1.00000-exp((-constants[91]*constants[0]*states[24])/(constants[75]*constants[76]))))
    algebraic[103] = 1.00000/(1.00000+power(constants[61]/states[14], 2.00000))
    algebraic[104] = exp((constants[60]*states[24]*constants[0])/(constants[75]*constants[76]))
    algebraic[105] = exp(((constants[60]-1.00000)*states[24]*constants[0])/(constants[75]*constants[76]))
    algebraic[106] = (power(constants[83], 3.00000))*states[14]+(power(states[3], 3.00000))*constants[85]+(power(constants[58], 3.00000))*states[14]+constants[56]*(power(states[3], 3.00000))+(power(constants[57], 3.00000))*constants[85]*(1.00000+states[14]/constants[55])+constants[55]*(power(constants[83], 3.00000))*(1.00000+power(states[3]/constants[57], 3.00000))
    algebraic[107] = constants[54]*algebraic[103]*((algebraic[104]*(power(states[3], 3.00000))*constants[85]-algebraic[105]*(power(constants[83], 3.00000))*states[14])/(algebraic[106]*(1.00000+constants[59]*algebraic[105])))
    algebraic[53] = constants[41]*constants[74]*(states[24]-algebraic[52])
    algebraic[127] = algebraic[125]*constants[74]*(states[14]/(constants[65]+states[14]))
    algebraic[112] = 0.740000*states[62]+0.260000
    algebraic[113] = constants[66]*constants[74]*states[60]*algebraic[112]*(states[24]-algebraic[52])
    algebraic[135] = algebraic[131]+algebraic[133]
    algebraic[143] = ((((((((algebraic[37]+algebraic[87]+algebraic[95]+algebraic[92]+algebraic[98])-constants[0]*algebraic[115])+algebraic[140]+algebraic[43]+algebraic[108]+algebraic[73])-constants[0]*algebraic[117])+algebraic[47]+algebraic[81]+constants[0]*algebraic[121]+algebraic[51]+algebraic[126]+algebraic[111]+algebraic[71])-2.00000*constants[0]*algebraic[119])+algebraic[135])-algebraic[55])-algebraic[63]
    algebraic[137] = algebraic[132]+algebraic[134]
    algebraic[144] = ((((algebraic[41]+algebraic[90]+algebraic[96]+algebraic[94]+algebraic[100]+constants[0]*algebraic[115]+algebraic[141]+algebraic[45]+algebraic[109]+algebraic[74]+algebraic[107]+constants[0]*algebraic[117]+algebraic[49]+algebraic[82])-constants[0]*algebraic[121])+algebraic[53]+algebraic[127]+algebraic[113]+algebraic[72]+2.00000*constants[0]*algebraic[119]+algebraic[137])-algebraic[57])-algebraic[67]
    algebraic[33] = (states[64]+algebraic[16])/constants[163]
    algebraic[36] = ((constants[172]-constants[173]*algebraic[33])+constants[174]*(power(algebraic[33], 2.00000)))-constants[175]*(power(algebraic[33], 3.00000))
    algebraic[142] = algebraic[138]
    return algebraic

initialGuess0 = None
def rootfind_0(voi, constants, states, algebraic):
    """Calculate value of algebraic variable for DAE"""
    from scipy.optimize import fsolve
    global initialGuess0
    if initialGuess0 is None: initialGuess0 = 0.1
    if not iterable(voi):
        algebraic[2] = fsolve(residualSN_0, initialGuess0, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess0 = algebraic[2]
    else:
        for (i,t) in enumerate(voi):
            algebraic[2][i] = fsolve(residualSN_0, initialGuess0, args=(algebraic[:,i], voi[i], constants, rates, states[:,i]), xtol=1E-6)
            initialGuess0 = algebraic[2][i]

def residualSN_0(algebraicCandidate, algebraic, voi, constants, rates, states):
    algebraic[2] = algebraicCandidate
    return (1.00000) - (algebraic[2]+states[35]+states[36]+states[37]+states[38]+states[39]+states[40])

initialGuess1 = None
def rootfind_1(voi, constants, states, algebraic):
    """Calculate value of algebraic variable for DAE"""
    from scipy.optimize import fsolve
    global initialGuess1
    if initialGuess1 is None: initialGuess1 = 0.1
    if not iterable(voi):
        algebraic[3] = fsolve(residualSN_1, initialGuess1, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess1 = algebraic[3]
    else:
        for (i,t) in enumerate(voi):
            algebraic[3][i] = fsolve(residualSN_1, initialGuess1, args=(algebraic[:,i], voi[i], constants, rates, states[:,i]), xtol=1E-6)
            initialGuess1 = algebraic[3][i]

def residualSN_1(algebraicCandidate, algebraic, voi, constants, rates, states):
    algebraic[3] = algebraicCandidate
    return (1.00000) - (algebraic[3]+states[41]+states[42]+states[43]+states[44]+states[45]+states[46])

initialGuess2 = None
def rootfind_2(voi, constants, rates, states, algebraic):
    """Calculate values of algebraic variables for DAE"""
    from scipy.optimize import fsolve
    global initialGuess2
    if initialGuess2 is None: initialGuess2 = ones(2)*0.1
    if not iterable(voi):
        soln = fsolve(residualSN_2, initialGuess2, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess2 = soln
        algebraic[64] = soln[0]
        algebraic[65] = soln[1]
    else:
        for (i,t) in enumerate(voi):
            soln = fsolve(residualSN_2, initialGuess2, args=(algebraic[:,i], voi[i], constants, rates[:i], states[:,i]), xtol=1E-6)
            initialGuess2 = soln
            algebraic[64][i] = soln[0]
            algebraic[65][i] = soln[1]

def residualSN_2(algebraicCandidate, algebraic, voi, constants, rates, states):
    resid = array([0.0] * 2)
    algebraic[64] = algebraicCandidate[0]
    algebraic[65] = algebraicCandidate[1]
    resid[0] = (algebraic[65]-(states[27]/constants[90])*algebraic[64])
    resid[1] = (algebraic[64]-(1.00000-(states[29]+states[31]+states[33]+algebraic[58]+algebraic[60]+algebraic[62]+algebraic[65])))
    return resid

initialGuess3 = None
def rootfind_3(voi, constants, rates, states, algebraic):
    """Calculate values of algebraic variables for DAE"""
    from scipy.optimize import fsolve
    global initialGuess3
    if initialGuess3 is None: initialGuess3 = ones(2)*0.1
    if not iterable(voi):
        soln = fsolve(residualSN_3, initialGuess3, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess3 = soln
        algebraic[68] = soln[0]
        algebraic[69] = soln[1]
    else:
        for (i,t) in enumerate(voi):
            soln = fsolve(residualSN_3, initialGuess3, args=(algebraic[:,i], voi[i], constants, rates[:i], states[:,i]), xtol=1E-6)
            initialGuess3 = soln
            algebraic[68][i] = soln[0]
            algebraic[69][i] = soln[1]

def residualSN_3(algebraicCandidate, algebraic, voi, constants, rates, states):
    resid = array([0.0] * 2)
    algebraic[68] = algebraicCandidate[0]
    algebraic[69] = algebraicCandidate[1]
    resid[0] = (algebraic[69]-(states[28]/constants[90])*algebraic[68])
    resid[1] = (algebraic[68]-(1.00000-(states[30]+states[32]+states[34]+algebraic[59]+algebraic[61]+algebraic[66]+algebraic[69])))
    return resid

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)