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.geometry.euclidean.threed.Vector3D;
20  import org.hipparchus.util.FastMath;
21  import org.orekit.bodies.CelestialBody;
22  import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
23  
24  /**
25   * This class is a container for the common parameters used in
26   * {@link DSSTThirdBody}.
27   * <p>
28   * It performs parameters initialization at each integration step for the third
29   * body attraction perturbation. These parameters change for each integration
30   * step.
31   * </p>
32   * @author Bryan Cazabonne
33   * @since 11.3.3
34   */
35  public class DSSTThirdBodyDynamicContext extends ForceModelContext {
36  
37      /** Standard gravitational parameter μ for the body in m³/s². */
38      private double gm;
39  
40      /** Distance from center of mass of the central body to the 3rd body. */
41      private double R3;
42  
43      /** A = sqrt(μ * a). */
44      private double A;
45  
46      /** α. */
47      private double alpha;
48  
49      /** β. */
50      private double beta;
51  
52      /** γ. */
53      private double gamma;
54  
55      /** B². */
56      private double BB;
57  
58      /** B³. */
59      private double BBB;
60  
61      /** &Chi; = 1 / sqrt(1 - e²) = 1 / B. */
62      private double X;
63  
64      /** &Chi;². */
65      private double XX;
66  
67      /** &Chi;³. */
68      private double XXX;
69  
70      /** -2 * a / A. */
71      private double m2aoA;
72  
73      /** B / A. */
74      private double BoA;
75  
76      /** 1 / (A * B). */
77      private double ooAB;
78  
79      /** -C / (2 * A * B). */
80      private double mCo2AB;
81  
82      /** B / A(1 + B). */
83      private double BoABpo;
84  
85      /** mu3 / R3. */
86      private double muoR3;
87  
88      /** b = 1 / (1 + sqrt(1 - e²)) = 1 / (1 + B). */
89      private double b;
90  
91      /** h * &Chi;³. */
92      private double hXXX;
93  
94      /** k * &Chi;³. */
95      private double kXXX;
96  
97      /** Keplerian mean motion. */
98      private double motion;
99  
100     /** Constructor.
101      * @param aux auxiliary elements related to the current orbit
102      * @param body body the 3rd body to consider
103      * @param parameters values of the force model parameters
104      */
105     public DSSTThirdBodyDynamicContext(final AuxiliaryElements aux,
106                                        final CelestialBody body,
107                                        final double[] parameters) {
108         super(aux);
109 
110         // Parameters related to force model drivers
111         final double mu = parameters[1];
112         A = FastMath.sqrt(mu * aux.getSma());
113         this.gm = parameters[0];
114         final double absA = FastMath.abs(aux.getSma());
115         motion = FastMath.sqrt(mu / absA) / absA;
116 
117         // Distance from center of mass of the central body to the 3rd body
118         final Vector3D bodyPos = body.getPosition(aux.getDate(), aux.getFrame());
119         R3 = bodyPos.getNorm();
120 
121         // Direction cosines
122         final Vector3D bodyDir = bodyPos.normalize();
123         alpha = bodyDir.dotProduct(aux.getVectorF());
124         beta = bodyDir.dotProduct(aux.getVectorG());
125         gamma = bodyDir.dotProduct(aux.getVectorW());
126 
127         // &Chi;<sup>-2</sup>.
128         BB = aux.getB() * aux.getB();
129         // &Chi;<sup>-3</sup>.
130         BBB = BB * aux.getB();
131 
132         // b = 1 / (1 + B)
133         b = 1. / (1. + aux.getB());
134 
135         // &Chi;
136         X = 1. / aux.getB();
137         XX = X * X;
138         XXX = X * XX;
139         // -2 * a / A
140         m2aoA = -2. * aux.getSma() / A;
141         // B / A
142         BoA = aux.getB() / A;
143         // 1 / AB
144         ooAB = 1. / (A * aux.getB());
145         // -C / 2AB
146         mCo2AB = -aux.getC() * ooAB / 2.;
147         // B / A(1 + B)
148         BoABpo = BoA / (1. + aux.getB());
149 
150         // mu3 / R3
151         muoR3 = gm / R3;
152 
153         // h * &Chi;³
154         hXXX = aux.getH() * XXX;
155         // k * &Chi;³
156         kXXX = aux.getK() * XXX;
157 
158     }
159 
160     /** Get A = sqrt(μ * a).
161      * @return A
162      */
163     public double getA() {
164         return A;
165     }
166 
167     /** Get the distance from center of mass of the central body to the 3rd body.
168      * @return the distance from center of mass of the central body to the 3rd body
169      */
170     public double getR3() {
171         return R3;
172     }
173 
174     /** Get direction cosine α for central body.
175      * @return α
176      */
177     public double getAlpha() {
178         return alpha;
179     }
180 
181     /** Get direction cosine β for central body.
182      * @return β
183      */
184     public double getBeta() {
185         return beta;
186     }
187 
188     /** Get direction cosine γ for central body.
189      * @return γ
190      */
191     public double getGamma() {
192         return gamma;
193     }
194 
195     /** Get B².
196      * @return B²
197      */
198     public double getBB() {
199         return BB;
200     }
201 
202     /** Get B³.
203      * @return B³
204      */
205     public double getBBB() {
206         return BBB;
207     }
208 
209     /** Get b = 1 / (1 + sqrt(1 - e²)) = 1 / (1 + B).
210      * @return b
211      */
212     public double getb() {
213         return b;
214     }
215 
216     /** Get &Chi; = 1 / sqrt(1 - e²) = 1 / B.
217      * @return &Chi;
218      */
219     public double getX() {
220         return X;
221     }
222 
223     /** Get &Chi;².
224      * @return &Chi;²
225      */
226     public double getXX() {
227         return XX;
228     }
229 
230     /** Get m2aoA = -2 * a / A.
231      * @return m2aoA
232      */
233     public double getM2aoA() {
234         return m2aoA;
235     }
236 
237     /** Get B / A.
238      * @return BoA
239      */
240     public double getBoA() {
241         return BoA;
242     }
243 
244     /** Get ooAB = 1 / (A * B).
245      * @return ooAB
246      */
247     public double getOoAB() {
248         return ooAB;
249     }
250 
251     /** Get mCo2AB = -C / 2AB.
252      * @return mCo2AB
253      */
254     public double getMCo2AB() {
255         return mCo2AB;
256     }
257 
258     /** Get BoABpo = B / A(1 + B).
259      * @return BoABpo
260      */
261     public double getBoABpo() {
262         return BoABpo;
263     }
264 
265     /** Get muoR3 = mu3 / R3.
266      * @return muoR3
267      */
268     public double getMuoR3() {
269         return muoR3;
270     }
271 
272     /** Get hXXX = h * &Chi;³.
273      * @return hXXX
274      */
275     public double getHXXX() {
276         return hXXX;
277     }
278 
279     /** Get kXXX = h * &Chi;³.
280      * @return kXXX
281      */
282     public double getKXXX() {
283         return kXXX;
284     }
285 
286     /** Get the Keplerian mean motion.
287      * <p>The Keplerian mean motion is computed directly from semi major axis
288      * and central acceleration constant.</p>
289      * @return Keplerian mean motion in radians per second
290      */
291     public double getMeanMotion() {
292         return motion;
293     }
294 
295 }