Example #1
0
def test_perapo2aecc_circular():
    r_per = 8000
    r_apo = r_per
    a_actual = r_per
    p_actual = r_per
    ecc_actual = 0
    a, p, ecc = kepler.perapo2aecc(r_per, r_apo)
    np.testing.assert_allclose((a, p, ecc), (a_actual, p_actual, ecc_actual))
Example #2
0
def test_planar_orbit_intersection():
    ecc1 = 0.75
    p1 = kepler.semilatus_rectum(4.5*constants.earth.radius, ecc1)
    a2, p2, ecc2 = kepler.perapo2aecc(2 * constants.earth.radius, 6 * constants.earth.radius)
    dargp = np.deg2rad(35)

    nu = maneuver.planar_conic_orbit_intersection(p1, p2, ecc1, ecc2, dargp)
    np.testing.assert_allclose(nu, np.deg2rad(110.342156))
Example #3
0
"""Problem 12 HW6 2017
"""
from astro import kepler, maneuver, constants
import numpy as np

r1 = 8000
r2 = 42160
i1 = np.deg2rad(30)
i2 = 0
mu = constants.earth.mu

# hohmann transfer and combined plane change at apoapsis
at, pt, et = kepler.perapo2aecc(r1, r2)
vt1 = maneuver.vel_mag(r1, at, mu)
vt2 = maneuver.vel_mag(r2, at, mu)
v1 = maneuver.vel_mag(r1, r1, mu)
v2 = maneuver.vel_mag(r2, r2, mu)

dv1, alpha1, beta1 = maneuver.delta_v_solve_planar(v1, vt1, 0, 0)
dv2, beta2, _ = maneuver.delta_v_solve_planar(vt2, v2, i1, 0)

print('Combined plane change at apoapsis')
print('V1 : {} , V2 : {} km/sec'.format(v1, v2))
print('VT1 : {} , VT2 : {} km/sec'.format(vt1, vt2))
print('DV1 : {} km/sec'.format(dv1))
print('DV2 : {} km/sec'.format(dv2))
print('Beta (outofplane) : {} deg'.format(np.rad2deg(beta2)))
Example #4
0
def test_perapo2aecc_semi_major_axis_mean():
    r_per = 10000
    r_apo = 20000
    a_actual = (r_per + r_apo) / 2
    a, _, _ = kepler.perapo2aecc(r_per, r_apo)
    np.testing.assert_allclose(a, a_actual)
Example #5
0
from astro import kepler, maneuver, constants 
import numpy as np

mu = constants.moon.mu
rm = constants.moon.radius
r1 = 100 + rm
r2 = 100 + rm
ri = 17000

delta_inc = np.pi/2

v1 = maneuver.vel_mag(r1, r1,  mu)
v2 = maneuver.vel_mag(r2, r2, mu)

# bielliptical transfer orbit
a_bi, p_bi, ecc_bi= kepler.perapo2aecc(r1, ri)

# simple plane change at current altitude
dv_current = maneuver.simple_plane_change(v1, delta_inc)

# first manuever
v1_bi = maneuver.vel_mag(r1, a_bi, mu)
dv1 = np.absolute(v1 - v1_bi)

# plane change at apoapsis of bielliptical transfer
v2_bi = maneuver.vel_mag(ri, a_bi, mu)
dv2 = maneuver.simple_plane_change(v2_bi, delta_inc)


# third maneuver circularize at same altitude in polar oribt
v3_bi = maneuver.vel_mag(r2, a_bi, mu)
Example #6
0
"""Bielliptical transfer Problem 10 HW6 2017
"""

from astro import kepler, maneuver, constants
import numpy as np

r1 = 8000
r2 = 120000
ri = 280000
mu = constants.earth.mu

v1 = maneuver.vel_mag(r1, r1, mu)
v2 = maneuver.vel_mag(r2, r2, mu)

# bielliptical transfer orbit
ab1, pb1, eccb1 = kepler.perapo2aecc(r1, ri)
ab2, pb2, eccb2 = kepler.perapo2aecc(r2, ri)

# first manuever
vb1 = maneuver.vel_mag(r1, ab1, mu)
dv1 = np.absolute(v1 - vb1)

# second manuever at intermediate radius
vb1i = maneuver.vel_mag(ri, ab1, mu)
vb2i = maneuver.vel_mag(ri, ab2, mu)

dv2 = np.absolute(vb2i - vb1i)

# third maneuver
vb2 = maneuver.vel_mag(r2, ab2, mu)
dv3 = np.absolute(v2 - vb2)
Example #7
0
import pdb
ra = 7000
rb = 14000
mu = constants.earth.mu

# define hyperbolic arrival orbit
va1 = 12
e_h = va1**2 / 2 - mu / ra
a_h = -mu / e_h / 2
ecc_h = ra / np.absolute(a_h) + 1
p_h = kepler.semilatus_rectum(np.absolute(a_h), ecc_h)
nu_h = 0

# hohmann transfer from hyperbolic orbit to circular orbit rb
a_t, p_t, ecc_t = kepler.perapo2aecc(ra, rb)
vt1 = maneuver.vel_mag(ra, a_t, mu)
dva1, _, toft, phaset = maneuver.hohmann(ra, rb, ecc_h, 0, 0, 0, mu)

# final orbit mean motion
n2 = np.sqrt(mu / rb**3)
angle = n2 * toft
p2 = 2 * np.pi * np.sqrt(rb**3 / mu)

phasing_period = p2 - toft

# design of phasing orbit
a_p = kepler.period2sma(phasing_period, mu)
rc = a_p * 2 - rb
a_p, p_p, ecc_p = kepler.perapo2aecc(rc, rb)
Example #8
0
"""Problem 9 HW6 2017
"""
from astro import maneuver, kepler, constants
import numpy as np

ra = 25000
rb = 40000
rc = 10000
rd = 55000

mu = constants.earth.mu
# orbit 1 properties
a1, p1, ecc1 = kepler.perapo2aecc(ra, rb)
va1 = maneuver.vel_mag(ra, a1, mu)
vb1 = maneuver.vel_mag(rb, a1, mu)

# orbit 2 properties
a2, p2, ecc2 = kepler.perapo2aecc(rc, rd)
vc2 = maneuver.vel_mag(rc, a2, mu)
vd2 = maneuver.vel_mag(rd, a2, mu)

# A to C Hohmann trasnfer
at1, pt1, ecct1 = kepler.perapo2aecc(rc, ra)
vat = maneuver.vel_mag(ra, at1, mu)
vct = maneuver.vel_mag(rc, at1, mu)

dv1, dv2, tof1, _ = maneuver.hohmann(ra, rc, ecc1, ecc2, 0, 0, mu)
dvt1 = np.absolute(dv1) + np.absolute(dv2)

print('A to C hohmann transfer')
print('Semimajor axis : {} km'.format(at1))
Example #9
0
"""Solve problem 2

"""

from astro import kepler, constants
import numpy as np

mu = constants.earth.mu
r_per = 7000  # km
r_apo = 70000 # km

a, p, ecc = kepler.perapo2aecc(r_per, r_apo)
print('a : {} km, p : {} km, ecc : {}'.format(a, p, ecc))

period = 2 * np.pi * np.sqrt(a**3/mu)
print('period : {} sec'.format(period))

energy = - mu / 2 / a
print('energy : {} km^2/sec^2'.format(energy))

r = 1000 + constants.earth.radius
theta = np.arccos(p / r / ecc - 1 / ecc)
print('nu : +- {} deg'.format(np.rad2deg(theta)))
def velocity(p, ecc, mu, nu):
    vr = np.sqrt(mu/ p) * ecc * np.sin(nu)
    vtheta = np.sqrt(mu/p) * ( 1 + ecc * np.cos(nu))
    return vr, vtheta

vr1, vtheta1 = velocity(p, ecc, mu, theta)
vr2, vtheta2 = velocity(p, ecc, mu, -theta)
Example #10
0
# true anoamaly at altitude
nu_1 = kepler.nu_solve(p_h, ecc_h, r_high)
nu_1 = np.array(nu_1)
nu_1 = nu_1[nu_1 < 0][0]
# true anomaly at surface
nu_2 = kepler.nu_solve(p_h, ecc_h, re)
nu_2 = np.array(nu_2)
nu_2 = nu_2[nu_2 < 0][0]
# tof between the two
tof_h = kepler.tof_nu(p_h, ecc_h, nu_1, nu_2, mu)

print("TOF of {} sec from {} deg to {} deg".format(tof_h, np.rad2deg(nu_1),
                                                   np.rad2deg(nu_2)))

# time of flight for elliptical orbit
a_e, p_e, ecc_e = kepler.perapo2aecc(rp, ra)

nu_1 = kepler.nu_solve(p_e, ecc_e, re)
nu_1 = np.array(nu_1)
nu_1 = nu_1[nu_1 > 0][0]

nu_2 = np.deg2rad(180)

tof_e = kepler.tof_nu(p_e, ecc_e, nu_1, nu_2, mu)
print("TOF of {} sec from {} deg to {} deg".format(tof_e[0], np.rad2deg(nu_1),
                                                   np.rad2deg(nu_2)))

# velocity at intercept

# hyperbolic velocity at missile apogee
sme_h = -mu / 2 / a_h