示例#1
0
 def test_vallado62(self):
     alt_i = 191.34411  # km
     alt_b = 503873  # km
     alt_f = 376310.0  # km
     k = k_earth.to(units.km ** 3 / units.s ** 2).value
     R = R_earth.to(units.km).value
     expected_dv = 3.904057  # km/s
     expected_t_trans = 593.919803  # h
     r_i = R + alt_i
     r_b = R + alt_b
     r_f = R + alt_f
     dva, dvb, dvc, _, _, t_trans1, t_trans2 = bielliptic(k, r_i, r_b, r_f)
     dv = abs(dva) + abs(dvb) + abs(dvc)
     t_trans = t_trans1 + t_trans2
     assert_almost_equal(dv, expected_dv, decimal=2)
     assert_almost_equal(t_trans / 3600, expected_t_trans, decimal=0)
v_i = 7.905  # km/s, immaterial

R = np.linspace(2, 75, num=1000)
Rstar = [15.58, 40, 60, 100, 200, np.inf]

hohmann_data = np.zeros_like(R)
bielliptic_data = np.zeros((len(R), len(Rstar)))

r_i = k_Earth / v_i ** 2
for ii, r in enumerate(R):
    r_f = r * r_i
    dva, dvb, _, _ = twobody.hohmann(k_Earth, r_i, r_f)
    hohmann_data[ii] = (abs(dva) + abs(dvb)) / v_i
    for jj, rstar in enumerate(Rstar):
        r_b = rstar * r_i
        dva, dvb, dvc, *_ = twobody.bielliptic(k_Earth, r_i, r_b, r_f)
        bielliptic_data[ii, jj] = (abs(dva) + abs(dvb) + abs(dvc)) / v_i

idx_max = np.argmax(hohmann_data)
hohmann_max = hohmann_data[idx_max]

ylims = (0.35, 0.6)

fig, ax = plt.subplots()

l, = ax.plot(R, hohmann_data, lw=2)
for jj in range(len(Rstar)):
    ax.plot(R, bielliptic_data[:, jj], color=l.get_color())
ax.vlines([11.94, R[idx_max]], *ylims, color='0.6')

if ZOOM: