Ejemplo n.º 1
0
def _dv_mga(pl1,
            pl2,
            tof,
            max_revs,
            rvt_outs,
            rvt_ins,
            rvt_pls,
            dvs,
            lps=None):
    rvt_pl = rvt_pls[-1]  # current planet
    v_in = rvt_pl._v if rvt_ins[-1] is None else rvt_ins[-1]._v
    rvt_pl2 = rvt_planet(pl2, rvt_pl._t + tof)
    rvt_pls.append(rvt_pl2)
    r = rvt_pl._r
    vpl = rvt_pl._v
    r2 = rvt_pl2._r
    lp = lambert_problem(r, r2, tof, rvt_pl._mu, False, max_revs)
    lp = lambert_problem_multirev_ga(v_in, lp, pl1, vpl)
    if not lps is None:
        lps.append(lp)
    v_out = lp.get_v1()[0]
    rvt_out = rvt(r, v_out, rvt_pl._t, rvt_pl._mu)
    rvt_outs.append(rvt_out)
    rvt_in = rvt(r2, lp.get_v2()[0], rvt_pl._t + tof, rvt_pl._mu)
    rvt_ins.append(rvt_in)
    vr_in = [a - b for a, b in zip(v_in, vpl)]
    vr_out = [a - b for a, b in zip(v_out, vpl)]
    dv = fb_vel(vr_in, vr_out, pl1)
    dvs.append(dv)
Ejemplo n.º 2
0
    def _compute_dvs(self, x: List[float]) -> Tuple[
            float,  # DVlaunch
            List[float],  # DVs
            float,  # DVarrival,
            List[Any],  # Lambert legs
            float,  #DVlaunch_tot
            List[float],  # T
            List[Tuple[List[float], List[float]]],  # ballistic legs
            List[float],  # epochs of ballistic legs
    ]:
        # 1 -  we 'decode' the times of flights and compute epochs (mjd2000)
        T: List[float] = self._decode_tofs(x)  # [T1, T2 ...]
        ep = np.insert(T, 0, x[0])  # [t0, T1, T2 ...]
        ep = np.cumsum(ep)  # [t0, t1, t2, ...]
        # 2 - we compute the ephemerides
        r = [0] * len(self.seq)
        v = [0] * len(self.seq)
        for i in range(len(self.seq)):
            r[i], v[i] = self.seq[i].eph(float(ep[i]))

        l = list()
        ballistic_legs: List[Tuple[List[float], List[float]]] = []
        ballistic_ep: List[float] = []

        # 3 - we solve the lambert problems
        vi = v[0]
        for i in range(self._n_legs):
            lp = lambert_problem_multirev(
                vi,
                lambert_problem(r[i], r[i + 1], T[i] * DAY2SEC,
                                self._common_mu, False, self.max_revs))
            l.append(lp)
            vi = lp.get_v2()[0]
            ballistic_legs.append((r[i], lp.get_v1()[0]))
            ballistic_ep.append(ep[i])
        # 4 - we compute the various dVs needed at fly-bys to match incoming
        # and outcoming
        DVfb = list()
        for i in range(len(l) - 1):
            vin = [a - b for a, b in zip(l[i].get_v2()[0], v[i + 1])]
            vout = [a - b for a, b in zip(l[i + 1].get_v1()[0], v[i + 1])]
            DVfb.append(fb_vel(vin, vout, self.seq[i + 1]))
        # 5 - we add the departure and arrival dVs
        DVlaunch_tot = np.linalg.norm(
            [a - b for a, b in zip(v[0], l[0].get_v1()[0])])
        DVlaunch = max(0, DVlaunch_tot - self.vinf)
        DVarrival = np.linalg.norm(
            [a - b for a, b in zip(v[-1], l[-1].get_v2()[0])])
        if self.orbit_insertion:
            # In this case we compute the insertion DV as a single pericenter
            # burn
            DVper = np.sqrt(DVarrival * DVarrival +
                            2 * self.seq[-1].mu_self / self.rp_target)
            DVper2 = np.sqrt(2 * self.seq[-1].mu_self / self.rp_target -
                             self.seq[-1].mu_self / self.rp_target *
                             (1. - self.e_target))
            DVarrival = np.abs(DVper - DVper2)
        return (DVlaunch, DVfb, DVarrival, l, DVlaunch_tot, T, ballistic_legs,
                ballistic_ep)
Ejemplo n.º 3
0
 def _compute_dvs(self, x):
     # 1 -  we 'decode' the times of flights and compute epochs (mjd2000)
     T = self._decode_tofs(x)  # [T1, T2 ...]
     ep = np.insert(T, 0, x[0])  # [t0, T1, T2 ...]
     ep = np.cumsum(ep)  # [t0, t1, t2, ...]
     # 2 - we compute the ephemerides
     r = [0] * len(self.seq)
     v = [0] * len(self.seq)
     for i in range(len(self.seq)):
         r[i], v[i] = self.seq[i].eph(ep[i])
     # 3 - we solve the lambert problems
     l = list()
     for i in range(self._n_legs):
         l.append(
             lambert_problem(r[i], r[i + 1], T[i] * DAY2SEC,
                             self._common_mu, False, 0))
     # 4 - we compute the various dVs needed at fly-bys to match incoming
     # and outcoming
     DVfb = list()
     for i in range(len(l) - 1):
         vin = [a - b for a, b in zip(l[i].get_v2()[0], v[i + 1])]
         vout = [a - b for a, b in zip(l[i + 1].get_v1()[0], v[i + 1])]
         DVfb.append(fb_vel(vin, vout, self.seq[i + 1]))
     # 5 - we add the departure and arrival dVs
     DVlaunch_tot = np.linalg.norm(
         [a - b for a, b in zip(v[0], l[0].get_v1()[0])])
     DVlaunch = max(0, DVlaunch_tot - self.vinf)
     DVarrival = np.linalg.norm(
         [a - b for a, b in zip(v[-1], l[-1].get_v2()[0])])
     if self.orbit_insertion:
         # In this case we compute the insertion DV as a single pericenter
         # burn
         DVper = np.sqrt(DVarrival * DVarrival +
                         2 * self.seq[-1].mu_self / self.rp_target)
         DVper2 = np.sqrt(2 * self.seq[-1].mu_self / self.rp_target -
                          self.seq[-1].mu_self / self.rp_target *
                          (1. - self.e_target))
         DVarrival = np.abs(DVper - DVper2)
     return (DVlaunch, DVfb, DVarrival, l, DVlaunch_tot)