InertialForces.java

  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.inertia;

  18. import java.util.Collections;
  19. import java.util.List;

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Rotation;
  24. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  25. import org.orekit.errors.OrekitIllegalArgumentException;
  26. import org.orekit.errors.OrekitMessages;
  27. import org.orekit.forces.ForceModel;
  28. import org.orekit.frames.FieldTransform;
  29. import org.orekit.frames.Frame;
  30. import org.orekit.frames.Transform;
  31. import org.orekit.propagation.FieldSpacecraftState;
  32. import org.orekit.propagation.SpacecraftState;
  33. import org.orekit.utils.AbsolutePVCoordinates;
  34. import org.orekit.utils.ParameterDriver;

  35. /** Inertial force model.
  36.  * <p>
  37.  * This force model adds the pseudo-forces due to inertia between the
  38.  * integrating frame and a reference inertial frame from which
  39.  * this force model is built.
  40.  * </p>
  41.  * <p>
  42.  * Two typical use-cases are propagating {@link AbsolutePVCoordinates} in either:
  43.  * </p>
  44.  * <ul>
  45.  *   <li>a non-inertial frame (for example propagating in the rotating {@link
  46.  *       org.orekit.frames.FramesFactory#getITRF(org.orekit.utils.IERSConventions, boolean) ITRF}
  47.  *       frame),</li>
  48.  *   <li>an inertial frame that is not related to the main attracting body (for example
  49.  *       propagating in {@link org.orekit.frames.FramesFactory#getEME2000() EME2000} frame a
  50.  *       trajectory about the Sun and Jupiter).</li>
  51.  * </ul>
  52.  * <p>
  53.  * In the second used case above, the attraction from the two main bodies, i.e. the Sun and
  54.  * Jupiter, should be represented by {@link org.orekit.forces.gravity.SingleBodyAbsoluteAttraction}
  55.  * instances.
  56.  * </p>
  57.  * @see org.orekit.forces.gravity.SingleBodyAbsoluteAttraction
  58.  * @author Guillaume Obrecht
  59.  * @author Luc Maisonobe
  60.  */
  61. public class InertialForces implements ForceModel {

  62.     /** Reference inertial frame to use to compute inertial forces. */
  63.     private final Frame referenceInertialFrame;

  64.     /** Simple constructor.
  65.      * @param referenceInertialFrame the pseudo-inertial frame to use as reference for the inertial forces
  66.      * @exception OrekitIllegalArgumentException if frame is not a {@link
  67.      * Frame#isPseudoInertial pseudo-inertial frame}
  68.      */
  69.     public InertialForces(final Frame referenceInertialFrame)
  70.         throws OrekitIllegalArgumentException {
  71.         if (!referenceInertialFrame.isPseudoInertial()) {
  72.             throw new OrekitIllegalArgumentException(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME_NOT_SUITABLE_AS_REFERENCE_FOR_INERTIAL_FORCES,
  73.                                                      referenceInertialFrame.getName());
  74.         }
  75.         this.referenceInertialFrame = referenceInertialFrame;
  76.     }

  77.     /** {@inheritDoc} */
  78.     @Override
  79.     public boolean dependsOnPositionOnly() {
  80.         return false;
  81.     }

  82.     /** {@inheritDoc} */
  83.     @Override
  84.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {

  85.         final Transform inertToStateFrame = referenceInertialFrame.getTransformTo(s.getFrame(), s.getDate());
  86.         final Vector3D  a1                = inertToStateFrame.getCartesian().getAcceleration();
  87.         final Rotation  r1                = inertToStateFrame.getAngular().getRotation();
  88.         final Vector3D  o1                = inertToStateFrame.getAngular().getRotationRate();
  89.         final Vector3D  oDot1             = inertToStateFrame.getAngular().getRotationAcceleration();

  90.         final Vector3D  p2                = s.getPosition();
  91.         final Vector3D  v2                = s.getPVCoordinates().getVelocity();

  92.         final Vector3D crossCrossP        = Vector3D.crossProduct(o1,    Vector3D.crossProduct(o1, p2));
  93.         final Vector3D crossV             = Vector3D.crossProduct(o1,    v2);
  94.         final Vector3D crossDotP          = Vector3D.crossProduct(oDot1, p2);

  95.         // we intentionally DON'T include s.getPVCoordinates().getAcceleration()
  96.         // because we want only the coupling effect of the frames transforms
  97.         return r1.applyTo(a1).subtract(new Vector3D(2, crossV, 1, crossCrossP, 1, crossDotP));

  98.     }

  99.     /** {@inheritDoc} */
  100.     @Override
  101.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
  102.                                                                          final T[] parameters) {

  103.         final FieldTransform<T> inertToStateFrame = referenceInertialFrame.getTransformTo(s.getFrame(), s.getDate());
  104.         final FieldVector3D<T>  a1                = inertToStateFrame.getCartesian().getAcceleration();
  105.         final FieldRotation<T>  r1                = inertToStateFrame.getAngular().getRotation();
  106.         final FieldVector3D<T>  o1                = inertToStateFrame.getAngular().getRotationRate();
  107.         final FieldVector3D<T>  oDot1             = inertToStateFrame.getAngular().getRotationAcceleration();

  108.         final FieldVector3D<T>  p2                = s.getPosition();
  109.         final FieldVector3D<T>  v2                = s.getPVCoordinates().getVelocity();

  110.         final FieldVector3D<T> crossCrossP        = FieldVector3D.crossProduct(o1,    FieldVector3D.crossProduct(o1, p2));
  111.         final FieldVector3D<T> crossV             = FieldVector3D.crossProduct(o1,    v2);
  112.         final FieldVector3D<T> crossDotP          = FieldVector3D.crossProduct(oDot1, p2);

  113.         // we intentionally DON'T include s.getPVCoordinates().getAcceleration()
  114.         // because we want only the coupling effect of the frames transforms
  115.         return r1.applyTo(a1).subtract(new FieldVector3D<>(2, crossV, 1, crossCrossP, 1, crossDotP));

  116.     }

  117.     /** {@inheritDoc} */
  118.     @Override
  119.     public List<ParameterDriver> getParametersDrivers() {
  120.         return Collections.emptyList();
  121.     }
  122. }