MassDepletionDelay.java

  1. /* Copyright 2002-2022 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.time.AbsoluteDate;

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

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

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

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

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

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

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

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

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

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

  68.     /** {@inheritDoc} */
  69.     @Override
  70.     public double[] derivatives(final SpacecraftState state) {

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

  74.         if (forward == manageStart) {

  75.             // current acceleration
  76.             final double[] parameters   = maneuver.getParameters();
  77.             final Vector3D acceleration = maneuver.acceleration(state, parameters);

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

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

  91.         }

  92.         return pDot;

  93.     }

  94. }