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