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.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
21  import org.orekit.frames.Frame;
22  import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
23  import org.orekit.time.AbsoluteDate;
24  
25  /**
26   * This class is a container for the common "field" parameters used in {@link DSSTZonal}.
27   * <p>
28   * It performs parameters initialization at each integration step for the Zonal contribution
29   * to the central body gravitational perturbation.
30   * </p>
31   * @author Bryan Cazabonne
32   * @since 10.0
33   * @param <T> type of the field elements
34   */
35  public class FieldDSSTZonalContext<T extends CalculusFieldElement<T>> extends FieldDSSTGravityContext<T> {
36  
37      /** &Chi;³ = 1 / B³. */
38      private final T chi3;
39  
40      // Short period terms
41      /** h * k. */
42      private T hk;
43      /** k² - h². */
44      private T k2mh2;
45      /** (k² - h²) / 2. */
46      private T k2mh2o2;
47      /** 1 / (n² * a²). */
48      private T oon2a2;
49      /** 1 / (n² * a) . */
50      private T oon2a;
51      /** χ³ / (n² * a). */
52      private T x3on2a;
53      /** χ / (n² * a²). */
54      private T xon2a2;
55      /** (C * χ) / ( 2 * n² * a² ). */
56      private T cxo2n2a2;
57      /** (χ²) / (n² * a² * (χ + 1 ) ). */
58      private T x2on2a2xp1;
59      /** B * B. */
60      private T BB;
61  
62      /** Constructor with central body frame equals orbit frame.
63       *
64       * @param auxiliaryElements auxiliary elements related to the current orbit
65       * @param provider          provider for spherical harmonics
66       * @param parameters        values of the force model parameters (only 1 values
67       * for each parameters corresponding to state date) obtained by calling the extract
68       * parameter method {@link #extractParameters(double[], AbsoluteDate)}
69       * to selected the right value for state date or by getting the parameters for a specific date
70       * @deprecated since 12.2 and issue 1104, should be removed in 13.0
71       */
72      @Deprecated
73      FieldDSSTZonalContext(final FieldAuxiliaryElements<T> auxiliaryElements,
74                            final UnnormalizedSphericalHarmonicsProvider provider,
75                            final T[] parameters) {
76  
77          this(auxiliaryElements, auxiliaryElements.getFrame(), provider, parameters);
78      }
79  
80      /** Constructor with central body frame potentially different from orbit frame.
81       *
82       * @param auxiliaryElements auxiliary elements related to the current orbit
83       * @param centralBodyFrame  rotating body frame
84       * @param provider          provider for spherical harmonics
85       * @param parameters        values of the force model parameters (only 1 values
86       * for each parameters corresponding to state date) obtained by calling the extract
87       * parameter method {@link #extractParameters(double[], AbsoluteDate)}
88       * to selected the right value for state date or by getting the parameters for a specific date
89       * @since 12.2
90       */
91      FieldDSSTZonalContext(final FieldAuxiliaryElements<T> auxiliaryElements,
92                            final Frame centralBodyFrame,
93                            final UnnormalizedSphericalHarmonicsProvider provider,
94                            final T[] parameters) {
95  
96          super(auxiliaryElements, centralBodyFrame, provider, parameters);
97  
98          // Chi3
99          final T chi = getChi();
100         this.chi3 = chi.multiply(getChi2());
101 
102         // Short period terms
103         // -----
104 
105         // h * k.
106         hk = auxiliaryElements.getH().multiply(auxiliaryElements.getK());
107         // k² - h².
108         k2mh2 = auxiliaryElements.getK().multiply(auxiliaryElements.getK()).subtract(auxiliaryElements.getH().multiply(auxiliaryElements.getH()));
109         // (k² - h²) / 2.
110         k2mh2o2 = k2mh2.divide(2.);
111         // 1 / (n² * a²) = 1 / (n * A)
112         oon2a2 = (getA().multiply(getMeanMotion())).reciprocal();
113         // 1 / (n² * a) = a / (n * A)
114         oon2a = auxiliaryElements.getSma().multiply(oon2a2);
115         // χ³ / (n² * a)
116         x3on2a = chi3.multiply(oon2a);
117         // χ / (n² * a²)
118         xon2a2 = chi.multiply(oon2a2);
119         // (C * χ) / ( 2 * n² * a² )
120         cxo2n2a2 = xon2a2.multiply(auxiliaryElements.getC()).divide(2.);
121         // (χ²) / (n² * a² * (χ + 1 ) )
122         x2on2a2xp1 = xon2a2.multiply(chi).divide(chi.add(1.));
123         // B * B
124         BB = auxiliaryElements.getB().multiply(auxiliaryElements.getB());
125     }
126 
127 
128     /** Getter for the &Chi;³.
129      * @return the &Chi;³
130      */
131     public T getChi3() {
132         return chi3;
133     }
134 
135     /** Get h * k.
136      * @return hk
137      */
138     public T getHK() {
139         return hk;
140     }
141 
142     /** Get k² - h².
143      * @return k2mh2
144      */
145     public T getK2MH2() {
146         return k2mh2;
147     }
148 
149     /** Get (k² - h²) / 2.
150      * @return k2mh2o2
151      */
152     public T getK2MH2O2() {
153         return k2mh2o2;
154     }
155 
156     /** Get 1 / (n² * a²).
157      * @return oon2a2
158      */
159     public T getOON2A2() {
160         return oon2a2;
161     }
162 
163     /** Get χ³ / (n² * a).
164      * @return x3on2a
165      */
166     public T getX3ON2A() {
167         return x3on2a;
168     }
169 
170     /** Get χ / (n² * a²).
171      * @return xon2a2
172      */
173     public T getXON2A2() {
174         return xon2a2;
175     }
176 
177     /** Get (C * χ) / ( 2 * n² * a² ).
178      * @return cxo2n2a2
179      */
180     public T getCXO2N2A2() {
181         return cxo2n2a2;
182     }
183 
184     /** Get (χ²) / (n² * a² * (χ + 1 ) ).
185      * @return x2on2a2xp1
186      */
187     public T getX2ON2A2XP1() {
188         return x2on2a2xp1;
189     }
190 
191     /** Get B * B.
192      * @return BB
193      */
194     public T getBB() {
195         return BB;
196     }
197 
198 }