def test_diff_equation_exponential_euler(self): eq = DifferentialEquation('dy/dt = 0+(1)*y : float') eq.select("Exponential Euler") y, t,dt = 1.0, 1.0, 0.01 for i in range(int(t/dt)): y = eq.evaluate(y, dt) assert abs(y-np.exp(1)) < 0.0001
def test_diff_equation_runge_kutta_2(self): eq = DifferentialEquation('dy/dt = y : float') eq.select("Runge Kutta 2") y, t,dt = 1.0, 1.0, 0.001 for i in range(int(t/dt)): y = eq.evaluate(y, dt) assert abs(y-np.exp(1)) < 0.0001
def test(): eq = DifferentialEquation('y=1') self.assertRaises(DifferentialEquationError,test)
def test_exponential_form_3(self): eq = DifferentialEquation('dy/dt = (1.3)*y') assert eq._A_string == '0' assert eq._B_string == '-1.3'
def test_exponential_form_1(self): eq = DifferentialEquation('dy/dt = 1.2+(3.4)*y') assert eq._A_string == '1.2' assert eq._B_string == '-3.4'
def test_standard_form_4(self): eq = DifferentialEquation('dy/dt = 1.2+(3.4)*y') assert eq._varname == 'y' assert eq._dtype == 'float'
def test_standard_form_3(self): eq = DifferentialEquation('dy/dt = 1.0 : int') assert eq._varname == 'y' assert eq._dtype == 'int'