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.geometry.euclidean.threed.FieldVector3D;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.hipparchus.util.FastMath;
23 import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
24 import org.orekit.frames.FieldStaticTransform;
25 import org.orekit.frames.Frame;
26 import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
27
28 /**
29 * This class is a container for the common parameters used in {@link DSSTTesseral} and {@link DSSTZonal}.
30 * <p>
31 * It performs parameters initialization at each integration step for the Tesseral and Zonal contribution
32 * to the central body gravitational perturbation.
33 * </p>
34 * @author Bryan Cazabonne
35 * @author Maxime Journot
36 * @since 12.2
37 */
38 public class FieldDSSTGravityContext<T extends CalculusFieldElement<T>> extends FieldForceModelContext<T> {
39
40 /** A = sqrt(μ * a). */
41 private final T A;
42
43 /** Χ = 1 / sqrt(1 - e²) = 1 / B. */
44 private final T chi;
45
46 /** Χ². */
47 private final T chi2;
48
49 // Common factors from equinoctial coefficients
50 /** 2 * a / A . */
51 private final T ax2oA;
52
53 /** 1 / (A * B) . */
54 private final T ooAB;
55
56 /** B / A . */
57 private final T BoA;
58
59 /** B / (A * (1 + B)) . */
60 private final T BoABpo;
61
62 /** C / (2 * A * B) . */
63 private final T Co2AB;
64
65 /** μ / a . */
66 private final T muoa;
67
68 /** R / a . */
69 private final T roa;
70
71 /** Keplerian mean motion. */
72 private final T n;
73
74 /** Direction cosine α. */
75 private final T alpha;
76
77 /** Direction cosine β. */
78 private final T beta;
79
80 /** Direction cosine γ. */
81 private final T gamma;
82
83 /** Transform from body-fixed frame to inertial frame. */
84 private final FieldStaticTransform<T> bodyFixedToInertialTransform;
85
86 /**
87 * Constructor.
88 *
89 * @param auxiliaryElements auxiliary elements related to the current orbit
90 * @param centralBodyFixedFrame rotating body frame
91 * @param provider provider for spherical harmonics
92 * @param parameters values of the force model parameters
93 */
94 FieldDSSTGravityContext(final FieldAuxiliaryElements<T> auxiliaryElements,
95 final Frame centralBodyFixedFrame,
96 final UnnormalizedSphericalHarmonicsProvider provider,
97 final T[] parameters) {
98
99 super(auxiliaryElements);
100
101 // µ
102 final T mu = parameters[0];
103
104 // Semi-major axis
105 final T a = auxiliaryElements.getSma();
106
107 // Keplerian Mean Motion
108 final T absA = FastMath.abs(a);
109 this.n = FastMath.sqrt(mu.divide(absA)).divide(absA);
110
111 // A = sqrt(µ * |a|)
112 this.A = FastMath.sqrt(mu.multiply(absA));
113
114 // Χ = 1 / B
115 final T B = auxiliaryElements.getB();
116 this.chi = auxiliaryElements.getB().reciprocal();
117 this.chi2 = chi.multiply(chi);
118
119 // Common factors from equinoctial coefficients
120 // 2 * a / A
121 this.ax2oA = a.divide(A).multiply(2.);
122 // B / A
123 this.BoA = B.divide(A);;
124 // 1 / AB
125 this.ooAB = A.multiply(B).reciprocal();;
126 // C / 2AB
127 this.Co2AB = auxiliaryElements.getC().multiply(ooAB).divide(2.);;
128 // B / (A * (1 + B))
129 this.BoABpo = BoA.divide(B.add(1.));
130 // &mu / a
131 this.muoa = mu.divide(a);
132 // R / a
133 this.roa = a.divide(provider.getAe()).reciprocal();
134
135
136 // If (centralBodyFrame == null), then centralBodyFrame = orbit frame (see DSSTZonal constructors for more on this).
137 final Frame internalCentralBodyFrame = centralBodyFixedFrame == null ? auxiliaryElements.getFrame() : centralBodyFixedFrame;
138
139 // Transform from body-fixed frame (typically ITRF) to inertial frame
140 bodyFixedToInertialTransform = internalCentralBodyFrame.
141 getStaticTransformTo(auxiliaryElements.getFrame(), auxiliaryElements.getDate());
142
143 final FieldVector3D<T> zB = bodyFixedToInertialTransform.transformVector(Vector3D.PLUS_K);
144
145 // Direction cosines for central body [Eq. 2.1.9-(1)]
146 alpha = FieldVector3D.dotProduct(zB, auxiliaryElements.getVectorF());
147 beta = FieldVector3D.dotProduct(zB, auxiliaryElements.getVectorG());
148 gamma = FieldVector3D.dotProduct(zB, auxiliaryElements.getVectorW());
149 }
150
151 /** A = sqrt(μ * a).
152 * @return A
153 */
154 public T getA() {
155 return A;
156 }
157
158 /** Get Χ = 1 / sqrt(1 - e²) = 1 / B.
159 * @return chi
160 */
161 public T getChi() {
162 return chi;
163 }
164
165 /** Get Χ².
166 * @return chi2
167 */
168 public T getChi2() {
169 return chi2;
170 }
171
172 /** Getter for the ax2oA.
173 * @return the ax2oA
174 */
175 public T getAx2oA() {
176 return ax2oA;
177 }
178
179 /** Get ooAB = 1 / (A * B).
180 * @return ooAB
181 */
182 public T getOoAB() {
183 return ooAB;
184 }
185
186 /** Get B / A.
187 * @return BoA
188 */
189 public T getBoA() {
190 return BoA;
191 }
192
193 /** Get BoABpo = B / A(1 + B).
194 * @return BoABpo
195 */
196 public T getBoABpo() {
197 return BoABpo;
198 }
199
200 /** Get Co2AB = C / 2AB.
201 * @return Co2AB
202 */
203 public T getCo2AB() {
204 return Co2AB;
205 }
206
207 /** Get muoa = μ / a.
208 * @return the muoa
209 */
210 public T getMuoa() {
211 return muoa;
212 }
213
214 /** Get roa = R / a.
215 * @return roa
216 */
217 public T getRoa() {
218 return roa;
219 }
220
221 /** Get the Keplerian mean motion.
222 * <p>The Keplerian mean motion is computed directly from semi major axis
223 * and central acceleration constant.</p>
224 * @return Keplerian mean motion in radians per second
225 */
226 public T getMeanMotion() {
227 return n;
228 }
229
230 /** Get direction cosine α for central body.
231 * @return α
232 */
233 public T getAlpha() {
234 return alpha;
235 }
236
237 /** Get direction cosine β for central body.
238 * @return β
239 */
240 public T getBeta() {
241 return beta;
242 }
243
244 /** Get direction cosine γ for central body.
245 * @return the γ
246 */
247 public T getGamma() {
248 return gamma;
249 }
250
251 /** Getter for the bodyFixedToInertialTransform.
252 * @return the bodyFixedToInertialTransform
253 */
254 public FieldStaticTransform<T> getBodyFixedToInertialTransform() {
255 return bodyFixedToInertialTransform;
256 }
257 }