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