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.geometry.euclidean.threed.Vector3D;
20 import org.hipparchus.util.FastMath;
21 import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
22 import org.orekit.frames.Frame;
23 import org.orekit.frames.StaticTransform;
24 import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
25
26 /**
27 * This class is a container for the common parameters used in {@link DSSTTesseral}.
28 * <p>
29 * It performs parameters initialization at each integration step for the Tesseral contribution
30 * to the central body gravitational perturbation.
31 * </p>
32 * @author Bryan Cazabonne
33 * @since 10.0
34 */
35 public class DSSTTesseralContext extends ForceModelContext {
36
37 /** Retrograde factor I.
38 * <p>
39 * DSST model needs equinoctial orbit as internal representation.
40 * Classical equinoctial elements have discontinuities when inclination
41 * is close to zero. In this representation, I = +1. <br>
42 * To avoid this discontinuity, another representation exists and equinoctial
43 * elements can be expressed in a different way, called "retrograde" orbit.
44 * This implies I = -1. <br>
45 * As Orekit doesn't implement the retrograde orbit, I is always set to +1.
46 * But for the sake of consistency with the theory, the retrograde factor
47 * has been kept in the formulas.
48 * </p>
49 */
50 private static final int I = 1;
51
52 /** A = sqrt(μ * a). */
53 private double A;
54
55 // Common factors for potential computation
56 /** Χ = 1 / sqrt(1 - e²) = 1 / B. */
57 private double chi;
58
59 /** Χ². */
60 private double chi2;
61
62 /** Central body rotation angle θ. */
63 private double theta;
64
65 // Common factors from equinoctial coefficients
66 /** 2 * a / A . */
67 private double ax2oA;
68
69 /** 1 / (A * B) . */
70 private double ooAB;
71
72 /** B / A . */
73 private double BoA;
74
75 /** B / (A * (1 + B)) . */
76 private double BoABpo;
77
78 /** C / (2 * A * B) . */
79 private double Co2AB;
80
81 /** μ / a . */
82 private double moa;
83
84 /** R / a . */
85 private double roa;
86
87 /** ecc². */
88 private double e2;
89
90 /** Keplerian mean motion. */
91 private double n;
92
93 /** Keplerian period. */
94 private double period;
95
96 /** Ratio of satellite period to central body rotation period. */
97 private double ratio;
98
99 /**
100 * Simple constructor.
101 *
102 * @param auxiliaryElements auxiliary elements related to the current orbit
103 * @param centralBodyFrame rotating body frame
104 * @param provider provider for spherical harmonics
105 * @param maxFrequencyShortPeriodics maximum value for j
106 * @param bodyPeriod central body rotation period (seconds)
107 * @param parameters values of the force model parameters
108 */
109 DSSTTesseralContext(final AuxiliaryElements auxiliaryElements,
110 final Frame centralBodyFrame,
111 final UnnormalizedSphericalHarmonicsProvider provider,
112 final int maxFrequencyShortPeriodics,
113 final double bodyPeriod,
114 final double[] parameters) {
115
116 super(auxiliaryElements);
117
118 final double mu = parameters[0];
119
120 // Keplerian Mean Motion
121 final double absA = FastMath.abs(auxiliaryElements.getSma());
122 n = FastMath.sqrt(mu / absA) / absA;
123
124 // Keplerian period
125 final double a = auxiliaryElements.getSma();
126 period = (a < 0) ? Double.POSITIVE_INFINITY : 2.0 * FastMath.PI * a * FastMath.sqrt(a / mu);
127
128 A = FastMath.sqrt(mu * auxiliaryElements.getSma());
129
130 // Eccentricity square
131 e2 = auxiliaryElements.getEcc() * auxiliaryElements.getEcc();
132
133 // Central body rotation angle from equation 2.7.1-(3)(4).
134 final StaticTransform t = centralBodyFrame.getStaticTransformTo(
135 auxiliaryElements.getFrame(),
136 auxiliaryElements.getDate());
137 final Vector3D xB = t.transformVector(Vector3D.PLUS_I);
138 final Vector3D yB = t.transformVector(Vector3D.PLUS_J);
139 theta = FastMath.atan2(-auxiliaryElements.getVectorF().dotProduct(yB) + I * auxiliaryElements.getVectorG().dotProduct(xB),
140 auxiliaryElements.getVectorF().dotProduct(xB) + I * auxiliaryElements.getVectorG().dotProduct(yB));
141
142 // Common factors from equinoctial coefficients
143 // 2 * a / A
144 ax2oA = 2. * auxiliaryElements.getSma() / A;
145 // B / A
146 BoA = auxiliaryElements.getB() / A;
147 // 1 / AB
148 ooAB = 1. / (A * auxiliaryElements.getB());
149 // C / 2AB
150 Co2AB = auxiliaryElements.getC() * ooAB / 2.;
151 // B / (A * (1 + B))
152 BoABpo = BoA / (1. + auxiliaryElements.getB());
153 // &mu / a
154 moa = mu / auxiliaryElements.getSma();
155 // R / a
156 roa = provider.getAe() / auxiliaryElements.getSma();
157
158 // Χ = 1 / B
159 chi = 1. / auxiliaryElements.getB();
160 chi2 = chi * chi;
161
162 // Ratio of satellite to central body periods to define resonant terms
163 ratio = period / bodyPeriod;
164
165 }
166
167 /** Get ecc².
168 * @return e2
169 */
170 public double getE2() {
171 return e2;
172 }
173
174 /**
175 * Get Central body rotation angle θ.
176 * @return theta
177 */
178 public double getTheta() {
179 return theta;
180 }
181
182 /**
183 * Get ax2oA = 2 * a / A .
184 * @return ax2oA
185 */
186 public double getAx2oA() {
187 return ax2oA;
188 }
189
190 /**
191 * Get Χ = 1 / sqrt(1 - e²) = 1 / B.
192 * @return chi
193 */
194 public double getChi() {
195 return chi;
196 }
197
198 /**
199 * Get Χ².
200 * @return chi2
201 */
202 public double getChi2() {
203 return chi2;
204 }
205
206 /**
207 * Get B / A.
208 * @return BoA
209 */
210 public double getBoA() {
211 return BoA;
212 }
213
214 /**
215 * Get ooAB = 1 / (A * B).
216 * @return ooAB
217 */
218 public double getOoAB() {
219 return ooAB;
220 }
221
222 /**
223 * Get Co2AB = C / 2AB.
224 * @return Co2AB
225 */
226 public double getCo2AB() {
227 return Co2AB;
228 }
229
230 /**
231 * Get BoABpo = B / A(1 + B).
232 * @return BoABpo
233 */
234 public double getBoABpo() {
235 return BoABpo;
236 }
237
238 /**
239 * Get μ / a .
240 * @return moa
241 */
242 public double getMoa() {
243 return moa;
244 }
245
246 /**
247 * Get roa = R / a.
248 * @return roa
249 */
250 public double getRoa() {
251 return roa;
252 }
253
254 /**
255 * Get the Keplerian period.
256 * <p>
257 * The Keplerian period is computed directly from semi major axis and central
258 * acceleration constant.
259 * </p>
260 * @return Keplerian period in seconds, or positive infinity for hyperbolic
261 * orbits
262 */
263 public double getOrbitPeriod() {
264 return period;
265 }
266
267 /**
268 * Get the Keplerian mean motion.
269 * <p>
270 * The Keplerian mean motion is computed directly from semi major axis and
271 * central acceleration constant.
272 * </p>
273 * @return Keplerian mean motion in radians per second
274 */
275 public double getMeanMotion() {
276 return n;
277 }
278
279 /**
280 * Get the ratio of satellite period to central body rotation period.
281 * @return ratio
282 */
283 public double getRatio() {
284 return ratio;
285 }
286
287 }