SDP4.java

  1. /* Copyright 2002-2025 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.util.FastMath;
  19. import org.hipparchus.util.MathUtils;
  20. import org.hipparchus.util.SinCos;
  21. import org.orekit.attitudes.AttitudeProvider;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.time.AbsoluteDate;
  24. import org.orekit.time.DateTimeComponents;
  25. import org.orekit.utils.Constants;

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

  39.     // CHECKSTYLE: stop VisibilityModifier check

  40.     /** New perigee argument. */
  41.     protected double omgadf;

  42.     /** New mean motion. */
  43.     protected double xn;

  44.     /** Parameter for xl computation. */
  45.     protected double xll;

  46.     /** New eccentricity. */
  47.     protected double em;

  48.     /** New inclination. */
  49.     protected double xinc;

  50.     // CHECKSTYLE: resume VisibilityModifier check

  51.     /** Constructor for a unique initial TLE.
  52.      * @param initialTLE the TLE to propagate.
  53.      * @param attitudeProvider provider for attitude computation
  54.      * @param mass spacecraft mass (kg)
  55.      * @param teme the TEME frame to use for propagation.
  56.      */
  57.     protected SDP4(final TLE initialTLE,
  58.                    final AttitudeProvider attitudeProvider,
  59.                    final double mass,
  60.                    final Frame teme) {
  61.         super(initialTLE, attitudeProvider, mass, teme);
  62.     }

  63.     /** Initialization proper to each propagator (SGP or SDP).
  64.      */
  65.     protected void sxpInitialize() {
  66.         luniSolarTermsComputation();
  67.     }  // End of initialization

  68.     /** Propagation proper to each propagator (SGP or SDP).
  69.      * @param tSince the offset from initial epoch (minutes)
  70.      */
  71.     protected void sxpPropagate(final double tSince) {

  72.         // Update for secular gravity and atmospheric drag
  73.         omgadf = tle.getPerigeeArgument() + omgdot * tSince;
  74.         final double xnoddf = tle.getRaan() + xnodot * tSince;
  75.         final double tSinceSq = tSince * tSince;
  76.         xnode = xnoddf + xnodcf * tSinceSq;
  77.         xn = xn0dp;

  78.         // Update for deep-space secular effects
  79.         xll = tle.getMeanAnomaly() + xmdot * tSince;

  80.         deepSecularEffects(tSince);

  81.         final double tempa = 1 - c1 * tSince;
  82.         a   = FastMath.pow(TLEConstants.XKE / xn, TLEConstants.TWO_THIRD) * tempa * tempa;
  83.         em -= tle.getBStar(tle.getDate().shiftedBy(tSince)) * c4 * tSince;

  84.         // Update for deep-space periodic effects
  85.         xll += xn0dp * t2cof * tSinceSq;

  86.         deepPeriodicEffects(tSince);

  87.         xl = xll + omgadf + xnode;

  88.         // Dundee change:  Reset cosio,  sinio for new xinc:
  89.         final SinCos scI0 = FastMath.sinCos(xinc);
  90.         cosi0 = scI0.cos();
  91.         sini0 = scI0.sin();
  92.         e = em;
  93.         i = xinc;
  94.         omega = omgadf;
  95.         // end of calculus, go for PV computation
  96.     }

  97.     /** Computes SPACETRACK#3 compliant earth rotation angle.
  98.      * @param date the current date
  99.      * @return the ERA (rad)
  100.      */
  101.     protected double thetaG(final AbsoluteDate date) {

  102.         // Reference:  The 1992 Astronomical Almanac, page B6.
  103.         final double omega_E = 1.00273790934;
  104.         final double jd = date
  105.                 .getComponents(utc)
  106.                 .offsetFrom(DateTimeComponents.JULIAN_EPOCH) /
  107.                 Constants.JULIAN_DAY;

  108.         // Earth rotations per sidereal day (non-constant)
  109.         final double UT = (jd + 0.5) % 1;
  110.         final double seconds_per_day = Constants.JULIAN_DAY;
  111.         final double jd_2000 = 2451545.0;   /* 1.5 Jan 2000 = JD 2451545. */
  112.         final double t_cen = (jd - UT - jd_2000) / 36525.;
  113.         double GMST = 24110.54841 +
  114.                       t_cen * (8640184.812866 + t_cen * (0.093104 - t_cen * 6.2E-6));
  115.         GMST = (GMST + seconds_per_day * omega_E * UT) % seconds_per_day;
  116.         if (GMST < 0.) {
  117.             GMST += seconds_per_day;
  118.         }

  119.         return MathUtils.TWO_PI * GMST / seconds_per_day;

  120.     }

  121.     /** Computes luni - solar terms from initial coordinates and epoch.
  122.      */
  123.     protected abstract void luniSolarTermsComputation();

  124.     /** Computes secular terms from current coordinates and epoch.
  125.      * @param t offset from initial epoch (min)
  126.      */
  127.     protected abstract void deepSecularEffects(double t);

  128.     /** Computes periodic terms from current coordinates and epoch.
  129.      * @param t offset from initial epoch (min)
  130.      */
  131.     protected abstract void deepPeriodicEffects(double t);

  132. }