# Size of variable arrays: sizeAlgebraic = 0 sizeStates = 0 sizeConstants = 156 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_constants[0] = "elementary_charge in component codata_2006_electromagnetic (coulomb)" legend_constants[1] = "magnetic_flux_quantum in component codata_2006_electromagnetic (weber)" legend_constants[2] = "conductance_quantum in component codata_2006_electromagnetic (siemens)" legend_constants[3] = "inverse_of_conductance_quantum in component codata_2006_electromagnetic (ohm)" legend_constants[4] = "Josephson_constant in component codata_2006_electromagnetic (hertz_per_volt)" legend_constants[5] = "von_Klitzing_constant in component codata_2006_electromagnetic (ohm)" legend_constants[6] = "Bohr_magneton in component codata_2006_electromagnetic (joule_per_tesla)" legend_constants[7] = "nuclear_magneton in component codata_2006_electromagnetic (joule_per_tesla)" legend_constants[8] = "speed_of_light_in_vacuum in component codata_2006_universal (metre_per_second)" legend_constants[9] = "magnetic_constant in component codata_2006_universal (newton_per_square_ampere)" legend_constants[10] = "electric_constant in component codata_2006_universal (farad_per_metre)" legend_constants[11] = "characteristic_impedance_of_vacuum in component codata_2006_universal (ohm)" legend_constants[12] = "Newtonian_constant_of_gravitation in component codata_2006_universal (cubic_metre_per_kilogram_per_square_second)" legend_constants[13] = "Planck_constant in component codata_2006_universal (joule_second)" legend_constants[14] = "Planck_constant_over_2_pi in component codata_2006_universal (joule_second)" legend_constants[15] = "Planck_mass in component codata_2006_universal (kilogram)" legend_constants[16] = "Planck_temperature in component codata_2006_universal (kelvin)" legend_constants[17] = "Planck_length in component codata_2006_universal (metre)" legend_constants[18] = "Planck_time in component codata_2006_universal (second)" legend_constants[19] = "fine_structure_constant in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[20] = "inverse_fine_structure_constant in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[21] = "Rydberg_constant in component codata_2006_atomic_and_nuclear (per_metre)" legend_constants[22] = "Bohr_radius in component codata_2006_atomic_and_nuclear (metre)" legend_constants[23] = "Hartree_energy in component codata_2006_atomic_and_nuclear (joule)" legend_constants[24] = "quantum_of_circulation in component codata_2006_atomic_and_nuclear (square_metre_per_second)" legend_constants[25] = "Fermi_coupling_constant in component codata_2006_atomic_and_nuclear (per_square_gigaelectronvolt)" legend_constants[26] = "weak_mixing_angle in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[27] = "electron_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[28] = "electron_muon_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[29] = "electron_tau_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[30] = "electron_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[31] = "electron_neutron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[32] = "electron_deuteron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[33] = "electron_alpha_particle_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[34] = "electron_charge_to_mass_quotient in component codata_2006_atomic_and_nuclear (coulomb_per_kilogram)" legend_constants[35] = "electron_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[36] = "Compton_wavelength in component codata_2006_atomic_and_nuclear (metre)" legend_constants[37] = "classic_electron_radius in component codata_2006_atomic_and_nuclear (metre)" legend_constants[38] = "Thomson_cross_section in component codata_2006_atomic_and_nuclear (square_metre)" legend_constants[39] = "electron_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[40] = "electron_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[41] = "electron_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[42] = "electron_magnetic_moment_anomaly in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[43] = "electron_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[44] = "electron_muon_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[45] = "electron_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[46] = "electron_to_shielded_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[47] = "electron_neutron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[48] = "electron_deuteron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[49] = "electron_to_shielded_helion_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[50] = "electron_gyromagnetic_ratio in component codata_2006_atomic_and_nuclear (per_second_per_tesla)" legend_constants[51] = "muon_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[52] = "muon_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[53] = "muon_tau_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[54] = "muon_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[55] = "muon_neutron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[56] = "muon_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[57] = "muon_Compton_wavelength in component codata_2006_atomic_and_nuclear (metre)" legend_constants[58] = "muon_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[59] = "muon_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[60] = "muon_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[61] = "muon_magnetic_moment_anomaly in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[62] = "muon_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[63] = "muon_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[64] = "tau_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[65] = "tau_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[66] = "tau_muon_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[67] = "tau_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[68] = "tau_neutron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[69] = "tau_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[70] = "tau_Compton_wavelength in component codata_2006_atomic_and_nuclear (metre)" legend_constants[71] = "proton_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[72] = "proton_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[73] = "proton_muon_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[74] = "proton_tau_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[75] = "proton_neutron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[76] = "proton_charge_to_mass_quotient in component codata_2006_atomic_and_nuclear (coulomb_per_kilogram)" legend_constants[77] = "proton_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[78] = "proton_Compton_wavelength in component codata_2006_atomic_and_nuclear (metre)" legend_constants[79] = "proton_rms_electron_radius in component codata_2006_atomic_and_nuclear (metre)" legend_constants[80] = "proton_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[81] = "proton_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[82] = "proton_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[83] = "proton_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[84] = "proton_neutron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[85] = "shielded_proton_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[86] = "shielded_proton_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[87] = "shielded_proton_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[88] = "proton_magnetic_shielding_correction in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[89] = "proton_gyromagnetic_ratio in component codata_2006_atomic_and_nuclear (per_second_per_tesla)" legend_constants[90] = "shielded_proton_gyromagnetic_ratio in component codata_2006_atomic_and_nuclear (per_second_per_tesla)" legend_constants[91] = "neutron_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[92] = "neutron_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[93] = "neutron_muon_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[94] = "neutron_tau_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[95] = "neutron_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[96] = "neutron_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[97] = "neutron_Compton_wavelength in component codata_2006_atomic_and_nuclear (metre)" legend_constants[98] = "neutron_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[99] = "neutron_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[100] = "neutron_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[101] = "neutron_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[102] = "neutron_electron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[103] = "neutron_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[104] = "neutron_to_shielded_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[105] = "neutron_gyromagnetic_ratio in component codata_2006_atomic_and_nuclear (per_second_per_tesla)" legend_constants[106] = "deuteron_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[107] = "deuteron_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[108] = "deuteron_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[109] = "deuteron_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[110] = "deuteron_rms_charge_radius in component codata_2006_atomic_and_nuclear (metre)" legend_constants[111] = "deuteron_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[112] = "deuteron_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[113] = "deuteron_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[114] = "deuteron_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[115] = "deuteron_electron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[116] = "deuteron_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[117] = "deuteron_neutron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[118] = "triton_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[119] = "triton_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[120] = "triton_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[121] = "triton_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[122] = "triton_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[123] = "triton_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[124] = "triton_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[125] = "triton_g_factor in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[126] = "triton_electron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[127] = "triton_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[128] = "triton_neutron_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[129] = "helion_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[130] = "helion_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[131] = "helion_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[132] = "helion_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[133] = "shielded_helion_magnetic_moment in component codata_2006_atomic_and_nuclear (joule_per_tesla)" legend_constants[134] = "shielded_helion_magnetic_moment_to_Bohr_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[135] = "shielded_helion_magnetic_moment_to_nuclear_magneton_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[136] = "shielded_helion_to_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[137] = "shielded_helion_to_shielded_proton_magnetic_moment_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[138] = "shielded_helion_gyromagnetic_ratio in component codata_2006_atomic_and_nuclear (per_second_per_tesla)" legend_constants[139] = "alpha_particle_mass in component codata_2006_atomic_and_nuclear (kilogram)" legend_constants[140] = "alpha_particle_to_electron_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[141] = "alpha_particle_to_proton_mass_ratio in component codata_2006_atomic_and_nuclear (dimensionless)" legend_constants[142] = "alpha_particle_molar_mass in component codata_2006_atomic_and_nuclear (kilogram_per_mole)" legend_constants[143] = "Avogadro_constant in component codata_2006_physicochemical (per_mole)" legend_constants[144] = "atomic_mass_constant in component codata_2006_physicochemical (kilogram)" legend_constants[145] = "Faraday_constant in component codata_2006_physicochemical (coulomb_per_mole)" legend_constants[146] = "molar_Planck_constant in component codata_2006_physicochemical (joule_second_per_mole)" legend_constants[147] = "molar_gas_constant in component codata_2006_physicochemical (joule_per_mole_per_kelvin)" legend_constants[148] = "Boltzmann_constant in component codata_2006_physicochemical (joule_per_kelvin)" legend_constants[149] = "molar_volume_of_ideal_gas in component codata_2006_physicochemical (cubic_metre_per_mole)" legend_constants[150] = "Sackur_Tetrode_constant in component codata_2006_physicochemical (dimensionless)" legend_constants[151] = "Stefan_Boltzmann_constant in component codata_2006_physicochemical (watt_per_square_meter_per_quartic_kelvin)" legend_constants[152] = "first_radiation_constant in component codata_2006_physicochemical (watt_per_square_metre)" legend_constants[153] = "first_radiation_constant_for_spectral_radiance in component codata_2006_physicochemical (watt_per_square_metre_per_steradian)" legend_constants[154] = "second_radiation_constant in component codata_2006_physicochemical (metre_kelvin)" legend_constants[155] = "Wien_displacement_law_constant in component codata_2006_physicochemical (metre_kelvin)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 1.602176487e-19 constants[1] = 2.067833667e-15 constants[2] = 7.7480917004e-5 constants[3] = 12906.4037787 constants[4] = 483597.891e9 constants[5] = 25812.807557 constants[6] = 927.400915e-26 constants[7] = 5.05078324e-27 constants[8] = 299792458 constants[9] = 1.2566370614359172953850573533118011536788677597500423283899778369231265625145e-6 constants[10] = 8.8541878176203898505365630317107502606083701665994498081024171524053950954600e-12 constants[11] = 376.73031346177065546819840042031930826862350835241865523207463829670726922131 constants[12] = 6.67428e-11 constants[13] = 6.62606896e-34 constants[14] = 1.054571628e-34 constants[15] = 6.62606896e-34 constants[16] = 1.416785e32 constants[17] = 1.616252e-35 constants[18] = 5.39124e-44 constants[19] = 7.2973525376e-3 constants[20] = 137.035999679 constants[21] = 10973731.568527 constants[22] = 0.52917720859e-10 constants[23] = 4.35974394e-18 constants[24] = 3.6369475199e-4 constants[25] = 1.6637e-5 constants[26] = 0.22255 constants[27] = 9.10938215e-31 constants[28] = 4.83633171e-3 constants[29] = 2.87564e-4 constants[30] = 5.4461702177e-4 constants[31] = 5.4386734459e-4 constants[32] = 2.7244371093e-4 constants[33] = 1.37093355570e-4 constants[34] = -1.758820150e11 constants[35] = 5.4857990943e-7 constants[36] = 2.4263102175e-12 constants[37] = 2.4263102175e-12 constants[38] = 0.6652458558e-28 constants[39] = -928.476377e-26 constants[40] = -1.00115965218111 constants[41] = -1838.28197092 constants[42] = 1.15965218111e-3 constants[43] = -2.0023193043622 constants[44] = 206.7669877 constants[45] = -658.2106848 constants[46] = -658.2275971 constants[47] = 960.92050 constants[48] = -2143.923498 constants[49] = 864.058257 constants[50] = 1.760859770e11 constants[51] = 1.88353130e-28 constants[52] = 206.7682823 constants[53] = 5.94592e-2 constants[54] = 0.1126095261 constants[55] = 0.1124545167 constants[56] = 0.1134289256e-3 constants[57] = 11.73444104e-15 constants[58] = -4.49044786e-26 constants[59] = -4.84197049e-3 constants[60] = -8.89059705 constants[61] = 1.16592069e-3 constants[62] = -2.0023318414 constants[63] = -3.183345137 constants[64] = 3.16777e-27 constants[65] = 3477.48 constants[66] = 16.8183 constants[67] = 1.89390 constants[68] = 1.89129 constants[69] = 1.90768e-3 constants[70] = 0.69772e-15 constants[71] = 1.672621637e-27 constants[72] = 1836.15267247 constants[73] = 8.88024339 constants[74] = 0.528012 constants[75] = 0.99862347824 constants[76] = 9.57883392e7 constants[77] = 1.00727646677e-3 constants[78] = 1.3214098446e-15 constants[79] = 0.8768e-15 constants[80] = 1.410606662e-26 constants[81] = 1.521032209e-3 constants[82] = 2.792847356 constants[83] = 5.585694713 constants[84] = -1.45989806 constants[85] = 1.410570419e-26 constants[86] = 1.520993128e-3 constants[87] = 2.792775598 constants[88] = 25.694e-6 constants[89] = 2.675222099e8 constants[90] = 2.675153362e8 constants[91] = 1.674927211e-27 constants[92] = 1838.6836605 constants[93] = 8.89248409 constants[94] = 0.528740 constants[95] = 1.00137841918 constants[96] = 1.00866491597e-3 constants[97] = 1.3195908951e-15 constants[98] = -0.96623641e-26 constants[99] = -1.04187563e-3 constants[100] = -1.91304273 constants[101] = -3.82608545 constants[102] = 1.04066882e-3 constants[103] = -0.68497934 constants[104] = -0.68499694 constants[105] = 1.83247185e8 constants[106] = 3.34358320e-27 constants[107] = 3670.4829654 constants[108] = 1.99900750108 constants[109] = 2.013553212724e-3 constants[110] = 2.1402e-15 constants[111] = 0.433073465e-26 constants[112] = -0.4669754556e-3 constants[113] = 0.8574382308 constants[114] = 0.8574382308 constants[115] = -4.664345537e-4 constants[116] = 0.3070122070 constants[117] = -0.44820652 constants[118] = 5.00735588e-27 constants[119] = 5496.9215269 constants[120] = 2.9937170309 constants[121] = 3.0155007134e-3 constants[122] = 1.504609361e-26 constants[123] = 1.622393657e-3 constants[124] = 2.978962448 constants[125] = 5.957924896 constants[126] = -1.620514423e-3 constants[127] = 1.066639908 constants[128] = -1.55718553 constants[129] = 5.00641192e-27 constants[130] = 5495.8852765 constants[131] = 2.9931526713 constants[132] = 3.0149322473e-3 constants[133] = -1.074552982e-26 constants[134] = -1.158671471e-3 constants[135] = -2.127497718 constants[136] = -0.761766558 constants[137] = -0.7617861313 constants[138] = 2.037894730e8 constants[139] = 6.64465620e-27 constants[140] = 7294.2995365 constants[141] = 3.97259968951 constants[142] = 4.001506179127e-3 constants[143] = 6.02214179e23 constants[144] = 1.660538782e-27 constants[145] = 96485.3399 constants[146] = 3.9903126821e-10 constants[147] = 8.314472 constants[148] = 1.3806504e-23 constants[149] = 22.413996e-3 constants[150] = -1.1648677 constants[151] = 5.670400e-8 constants[152] = 3.74177118e-16 constants[153] = 1.191042759e-16 constants[154] = 1.4387752e-2 constants[155] = 2.8977685e-3 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) 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)