API Refactor: Hohmann - poliastro/poliastro GitHub Wiki
These are the notes I took while thinking about the refactoring of the API. In this case, computing a simple Hohmann transfer.
Vallado, example 6.1.
- Attractor = Earth
- Initial altitude = 191.34411 km
- Final altitude = 35781.34857
Find out: cost (delta v), time of flight
Refs
- [Hohmann] http://en.wikipedia.org/wiki/Hohmann_transfer_orbit
- [IPython] http://nbviewer.ipython.org/github/ipython/ipython/blob/master/examples/notebooks/Custom%20Display%20Logic.ipynb
from poliastro import *
initial = State.circular(Earth, alt=191.34411 * u.km)
# OOP (safe) API
maneuver = Maneuver.hohmann(initial, alt=35781.34857 * u.km)
print(maneuver.total_cost, maneuver.time_of_flight)
print(maneuver) # Nice printing of all the information?
# Procedural (unsafe) API
from poliastro import maneuver
R_i = Earth.R + 191.34411 * u.km
R_f = Earth.R + 35781.34857 * u.km
res_hohmann = maneuver.compute_hohmann(Earth.k, R_i, R_f) # This ain't a Maneuver
print(res_hohmann)