def test_energy(data): print("\n test energy") E_ini = E_kin(data["vel_0"], data["mass"]) E_end = E_kin(data["vel"], data["mass"]) assert E_ini == E_end
def test_energy_hypothesis(mass1, mass2): # initial condition and simulation parameters domain = ([0, 20], [0, 20]) dt = 0.5 t_max = 6 loc_0 = np.array([[3, 4], [15, 2]]) vel_0 = np.array([[1, 0.5], [-1, -.25]]) radius = 1 # mass chosen by hypothesis mass = [mass1, mass2] # run the simulation loc, vel = sim2d.simulation(t_max, dt, mass, radius, loc_0, vel_0, domain) E_ini = E_kin(vel_0, mass) E_end = E_kin(vel, mass) print("testing for mass = {}. E_ini= {}. E_end = {}".format( mass, E_ini, E_end)) pass
def test_collision_2d_en(): v1_i, v2_i = [3, 1], [1, -2] m1, m2 = 1, 2 v1_f, v2_f = ec.collision_2d(v1=v1_i, v2=v2_i, r12=[0, 1], m1=m1, m2=m2) assert E_kin([v1_i,v2_i], [m1, m2]) == E_kin([v1_f,v2_f], [m1, m2])
def test_collision_1d_en(): v1_i, v2_i = 1, -2 m1, m2 = 1, 3 v1_f, v2_f = ec.collision_1d(v1_i, v2_i, m1, m2) assert E_kin([v1_i, v2_i], [m1, m2]) == E_kin([v1_f, v2_f], [m1, m2])