def test_calculate_b(self): a = 1.0 e = 0.0 self.assertEqual(cde.calculate_b(a, e), a) a = 2.0 e = np.sqrt(.75) #This is off to machine precision. self.assertTrue(abs(cde.calculate_b(a, e) - 1.0) < 10**-9)
def test_calculate_b(self): a = 1.0 e = 0.0 self.assertEqual(cde.calculate_b(a, e), a) a = 2.0 e = np.sqrt(.75) #This is off to machine precision. self.assertTrue(abs(cde.calculate_b(a, e) - 1.0) < 10 ** -9)
def test_calculate_orbit(self): halleys_aphelion = 36.1 * cde.AU halleys_perhelion = 0.586 * cde.AU halleys_a = 17.8 * cde.AU halleys_e = 0.967 halleys_period = 75.3 * cde.year halleys_b = cde.calculate_b(halleys_a, halleys_e) halleys_area = np.pi * halleys_a * halleys_b halleys_area_over_time = halleys_area / halleys_period # .5 * r * r * thetadot = area_over_time #thetadot = 2.0 * area_over_time / r^2 v0 = 2.0 * halleys_area_over_time / halleys_aphelion #@ max distance l_over_m = v0 * halleys_aphelion print 'first L: ', l_over_m start_pos = np.array([halleys_aphelion, 0.0]) start_vel = np.array([0.0, v0]) start_coords = np.array([start_pos, start_vel]).T dt = 1.0 * 60 * 60 * 24 # 1 day pos_record = cde.calculate_orbit(start_coords, dt, expected_period=halleys_period) pos_diff = pos_record[-1] - pos_record[0] print pos_diff / pos_record[0][0]