Пример #1
0
def J(t0, tof):
    ep1 = pk.epoch(t0)
    ep2 = pk.epoch(t0 + tof)
    r1, v1 = p1.eph(ep1)
    r2, v2 = p2.eph(ep2)
    resJ = []
    for lw in [False, True]:
        prob = pk.lambert_exposin(r1, r2, tof * pk.DAY2SEC, pk.MU_SUN, lw, n,
                                  k2)
        for i in range(prob.num_solutions()):
            exps = prob.get_exposins()[i]
            dv1 = Vector.mag(Vector.sub(prob.get_v1()[i], v1))
            dv2 = Vector.mag(Vector.sub(prob.get_v2()[i], v2))
            dvlt = exps.get_delta_v(pk.MU_SUN)
            resJ.append(1.0 - math.exp(-(dv1 + dv2) / 9.81 / isp_chem -
                                       dvlt / 9.81 / isp_lt))
    if len(resJ) == 0:
        return numpy.nan
    else:
        return numpy.nanmin(resJ)
Пример #2
0
Check the state vector of an exposin for discrepancies
'''
import PyKEP

earth = PyKEP.planet.jpl_lp('earth')
mars = PyKEP.planet.jpl_lp('mars')
k2 = 0.6
n = 1
t0 = 250.0
tof = 520.0
lw = True

r1, v1 = earth.eph(PyKEP.epoch(t0, "mjd2000"))
r2, v2 = mars.eph(PyKEP.epoch(t0 + tof, "mjd2000"))

prob = PyKEP.lambert_exposin(r1, r2, tof * PyKEP.DAY2SEC, PyKEP.MU_SUN, lw, n,
                             k2)
print prob
'''
To look for discrepancies in propagated state, we find v by propagation as well as the implemented analytical v
'''
import random
import Vector

exps = prob.get_exposins()[0]

# any random progress into the trajectory
rand_psi = random.uniform(0.0, exps.get_psi())
r, v, a = exps.get_state(rand_psi, PyKEP.MU_SUN)

# we take the angular variation of r using given v
dpsi = Vector.mag(Vector.scale(Vector.cross(r, v), 1.0 / Vector.mag(r)**2))