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
19 import org.hipparchus.geometry.euclidean.threed.Vector3D;
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
26 /** Generator for effect of delaying mass depletion when delaying a maneuver.
27 * @author Luc Maisonobe
28 * @since 11.1
29 */
30 public class MassDepletionDelay implements AdditionalDerivativesProvider {
31
32 /** Prefix for state name. */
33 public static final String PREFIX = "Orekit-depletion-";
34
35 /** Name of the mass depletion additional state. */
36 private final String depletionName;
37
38 /** Start/stop management flag. */
39 private final boolean manageStart;
40
41 /** Maneuver that is delayed. */
42 private final Maneuver maneuver;
43
44 /** Indicator for forward propagation. */
45 private boolean forward;
46
47 /** Simple 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 */
56 public MassDepletionDelay(final String triggerName, final boolean manageStart, final Maneuver maneuver) {
57 this.depletionName = PREFIX + triggerName;
58 this.manageStart = manageStart;
59 this.maneuver = maneuver;
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 public String getName() {
65 return depletionName;
66 }
67
68 /** Get the dimension of the generated column.
69 * @return dimension of the generated column
70 */
71 public int getDimension() {
72 return 6;
73 }
74
75 /** {@inheritDoc} */
76 @Override
77 public void init(final SpacecraftState initialState, final AbsoluteDate target) {
78 forward = target.isAfterOrEqualTo(initialState);
79 }
80
81 /** {@inheritDoc} */
82 @Override
83 public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {
84
85 // retrieve current Jacobian column
86 final double[] p = state.getAdditionalState(getName());
87 final double[] pDot = new double[6];
88
89 if (forward == manageStart) {
90
91 // current acceleration
92 final double[] parameters = maneuver.getParameters(state.getDate());
93 // for the acceleration method we need all the span values of all the parameters driver
94 // as in the acceleration method an exctractParameter method is called
95 final Vector3D acceleration = maneuver.acceleration(state, parameters);
96
97 // we have acceleration Γ = F/m and m = m₀ - q (t - tₛ)
98 // where m is current mass, m₀ is initial mass and tₛ is maneuver trigger time
99 // a delay dtₛ on trigger time induces delaying mass depletion
100 // we get: dΓ = -F/m² dm = -F/m² q dtₛ = -Γ q/m dtₛ
101 final double minusQ = maneuver.getPropulsionModel().getMassDerivatives(state, maneuver.getParameters(state.getDate()));
102 final double m = state.getMass();
103 final double ratio = minusQ / m;
104
105 pDot[0] = p[3];
106 pDot[1] = p[4];
107 pDot[2] = p[5];
108 pDot[3] = ratio * acceleration.getX();
109 pDot[4] = ratio * acceleration.getY();
110 pDot[5] = ratio * acceleration.getZ();
111
112 }
113
114 return new CombinedDerivatives(pDot, null);
115
116 }
117
118 }
119