def f(t0, u_, k):
     du_kep = func_twobody(t0, u_, k)
     ax, ay, az = radiation_pressure(
         t0,
         u_,
         k,
         R=Earth.R.to(u.km).value,
         C_R=2.0,
         A_over_m=2e-4 / 100,
         Wdivc_s=Wdivc_sun.value,
         star=sun_normalized,
     )
     du_ad = np.array([0, 0, 0, ax, ay, az])
     return du_kep + du_ad
示例#2
0
def a_d(t0, state, k, perturbations: Dict):
    """
    Custom perturbation function that is passed directly to poliastro to be executed in their code, hence the need for
    summation() to be included within. Current structure allows user to pick and chose which perturbations they would
    like to include, requiring that the desired perturbation objects are created, filled, and passed.

    Note: To improve upon existing perturbation functions or to add more, everything must be self-contained within the
    function.

    :param t0: Required by poliastro
    :param state: Required by poliastro
    :param k: Required by poliastro (gravitational parameter-mu)
    :param perturbations: Dictionary of perturbations desired by the user. Keys correspond to the perturbations Enum
    class in Enum.py, while values correspond to objects in the dto.py class.
    :return: Returns a force that describes the impact of all desired perturbations
    """
    fun = []
    if Perturbations.J2 in perturbations:
        perturbation = perturbations.get(Perturbations.J2)
        fun.append(J2_perturbation(t0, state, k, perturbation.J2, perturbation.R))
    if Perturbations.Drag in perturbations:
        perturbation = perturbations.get(Perturbations.Drag)
        fun.append(atmospheric_drag(t0, state, k, perturbation.R, perturbation.C_D, perturbation.A, perturbation.m,
                                    perturbation.H0, perturbation.rho0))
    if Perturbations.J3 in perturbations:
        perturbation = perturbations.get(Perturbations.J3)
        fun.append(J3_perturbation(t0, state, k, perturbation.J3, perturbation.R))
    if Perturbations.SRP in perturbations:
        perturbation = perturbations.get(Perturbations.SRP)
        fun.append(radiation_pressure(t0, state, k, perturbation.R, perturbation.C_R, perturbation.A, perturbation.m,
                                      perturbation.Wdivc_s, perturbation.star))
    if Perturbations.Moon in perturbations:
        perturbation = perturbations.get(Perturbations.Moon)
        fun.append(third_body(t0, state, k, perturbation.k_third, perturbation.third_body))
    if Perturbations.Sun in perturbations:
        perturbation = perturbations.get(Perturbations.Sun)
        fun.append(third_body(t0, state, k, perturbation.k_third, perturbation.third_body))

    def summation(arr):
        if len(arr) == 0:
            return np.zeros(3)
        output = arr[0]
        for i in range(1, len(arr)):
            output += arr[i]
        return output

    return summation(fun)