def test_solver(): dt = 0.1; T = 100; m = 0.43; g = 9.81; rho = 1000; mu = 0.00089; r = 11; CD = 0.45 plot = False v, t = mod.solver(dt, T, m, g, rho, mu, r, CD, False) t_e = np.linspace(0, 100, 1001) v_e = mod.exact_solution_neg_drag(t_e, m, g, rho, mu, r) if (plot): import matplotlib.pyplot as plt plt.plot(t, v, 'b--o') plt.plot(t_e, v_e, 'b-') plt.hold("on") plt.xlabel("t") plt.ylabel("v") plt.show() difference = abs(v_e - v).max() tol = 1.0 success = difference <= tol assert success == True
def test_solver(): dt = 0.1 T = 100 m = 0.43 g = 9.81 rho = 1000 mu = 0.00089 r = 11 CD = 0.45 plot = False v, t = mod.solver(dt, T, m, g, rho, mu, r, CD, False) t_e = np.linspace(0, 100, 1001) v_e = mod.exact_solution_neg_drag(t_e, m, g, rho, mu, r) if (plot): import matplotlib.pyplot as plt plt.plot(t, v, 'b--o') plt.plot(t_e, v_e, 'b-') plt.hold("on") plt.xlabel("t") plt.ylabel("v") plt.show() difference = abs(v_e - v).max() tol = 1.0 success = difference <= tol assert success == True
def solve(self): from vertical_motion_mod import solver self.v, self.t = solver(self.dt, self.T, self.problem.m, self.problem.g, self.problem.rho, self.problem.mu, self.problem.r, self.problem.CD)