class TestLorenzEquation(unittest.TestCase): def setUp(self): self.ode = LorenzEquation() self.solver = ODESolver(ode=self.ode) self.solver.initial_state = [10., 50., 50.] def test_eval(self): dX = self.ode.eval(self.solver.initial_state, 0.0) self.assertAlmostEqual(dX[0], 400) self.assertAlmostEqual(dX[1], -270) self.assertAlmostEqual(dX[2], 1100 / 3.) def test_solve(self): soln = self.solver.solution[1, :] self.assertAlmostEqual(soln[0], 13.65484958) self.assertAlmostEqual(soln[1], 46.64090341) self.assertAlmostEqual(soln[2], 54.35797299)
def setUp(self): self.ode = LorenzEquation() self.solver = ODESolver(ode=self.ode) self.solver.initial_state = [10., 50., 50.] self.solver.t = numpy.linspace(0, 10, 1001)
def setUp(self): self.ode = LorenzEquation() self.solver = ODESolver(ode=self.ode) self.solver.initial_state = [10., 50., 50.]
def _plot_default(self): self._set_arr(self.index_name, 'index') self._set_arr(self.value_name, 'value') plot = Plot(self.pd) plot.tools.append(TraitsTool(component=plot)) plot.tools.append(ZoomTool(component=plot)) plot.tools.append(PanTool(component=plot)) plot.x_axis.title = self.index_name plot.y_axis.title = self.value_name plot.plot(('index', 'value')) return plot def _index_name_default(self): return self.name_list[0] def _value_name_default(self): return self.name_list[-1] if __name__ == '__main__': from ode import EpidemicODE, LorenzEquation, GenericODE import numpy ode = EpidemicODE() ode = LorenzEquation() ode.configure_traits() solver = ODESolver(ode=ode, initial_state=[10., 50., 50.], t=numpy.linspace(0, 10, 1001)) plot = ODEPlot(solver=solver) plot.configure_traits()