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  
19  import org.hipparchus.util.FastMath;
20  import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
21  
22  /**
23   * This class is a container for the common parameters used in {@link AbstractGaussianContribution}.
24   * <p>
25   * It performs parameters initialization at each integration step for the Gaussian contributions
26   * </p>
27   * @author Bryan Cazabonne
28   * @since 10.0
29   */
30  public class AbstractGaussianContributionContext extends ForceModelContext {
31  
32      // CHECKSTYLE: stop VisibilityModifier check
33  
34      /** 2 / (n² * a) . */
35      protected double ton2a;
36  
37      /** 1 / A . */
38      protected double ooA;
39  
40      /** 1 / (A * B) . */
41      protected double ooAB;
42  
43      /** C / (2 * A * B) . */
44      protected double co2AB;
45  
46      /** 1 / (1 + B) . */
47      protected double ooBpo;
48  
49      /** 1 / μ . */
50      protected double ooMu;
51  
52      /** A = sqrt(μ * a). */
53      private final double A;
54  
55      /** Keplerian mean motion. */
56      private final double n;
57  
58      /** Central attraction coefficient. */
59      private double mu;
60  
61      // CHECKSTYLE: resume VisibilityModifier check
62  
63      /**
64       * Simple constructor.
65       *
66       * @param auxiliaryElements auxiliary elements related to the current orbit
67       * @param parameters        parameters values of the force model parameters
68       *                          only 1 value for each parameterDriver
69       */
70      AbstractGaussianContributionContext(final AuxiliaryElements auxiliaryElements, final double[] parameters) {
71  
72          super(auxiliaryElements);
73  
74          // mu driver corresponds to the last term of parameters driver array
75          mu = parameters[parameters.length - 1];
76  
77          // Keplerian Mean Motion
78          final double absA = FastMath.abs(auxiliaryElements.getSma());
79          n = FastMath.sqrt(mu / absA) / absA;
80  
81          // sqrt(μ * a)
82          A = FastMath.sqrt(mu * auxiliaryElements.getSma());
83          // 1 / A
84          ooA = 1. / A;
85          // 1 / AB
86          ooAB = ooA / auxiliaryElements.getB();
87          // C / 2AB
88          co2AB = auxiliaryElements.getC() * ooAB / 2.;
89          // 1 / (1 + B)
90          ooBpo = 1. / (1. + auxiliaryElements.getB());
91          // 2 / (n² * a)
92          ton2a = 2. / (n * n * auxiliaryElements.getSma());
93          // 1 / mu
94          ooMu = 1. / mu;
95  
96      }
97  
98      /** Get central attraction coefficient.
99       * @return mu
100      */
101     public double getMu() {
102         return mu;
103     }
104 
105     /** Get ooA = 1 / A.
106      * @return ooA
107      */
108     public double getOOA() {
109         return ooA;
110     }
111 
112     /** Get ooAB = 1 / (A * B).
113      * @return ooAB
114      */
115     public double getOOAB() {
116         return ooAB;
117     }
118 
119     /** Get co2AB = C / 2AB.
120      * @return co2AB
121      */
122     public double getCo2AB() {
123         return co2AB;
124     }
125 
126     /** Get ooBpo = 1 / (B + 1).
127      * @return ooBpo
128      */
129     public double getOoBpo() {
130         return ooBpo;
131     }
132 
133     /** Get ton2a = 2 / (n² * a).
134      * @return ton2a
135      */
136     public double getTon2a() {
137         return ton2a;
138     }
139 
140     /** Get ooMu = 1 / mu.
141      * @return ooMu
142      */
143     public double getOoMU() {
144         return ooMu;
145     }
146 
147     /** Get the Keplerian mean motion.
148      * <p>The Keplerian mean motion is computed directly from semi major axis
149      * and central acceleration constant.</p>
150      * @return Keplerian mean motion in radians per second
151      */
152     public double getMeanMotion() {
153         return n;
154     }
155 }