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.maneuvers.Maneuver;
  20. import org.orekit.propagation.SpacecraftState;
  21. import org.orekit.propagation.integration.AdditionalDerivativesProvider;
  22. import org.orekit.propagation.integration.CombinedDerivatives;
  23. import org.orekit.time.AbsoluteDate;

  24. /** Generator for effect of delaying mass depletion when delaying a maneuver.
  25.  * @author Luc Maisonobe
  26.  * @since 11.1
  27.  */
  28. public class MassDepletionDelay implements AdditionalDerivativesProvider {

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

  31.     /** Name of the mass depletion additional state. */
  32.     private final String depletionName;

  33.     /** Start/stop management flag. */
  34.     private final boolean manageStart;

  35.     /** Maneuver that is delayed. */
  36.     private final Maneuver maneuver;

  37.     /** Indicator for forward propagation. */
  38.     private boolean forward;

  39.     /** Simple constructor.
  40.      * <p>
  41.      * The generated additional state and derivatives will be named by prepending
  42.      * the {@link #PREFIX} to the name of the date trigger parameter.
  43.      * </p>
  44.      * @param triggerName name of the date trigger parameter
  45.      * @param manageStart if true, we compute derivatives with respect to maneuver start
  46.      * @param maneuver maneuver that is delayed
  47.      */
  48.     public MassDepletionDelay(final String triggerName, final boolean manageStart, final Maneuver maneuver) {
  49.         this.depletionName = PREFIX + triggerName;
  50.         this.manageStart   = manageStart;
  51.         this.maneuver      = maneuver;
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public String getName() {
  56.         return depletionName;
  57.     }

  58.     /** Get the dimension of the generated column.
  59.      * @return dimension of the generated column
  60.      */
  61.     public int getDimension() {
  62.         return 6;
  63.     }

  64.     /** {@inheritDoc} */
  65.     @Override
  66.     public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  67.         forward = target.isAfterOrEqualTo(initialState);
  68.     }

  69.     /** {@inheritDoc} */
  70.     @Override
  71.     public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {

  72.         // retrieve current Jacobian column
  73.         final double[] p = state.getAdditionalState(getName());
  74.         final double[] pDot = new double[6];

  75.         if (forward == manageStart) {

  76.             // current acceleration
  77.             final double[] parameters   = maneuver.getParameters(state.getDate());
  78.             // for the acceleration method we need all the span values of all the parameters driver
  79.             // as in the acceleration method an exctractParameter method is called
  80.             final Vector3D acceleration = maneuver.acceleration(state, parameters);

  81.             // we have acceleration Γ = F/m and m = m₀ - q (t - tₛ)
  82.             // where m is current mass, m₀ is initial mass and tₛ is maneuver trigger time
  83.             // a delay dtₛ on trigger time induces delaying mass depletion
  84.             // we get: dΓ = -F/m² dm = -F/m² q dtₛ = -Γ q/m dtₛ
  85.             final double minusQ = maneuver.getPropulsionModel().getMassDerivatives(state, maneuver.getParameters(state.getDate()));
  86.             final double m      = state.getMass();
  87.             final double ratio  = minusQ / m;

  88.             pDot[0] = p[3];
  89.             pDot[1] = p[4];
  90.             pDot[2] = p[5];
  91.             pDot[3] = ratio * acceleration.getX();
  92.             pDot[4] = ratio * acceleration.getY();
  93.             pDot[5] = ratio * acceleration.getZ();

  94.         }

  95.         return new CombinedDerivatives(pDot, null);

  96.     }

  97. }