FieldSDP4.java

  1. /* Copyright 2002-2022 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.propagation.analytical.tle;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.util.FastMath;
  20. import org.hipparchus.util.FieldSinCos;
  21. import org.hipparchus.util.MathUtils;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.frames.Frame;
  24. import org.orekit.time.DateTimeComponents;
  25. import org.orekit.time.FieldAbsoluteDate;
  26. import org.orekit.utils.Constants;

  27. /** This class contains methods to compute propagated coordinates with the SDP4 model.
  28.  * <p>
  29.  * The user should not bother in this class since it is handled internally by the
  30.  * {@link TLEPropagator}.
  31.  * </p>
  32.  * <p>This implementation is largely inspired from the paper and source code <a
  33.  * href="https://www.celestrak.com/publications/AIAA/2006-6753/">Revisiting Spacetrack
  34.  * Report #3</a> and is fully compliant with its results and tests cases.</p>
  35.  * @author Felix R. Hoots, Ronald L. Roehrich, December 1980 (original fortran)
  36.  * @author David A. Vallado, Paul Crawford, Richard Hujsak, T.S. Kelso (C++ translation and improvements)
  37.  * @author Fabien Maussion (java translation)
  38.  * @author Thomas Paulet (field translation)
  39.  * @since 11.0
  40.  */
  41. abstract class FieldSDP4<T extends CalculusFieldElement<T>>  extends FieldTLEPropagator<T> {

  42.     // CHECKSTYLE: stop VisibilityModifier check

  43.     /** New perigee argument. */
  44.     protected T omgadf;

  45.     /** New mean motion. */
  46.     protected T xn;

  47.     /** Parameter for xl computation. */
  48.     protected T xll;

  49.     /** New eccentricity. */
  50.     protected T em;

  51.     /** New inclination. */
  52.     protected T xinc;

  53.     // CHECKSTYLE: resume VisibilityModifier check

  54.     /** Constructor for a unique initial TLE.
  55.      * @param initialTLE the TLE to propagate.
  56.      * @param attitudeProvider provider for attitude computation
  57.      * @param mass spacecraft mass (kg)
  58.      * @param teme the TEME frame to use for propagation.
  59.      * @param parameters SGP4 and SDP4 model parameters
  60.      */
  61.     protected FieldSDP4(final FieldTLE<T> initialTLE,
  62.                    final AttitudeProvider attitudeProvider,
  63.                    final T mass,
  64.                    final Frame teme,
  65.                    final T[] parameters) {
  66.         super(initialTLE, attitudeProvider, mass, teme, parameters);
  67.     }

  68.     /** Initialization proper to each propagator (SGP or SDP).
  69.      * @param parameters model parameters
  70.      */
  71.     protected void sxpInitialize(final T[] parameters) {
  72.         luniSolarTermsComputation();
  73.     }  // End of initialization

  74.     /** Propagation proper to each propagator (SGP or SDP).
  75.      * @param tSince the offset from initial epoch (minutes)
  76.      * @param parameters model parameters
  77.      */
  78.     protected void sxpPropagate(final T tSince, final T[] parameters) {

  79.         // Update for secular gravity and atmospheric drag
  80.         final T bStar = parameters[0];
  81.         omgadf = tle.getPerigeeArgument().add(omgdot.multiply(tSince));
  82.         final T xnoddf = tle.getRaan().add(xnodot.multiply(tSince));
  83.         final T tSinceSq = tSince.multiply(tSince);
  84.         xnode = xnoddf.add(xnodcf.multiply(tSinceSq));
  85.         xn = xn0dp;

  86.         // Update for deep-space secular effects
  87.         xll = tle.getMeanAnomaly().add(xmdot.multiply(tSince));

  88.         deepSecularEffects(tSince);

  89.         final T tempa = c1.multiply(tSince).negate().add(1.0);
  90.         a  = xn.reciprocal().multiply(TLEConstants.XKE).pow(TLEConstants.TWO_THIRD).multiply(tempa).multiply(tempa);
  91.         em = em.subtract(bStar.multiply(c4).multiply(tSince));

  92.         // Update for deep-space periodic effects
  93.         xll = xll.add(xn0dp.multiply(t2cof).multiply(tSinceSq));

  94.         deepPeriodicEffects(tSince);

  95.         xl = xll.add(omgadf).add(xnode);

  96.         // Dundee change:  Reset cosio,  sinio for new xinc:
  97.         final FieldSinCos<T> scI0 = FastMath.sinCos(xinc);
  98.         cosi0 = scI0.cos();
  99.         sini0 = scI0.sin();
  100.         e = em;
  101.         i = xinc;
  102.         omega = omgadf;
  103.         // end of calculus, go for PV computation
  104.     }

  105.     /** Computes SPACETRACK#3 compliant earth rotation angle.
  106.      * @param date the current date
  107.      * @return the ERA (rad)
  108.      */
  109.     protected double thetaG(final FieldAbsoluteDate<T> date) {

  110.         // Reference:  The 1992 Astronomical Almanac, page B6.
  111.         final double omega_E = 1.00273790934;
  112.         final double jd = date
  113.                 .getComponents(utc)
  114.                 .offsetFrom(DateTimeComponents.JULIAN_EPOCH) /
  115.                 Constants.JULIAN_DAY;

  116.         // Earth rotations per sidereal day (non-constant)
  117.         final double UT = (jd + 0.5) % 1;
  118.         final double seconds_per_day = Constants.JULIAN_DAY;
  119.         final double jd_2000 = 2451545.0;   /* 1.5 Jan 2000 = JD 2451545. */
  120.         final double t_cen = (jd - UT - jd_2000) / 36525.;
  121.         double GMST = 24110.54841 +
  122.                       t_cen * (8640184.812866 + t_cen * (0.093104 - t_cen * 6.2E-6));
  123.         GMST = (GMST + seconds_per_day * omega_E * UT) % seconds_per_day;
  124.         if (GMST < 0.) {
  125.             GMST += seconds_per_day;
  126.         }

  127.         return MathUtils.TWO_PI * GMST / seconds_per_day;

  128.     }

  129.     /** Computes luni - solar terms from initial coordinates and epoch.
  130.      */
  131.     protected abstract void luniSolarTermsComputation();

  132.     /** Computes secular terms from current coordinates and epoch.
  133.      * @param t offset from initial epoch (min)
  134.      */
  135.     protected abstract void deepSecularEffects(T t);

  136.     /** Computes periodic terms from current coordinates and epoch.
  137.      * @param t offset from initial epoch (min)
  138.      */
  139.     protected abstract void deepPeriodicEffects(T t);

  140. }