1 /* Copyright 2002-2021 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.Transform;
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 Transform t = centralBodyFrame.getTransformTo(auxiliaryElements.getFrame(), auxiliaryElements.getDate());
135 final Vector3D xB = t.transformVector(Vector3D.PLUS_I);
136 final Vector3D yB = t.transformVector(Vector3D.PLUS_J);
137 theta = FastMath.atan2(-auxiliaryElements.getVectorF().dotProduct(yB) + I * auxiliaryElements.getVectorG().dotProduct(xB),
138 auxiliaryElements.getVectorF().dotProduct(xB) + I * auxiliaryElements.getVectorG().dotProduct(yB));
139
140 // Common factors from equinoctial coefficients
141 // 2 * a / A
142 ax2oA = 2. * auxiliaryElements.getSma() / A;
143 // B / A
144 BoA = auxiliaryElements.getB() / A;
145 // 1 / AB
146 ooAB = 1. / (A * auxiliaryElements.getB());
147 // C / 2AB
148 Co2AB = auxiliaryElements.getC() * ooAB / 2.;
149 // B / (A * (1 + B))
150 BoABpo = BoA / (1. + auxiliaryElements.getB());
151 // &mu / a
152 moa = mu / auxiliaryElements.getSma();
153 // R / a
154 roa = provider.getAe() / auxiliaryElements.getSma();
155
156 // Χ = 1 / B
157 chi = 1. / auxiliaryElements.getB();
158 chi2 = chi * chi;
159
160 // Ratio of satellite to central body periods to define resonant terms
161 ratio = period / bodyPeriod;
162
163 }
164
165 /** Get ecc².
166 * @return e2
167 */
168 public double getE2() {
169 return e2;
170 }
171
172 /**
173 * Get Central body rotation angle θ.
174 * @return theta
175 */
176 public double getTheta() {
177 return theta;
178 }
179
180 /**
181 * Get ax2oA = 2 * a / A .
182 * @return ax2oA
183 */
184 public double getAx2oA() {
185 return ax2oA;
186 }
187
188 /**
189 * Get Χ = 1 / sqrt(1 - e²) = 1 / B.
190 * @return chi
191 */
192 public double getChi() {
193 return chi;
194 }
195
196 /**
197 * Get Χ².
198 * @return chi2
199 */
200 public double getChi2() {
201 return chi2;
202 }
203
204 /**
205 * Get B / A.
206 * @return BoA
207 */
208 public double getBoA() {
209 return BoA;
210 }
211
212 /**
213 * Get ooAB = 1 / (A * B).
214 * @return ooAB
215 */
216 public double getOoAB() {
217 return ooAB;
218 }
219
220 /**
221 * Get Co2AB = C / 2AB.
222 * @return Co2AB
223 */
224 public double getCo2AB() {
225 return Co2AB;
226 }
227
228 /**
229 * Get BoABpo = B / A(1 + B).
230 * @return BoABpo
231 */
232 public double getBoABpo() {
233 return BoABpo;
234 }
235
236 /**
237 * Get μ / a .
238 * @return moa
239 */
240 public double getMoa() {
241 return moa;
242 }
243
244 /**
245 * Get roa = R / a.
246 * @return roa
247 */
248 public double getRoa() {
249 return roa;
250 }
251
252 /**
253 * Get the Keplerian period.
254 * <p>
255 * The Keplerian period is computed directly from semi major axis and central
256 * acceleration constant.
257 * </p>
258 * @return Keplerian period in seconds, or positive infinity for hyperbolic
259 * orbits
260 */
261 public double getOrbitPeriod() {
262 return period;
263 }
264
265 /**
266 * Get the Keplerian mean motion.
267 * <p>
268 * The Keplerian mean motion is computed directly from semi major axis and
269 * central acceleration constant.
270 * </p>
271 * @return Keplerian mean motion in radians per second
272 */
273 public double getMeanMotion() {
274 return n;
275 }
276
277 /**
278 * Get the ratio of satellite period to central body rotation period.
279 * @return ratio
280 */
281 public double getRatio() {
282 return ratio;
283 }
284
285 }