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.ForceModel;
21 import org.orekit.forces.maneuvers.Maneuver;
22 import org.orekit.propagation.SpacecraftState;
23 import org.orekit.propagation.integration.AdditionalDerivativesProvider;
24 import org.orekit.propagation.integration.CombinedDerivatives;
25 import org.orekit.time.AbsoluteDate;
26
27 import java.util.Arrays;
28 import java.util.List;
29
30 /** Generator for effect of delaying mass depletion when delaying a maneuver,
31 * when the mass itself is not included in the transition matrix.
32 * It neglects the influence of mass in other force models e.g. drag.
33 * For more accurate derivatives, one should use the full 7x7 state transition matrix instead.
34 * @author Luc Maisonobe
35 * @since 11.1
36 */
37 public class MassDepletionDelay implements AdditionalDerivativesProvider {
38
39 /** Prefix for state name. */
40 public static final String PREFIX = "Orekit-depletion-";
41
42 /** Name of the mass depletion additional state. */
43 private final String depletionName;
44
45 /** Start/stop management flag. */
46 private final boolean manageStart;
47
48 /** Maneuver that is delayed. */
49 private final Maneuver maneuver;
50
51 /** Indicator for forward propagation. */
52 private boolean forward;
53
54 /** List of non-gravitational forces, used only if mass is not in STM. */
55 private final List<ForceModel> nonGravitationalForces;
56
57 /** Constructor.
58 * <p>
59 * The generated additional state and derivatives will be named by prepending
60 * the {@link #PREFIX} to the name of the date trigger parameter.
61 * </p>
62 * @param triggerName name of the date trigger parameter
63 * @param manageStart if true, we compute derivatives with respect to maneuver start
64 * @param maneuver maneuver that is delayed
65 * @param nonGravitationalForces list of non-gravitational forces, used only if mass is not in STM.
66 * They are assumed to be inversely depending on mass.
67 */
68 public MassDepletionDelay(final String triggerName, final boolean manageStart, final Maneuver maneuver,
69 final ForceModel... nonGravitationalForces) {
70 this.depletionName = PREFIX + triggerName;
71 this.manageStart = manageStart;
72 this.maneuver = maneuver;
73 this.nonGravitationalForces = Arrays.asList(nonGravitationalForces);
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public String getName() {
79 return depletionName;
80 }
81
82 /** Get the dimension of the generated column.
83 * @return dimension of the generated column
84 */
85 public int getDimension() {
86 return 6;
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public void init(final SpacecraftState initialState, final AbsoluteDate target) {
92 forward = target.isAfterOrEqualTo(initialState);
93 }
94
95 /** {@inheritDoc} */
96 @Override
97 public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {
98
99 // retrieve current Jacobian column
100 final double[] p = state.getAdditionalState(getName());
101 final double[] pDot = new double[getDimension()];
102
103 if (forward == manageStart) {
104
105 // current acceleration
106 final double[] parameters = maneuver.getParameters(state.getDate());
107 // for the acceleration method we need all the span values of all the parameters driver
108 // as in the acceleration method an exctractParameter method is called
109 Vector3D acceleration = maneuver.acceleration(state, parameters);
110 for (final ForceModel forceModel: nonGravitationalForces) {
111 acceleration = acceleration.add(forceModel.acceleration(state, forceModel.getParameters(state.getDate())));
112 }
113
114 // it is assumed the non-gravitational accelerations are inversely proportional to the mass
115 final double m = state.getMass();
116 final double ratio = -1. / m;
117 pDot[0] = p[3];
118 pDot[1] = p[4];
119 pDot[2] = p[5];
120 pDot[3] = ratio * acceleration.getX();
121 pDot[4] = ratio * acceleration.getY();
122 pDot[5] = ratio * acceleration.getZ();
123
124 }
125
126 return new CombinedDerivatives(pDot, null);
127
128 }
129
130 }
131