Example #1
0
 def test_verbose(self):
     solver = CupSodaSimulator(model, tspan=self.tspan, verbose=True,
                               vol=1e-5,
                               integrator_options={'atol': 1e-12,
                                                   'rtol': 1e-12,
                                                   'max_steps': 20000})
     solver.run()
Example #2
0
 def test_multi_chunks(self):
     sim = CupSodaSimulator(model,
                            tspan=self.tspan,
                            verbose=False,
                            initials=self.y0,
                            integrator_options={
                                'atol': 1e-12,
                                'rtol': 1e-12,
                                'chunksize': 25,
                                'max_steps': 20000
                            })
     res = sim.run()
     assert res.nsims == self.n_sims
Example #3
0
 def setUp(self):
     self.n_sims = 50
     self.tspan = np.linspace(0, 500, 101)
     self.solver = CupSodaSimulator(model, tspan=self.tspan, verbose=False,
                                    integrator_options={'atol': 1e-12,
                                                        'rtol': 1e-12,
                                                        'max_steps': 20000})
     len_model_species = len(model.species)
     y0 = np.zeros((self.n_sims, len_model_species))
     for ic in model.initial_conditions:
         for j in range(len_model_species):
             if str(ic[0]) == str(model.species[j]):
                 y0[:, j] = ic[1].value
                 break
     self.y0 = y0
Example #4
0
def run():
    n_sims = 100
    vol = model.parameters['vol'].value
    tspan = np.linspace(0, 500, 501)
    sim = CupSodaSimulator(model,
                           tspan,
                           vol=vol,
                           verbose=True,
                           integrator_options={
                               'atol': 1e-12,
                               'rtol': 1e-6,
                               'max_steps': 20000
                           })

    # Rate constants
    param_values = np.ones((n_sims, len(model.parameters)))
    for i in range(len(param_values)):
        for j in range(len(param_values[i])):
            param_values[i][j] *= model.parameters[j].value

    # Initial concentrations
    initials = np.zeros((n_sims, len(model.species)))
    for i in range(len(initials)):
        for ic in model.initial_conditions:
            for j in range(len(initials[i])):
                if str(ic[0]) == str(model.species[j]):
                    initials[i][j] = ic[1].value
                    break

    x = sim.run(initials=initials, param_values=param_values)

    # Plot results of the first simulation
    t = x.tout[0]
    plt.plot(t, x.all[0]['CT'], lw=2, label='CT')  # should be constant
    plt.plot(t, x.all[0]['YT'], lw=2, label='YT')
    plt.plot(t, x.all[0]['M'], lw=2, label='M')

    plt.xlabel('time')
    plt.ylabel('population')
    plt.legend(loc=0)

    plt.show()
 def test_invalid_integrator_option(self):
     CupSodaSimulator(model,
                      tspan=self.tspan,
                      integrator_options={'spam': 'eggs'})
 def test_invalid_init_kwarg(self):
     CupSodaSimulator(model, tspan=self.tspan, spam='eggs')
Example #7
0
#    repeated_parameter_values[:, idx] = sample_lognormal(par, size=samples)
# np.save('earm_diff_IC_par0.npy', repeated_parameter_values)

repeated_parameter_values = np.load('earm_diff_IC_par0.npy')
rate_params = model.parameters_rules()
rate_idxs = [idx for idx, p in enumerate(model.parameters) if p in rate_params]
for par_idx in rate_idxs:
    repeated_parameter_values[:, par_idx] = par_clus4[par_idx]

t = np.linspace(0, 20000, 100)

vol = 1e-19
integrator_opt = {'rtol': 1e-6, 'atol': 1e-6, 'mxsteps': 20000}
sims = CupSodaSimulator(model,
                        tspan=t,
                        obs_species_only=False,
                        gpu=0,
                        memory_usage='shared_constant',
                        vol=vol,
                        integrator_options=integrator_opt).run(
                            param_values=repeated_parameter_values)
sims.save('earm_cupsoda_sims_ic_par1.h5')

signatures = run_tropical_multi(model=model,
                                simulations=sims,
                                cpu_cores=30,
                                verbose=True)

with open('earm_signatures_ic_par1.pickle', 'wb') as handle:
    pickle.dump(signatures, handle, protocol=pickle.HIGHEST_PROTOCOL)