1   /* Copyright 2002-2024 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.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
21  import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
22  
23  /**
24   * This class is a container for the common parameters used in {@link DSSTZonal}.
25   * <p>
26   * It performs parameters initialization at each integration step for the Zonal contribution
27   * to the central body gravitational perturbation.
28   * </p>
29   * @author Bryan Cazabonne
30   * @since 10.0
31   */
32  public class DSSTZonalContext extends ForceModelContext {
33  
34      // Common factors for potential computation
35      /** A = sqrt(μ * a). */
36      private final double A;
37      /** &Chi; = 1 / sqrt(1 - e²) = 1 / B. */
38      private double X;
39      /** &Chi;². */
40      private double XX;
41      /** &Chi;³. */
42      private double XXX;
43      /** 1 / (A * B) . */
44      private double ooAB;
45      /** B / A . */
46      private double BoA;
47      /** B / A(1 + B) . */
48      private double BoABpo;
49      /** -C / (2 * A * B) . */
50      private double mCo2AB;
51      /** -2 * a / A . */
52      private double m2aoA;
53      /** μ / a . */
54      private double muoa;
55      /** R / a . */
56      private double roa;
57  
58      /** Keplerian mean motion. */
59      private final double n;
60  
61      // Short period terms
62      /** h * k. */
63      private double hk;
64      /** k² - h². */
65      private double k2mh2;
66      /** (k² - h²) / 2. */
67      private double k2mh2o2;
68      /** 1 / (n² * a²). */
69      private double oon2a2;
70      /** 1 / (n² * a) . */
71      private double oon2a;
72      /** χ³ / (n² * a). */
73      private double x3on2a;
74      /** χ / (n² * a²). */
75      private double xon2a2;
76      /** (C * χ) / ( 2 * n² * a² ). */
77      private double cxo2n2a2;
78      /** (χ²) / (n² * a² * (χ + 1 ) ). */
79      private double x2on2a2xp1;
80      /** B * B. */
81      private double BB;
82  
83      /**
84       * Simple constructor.
85       *
86       * @param auxiliaryElements auxiliary elements related to the current orbit
87       * @param provider          provider for spherical harmonics
88       * @param parameters        values of the force model parameters
89       */
90      DSSTZonalContext(final AuxiliaryElements auxiliaryElements,
91                       final UnnormalizedSphericalHarmonicsProvider provider,
92              final double[] parameters) {
93  
94          super(auxiliaryElements);
95  
96          final double mu = parameters[0];
97  
98          // Keplerian Mean Motion
99          final double absA = FastMath.abs(auxiliaryElements.getSma());
100         n = FastMath.sqrt(mu / absA) / absA;
101 
102         A = FastMath.sqrt(mu * auxiliaryElements.getSma());
103 
104         // &Chi; = 1 / B
105         X = 1. / auxiliaryElements.getB();
106         XX = X * X;
107         XXX = X * XX;
108 
109         // 1 / AB
110         ooAB = 1. / (A * auxiliaryElements.getB());
111         // B / A
112         BoA = auxiliaryElements.getB() / A;
113         // -C / 2AB
114         mCo2AB = -auxiliaryElements.getC() * ooAB / 2.;
115         // B / A(1 + B)
116         BoABpo = BoA / (1. + auxiliaryElements.getB());
117         // -2 * a / A
118         m2aoA = -2 * auxiliaryElements.getSma() / A;
119         // μ / a
120         muoa = mu / auxiliaryElements.getSma();
121         // R / a
122         roa = provider.getAe() / auxiliaryElements.getSma();
123 
124         // Short period terms
125 
126         // h * k.
127         hk = auxiliaryElements.getH() * auxiliaryElements.getK();
128         // k² - h².
129         k2mh2 = auxiliaryElements.getK() * auxiliaryElements.getK() - auxiliaryElements.getH() * auxiliaryElements.getH();
130         // (k² - h²) / 2.
131         k2mh2o2 = k2mh2 / 2.;
132         // 1 / (n² * a²) = 1 / (n * A)
133         oon2a2 = 1 / (A * n);
134         // 1 / (n² * a) = a / (n * A)
135         oon2a = auxiliaryElements.getSma() * oon2a2;
136         // χ³ / (n² * a)
137         x3on2a = XXX * oon2a;
138         // χ / (n² * a²)
139         xon2a2 = X * oon2a2;
140         // (C * χ) / ( 2 * n² * a² )
141         cxo2n2a2 = xon2a2 * auxiliaryElements.getC() / 2;
142         // (χ²) / (n² * a² * (χ + 1 ) )
143         x2on2a2xp1 = xon2a2 * X / (X + 1);
144         // B * B
145         BB = auxiliaryElements.getB() * auxiliaryElements.getB();
146     }
147 
148     /** Get &Chi; = 1 / sqrt(1 - e²) = 1 / B.
149      * @return &Chi;
150      */
151     public double getX() {
152         return X;
153     }
154 
155     /** Get &Chi;².
156      * @return &Chi;².
157      */
158     public double getXX() {
159         return XX;
160     }
161 
162     /** Get &Chi;³.
163      * @return &Chi;³
164      */
165     public double getXXX() {
166         return XXX;
167     }
168 
169     /** Get m2aoA = -2 * a / A.
170      * @return m2aoA
171      */
172     public double getM2aoA() {
173         return m2aoA;
174     }
175 
176     /** Get B / A.
177      * @return BoA
178      */
179     public double getBoA() {
180         return BoA;
181     }
182 
183     /** Get ooAB = 1 / (A * B).
184      * @return ooAB
185      */
186     public double getOoAB() {
187         return ooAB;
188     }
189 
190     /** Get mCo2AB = -C / 2AB.
191      * @return mCo2AB
192      */
193     public double getMCo2AB() {
194         return mCo2AB;
195     }
196 
197     /** Get BoABpo = B / A(1 + B).
198      * @return BoABpo
199      */
200     public double getBoABpo() {
201         return BoABpo;
202     }
203 
204     /** Get μ / a .
205      * @return muoa
206      */
207     public double getMuoa() {
208         return muoa;
209     }
210 
211     /** Get roa = R / a.
212      * @return roa
213      */
214     public double getRoa() {
215         return roa;
216     }
217 
218     /** Get the Keplerian mean motion.
219      * <p>The Keplerian mean motion is computed directly from semi major axis
220      * and central acceleration constant.</p>
221      * @return Keplerian mean motion in radians per second
222      */
223     public double getMeanMotion() {
224         return n;
225     }
226 
227     /** Get h * k.
228      * @return hk
229      */
230     public double getHK() {
231         return hk;
232     }
233 
234     /** Get k² - h².
235      * @return k2mh2
236      */
237     public double getK2MH2() {
238         return k2mh2;
239     }
240 
241     /** Get (k² - h²) / 2.
242      * @return k2mh2o2
243      */
244     public double getK2MH2O2() {
245         return k2mh2o2;
246     }
247 
248     /** Get 1 / (n² * a²).
249      * @return oon2a2
250      */
251     public double getOON2A2() {
252         return oon2a2;
253     }
254 
255     /** Get χ³ / (n² * a).
256      * @return x3on2a
257      */
258     public double getX3ON2A() {
259         return x3on2a;
260     }
261 
262     /** Get χ / (n² * a²).
263      * @return xon2a2
264      */
265     public double getXON2A2() {
266         return xon2a2;
267     }
268 
269     /** Get (C * χ) / ( 2 * n² * a² ).
270      * @return cxo2n2a2
271      */
272     public double getCXO2N2A2() {
273         return cxo2n2a2;
274     }
275 
276     /** Get (χ²) / (n² * a² * (χ + 1 ) ).
277      * @return x2on2a2xp1
278      */
279     public double getX2ON2A2XP1() {
280         return x2on2a2xp1;
281     }
282 
283     /** Get B * B.
284      * @return BB
285      */
286     public double getBB() {
287         return BB;
288     }
289 
290 }