def test_solve(self): # Create model and solver parameters. mp = solver.ModelParams() mp.k_on = 0 mp.k_off = 0 mp.t_cut = 1 sp = solver.SolverParams() sp.n = 100 sp.m = 10 # Define initial values. def const(x): return 1.0 # Initialise tracers. x = np.array(np.linspace(0, 1, num=5)) # Run solver. rho, ca, v, sigma, x, idx = solver.solve(mp, sp, const, const, x) # Check returned arrays. const_exp = np.vectorize(const)(np.zeros((sp.m + 1, sp.n))) np.testing.assert_equal(rho.shape, (sp.m + 1, sp.n)) np.testing.assert_equal(ca.shape, (sp.m + 1, sp.n)) np.testing.assert_allclose(rho, const_exp, atol=1e-7) np.testing.assert_allclose(ca, const_exp, atol=1e-7) np.testing.assert_allclose(v, np.zeros((sp.m + 1, sp.n + 1)), atol=1e-7)
'size': 30 } plt.rc('font', **font) plt.rc('text', usetex=True) # Set output quality. dpi = 100 # Set path where results are saved. resultpath = 'results/{0}'.format( datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')) if not os.path.exists(resultpath): os.makedirs(resultpath) # Create model and solver parameters. mp = solver.ModelParams() mp.eta = 1 mp.xi = 0.1 mp.chi = 1 mp.t_cut = 0 mp.k_on = 200 mp.k_off = 10 sp = solver.SolverParams() sp.n = 300 sp.m = 300 sp.T = 0.1 sp.dt = 2.5e-6 sp.delta = 1e-2