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.forces.gravity;
18  
19  import java.util.Collections;
20  import java.util.List;
21  
22  import org.hipparchus.CalculusFieldElement;
23  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24  import org.hipparchus.geometry.euclidean.threed.Vector3D;
25  import org.hipparchus.util.FastMath;
26  import org.orekit.forces.ForceModel;
27  import org.orekit.frames.FieldStaticTransform;
28  import org.orekit.frames.Frame;
29  import org.orekit.frames.StaticTransform;
30  import org.orekit.propagation.FieldSpacecraftState;
31  import org.orekit.propagation.SpacecraftState;
32  import org.orekit.utils.Constants;
33  import org.orekit.utils.FieldPVCoordinates;
34  import org.orekit.utils.PVCoordinates;
35  import org.orekit.utils.ParameterDriver;
36  
37  /**
38   * Lense-Thirring post-Newtonian correction force due to general relativity.
39   * <p>
40   * Lense-Thirring term causes a precession of the orbital plane at a rate of
41   * the order of 0.8 mas per year (geostationary) to 180 mas per year (low orbit).
42   * </p>
43   * @see "Petit, G. and Luzum, B. (eds.), IERS Conventions (2010), Chapter 10,
44   * General relativistic models for space-time coordinates and equations of motion (2010)"
45   *
46   * @author Bryan Cazabonne
47   * @since 10.3
48   */
49  public class LenseThirringRelativity implements ForceModel {
50  
51      /** Intensity of the Earth's angular momentum per unit mass [m²/s]. */
52      private static final double J = 9.8e8;
53  
54      /** Central attraction scaling factor.
55       * <p>
56       * We use a power of 2 to avoid numeric noise introduction
57       * in the multiplications/divisions sequences.
58       * </p>
59       */
60      private static final double MU_SCALE = FastMath.scalb(1.0, 32);
61  
62      /** Driver for gravitational parameter. */
63      private final ParameterDriver gmParameterDriver;
64  
65      /** Central body frame. */
66      private final Frame bodyFrame;
67  
68      /**
69       * Constructor.
70       * @param gm Earth's gravitational parameter.
71       * @param bodyFrame central body frame
72       */
73      public LenseThirringRelativity(final double gm, final Frame bodyFrame) {
74          gmParameterDriver = new ParameterDriver(NewtonianAttraction.CENTRAL_ATTRACTION_COEFFICIENT,
75                                                  gm, MU_SCALE,
76                                                  0.0, Double.POSITIVE_INFINITY);
77          this.bodyFrame = bodyFrame;
78      }
79  
80      /** {@inheritDoc} */
81      @Override
82      public boolean dependsOnPositionOnly() {
83          return false;
84      }
85  
86      /** {@inheritDoc} */
87      @Override
88      public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {
89  
90          // Useful constant
91          final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;
92  
93          // Earth's gravitational parameter
94          final double gm = parameters[0];
95  
96          // Satellite position and velocity with respect to the Earth
97          final PVCoordinates pv = s.getPVCoordinates();
98          final Vector3D p = pv.getPosition();
99          final Vector3D v = pv.getVelocity();
100 
101         // Radius
102         final double r  = p.getNorm();
103         final double r2 = r * r;
104 
105         // Earth’s angular momentum per unit mass
106         final StaticTransform t =
107                 bodyFrame.getStaticTransformTo(s.getFrame(), s.getDate());
108         final Vector3D  j = t.transformVector(Vector3D.PLUS_K).scalarMultiply(J);
109 
110         // Eq. 10.12
111         return new Vector3D(3.0 * p.dotProduct(j) / r2,
112                             p.crossProduct(v),
113                             1.0,
114                             v.crossProduct(j))
115                             .scalarMultiply((2.0 * gm) / (r2 * r * c2));
116     }
117 
118     /** {@inheritDoc} */
119     @Override
120     public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
121                                                                          final T[] parameters) {
122 
123         // Useful constant
124         final double c2 = Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT;
125 
126         // Earth's gravitational parameter
127         final T gm = parameters[0];
128 
129         // Satellite position and velocity with respect to the Earth
130         final FieldPVCoordinates<T> pv = s.getPVCoordinates();
131         final FieldVector3D<T> p = pv.getPosition();
132         final FieldVector3D<T> v = pv.getVelocity();
133 
134         // Radius
135         final T r  = p.getNorm();
136         final T r2 = r.square();
137 
138         // Earth’s angular momentum per unit mass
139         final FieldStaticTransform<T> t = bodyFrame.getStaticTransformTo(s.getFrame(), s.getDate());
140         final FieldVector3D<T>        j = t.transformVector(Vector3D.PLUS_K).scalarMultiply(J);
141 
142         return new FieldVector3D<>(p.dotProduct(j).multiply(3.0).divide(r2),
143                                    p.crossProduct(v),
144                                    r.getField().getOne(),
145                                    v.crossProduct(j))
146                                    .scalarMultiply(gm.multiply(2.0).divide(r2.multiply(r).multiply(c2)));
147     }
148 
149     /** {@inheritDoc} */
150     @Override
151     public List<ParameterDriver> getParametersDrivers() {
152         return Collections.singletonList(gmParameterDriver);
153     }
154 
155 }