# Size of variable arrays: sizeAlgebraic = 80 sizeStates = 25 sizeConstants = 160 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_algebraic[0] = "sum_g_syn_e_s_1 in component synaptic_coupling (nanoS)" legend_algebraic[5] = "sum_g_syn_e_s_2 in component synaptic_coupling (nanoS)" legend_algebraic[10] = "sum_g_syn_e_s_3 in component synaptic_coupling (nanoS)" legend_algebraic[15] = "sum_g_syn_e_s_4 in component synaptic_coupling (nanoS)" legend_algebraic[20] = "sum_g_syn_e_s_5 in component synaptic_coupling (nanoS)" legend_constants[0] = "g_syn_e_1_2 in component synaptic_coupling (nanoS)" legend_constants[1] = "g_syn_e_1_3 in component synaptic_coupling (nanoS)" legend_constants[2] = "g_syn_e_1_4 in component synaptic_coupling (nanoS)" legend_constants[3] = "g_syn_e_1_5 in component synaptic_coupling (nanoS)" legend_constants[4] = "g_syn_e_2_1 in component synaptic_coupling (nanoS)" legend_constants[5] = "g_syn_e_2_3 in component synaptic_coupling (nanoS)" legend_constants[6] = "g_syn_e_2_4 in component synaptic_coupling (nanoS)" legend_constants[7] = "g_syn_e_2_5 in component synaptic_coupling (nanoS)" legend_constants[8] = "g_syn_e_3_1 in component synaptic_coupling (nanoS)" legend_constants[9] = "g_syn_e_3_2 in component synaptic_coupling (nanoS)" legend_constants[10] = "g_syn_e_3_4 in component synaptic_coupling (nanoS)" legend_constants[11] = "g_syn_e_3_5 in component synaptic_coupling (nanoS)" legend_constants[12] = "g_syn_e_4_1 in component synaptic_coupling (nanoS)" legend_constants[13] = "g_syn_e_4_2 in component synaptic_coupling (nanoS)" legend_constants[14] = "g_syn_e_4_3 in component synaptic_coupling (nanoS)" legend_constants[15] = "g_syn_e_4_5 in component synaptic_coupling (nanoS)" legend_constants[16] = "g_syn_e_5_1 in component synaptic_coupling (nanoS)" legend_constants[17] = "g_syn_e_5_2 in component synaptic_coupling (nanoS)" legend_constants[18] = "g_syn_e_5_3 in component synaptic_coupling (nanoS)" legend_constants[19] = "g_syn_e_5_4 in component synaptic_coupling (nanoS)" legend_states[0] = "s in component synaptic_input (dimensionless)" legend_states[1] = "s in component synaptic_input (dimensionless)" legend_states[2] = "s in component synaptic_input (dimensionless)" legend_states[3] = "s in component synaptic_input (dimensionless)" legend_states[4] = "s in component synaptic_input (dimensionless)" legend_voi = "time in component environment (millisecond)" legend_states[5] = "V in component membrane (millivolt)" legend_constants[20] = "C in component membrane (picoF)" legend_constants[21] = "i_app in component membrane (picoA)" legend_algebraic[60] = "i_NaP in component persistent_sodium_current (picoA)" legend_algebraic[45] = "i_Na in component fast_sodium_current (picoA)" legend_algebraic[50] = "i_K in component potassium_current (picoA)" legend_algebraic[65] = "i_L in component leakage_current (picoA)" legend_algebraic[70] = "i_tonic_e in component tonic_current (picoA)" legend_algebraic[75] = "i_syn_e in component synaptic_input (picoA)" legend_constants[22] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[23] = "g_Na in component fast_sodium_current (nanoS)" legend_algebraic[25] = "m_infinity in component fast_sodium_current_m_gate (dimensionless)" legend_states[6] = "n in component fast_sodium_current_n_gate (dimensionless)" legend_constants[24] = "theta_m in component fast_sodium_current_m_gate (millivolt)" legend_constants[25] = "sigma_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[1] = "n_infinity in component fast_sodium_current_n_gate (dimensionless)" legend_algebraic[26] = "tau_n in component fast_sodium_current_n_gate (millisecond)" legend_constants[26] = "tau_n_max in component fast_sodium_current_n_gate (millisecond)" legend_constants[27] = "theta_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[28] = "sigma_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[29] = "g_K in component potassium_current (nanoS)" legend_constants[30] = "E_K in component potassium_current (millivolt)" legend_states[7] = "n in component potassium_current_n_gate (dimensionless)" legend_algebraic[2] = "n_infinity in component potassium_current_n_gate (dimensionless)" legend_algebraic[27] = "tau_n in component potassium_current_n_gate (millisecond)" legend_constants[31] = "tau_n_max in component potassium_current_n_gate (millisecond)" legend_constants[32] = "theta_n in component potassium_current_n_gate (millivolt)" legend_constants[33] = "sigma_n in component potassium_current_n_gate (millivolt)" legend_constants[34] = "g_NaP in component persistent_sodium_current (nanoS)" legend_algebraic[55] = "m_infinity in component persistent_sodium_current_m_gate (dimensionless)" legend_states[8] = "h in component persistent_sodium_current_h_gate (dimensionless)" legend_constants[35] = "theta_m in component persistent_sodium_current_m_gate (millivolt)" legend_constants[36] = "sigma_m in component persistent_sodium_current_m_gate (millivolt)" legend_algebraic[3] = "h_infinity in component persistent_sodium_current_h_gate (dimensionless)" legend_algebraic[28] = "tau_h in component persistent_sodium_current_h_gate (millisecond)" legend_constants[37] = "tau_h_max in component persistent_sodium_current_h_gate (millisecond)" legend_constants[38] = "theta_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[39] = "sigma_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[40] = "g_L in component leakage_current (nanoS)" legend_constants[41] = "E_L in component leakage_current (millivolt)" legend_constants[42] = "E_syn_e in component tonic_current (millivolt)" legend_constants[43] = "g_tonic_e in component tonic_current (nanoS)" legend_algebraic[4] = "s_infinity in component synaptic_input (dimensionless)" legend_constants[44] = "kr in component synaptic_input (dimensionless)" legend_constants[45] = "tau_s in component synaptic_input (millisecond)" legend_constants[46] = "sigma_s in component synaptic_input (millivolt)" legend_constants[47] = "theta_s in component synaptic_input (millivolt)" legend_voi = "time in component environment (millisecond)" legend_states[9] = "V in component membrane (millivolt)" legend_constants[48] = "C in component membrane (picoF)" legend_constants[49] = "i_app in component membrane (picoA)" legend_algebraic[61] = "i_NaP in component persistent_sodium_current (picoA)" legend_algebraic[46] = "i_Na in component fast_sodium_current (picoA)" legend_algebraic[51] = "i_K in component potassium_current (picoA)" legend_algebraic[66] = "i_L in component leakage_current (picoA)" legend_algebraic[71] = "i_tonic_e in component tonic_current (picoA)" legend_algebraic[76] = "i_syn_e in component synaptic_input (picoA)" legend_constants[50] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[51] = "g_Na in component fast_sodium_current (nanoS)" legend_algebraic[29] = "m_infinity in component fast_sodium_current_m_gate (dimensionless)" legend_states[10] = "n in component fast_sodium_current_n_gate (dimensionless)" legend_constants[52] = "theta_m in component fast_sodium_current_m_gate (millivolt)" legend_constants[53] = "sigma_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[6] = "n_infinity in component fast_sodium_current_n_gate (dimensionless)" legend_algebraic[30] = "tau_n in component fast_sodium_current_n_gate (millisecond)" legend_constants[54] = "tau_n_max in component fast_sodium_current_n_gate (millisecond)" legend_constants[55] = "theta_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[56] = "sigma_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[57] = "g_K in component potassium_current (nanoS)" legend_constants[58] = "E_K in component potassium_current (millivolt)" legend_states[11] = "n in component potassium_current_n_gate (dimensionless)" legend_algebraic[7] = "n_infinity in component potassium_current_n_gate (dimensionless)" legend_algebraic[31] = "tau_n in component potassium_current_n_gate (millisecond)" legend_constants[59] = "tau_n_max in component potassium_current_n_gate (millisecond)" legend_constants[60] = "theta_n in component potassium_current_n_gate (millivolt)" legend_constants[61] = "sigma_n in component potassium_current_n_gate (millivolt)" legend_constants[62] = "g_NaP in component persistent_sodium_current (nanoS)" legend_algebraic[56] = "m_infinity in component persistent_sodium_current_m_gate (dimensionless)" legend_states[12] = "h in component persistent_sodium_current_h_gate (dimensionless)" legend_constants[63] = "theta_m in component persistent_sodium_current_m_gate (millivolt)" legend_constants[64] = "sigma_m in component persistent_sodium_current_m_gate (millivolt)" legend_algebraic[8] = "h_infinity in component persistent_sodium_current_h_gate (dimensionless)" legend_algebraic[32] = "tau_h in component persistent_sodium_current_h_gate (millisecond)" legend_constants[65] = "tau_h_max in component persistent_sodium_current_h_gate (millisecond)" legend_constants[66] = "theta_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[67] = "sigma_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[68] = "g_L in component leakage_current (nanoS)" legend_constants[69] = "E_L in component leakage_current (millivolt)" legend_constants[70] = "E_syn_e in component tonic_current (millivolt)" legend_constants[71] = "g_tonic_e in component tonic_current (nanoS)" legend_algebraic[9] = "s_infinity in component synaptic_input (dimensionless)" legend_constants[72] = "kr in component synaptic_input (dimensionless)" legend_constants[73] = "tau_s in component synaptic_input (millisecond)" legend_constants[74] = "sigma_s in component synaptic_input (millivolt)" legend_constants[75] = "theta_s in component synaptic_input (millivolt)" legend_voi = "time in component environment (millisecond)" legend_states[13] = "V in component membrane (millivolt)" legend_constants[76] = "C in component membrane (picoF)" legend_constants[77] = "i_app in component membrane (picoA)" legend_algebraic[62] = "i_NaP in component persistent_sodium_current (picoA)" legend_algebraic[47] = "i_Na in component fast_sodium_current (picoA)" legend_algebraic[52] = "i_K in component potassium_current (picoA)" legend_algebraic[67] = "i_L in component leakage_current (picoA)" legend_algebraic[72] = "i_tonic_e in component tonic_current (picoA)" legend_algebraic[77] = "i_syn_e in component synaptic_input (picoA)" legend_constants[78] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[79] = "g_Na in component fast_sodium_current (nanoS)" legend_algebraic[33] = "m_infinity in component fast_sodium_current_m_gate (dimensionless)" legend_states[14] = "n in component fast_sodium_current_n_gate (dimensionless)" legend_constants[80] = "theta_m in component fast_sodium_current_m_gate (millivolt)" legend_constants[81] = "sigma_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[11] = "n_infinity in component fast_sodium_current_n_gate (dimensionless)" legend_algebraic[34] = "tau_n in component fast_sodium_current_n_gate (millisecond)" legend_constants[82] = "tau_n_max in component fast_sodium_current_n_gate (millisecond)" legend_constants[83] = "theta_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[84] = "sigma_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[85] = "g_K in component potassium_current (nanoS)" legend_constants[86] = "E_K in component potassium_current (millivolt)" legend_states[15] = "n in component potassium_current_n_gate (dimensionless)" legend_algebraic[12] = "n_infinity in component potassium_current_n_gate (dimensionless)" legend_algebraic[35] = "tau_n in component potassium_current_n_gate (millisecond)" legend_constants[87] = "tau_n_max in component potassium_current_n_gate (millisecond)" legend_constants[88] = "theta_n in component potassium_current_n_gate (millivolt)" legend_constants[89] = "sigma_n in component potassium_current_n_gate (millivolt)" legend_constants[90] = "g_NaP in component persistent_sodium_current (nanoS)" legend_algebraic[57] = "m_infinity in component persistent_sodium_current_m_gate (dimensionless)" legend_states[16] = "h in component persistent_sodium_current_h_gate (dimensionless)" legend_constants[91] = "theta_m in component persistent_sodium_current_m_gate (millivolt)" legend_constants[92] = "sigma_m in component persistent_sodium_current_m_gate (millivolt)" legend_algebraic[13] = "h_infinity in component persistent_sodium_current_h_gate (dimensionless)" legend_algebraic[36] = "tau_h in component persistent_sodium_current_h_gate (millisecond)" legend_constants[93] = "tau_h_max in component persistent_sodium_current_h_gate (millisecond)" legend_constants[94] = "theta_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[95] = "sigma_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[96] = "g_L in component leakage_current (nanoS)" legend_constants[97] = "E_L in component leakage_current (millivolt)" legend_constants[98] = "E_syn_e in component tonic_current (millivolt)" legend_constants[99] = "g_tonic_e in component tonic_current (nanoS)" legend_algebraic[14] = "s_infinity in component synaptic_input (dimensionless)" legend_constants[100] = "kr in component synaptic_input (dimensionless)" legend_constants[101] = "tau_s in component synaptic_input (millisecond)" legend_constants[102] = "sigma_s in component synaptic_input (millivolt)" legend_constants[103] = "theta_s in component synaptic_input (millivolt)" legend_voi = "time in component environment (millisecond)" legend_states[17] = "V in component membrane (millivolt)" legend_constants[104] = "C in component membrane (picoF)" legend_constants[105] = "i_app in component membrane (picoA)" legend_algebraic[63] = "i_NaP in component persistent_sodium_current (picoA)" legend_algebraic[48] = "i_Na in component fast_sodium_current (picoA)" legend_algebraic[53] = "i_K in component potassium_current (picoA)" legend_algebraic[68] = "i_L in component leakage_current (picoA)" legend_algebraic[73] = "i_tonic_e in component tonic_current (picoA)" legend_algebraic[78] = "i_syn_e in component synaptic_input (picoA)" legend_constants[106] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[107] = "g_Na in component fast_sodium_current (nanoS)" legend_algebraic[37] = "m_infinity in component fast_sodium_current_m_gate (dimensionless)" legend_states[18] = "n in component fast_sodium_current_n_gate (dimensionless)" legend_constants[108] = "theta_m in component fast_sodium_current_m_gate (millivolt)" legend_constants[109] = "sigma_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[16] = "n_infinity in component fast_sodium_current_n_gate (dimensionless)" legend_algebraic[38] = "tau_n in component fast_sodium_current_n_gate (millisecond)" legend_constants[110] = "tau_n_max in component fast_sodium_current_n_gate (millisecond)" legend_constants[111] = "theta_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[112] = "sigma_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[113] = "g_K in component potassium_current (nanoS)" legend_constants[114] = "E_K in component potassium_current (millivolt)" legend_states[19] = "n in component potassium_current_n_gate (dimensionless)" legend_algebraic[17] = "n_infinity in component potassium_current_n_gate (dimensionless)" legend_algebraic[39] = "tau_n in component potassium_current_n_gate (millisecond)" legend_constants[115] = "tau_n_max in component potassium_current_n_gate (millisecond)" legend_constants[116] = "theta_n in component potassium_current_n_gate (millivolt)" legend_constants[117] = "sigma_n in component potassium_current_n_gate (millivolt)" legend_constants[118] = "g_NaP in component persistent_sodium_current (nanoS)" legend_algebraic[58] = "m_infinity in component persistent_sodium_current_m_gate (dimensionless)" legend_states[20] = "h in component persistent_sodium_current_h_gate (dimensionless)" legend_constants[119] = "theta_m in component persistent_sodium_current_m_gate (millivolt)" legend_constants[120] = "sigma_m in component persistent_sodium_current_m_gate (millivolt)" legend_algebraic[18] = "h_infinity in component persistent_sodium_current_h_gate (dimensionless)" legend_algebraic[40] = "tau_h in component persistent_sodium_current_h_gate (millisecond)" legend_constants[121] = "tau_h_max in component persistent_sodium_current_h_gate (millisecond)" legend_constants[122] = "theta_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[123] = "sigma_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[124] = "g_L in component leakage_current (nanoS)" legend_constants[125] = "E_L in component leakage_current (millivolt)" legend_constants[126] = "E_syn_e in component tonic_current (millivolt)" legend_constants[127] = "g_tonic_e in component tonic_current (nanoS)" legend_algebraic[19] = "s_infinity in component synaptic_input (dimensionless)" legend_constants[128] = "kr in component synaptic_input (dimensionless)" legend_constants[129] = "tau_s in component synaptic_input (millisecond)" legend_constants[130] = "sigma_s in component synaptic_input (millivolt)" legend_constants[131] = "theta_s in component synaptic_input (millivolt)" legend_voi = "time in component environment (millisecond)" legend_states[21] = "V in component membrane (millivolt)" legend_constants[132] = "C in component membrane (picoF)" legend_constants[133] = "i_app in component membrane (picoA)" legend_algebraic[64] = "i_NaP in component persistent_sodium_current (picoA)" legend_algebraic[49] = "i_Na in component fast_sodium_current (picoA)" legend_algebraic[54] = "i_K in component potassium_current (picoA)" legend_algebraic[69] = "i_L in component leakage_current (picoA)" legend_algebraic[74] = "i_tonic_e in component tonic_current (picoA)" legend_algebraic[79] = "i_syn_e in component synaptic_input (picoA)" legend_constants[134] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[135] = "g_Na in component fast_sodium_current (nanoS)" legend_algebraic[41] = "m_infinity in component fast_sodium_current_m_gate (dimensionless)" legend_states[22] = "n in component fast_sodium_current_n_gate (dimensionless)" legend_constants[136] = "theta_m in component fast_sodium_current_m_gate (millivolt)" legend_constants[137] = "sigma_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[21] = "n_infinity in component fast_sodium_current_n_gate (dimensionless)" legend_algebraic[42] = "tau_n in component fast_sodium_current_n_gate (millisecond)" legend_constants[138] = "tau_n_max in component fast_sodium_current_n_gate (millisecond)" legend_constants[139] = "theta_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[140] = "sigma_n in component fast_sodium_current_n_gate (millivolt)" legend_constants[141] = "g_K in component potassium_current (nanoS)" legend_constants[142] = "E_K in component potassium_current (millivolt)" legend_states[23] = "n in component potassium_current_n_gate (dimensionless)" legend_algebraic[22] = "n_infinity in component potassium_current_n_gate (dimensionless)" legend_algebraic[43] = "tau_n in component potassium_current_n_gate (millisecond)" legend_constants[143] = "tau_n_max in component potassium_current_n_gate (millisecond)" legend_constants[144] = "theta_n in component potassium_current_n_gate (millivolt)" legend_constants[145] = "sigma_n in component potassium_current_n_gate (millivolt)" legend_constants[146] = "g_NaP in component persistent_sodium_current (nanoS)" legend_algebraic[59] = "m_infinity in component persistent_sodium_current_m_gate (dimensionless)" legend_states[24] = "h in component persistent_sodium_current_h_gate (dimensionless)" legend_constants[147] = "theta_m in component persistent_sodium_current_m_gate (millivolt)" legend_constants[148] = "sigma_m in component persistent_sodium_current_m_gate (millivolt)" legend_algebraic[23] = "h_infinity in component persistent_sodium_current_h_gate (dimensionless)" legend_algebraic[44] = "tau_h in component persistent_sodium_current_h_gate (millisecond)" legend_constants[149] = "tau_h_max in component persistent_sodium_current_h_gate (millisecond)" legend_constants[150] = "theta_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[151] = "sigma_h in component persistent_sodium_current_h_gate (millivolt)" legend_constants[152] = "g_L in component leakage_current (nanoS)" legend_constants[153] = "E_L in component leakage_current (millivolt)" legend_constants[154] = "E_syn_e in component tonic_current (millivolt)" legend_constants[155] = "g_tonic_e in component tonic_current (nanoS)" legend_algebraic[24] = "s_infinity in component synaptic_input (dimensionless)" legend_constants[156] = "kr in component synaptic_input (dimensionless)" legend_constants[157] = "tau_s in component synaptic_input (millisecond)" legend_constants[158] = "sigma_s in component synaptic_input (millivolt)" legend_constants[159] = "theta_s in component synaptic_input (millivolt)" legend_rates[5] = "d/dt V in component membrane (millivolt)" legend_rates[6] = "d/dt n in component fast_sodium_current_n_gate (dimensionless)" legend_rates[7] = "d/dt n in component potassium_current_n_gate (dimensionless)" legend_rates[8] = "d/dt h in component persistent_sodium_current_h_gate (dimensionless)" legend_rates[0] = "d/dt s in component synaptic_input (dimensionless)" legend_rates[9] = "d/dt V in component membrane (millivolt)" legend_rates[10] = "d/dt n in component fast_sodium_current_n_gate (dimensionless)" legend_rates[11] = "d/dt n in component potassium_current_n_gate (dimensionless)" legend_rates[12] = "d/dt h in component persistent_sodium_current_h_gate (dimensionless)" legend_rates[1] = "d/dt s in component synaptic_input (dimensionless)" legend_rates[13] = "d/dt V in component membrane (millivolt)" legend_rates[14] = "d/dt n in component fast_sodium_current_n_gate (dimensionless)" legend_rates[15] = "d/dt n in component potassium_current_n_gate (dimensionless)" legend_rates[16] = "d/dt h in component persistent_sodium_current_h_gate (dimensionless)" legend_rates[2] = "d/dt s in component synaptic_input (dimensionless)" legend_rates[17] = "d/dt V in component membrane (millivolt)" legend_rates[18] = "d/dt n in component fast_sodium_current_n_gate (dimensionless)" legend_rates[19] = "d/dt n in component potassium_current_n_gate (dimensionless)" legend_rates[20] = "d/dt h in component persistent_sodium_current_h_gate (dimensionless)" legend_rates[3] = "d/dt s in component synaptic_input (dimensionless)" legend_rates[21] = "d/dt V in component membrane (millivolt)" legend_rates[22] = "d/dt n in component fast_sodium_current_n_gate (dimensionless)" legend_rates[23] = "d/dt n in component potassium_current_n_gate (dimensionless)" legend_rates[24] = "d/dt h in component persistent_sodium_current_h_gate (dimensionless)" legend_rates[4] = "d/dt s in component synaptic_input (dimensionless)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 0.10 constants[1] = 0.10 constants[2] = 0.10 constants[3] = 0.10 constants[4] = 0.10 constants[5] = 0.10 constants[6] = 0.10 constants[7] = 0.10 constants[8] = 0.10 constants[9] = 0.10 constants[10] = 0.10 constants[11] = 0.10 constants[12] = 0.10 constants[13] = 0.10 constants[14] = 0.10 constants[15] = 0.10 constants[16] = 0.10 constants[17] = 0.10 constants[18] = 0.10 constants[19] = 0.10 states[0] = 1 states[1] = 1 states[2] = 1 states[3] = 1 states[4] = 1 states[5] = -50.0 constants[20] = 21.0 constants[21] = 0.0 constants[22] = 50.0 constants[23] = 28.0 states[6] = 0.01 constants[24] = -34.0 constants[25] = -5.0 constants[26] = 10.0 constants[27] = -29.0 constants[28] = -4.0 constants[29] = 11.2 constants[30] = -85.0 states[7] = 0.01 constants[31] = 10.0 constants[32] = -29.0 constants[33] = -4.0 constants[34] = 2.8 states[8] = 0.46 constants[35] = -40.0 constants[36] = -6.0 constants[37] = 10000.0 constants[38] = -48.0 constants[39] = 6.0 constants[40] = 2.8 constants[41] = -57.5 constants[42] = 0.0 constants[43] = 0.0 constants[44] = 1.0 constants[45] = 5.0 constants[46] = -5.0 constants[47] = -10.0 states[9] = -50.0 constants[48] = 21.0 constants[49] = 0.0 constants[50] = 50.0 constants[51] = 28.0 states[10] = 0.01 constants[52] = -34.0 constants[53] = -5.0 constants[54] = 10.0 constants[55] = -29.0 constants[56] = -4.0 constants[57] = 11.2 constants[58] = -85.0 states[11] = 0.01 constants[59] = 10.0 constants[60] = -29.0 constants[61] = -4.0 constants[62] = 2.8 states[12] = 0.46 constants[63] = -40.0 constants[64] = -6.0 constants[65] = 10000.0 constants[66] = -48.0 constants[67] = 6.0 constants[68] = 2.8 constants[69] = -57.5 constants[70] = 0.0 constants[71] = 0.0 constants[72] = 1.0 constants[73] = 5.0 constants[74] = -5.0 constants[75] = -10.0 states[13] = -50.0 constants[76] = 21.0 constants[77] = 0.0 constants[78] = 50.0 constants[79] = 28.0 states[14] = 0.01 constants[80] = -34.0 constants[81] = -5.0 constants[82] = 10.0 constants[83] = -29.0 constants[84] = -4.0 constants[85] = 11.2 constants[86] = -85.0 states[15] = 0.01 constants[87] = 10.0 constants[88] = -29.0 constants[89] = -4.0 constants[90] = 2.8 states[16] = 0.46 constants[91] = -40.0 constants[92] = -6.0 constants[93] = 10000.0 constants[94] = -48.0 constants[95] = 6.0 constants[96] = 2.8 constants[97] = -57.5 constants[98] = 0.0 constants[99] = 0.0 constants[100] = 1.0 constants[101] = 5.0 constants[102] = -5.0 constants[103] = -10.0 states[17] = -50.0 constants[104] = 21.0 constants[105] = 0.0 constants[106] = 50.0 constants[107] = 28.0 states[18] = 0.01 constants[108] = -34.0 constants[109] = -5.0 constants[110] = 10.0 constants[111] = -29.0 constants[112] = -4.0 constants[113] = 11.2 constants[114] = -85.0 states[19] = 0.01 constants[115] = 10.0 constants[116] = -29.0 constants[117] = -4.0 constants[118] = 2.8 states[20] = 0.46 constants[119] = -40.0 constants[120] = -6.0 constants[121] = 10000.0 constants[122] = -48.0 constants[123] = 6.0 constants[124] = 2.8 constants[125] = -57.5 constants[126] = 0.0 constants[127] = 0.0 constants[128] = 1.0 constants[129] = 5.0 constants[130] = -5.0 constants[131] = -10.0 states[21] = -50.0 constants[132] = 21.0 constants[133] = 0.0 constants[134] = 50.0 constants[135] = 28.0 states[22] = 0.01 constants[136] = -34.0 constants[137] = -5.0 constants[138] = 10.0 constants[139] = -29.0 constants[140] = -4.0 constants[141] = 11.2 constants[142] = -85.0 states[23] = 0.01 constants[143] = 10.0 constants[144] = -29.0 constants[145] = -4.0 constants[146] = 2.8 states[24] = 0.46 constants[147] = -40.0 constants[148] = -6.0 constants[149] = 10000.0 constants[150] = -48.0 constants[151] = 6.0 constants[152] = 2.8 constants[153] = -57.5 constants[154] = 0.0 constants[155] = 0.0 constants[156] = 1.0 constants[157] = 5.0 constants[158] = -5.0 constants[159] = -10.0 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[4] = 1.00000/(1.00000+exp((states[5]-constants[47])/constants[46])) rates[0] = ((1.00000-states[0])*algebraic[4]--(constants[44]*states[0]))/constants[45] algebraic[9] = 1.00000/(1.00000+exp((states[9]-constants[75])/constants[74])) rates[1] = ((1.00000-states[1])*algebraic[9]--(constants[72]*states[1]))/constants[73] algebraic[14] = 1.00000/(1.00000+exp((states[13]-constants[103])/constants[102])) rates[2] = ((1.00000-states[2])*algebraic[14]--(constants[100]*states[2]))/constants[101] algebraic[19] = 1.00000/(1.00000+exp((states[17]-constants[131])/constants[130])) rates[3] = ((1.00000-states[3])*algebraic[19]--(constants[128]*states[3]))/constants[129] algebraic[24] = 1.00000/(1.00000+exp((states[21]-constants[159])/constants[158])) rates[4] = ((1.00000-states[4])*algebraic[24]--(constants[156]*states[4]))/constants[157] algebraic[1] = 1.00000/(1.00000+exp((states[5]-constants[27])/constants[28])) algebraic[26] = constants[26]/cosh((states[5]-constants[27])/(2.00000*constants[28])) rates[6] = (algebraic[1]-states[6])/algebraic[26] algebraic[2] = 1.00000/(1.00000+exp((states[5]-constants[32])/constants[33])) algebraic[27] = constants[31]/cosh((states[5]-constants[32])/(2.00000*constants[33])) rates[7] = (algebraic[2]-states[7])/algebraic[27] algebraic[3] = 1.00000/(1.00000+exp((states[5]-constants[38])/constants[39])) algebraic[28] = constants[37]/cosh((states[5]-constants[38])/(2.00000*constants[39])) rates[8] = (algebraic[3]-states[8])/algebraic[28] algebraic[6] = 1.00000/(1.00000+exp((states[9]-constants[55])/constants[56])) algebraic[30] = constants[54]/cosh((states[9]-constants[55])/(2.00000*constants[56])) rates[10] = (algebraic[6]-states[10])/algebraic[30] algebraic[7] = 1.00000/(1.00000+exp((states[9]-constants[60])/constants[61])) algebraic[31] = constants[59]/cosh((states[9]-constants[60])/(2.00000*constants[61])) rates[11] = (algebraic[7]-states[11])/algebraic[31] algebraic[8] = 1.00000/(1.00000+exp((states[9]-constants[66])/constants[67])) algebraic[32] = constants[65]/cosh((states[9]-constants[66])/(2.00000*constants[67])) rates[12] = (algebraic[8]-states[12])/algebraic[32] algebraic[11] = 1.00000/(1.00000+exp((states[13]-constants[83])/constants[84])) algebraic[34] = constants[82]/cosh((states[13]-constants[83])/(2.00000*constants[84])) rates[14] = (algebraic[11]-states[14])/algebraic[34] algebraic[12] = 1.00000/(1.00000+exp((states[13]-constants[88])/constants[89])) algebraic[35] = constants[87]/cosh((states[13]-constants[88])/(2.00000*constants[89])) rates[15] = (algebraic[12]-states[15])/algebraic[35] algebraic[13] = 1.00000/(1.00000+exp((states[13]-constants[94])/constants[95])) algebraic[36] = constants[93]/cosh((states[13]-constants[94])/(2.00000*constants[95])) rates[16] = (algebraic[13]-states[16])/algebraic[36] algebraic[16] = 1.00000/(1.00000+exp((states[17]-constants[111])/constants[112])) algebraic[38] = constants[110]/cosh((states[17]-constants[111])/(2.00000*constants[112])) rates[18] = (algebraic[16]-states[18])/algebraic[38] algebraic[17] = 1.00000/(1.00000+exp((states[17]-constants[116])/constants[117])) algebraic[39] = constants[115]/cosh((states[17]-constants[116])/(2.00000*constants[117])) rates[19] = (algebraic[17]-states[19])/algebraic[39] algebraic[18] = 1.00000/(1.00000+exp((states[17]-constants[122])/constants[123])) algebraic[40] = constants[121]/cosh((states[17]-constants[122])/(2.00000*constants[123])) rates[20] = (algebraic[18]-states[20])/algebraic[40] algebraic[21] = 1.00000/(1.00000+exp((states[21]-constants[139])/constants[140])) algebraic[42] = constants[138]/cosh((states[21]-constants[139])/(2.00000*constants[140])) rates[22] = (algebraic[21]-states[22])/algebraic[42] algebraic[22] = 1.00000/(1.00000+exp((states[21]-constants[144])/constants[145])) algebraic[43] = constants[143]/cosh((states[21]-constants[144])/(2.00000*constants[145])) rates[23] = (algebraic[22]-states[23])/algebraic[43] algebraic[23] = 1.00000/(1.00000+exp((states[21]-constants[150])/constants[151])) algebraic[44] = constants[149]/cosh((states[21]-constants[150])/(2.00000*constants[151])) rates[24] = (algebraic[23]-states[24])/algebraic[44] algebraic[55] = 1.00000/(1.00000+exp((states[5]-constants[35])/constants[36])) algebraic[60] = constants[34]*algebraic[55]*states[8]*(states[5]-constants[22]) algebraic[25] = 1.00000/(1.00000+exp((states[5]-constants[24])/constants[25])) algebraic[45] = constants[23]*(power(algebraic[25], 3.00000))*(1.00000-states[6])*(states[5]-constants[22]) algebraic[50] = constants[29]*(power(states[7], 4.00000))*(states[5]-constants[30]) algebraic[65] = constants[40]*(states[5]-constants[41]) algebraic[70] = constants[43]*(states[5]-constants[42]) algebraic[0] = constants[0]*states[0]+constants[1]*states[0]+constants[2]*states[0]+constants[3]*states[0] algebraic[75] = algebraic[0]*(states[5]-constants[42]) rates[5] = (-(algebraic[60]+algebraic[45]+algebraic[50]+algebraic[65]+algebraic[70]+algebraic[75])+constants[21])/constants[20] algebraic[56] = 1.00000/(1.00000+exp((states[9]-constants[63])/constants[64])) algebraic[61] = constants[62]*algebraic[56]*states[12]*(states[9]-constants[50]) algebraic[29] = 1.00000/(1.00000+exp((states[9]-constants[52])/constants[53])) algebraic[46] = constants[51]*(power(algebraic[29], 3.00000))*(1.00000-states[10])*(states[9]-constants[50]) algebraic[51] = constants[57]*(power(states[11], 4.00000))*(states[9]-constants[58]) algebraic[66] = constants[68]*(states[9]-constants[69]) algebraic[71] = constants[71]*(states[9]-constants[70]) algebraic[5] = constants[4]*states[1]+constants[5]*states[1]+constants[6]*states[1]+constants[7]*states[1] algebraic[76] = algebraic[5]*(states[9]-constants[70]) rates[9] = (-(algebraic[61]+algebraic[46]+algebraic[51]+algebraic[66]+algebraic[71]+algebraic[76])+constants[49])/constants[48] algebraic[57] = 1.00000/(1.00000+exp((states[13]-constants[91])/constants[92])) algebraic[62] = constants[90]*algebraic[57]*states[16]*(states[13]-constants[78]) algebraic[33] = 1.00000/(1.00000+exp((states[13]-constants[80])/constants[81])) algebraic[47] = constants[79]*(power(algebraic[33], 3.00000))*(1.00000-states[14])*(states[13]-constants[78]) algebraic[52] = constants[85]*(power(states[15], 4.00000))*(states[13]-constants[86]) algebraic[67] = constants[96]*(states[13]-constants[97]) algebraic[72] = constants[99]*(states[13]-constants[98]) algebraic[10] = constants[8]*states[2]+constants[9]*states[2]+constants[10]*states[2]+constants[11]*states[2] algebraic[77] = algebraic[10]*(states[13]-constants[98]) rates[13] = (-(algebraic[62]+algebraic[47]+algebraic[52]+algebraic[67]+algebraic[72]+algebraic[77])+constants[77])/constants[76] algebraic[58] = 1.00000/(1.00000+exp((states[17]-constants[119])/constants[120])) algebraic[63] = constants[118]*algebraic[58]*states[20]*(states[17]-constants[106]) algebraic[37] = 1.00000/(1.00000+exp((states[17]-constants[108])/constants[109])) algebraic[48] = constants[107]*(power(algebraic[37], 3.00000))*(1.00000-states[18])*(states[17]-constants[106]) algebraic[53] = constants[113]*(power(states[19], 4.00000))*(states[17]-constants[114]) algebraic[68] = constants[124]*(states[17]-constants[125]) algebraic[73] = constants[127]*(states[17]-constants[126]) algebraic[15] = constants[12]*states[3]+constants[13]*states[3]+constants[14]*states[3]+constants[15]*states[3] algebraic[78] = algebraic[15]*(states[17]-constants[126]) rates[17] = (-(algebraic[63]+algebraic[48]+algebraic[53]+algebraic[68]+algebraic[73]+algebraic[78])+constants[105])/constants[104] algebraic[59] = 1.00000/(1.00000+exp((states[21]-constants[147])/constants[148])) algebraic[64] = constants[146]*algebraic[59]*states[24]*(states[21]-constants[134]) algebraic[41] = 1.00000/(1.00000+exp((states[21]-constants[136])/constants[137])) algebraic[49] = constants[135]*(power(algebraic[41], 3.00000))*(1.00000-states[22])*(states[21]-constants[134]) algebraic[54] = constants[141]*(power(states[23], 4.00000))*(states[21]-constants[142]) algebraic[69] = constants[152]*(states[21]-constants[153]) algebraic[74] = constants[155]*(states[21]-constants[154]) algebraic[20] = constants[16]*states[4]+constants[17]*states[4]+constants[18]*states[4]+constants[19]*states[4] algebraic[79] = algebraic[20]*(states[21]-constants[154]) rates[21] = (-(algebraic[64]+algebraic[49]+algebraic[54]+algebraic[69]+algebraic[74]+algebraic[79])+constants[133])/constants[132] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[4] = 1.00000/(1.00000+exp((states[5]-constants[47])/constants[46])) algebraic[9] = 1.00000/(1.00000+exp((states[9]-constants[75])/constants[74])) algebraic[14] = 1.00000/(1.00000+exp((states[13]-constants[103])/constants[102])) algebraic[19] = 1.00000/(1.00000+exp((states[17]-constants[131])/constants[130])) algebraic[24] = 1.00000/(1.00000+exp((states[21]-constants[159])/constants[158])) algebraic[1] = 1.00000/(1.00000+exp((states[5]-constants[27])/constants[28])) algebraic[26] = constants[26]/cosh((states[5]-constants[27])/(2.00000*constants[28])) algebraic[2] = 1.00000/(1.00000+exp((states[5]-constants[32])/constants[33])) algebraic[27] = constants[31]/cosh((states[5]-constants[32])/(2.00000*constants[33])) algebraic[3] = 1.00000/(1.00000+exp((states[5]-constants[38])/constants[39])) algebraic[28] = constants[37]/cosh((states[5]-constants[38])/(2.00000*constants[39])) algebraic[6] = 1.00000/(1.00000+exp((states[9]-constants[55])/constants[56])) algebraic[30] = constants[54]/cosh((states[9]-constants[55])/(2.00000*constants[56])) algebraic[7] = 1.00000/(1.00000+exp((states[9]-constants[60])/constants[61])) algebraic[31] = constants[59]/cosh((states[9]-constants[60])/(2.00000*constants[61])) algebraic[8] = 1.00000/(1.00000+exp((states[9]-constants[66])/constants[67])) algebraic[32] = constants[65]/cosh((states[9]-constants[66])/(2.00000*constants[67])) algebraic[11] = 1.00000/(1.00000+exp((states[13]-constants[83])/constants[84])) algebraic[34] = constants[82]/cosh((states[13]-constants[83])/(2.00000*constants[84])) algebraic[12] = 1.00000/(1.00000+exp((states[13]-constants[88])/constants[89])) algebraic[35] = constants[87]/cosh((states[13]-constants[88])/(2.00000*constants[89])) algebraic[13] = 1.00000/(1.00000+exp((states[13]-constants[94])/constants[95])) algebraic[36] = constants[93]/cosh((states[13]-constants[94])/(2.00000*constants[95])) algebraic[16] = 1.00000/(1.00000+exp((states[17]-constants[111])/constants[112])) algebraic[38] = constants[110]/cosh((states[17]-constants[111])/(2.00000*constants[112])) algebraic[17] = 1.00000/(1.00000+exp((states[17]-constants[116])/constants[117])) algebraic[39] = constants[115]/cosh((states[17]-constants[116])/(2.00000*constants[117])) algebraic[18] = 1.00000/(1.00000+exp((states[17]-constants[122])/constants[123])) algebraic[40] = constants[121]/cosh((states[17]-constants[122])/(2.00000*constants[123])) algebraic[21] = 1.00000/(1.00000+exp((states[21]-constants[139])/constants[140])) algebraic[42] = constants[138]/cosh((states[21]-constants[139])/(2.00000*constants[140])) algebraic[22] = 1.00000/(1.00000+exp((states[21]-constants[144])/constants[145])) algebraic[43] = constants[143]/cosh((states[21]-constants[144])/(2.00000*constants[145])) algebraic[23] = 1.00000/(1.00000+exp((states[21]-constants[150])/constants[151])) algebraic[44] = constants[149]/cosh((states[21]-constants[150])/(2.00000*constants[151])) algebraic[55] = 1.00000/(1.00000+exp((states[5]-constants[35])/constants[36])) algebraic[60] = constants[34]*algebraic[55]*states[8]*(states[5]-constants[22]) algebraic[25] = 1.00000/(1.00000+exp((states[5]-constants[24])/constants[25])) algebraic[45] = constants[23]*(power(algebraic[25], 3.00000))*(1.00000-states[6])*(states[5]-constants[22]) algebraic[50] = constants[29]*(power(states[7], 4.00000))*(states[5]-constants[30]) algebraic[65] = constants[40]*(states[5]-constants[41]) algebraic[70] = constants[43]*(states[5]-constants[42]) algebraic[0] = constants[0]*states[0]+constants[1]*states[0]+constants[2]*states[0]+constants[3]*states[0] algebraic[75] = algebraic[0]*(states[5]-constants[42]) algebraic[56] = 1.00000/(1.00000+exp((states[9]-constants[63])/constants[64])) algebraic[61] = constants[62]*algebraic[56]*states[12]*(states[9]-constants[50]) algebraic[29] = 1.00000/(1.00000+exp((states[9]-constants[52])/constants[53])) algebraic[46] = constants[51]*(power(algebraic[29], 3.00000))*(1.00000-states[10])*(states[9]-constants[50]) algebraic[51] = constants[57]*(power(states[11], 4.00000))*(states[9]-constants[58]) algebraic[66] = constants[68]*(states[9]-constants[69]) algebraic[71] = constants[71]*(states[9]-constants[70]) algebraic[5] = constants[4]*states[1]+constants[5]*states[1]+constants[6]*states[1]+constants[7]*states[1] algebraic[76] = algebraic[5]*(states[9]-constants[70]) algebraic[57] = 1.00000/(1.00000+exp((states[13]-constants[91])/constants[92])) algebraic[62] = constants[90]*algebraic[57]*states[16]*(states[13]-constants[78]) algebraic[33] = 1.00000/(1.00000+exp((states[13]-constants[80])/constants[81])) algebraic[47] = constants[79]*(power(algebraic[33], 3.00000))*(1.00000-states[14])*(states[13]-constants[78]) algebraic[52] = constants[85]*(power(states[15], 4.00000))*(states[13]-constants[86]) algebraic[67] = constants[96]*(states[13]-constants[97]) algebraic[72] = constants[99]*(states[13]-constants[98]) algebraic[10] = constants[8]*states[2]+constants[9]*states[2]+constants[10]*states[2]+constants[11]*states[2] algebraic[77] = algebraic[10]*(states[13]-constants[98]) algebraic[58] = 1.00000/(1.00000+exp((states[17]-constants[119])/constants[120])) algebraic[63] = constants[118]*algebraic[58]*states[20]*(states[17]-constants[106]) algebraic[37] = 1.00000/(1.00000+exp((states[17]-constants[108])/constants[109])) algebraic[48] = constants[107]*(power(algebraic[37], 3.00000))*(1.00000-states[18])*(states[17]-constants[106]) algebraic[53] = constants[113]*(power(states[19], 4.00000))*(states[17]-constants[114]) algebraic[68] = constants[124]*(states[17]-constants[125]) algebraic[73] = constants[127]*(states[17]-constants[126]) algebraic[15] = constants[12]*states[3]+constants[13]*states[3]+constants[14]*states[3]+constants[15]*states[3] algebraic[78] = algebraic[15]*(states[17]-constants[126]) algebraic[59] = 1.00000/(1.00000+exp((states[21]-constants[147])/constants[148])) algebraic[64] = constants[146]*algebraic[59]*states[24]*(states[21]-constants[134]) algebraic[41] = 1.00000/(1.00000+exp((states[21]-constants[136])/constants[137])) algebraic[49] = constants[135]*(power(algebraic[41], 3.00000))*(1.00000-states[22])*(states[21]-constants[134]) algebraic[54] = constants[141]*(power(states[23], 4.00000))*(states[21]-constants[142]) algebraic[69] = constants[152]*(states[21]-constants[153]) algebraic[74] = constants[155]*(states[21]-constants[154]) algebraic[20] = constants[16]*states[4]+constants[17]*states[4]+constants[18]*states[4]+constants[19]*states[4] algebraic[79] = algebraic[20]*(states[21]-constants[154]) return algebraic 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)