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
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 @Deprecated
84 public double[] derivatives(final SpacecraftState state) {
85 return combinedDerivatives(state).getAdditionalDerivatives();
86 }
87
88 /** {@inheritDoc} */
89 @Override
90 public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {
91
92 // retrieve current Jacobian column
93 final double[] p = state.getAdditionalState(getName());
94 final double[] pDot = new double[6];
95
96 if (forward == manageStart) {
97
98 // current acceleration
99 final double[] parameters = maneuver.getParameters();
100 final Vector3D acceleration = maneuver.acceleration(state, parameters);
101
102 // we have acceleration Γ = F/m and m = m₀ - q (t - tₛ)
103 // where m is current mass, m₀ is initial mass and tₛ is maneuver trigger time
104 // a delay dtₛ on trigger time induces delaying mass depletion
105 // we get: dΓ = -F/m² dm = -F/m² q dtₛ = -Γ q/m dtₛ
106 final double minusQ = maneuver.getPropulsionModel().getMassDerivatives(state, parameters);
107 final double m = state.getMass();
108 final double ratio = minusQ / m;
109
110 pDot[0] = p[3];
111 pDot[1] = p[4];
112 pDot[2] = p[5];
113 pDot[3] = ratio * acceleration.getX();
114 pDot[4] = ratio * acceleration.getY();
115 pDot[5] = ratio * acceleration.getZ();
116
117 }
118
119 return new CombinedDerivatives(pDot, null);
120
121 }
122
123 }
124