MassDepletionDelay.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.maneuvers.jacobians;

  18. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  19. import org.orekit.forces.ForceModel;
  20. import org.orekit.forces.maneuvers.Maneuver;
  21. import org.orekit.propagation.SpacecraftState;
  22. import org.orekit.propagation.integration.AdditionalDerivativesProvider;
  23. import org.orekit.propagation.integration.CombinedDerivatives;
  24. import org.orekit.time.AbsoluteDate;

  25. import java.util.Arrays;
  26. import java.util.List;

  27. /** Generator for effect of delaying mass depletion when delaying a maneuver,
  28.  *  when the mass itself is not included in the transition matrix.
  29.  * It neglects the influence of mass in other force models e.g. drag.
  30.  * For more accurate derivatives, one should use the full 7x7 state transition matrix instead.
  31.  * @author Luc Maisonobe
  32.  * @since 11.1
  33.  */
  34. public class MassDepletionDelay implements AdditionalDerivativesProvider {

  35.     /** Prefix for state name. */
  36.     public static final String PREFIX = "Orekit-depletion-";

  37.     /** Name of the mass depletion additional state. */
  38.     private final String depletionName;

  39.     /** Start/stop management flag. */
  40.     private final boolean manageStart;

  41.     /** Maneuver that is delayed. */
  42.     private final Maneuver maneuver;

  43.     /** Indicator for forward propagation. */
  44.     private boolean forward;

  45.     /** List of non-gravitational forces, used only if mass is not in STM. */
  46.     private final List<ForceModel> nonGravitationalForces;

  47.     /** Constructor.
  48.      * <p>
  49.      * The generated additional state and derivatives will be named by prepending
  50.      * the {@link #PREFIX} to the name of the date trigger parameter.
  51.      * </p>
  52.      * @param triggerName name of the date trigger parameter
  53.      * @param manageStart if true, we compute derivatives with respect to maneuver start
  54.      * @param maneuver maneuver that is delayed
  55.      * @param nonGravitationalForces list of non-gravitational forces, used only if mass is not in STM.
  56.      *                               They are assumed to be inversely depending on mass.
  57.      */
  58.     public MassDepletionDelay(final String triggerName, final boolean manageStart, final Maneuver maneuver,
  59.                               final ForceModel... nonGravitationalForces) {
  60.         this.depletionName = PREFIX + triggerName;
  61.         this.manageStart   = manageStart;
  62.         this.maneuver      = maneuver;
  63.         this.nonGravitationalForces = Arrays.asList(nonGravitationalForces);
  64.     }

  65.     /** {@inheritDoc} */
  66.     @Override
  67.     public String getName() {
  68.         return depletionName;
  69.     }

  70.     /** Get the dimension of the generated column.
  71.      * @return dimension of the generated column
  72.      */
  73.     public int getDimension() {
  74.         return 6;
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  79.         forward = target.isAfterOrEqualTo(initialState);
  80.     }

  81.     /** {@inheritDoc} */
  82.     @Override
  83.     public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {

  84.         // retrieve current Jacobian column
  85.         final double[] p = state.getAdditionalState(getName());
  86.         final double[] pDot = new double[getDimension()];

  87.         if (forward == manageStart) {

  88.             // current acceleration
  89.             final double[] parameters   = maneuver.getParameters(state.getDate());
  90.             // for the acceleration method we need all the span values of all the parameters driver
  91.             // as in the acceleration method an exctractParameter method is called
  92.             Vector3D acceleration = maneuver.acceleration(state, parameters);
  93.             for (final ForceModel forceModel: nonGravitationalForces) {
  94.                 acceleration = acceleration.add(forceModel.acceleration(state, forceModel.getParameters(state.getDate())));
  95.             }

  96.             // it is assumed the non-gravitational accelerations are inversely proportional to the mass
  97.             final double m      = state.getMass();
  98.             final double ratio  = -1. / m;
  99.             pDot[0] = p[3];
  100.             pDot[1] = p[4];
  101.             pDot[2] = p[5];
  102.             pDot[3] = ratio * acceleration.getX();
  103.             pDot[4] = ratio * acceleration.getY();
  104.             pDot[5] = ratio * acceleration.getZ();

  105.         }

  106.         return new CombinedDerivatives(pDot, null);

  107.     }

  108. }