FieldDSSTTesseralContext.java

  1. /* Copyright 2002-2023 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.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
  23. import org.orekit.frames.FieldStaticTransform;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
  26. import org.orekit.time.AbsoluteDate;

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

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

  52.     /** A = sqrt(μ * a). */
  53.     private T A;

  54.     // Common factors for potential computation
  55.     /** &Chi; = 1 / sqrt(1 - e²) = 1 / B. */
  56.     private T chi;

  57.     /** &Chi;². */
  58.     private T chi2;

  59.     /** Central body rotation angle θ. */
  60.     private T theta;

  61.     // Common factors from equinoctial coefficients
  62.     /** 2 * a / A .*/
  63.     private T ax2oA;

  64.     /** 1 / (A * B) .*/
  65.     private T ooAB;

  66.     /** B / A .*/
  67.     private T BoA;

  68.     /** B / (A * (1 + B)) .*/
  69.     private T BoABpo;

  70.     /** C / (2 * A * B) .*/
  71.     private T Co2AB;

  72.     /** μ / a .*/
  73.     private T moa;

  74.     /** R / a .*/
  75.     private T roa;

  76.     /** ecc². */
  77.     private T e2;

  78.     /** Keplerian mean motion. */
  79.     private T n;

  80.     /** Keplerian period. */
  81.     private T period;

  82.     /** Ratio of satellite period to central body rotation period. */
  83.     private T ratio;

  84.     /**
  85.      * Simple constructor.
  86.      *
  87.      * @param auxiliaryElements auxiliary elements related to the current orbit
  88.      * @param centralBodyFrame rotating body frame
  89.      * @param provider provider for spherical harmonics
  90.      * @param maxFrequencyShortPeriodics maximum value for j
  91.      * @param bodyPeriod central body rotation period (seconds)
  92.      * @param parameters values of the force model parameters (only 1 values
  93.      * for each parameters corresponding to state date) obtained by calling
  94.      * the extract parameter method {@link #extractParameters(double[], AbsoluteDate)}
  95.      * to selected the right value for state date or by getting the parameters for a specific date
  96.      */
  97.     FieldDSSTTesseralContext(final FieldAuxiliaryElements<T> auxiliaryElements,
  98.                                     final Frame centralBodyFrame,
  99.                                     final UnnormalizedSphericalHarmonicsProvider provider,
  100.                                     final int maxFrequencyShortPeriodics,
  101.                                     final double bodyPeriod,
  102.                                     final T[] parameters) {

  103.         super(auxiliaryElements);

  104.         final Field<T> field = auxiliaryElements.getDate().getField();
  105.         final T zero = field.getZero();

  106.         final T mu = parameters[0];

  107.         // Keplerian mean motion
  108.         final T absA = FastMath.abs(auxiliaryElements.getSma());
  109.         n = FastMath.sqrt(mu.divide(absA)).divide(absA);

  110.         // Keplerian period
  111.         final T a = auxiliaryElements.getSma();
  112.         period = (a.getReal() < 0) ? zero.add(Double.POSITIVE_INFINITY) : a.multiply(a.getPi().multiply(2.0)).multiply(a.divide(mu).sqrt());

  113.         A = FastMath.sqrt(mu.multiply(auxiliaryElements.getSma()));

  114.         // Eccentricity square
  115.         e2 = auxiliaryElements.getEcc().multiply(auxiliaryElements.getEcc());

  116.         // Central body rotation angle from equation 2.7.1-(3)(4).
  117.         final FieldStaticTransform<T> t = centralBodyFrame.getStaticTransformTo(auxiliaryElements.getFrame(), auxiliaryElements.getDate());
  118.         final FieldVector3D<T> xB = t.transformVector(FieldVector3D.getPlusI(field));
  119.         final FieldVector3D<T> yB = t.transformVector(FieldVector3D.getPlusJ(field));
  120.         theta = FastMath.atan2(auxiliaryElements.getVectorF().dotProduct(yB).negate().add((auxiliaryElements.getVectorG().dotProduct(xB)).multiply(I)),
  121.                                auxiliaryElements.getVectorF().dotProduct(xB).add(auxiliaryElements.getVectorG().dotProduct(yB).multiply(I)));

  122.         // Common factors from equinoctial coefficients
  123.         // 2 * a / A
  124.         ax2oA  = auxiliaryElements.getSma().divide(A).multiply(2.);
  125.         // B / A
  126.         BoA    = auxiliaryElements.getB().divide(A);
  127.         // 1 / AB
  128.         ooAB   = A.multiply(auxiliaryElements.getB()).reciprocal();
  129.         // C / 2AB
  130.         Co2AB  = auxiliaryElements.getC().multiply(ooAB).divide(2.);
  131.         // B / (A * (1 + B))
  132.         BoABpo = BoA.divide(auxiliaryElements.getB().add(1.));
  133.         // &mu / a
  134.         moa    = mu.divide(auxiliaryElements.getSma());
  135.         // R / a
  136.         roa    = auxiliaryElements.getSma().divide(provider.getAe()).reciprocal();

  137.         // &Chi; = 1 / B
  138.         chi  = auxiliaryElements.getB().reciprocal();
  139.         chi2 = chi.multiply(chi);

  140.         // Ratio of satellite to central body periods to define resonant terms
  141.         ratio = period.divide(bodyPeriod);

  142.     }

  143.     /** Get ecc².
  144.      * @return e2
  145.      */
  146.     public T getE2() {
  147.         return e2;
  148.     }

  149.     /** Get Central body rotation angle θ.
  150.      * @return theta
  151.      */
  152.     public T getTheta() {
  153.         return theta;
  154.     }

  155.     /** Get ax2oA = 2 * a / A .
  156.      * @return ax2oA
  157.      */
  158.     public T getAx2oA() {
  159.         return ax2oA;
  160.     }

  161.     /** Get &Chi; = 1 / sqrt(1 - e²) = 1 / B.
  162.      * @return chi
  163.      */
  164.     public T getChi() {
  165.         return chi;
  166.     }

  167.     /** Get &Chi;².
  168.      * @return chi2
  169.      */
  170.     public T getChi2() {
  171.         return chi2;
  172.     }

  173.     /** Get B / A.
  174.      * @return BoA
  175.      */
  176.     public T getBoA() {
  177.         return BoA;
  178.     }

  179.     /** Get ooAB = 1 / (A * B).
  180.      * @return ooAB
  181.      */
  182.     public T getOoAB() {
  183.         return ooAB;
  184.     }

  185.     /** Get Co2AB = C / 2AB.
  186.      * @return Co2AB
  187.      */
  188.     public T getCo2AB() {
  189.         return Co2AB;
  190.     }

  191.     /** Get BoABpo = B / A(1 + B).
  192.      * @return BoABpo
  193.      */
  194.     public T getBoABpo() {
  195.         return BoABpo;
  196.     }

  197.     /** Get μ / a .
  198.      * @return moa
  199.      */
  200.     public T getMoa() {
  201.         return moa;
  202.     }

  203.     /** Get roa = R / a.
  204.      * @return roa
  205.      */
  206.     public T getRoa() {
  207.         return roa;
  208.     }

  209.     /** Get the Keplerian period.
  210.      * <p>The Keplerian period is computed directly from semi major axis
  211.      * and central acceleration constant.</p>
  212.      * @return Keplerian period in seconds, or positive infinity for hyperbolic orbits
  213.      */
  214.     public T getOrbitPeriod() {
  215.         return period;
  216.     }

  217.     /** Get the Keplerian mean motion.
  218.      * <p>The Keplerian mean motion is computed directly from semi major axis
  219.      * and central acceleration constant.</p>
  220.      * @return Keplerian mean motion in radians per second
  221.      */
  222.     public T getMeanMotion() {
  223.         return n;
  224.     }

  225.     /** Get the ratio of satellite period to central body rotation period.
  226.      * @return ratio
  227.      */
  228.     public T getRatio() {
  229.         return ratio;
  230.     }

  231. }