DSSTGravityContext.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.geometry.euclidean.threed.Vector3D;
  19. import org.hipparchus.util.FastMath;
  20. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
  21. import org.orekit.frames.Frame;
  22. import org.orekit.frames.StaticTransform;
  23. import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;

  24. /**
  25.  * This class is a container for the common parameters used in {@link DSSTTesseral} and {@link DSSTZonal}.
  26.  * <p>
  27.  * It performs parameters initialization at each integration step for the Tesseral  and Zonal contribution
  28.  * to the central body gravitational perturbation.
  29.  * </p>
  30.  * @author Bryan Cazabonne
  31.  * @author Maxime Journot
  32.  * @since 12.2
  33.  */
  34. public class DSSTGravityContext extends ForceModelContext {

  35.     /** A = sqrt(μ * a). */
  36.     private final double A;

  37.     /** &Chi; = 1 / sqrt(1 - e²) = 1 / B. */
  38.     private final double chi;

  39.     /** &Chi;². */
  40.     private final double chi2;

  41.     // Common factors from equinoctial coefficients
  42.     /** 2 * a / A . */
  43.     private final double ax2oA;

  44.     /** 1 / (A * B) . */
  45.     private final double ooAB;

  46.     /** B / A . */
  47.     private final double BoA;

  48.     /** B / (A * (1 + B)) . */
  49.     private final double BoABpo;

  50.     /** C / (2 * A * B) . */
  51.     private final double Co2AB;

  52.     /** μ / a . */
  53.     private final double muoa;

  54.     /** R / a . */
  55.     private final double roa;

  56.     /** Keplerian mean motion. */
  57.     private final double n;

  58.     /** Direction cosine α. */
  59.     private final double alpha;

  60.     /** Direction cosine β. */
  61.     private final double beta;

  62.     /** Direction cosine γ. */
  63.     private final double gamma;

  64.     /** Transform from body-fixed frame to inertial frame. */
  65.     private final StaticTransform bodyFixedToInertialTransform;

  66.     /**
  67.      * Constructor.
  68.      *
  69.      * @param auxiliaryElements auxiliary elements related to the current orbit
  70.      * @param bodyFixedFrame  rotating body frame
  71.      * @param provider   provider for spherical harmonics
  72.      * @param parameters values of the force model parameters
  73.      */
  74.     DSSTGravityContext(final AuxiliaryElements auxiliaryElements,
  75.                        final Frame bodyFixedFrame,
  76.                        final UnnormalizedSphericalHarmonicsProvider provider,
  77.                        final double[] parameters) {

  78.         super(auxiliaryElements);

  79.         // µ
  80.         final double mu = parameters[0];

  81.         // Semi-major axis
  82.         final double a = auxiliaryElements.getSma();

  83.         // Keplerian Mean Motion
  84.         final double absA = FastMath.abs(a);
  85.         this.n = FastMath.sqrt(mu / absA) / absA;

  86.         // A = sqrt(µ * |a|)
  87.         this.A = FastMath.sqrt(mu * absA);

  88.         // &Chi; = 1 / B
  89.         final double B = auxiliaryElements.getB();
  90.         this.chi = 1. / B;
  91.         this.chi2 = chi * chi;

  92.         // Common factors from equinoctial coefficients
  93.         // 2 * a / A
  94.         this.ax2oA = 2. * a / A;
  95.         // B / A
  96.         this.BoA = B / A;
  97.         // 1 / AB
  98.         this.ooAB = 1. / (A * B);
  99.         // C / 2AB
  100.         this.Co2AB = auxiliaryElements.getC() * ooAB / 2.;
  101.         // B / (A * (1 + B))
  102.         this.BoABpo = BoA / (1. + B);
  103.         // &mu / a
  104.         this.muoa = mu / a;
  105.         // R / a
  106.         this.roa = provider.getAe() / a;

  107.         // If (centralBodyFrame == null), then centralBodyFrame = orbit frame (see DSSTZonal constructors for more on this).
  108.         final Frame internalBodyFixedFrame = bodyFixedFrame == null ? auxiliaryElements.getFrame() : bodyFixedFrame;

  109.         // Transform from body-fixed frame (typically ITRF) to inertial frame
  110.         this.bodyFixedToInertialTransform = internalBodyFixedFrame.
  111.                         getStaticTransformTo(auxiliaryElements.getFrame(), auxiliaryElements.getDate());

  112.         final Vector3D zB = bodyFixedToInertialTransform.transformVector(Vector3D.PLUS_K);

  113.         // Direction cosines for central body [Eq. 2.1.9-(1)]
  114.         this.alpha = Vector3D.dotProduct(zB, auxiliaryElements.getVectorF());
  115.         this.beta  = Vector3D.dotProduct(zB, auxiliaryElements.getVectorG());
  116.         this.gamma = Vector3D.dotProduct(zB, auxiliaryElements.getVectorW());
  117.     }

  118.     /** Getter for the a.
  119.      * @return the a
  120.      */
  121.     public double getA() {
  122.         return A;
  123.     }

  124.     /** Getter for the chi.
  125.      * @return the chi
  126.      */
  127.     public double getChi() {
  128.         return chi;
  129.     }

  130.     /** Getter for the chi2.
  131.      * @return the chi2
  132.      */
  133.     public double getChi2() {
  134.         return chi2;
  135.     }

  136.     /** Getter for the ax2oA.
  137.      * @return the ax2oA
  138.      */
  139.     public double getAx2oA() {
  140.         return ax2oA;
  141.     }

  142.     /** ooAB = 1 / (A * B).
  143.      * @return the ooAB
  144.      */
  145.     public double getOoAB() {
  146.         return ooAB;
  147.     }

  148.     /** Get B / A.
  149.      * @return the boA
  150.      */
  151.     public double getBoA() {
  152.         return BoA;
  153.     }

  154.     /** Get BoABpo = B / A(1 + B).
  155.      * @return the boABpo
  156.      */
  157.     public double getBoABpo() {
  158.         return BoABpo;
  159.     }

  160.     /** Get Co2AB = C / 2AB.
  161.      * @return the co2AB
  162.      */
  163.     public double getCo2AB() {
  164.         return Co2AB;
  165.     }

  166.     /** Get μ / a.
  167.      * @return the muoa
  168.      */
  169.     public double getMuoa() {
  170.         return muoa;
  171.     }

  172.     /** Get roa = R / a.
  173.      * @return the roa
  174.      */
  175.     public double getRoa() {
  176.         return roa;
  177.     }

  178.     /**
  179.      * Get the Keplerian mean motion.
  180.      * <p>
  181.      * The Keplerian mean motion is computed directly from semi major axis and
  182.      * central acceleration constant.
  183.      * </p>
  184.      * @return Keplerian mean motion in radians per second
  185.      */
  186.     public double getMeanMotion() {
  187.         return n;
  188.     }

  189.     /** Get direction cosine α for central body.
  190.      * @return α
  191.      */
  192.     public double getAlpha() {
  193.         return alpha;
  194.     }

  195.     /** Get direction cosine β for central body.
  196.      * @return β
  197.      */
  198.     public double getBeta() {
  199.         return beta;
  200.     }

  201.     /** Get direction cosine γ for central body.
  202.      * @return γ
  203.      */
  204.     public double getGamma() {
  205.         return gamma;
  206.     }

  207.     /** Getter for the bodyFixedToInertialTransform.
  208.      * @return the bodyFixedToInertialTransform
  209.      */
  210.     public StaticTransform getBodyFixedToInertialTransform() {
  211.         return bodyFixedToInertialTransform;
  212.     }
  213. }