FieldDSSTTesseralContext.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.semianalytical.dsst.forces;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.util.FastMath;
  22. import org.hipparchus.util.MathUtils;
  23. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
  24. import org.orekit.frames.FieldStaticTransform;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
  27. import org.orekit.time.AbsoluteDate;

  28. /**
  29.  * This class is a container for the common "field" parameters used in {@link DSSTTesseral}.
  30.  * <p>
  31.  * It performs parameters initialization at each integration step for the Tesseral contribution
  32.  * to the central body gravitational perturbation.
  33.  * </p>
  34.  * @author Bryan Cazabonne
  35.  * @since 10.0
  36.  * @param <T> type of the field elements
  37.  */
  38. public class FieldDSSTTesseralContext<T extends CalculusFieldElement<T>> extends FieldDSSTGravityContext<T> {

  39.     /** Retrograde factor I.
  40.      *  <p>
  41.      *  DSST model needs equinoctial orbit as internal representation.
  42.      *  Classical equinoctial elements have discontinuities when inclination
  43.      *  is close to zero. In this representation, I = +1. <br>
  44.      *  To avoid this discontinuity, another representation exists and equinoctial
  45.      *  elements can be expressed in a different way, called "retrograde" orbit.
  46.      *  This implies I = -1. <br>
  47.      *  As Orekit doesn't implement the retrograde orbit, I is always set to +1.
  48.      *  But for the sake of consistency with the theory, the retrograde factor
  49.      *  has been kept in the formulas.
  50.      *  </p>
  51.      */
  52.     private static final int I = 1;

  53.     /** Central body rotation angle θ. */
  54.     private T theta;

  55.     /** ecc². */
  56.     private T e2;

  57.     /** Keplerian period. */
  58.     private T period;

  59.     /** Ratio of satellite period to central body rotation period. */
  60.     private T ratio;

  61.     /**
  62.      * Simple constructor.
  63.      *
  64.      * @param auxiliaryElements auxiliary elements related to the current orbit
  65.      * @param centralBodyFrame rotating body frame
  66.      * @param provider provider for spherical harmonics
  67.      * @param maxFrequencyShortPeriodics maximum value for j
  68.      * @param bodyPeriod central body rotation period (seconds)
  69.      * @param parameters values of the force model parameters (only 1 values
  70.      * for each parameters corresponding to state date) obtained by calling
  71.      * the extract parameter method {@link #extractParameters(double[], AbsoluteDate)}
  72.      * to selected the right value for state date or by getting the parameters for a specific date
  73.      */
  74.     FieldDSSTTesseralContext(final FieldAuxiliaryElements<T> auxiliaryElements,
  75.                              final Frame centralBodyFrame,
  76.                              final UnnormalizedSphericalHarmonicsProvider provider,
  77.                              final int maxFrequencyShortPeriodics,
  78.                              final double bodyPeriod,
  79.                              final T[] parameters) {

  80.         super(auxiliaryElements, centralBodyFrame, provider, parameters);

  81.         // Get field and zero
  82.         final Field<T> field = auxiliaryElements.getDate().getField();
  83.         final T zero = field.getZero();

  84.         // Keplerian period
  85.         final T a = auxiliaryElements.getSma();
  86.         period = (a.getReal() < 0) ? zero.newInstance(Double.POSITIVE_INFINITY) : getMeanMotion().reciprocal().multiply(MathUtils.TWO_PI);

  87.         // Eccentricity square
  88.         e2 = auxiliaryElements.getEcc().multiply(auxiliaryElements.getEcc());

  89.         // Central body rotation angle from equation 2.7.1-(3)(4).
  90.         final FieldStaticTransform<T> t = getBodyFixedToInertialTransform();
  91.         final FieldVector3D<T> xB = t.transformVector(FieldVector3D.getPlusI(field));
  92.         final FieldVector3D<T> yB = t.transformVector(FieldVector3D.getPlusJ(field));
  93.         theta = FastMath.atan2(auxiliaryElements.getVectorF().dotProduct(yB).negate().add((auxiliaryElements.getVectorG().dotProduct(xB)).multiply(I)),
  94.                                auxiliaryElements.getVectorF().dotProduct(xB).add(auxiliaryElements.getVectorG().dotProduct(yB).multiply(I)));

  95.         // Ratio of satellite to central body periods to define resonant terms
  96.         ratio = period.divide(bodyPeriod);
  97.     }

  98.     /** Get ecc².
  99.      * @return e2
  100.      */
  101.     public T getE2() {
  102.         return e2;
  103.     }

  104.     /** Get Central body rotation angle θ.
  105.      * @return theta
  106.      */
  107.     public T getTheta() {
  108.         return theta;
  109.     }

  110.     /** Get μ / a .
  111.      * @return moa
  112.      * @deprecated since 12.2 Use getMuoa() instead
  113.      */
  114.     @Deprecated
  115.     public T getMoa() {
  116.         return getMuoa();
  117.     }

  118.     /** Get the Keplerian period.
  119.      * <p>The Keplerian period is computed directly from semi major axis
  120.      * and central acceleration constant.</p>
  121.      * @return Keplerian period in seconds, or positive infinity for hyperbolic orbits
  122.      */
  123.     public T getOrbitPeriod() {
  124.         return period;
  125.     }

  126.     /** Get the ratio of satellite period to central body rotation period.
  127.      * @return ratio
  128.      */
  129.     public T getRatio() {
  130.         return ratio;
  131.     }
  132. }