-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Currently, the pl2pl_N_impulses
chromosome -> DVs
computation is inlined in the pretty()
function in
pykep/pykep/trajopt/_pl2pl_N_impulses.py
Lines 234 to 283 in 6425e53
def pretty(self, x): | |
# 1 - we 'decode' the chromosome recording the various deep space | |
# maneuvers timing (days) in the list T | |
T = list([0] * (self.N_max - 1)) | |
for i in range(len(T)): | |
T[i] = log(x[2 + 4 * i]) | |
total = sum(T) | |
T = [x[1] * time / total for time in T] | |
# 2 - We compute the starting and ending position | |
r_start, v_start = self.start.eph(epoch(x[0])) | |
if self.phase_free: | |
r_target, v_target = self.target.eph(epoch(x[-1])) | |
else: | |
r_target, v_target = self.target.eph(epoch(x[0] + x[1])) | |
# 3 - We loop across inner impulses | |
rsc = r_start | |
vsc = v_start | |
for i, time in enumerate(T[:-1]): | |
theta = 2 * pi * x[3 + 4 * i] | |
phi = acos(2 * x[4 + 4 * i] - 1) - pi / 2 | |
Vinfx = x[5 + 4 * i] * cos(phi) * cos(theta) | |
Vinfy = x[5 + 4 * i] * cos(phi) * sin(theta) | |
Vinfz = x[5 + 4 * i] * sin(phi) | |
# We apply the (i+1)-th impulse | |
vsc = [a + b for a, b in zip(vsc, [Vinfx, Vinfy, Vinfz])] | |
rsc, vsc = propagate_lagrangian( | |
rsc, vsc, T[i] * DAY2SEC, self.__common_mu) | |
cw = (ic2par(rsc, vsc, self.start.mu_central_body)[2] > pi / 2) | |
# We now compute the remaining two final impulses | |
# Lambert arc to reach seq[1] | |
dt = T[-1] * DAY2SEC | |
l = lambert_problem(rsc, r_target, dt, self.__common_mu, cw, False) | |
v_end_l = l.get_v2()[0] | |
v_beg_l = l.get_v1()[0] | |
DV1 = norm([a - b for a, b in zip(v_beg_l, vsc)]) | |
DV2 = norm([a - b for a, b in zip(v_end_l, v_target)]) | |
DV_others = list(x[5::4]) | |
DV_others.extend([DV1, DV2]) | |
print("Total DV (m/s): ", sum(DV_others)) | |
print("Dvs (m/s): ", DV_others) | |
print("Tofs (days): ", T) |
This makes it inconvenient to get those values out.
It would be nice to get them directly via the API, similar to
Line 247 in 6425e53
def _compute_dvs(self, x: List[float]) -> Tuple[ |
Metadata
Metadata
Assignees
Labels
No labels