Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to return DVs for pl2pl_N_impulses #165

Open
nh2 opened this issue Jan 3, 2023 · 0 comments
Open

Add functions to return DVs for pl2pl_N_impulses #165

nh2 opened this issue Jan 3, 2023 · 0 comments

Comments

@nh2
Copy link

nh2 commented Jan 3, 2023

Currently, the pl2pl_N_impulses chromosome -> DVs computation is inlined in the pretty() function in

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

def _compute_dvs(self, x: List[float]) -> Tuple[

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant