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;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.Vector3D;
21 import org.orekit.attitudes.AttitudeProvider;
22 import org.orekit.forces.maneuvers.propulsion.AbstractConstantThrustPropulsionModel;
23 import org.orekit.forces.maneuvers.propulsion.BasicConstantThrustPropulsionModel;
24 import org.orekit.forces.maneuvers.trigger.DateBasedManeuverTriggers;
25 import org.orekit.propagation.FieldSpacecraftState;
26 import org.orekit.propagation.SpacecraftState;
27 import org.orekit.time.AbsoluteDate;
28
29 /** This class implements a simple maneuver with constant thrust.
30 * <p>The maneuver is defined by a direction in satellite frame.
31 * The current attitude of the spacecraft, defined by the current
32 * spacecraft state, will be used to compute the thrust direction in
33 * inertial frame. A typical case for tangential maneuvers is to use a
34 * {@link org.orekit.attitudes.LofOffset LOF aligned} attitude provider
35 * for state propagation and a velocity increment along the +X satellite axis.</p>
36 * @author Fabien Maussion
37 * @author Véronique Pommier-Maurussane
38 * @author Luc Maisonobe
39 * @author Maxime Journot
40 */
41 public class ConstantThrustManeuver extends Maneuver {
42
43 /** Simple constructor for a constant direction and constant thrust.
44 * <p>
45 * It uses the propulsion model {@link BasicConstantThrustPropulsionModel} and
46 * the maneuver triggers {@link DateBasedManeuverTriggers}
47 * </p><p>
48 * Calling this constructor is equivalent to call {@link
49 * #ConstantThrustManeuver(AbsoluteDate, double, double, double, Vector3D, String)
50 * ConstantThrustManeuver(date, duration, thrust, isp, direction, "")},
51 * hence not using any prefix for the parameters drivers names.
52 * </p>
53 * @param date maneuver date
54 * @param duration the duration of the thrust (s) (if negative,
55 * the date is considered to be the stop date)
56 * @param thrust the thrust force (N)
57 * @param isp engine specific impulse (s)
58 * @param direction the acceleration direction in satellite frame.
59 */
60 public ConstantThrustManeuver(final AbsoluteDate date, final double duration,
61 final double thrust, final double isp,
62 final Vector3D direction) {
63 this(date, duration, thrust, isp, direction, "");
64 }
65
66 /** Simple constructor for a constant direction and constant thrust.
67 * <p>
68 * It uses the propulsion model {@link BasicConstantThrustPropulsionModel} and
69 * the maneuver triggers {@link DateBasedManeuverTriggers}
70 * </p><p>
71 * Calling this constructor is equivalent to call {@link
72 * #ConstantThrustManeuver(AbsoluteDate, double, double, double, Vector3D, String)
73 * ConstantThrustManeuver(date, duration, thrust, isp, direction, "")},
74 * hence not using any prefix for the parameters drivers names.
75 * </p>
76 * @param date maneuver date
77 * @param duration the duration of the thrust (s) (if negative,
78 * the date is considered to be the stop date)
79 * @param thrust the thrust force (N)
80 * @param isp engine specific impulse (s)
81 * @param attitudeOverride the attitude provider to use for the maneuver, or
82 * null if the attitude from the propagator should be used
83 * @param direction the acceleration direction in satellite frame.
84 * @since 9.2
85 */
86 public ConstantThrustManeuver(final AbsoluteDate date, final double duration,
87 final double thrust, final double isp,
88 final AttitudeProvider attitudeOverride, final Vector3D direction) {
89 this(date, duration, thrust, isp, attitudeOverride, direction, "");
90 }
91
92 /** Simple constructor for a constant direction and constant thrust.
93 * <p>
94 * It uses the propulsion model {@link BasicConstantThrustPropulsionModel} and
95 * the maneuver triggers {@link DateBasedManeuverTriggers}
96 * </p><p>
97 * The name of the maneuver is used to distinguish the parameter drivers.
98 * A typical use case is to use something like "1A-" or "2B-" as a prefix corresponding to the
99 * name of the thruster to use, so separate parameters can be adjusted
100 * for the different thrusters involved during an orbit determination
101 * where maneuvers parameters are estimated.
102 * </p>
103 * @param date maneuver date
104 * @param duration the duration of the thrust (s) (if negative,
105 * the date is considered to be the stop date)
106 * @param thrust the thrust force (N)
107 * @param isp engine specific impulse (s)
108 * @param direction the acceleration direction in satellite frame
109 * @param name name of the maneuver, used as a prefix for the {@link #getParametersDrivers() parameters drivers}
110 * @since 9.0
111 */
112 public ConstantThrustManeuver(final AbsoluteDate date, final double duration,
113 final double thrust, final double isp,
114 final Vector3D direction,
115 final String name) {
116 this(date, duration, thrust, isp, null, direction, name);
117 }
118
119 /** Simple constructor for a constant direction and constant thrust.
120 * <p>
121 * It uses the propulsion model {@link BasicConstantThrustPropulsionModel} and
122 * the maneuver triggers {@link DateBasedManeuverTriggers}
123 * </p><p>
124 * The name of the maneuver is used to distinguish the parameter drivers.
125 * A typical use case is to use something like "1A-" or "2B-" as a prefix corresponding to the
126 * name of the thruster to use, so separate parameters can be adjusted
127 * for the different thrusters involved during an orbit determination
128 * where maneuvers parameters are estimated.
129 * </p>
130 * @param date maneuver date
131 * @param duration the duration of the thrust (s) (if negative,
132 * the date is considered to be the stop date)
133 * @param thrust the thrust force (N)
134 * @param isp engine specific impulse (s)
135 * @param attitudeOverride the attitude provider to use for the maneuver, or
136 * null if the attitude from the propagator should be used
137 * @param direction the acceleration direction in satellite frame
138 * @param name name of the maneuver, used as a prefix for the {@link #getParametersDrivers() parameters drivers}
139 * @since 9.2
140 */
141 public ConstantThrustManeuver(final AbsoluteDate date, final double duration,
142 final double thrust, final double isp,
143 final AttitudeProvider attitudeOverride, final Vector3D direction,
144 final String name) {
145 this(date, duration, attitudeOverride, new BasicConstantThrustPropulsionModel(thrust, isp, direction, name));
146 }
147
148 /** Simple constructor for a constant direction and constant thrust.
149 * <p>
150 * It uses an {@link AbstractConstantThrustPropulsionModel} and
151 * the maneuver triggers {@link DateBasedManeuverTriggers}
152 * </p><p>
153 * The names of the maneuver (and thus its parameter drivers) are extracted
154 * from the propulsion model.
155 * </p>
156 * @param date maneuver date
157 * @param duration the duration of the thrust (s) (if negative,
158 * the date is considered to be the stop date)
159 * @param attitudeOverride the attitude provider to use for the maneuver, or
160 * null if the attitude from the propagator should be used
161 * @param constantThrustPropulsionModel user-defined constant thrust propulsion model
162 */
163 public ConstantThrustManeuver(final AbsoluteDate date, final double duration,
164 final AttitudeProvider attitudeOverride,
165 final AbstractConstantThrustPropulsionModel constantThrustPropulsionModel) {
166 this(attitudeOverride,
167 new DateBasedManeuverTriggers(constantThrustPropulsionModel.getName(), date, duration),
168 constantThrustPropulsionModel);
169 }
170
171 /** Simple constructor for a constant direction and constant thrust.
172 * <p>
173 * It uses an {@link AbstractConstantThrustPropulsionModel} and
174 * the maneuver triggers {@link DateBasedManeuverTriggers}
175 * </p><p>
176 * The names of the maneuver (and thus its parameter drivers) are extracted
177 * from the propulsion model or the maneuver triggers.
178 * Propulsion model name is evaluated first, if it isn't empty, it becomes the name of the maneuver.
179 * In that case the name in the maneuver triggers should be the same or empty, otherwise this could be
180 * misleading when retrieving estimated parameters by their names.
181 * </p>
182 * @param attitudeOverride the attitude provider to use for the maneuver, or
183 * null if the attitude from the propagator should be used
184 * @param dateBasedManeuverTriggers user-defined maneuver triggers object based on a start and end date
185 * @param constantThrustPropulsionModel user-defined constant thrust propulsion model
186 */
187 public ConstantThrustManeuver(final AttitudeProvider attitudeOverride,
188 final DateBasedManeuverTriggers dateBasedManeuverTriggers,
189 final AbstractConstantThrustPropulsionModel constantThrustPropulsionModel) {
190 super(attitudeOverride, dateBasedManeuverTriggers, constantThrustPropulsionModel);
191 }
192
193 /** Get the thrust vector (N) in S/C frame.
194 * @return thrust vector (N) in S/C frame.
195 */
196 public Vector3D getThrustVector() {
197 return ((AbstractConstantThrustPropulsionModel) (getPropulsionModel())).getThrustVector();
198 }
199
200 /** Get the thrust.
201 * @return thrust force (N).
202 */
203 public double getThrust() {
204 return getThrustVector().getNorm();
205 }
206
207 /** Get the specific impulse.
208 * @return specific impulse (s).
209 */
210 public double getISP() {
211 return ((AbstractConstantThrustPropulsionModel) (getPropulsionModel())).getIsp();
212 }
213
214 /** Get the flow rate.
215 * @return flow rate (negative, kg/s).
216 */
217 public double getFlowRate() {
218 return ((AbstractConstantThrustPropulsionModel) (getPropulsionModel())).getFlowRate();
219 }
220
221 /** Get the direction.
222 * @return the direction
223 * @since 9.2
224 */
225 public Vector3D getDirection() {
226 return getThrustVector().normalize();
227 }
228
229 /** Get the start date.
230 * @return the start date
231 * @since 9.2
232 */
233 public AbsoluteDate getStartDate() {
234 return ((DateBasedManeuverTriggers) (getManeuverTriggers())).getStartDate();
235 }
236
237 /** Get the end date.
238 * @return the end date
239 * @since 9.2
240 */
241 public AbsoluteDate getEndDate() {
242 return ((DateBasedManeuverTriggers) (getManeuverTriggers())).getEndDate();
243 }
244
245 /** Get the duration of the maneuver (s).
246 * duration = endDate - startDate
247 * @return the duration of the maneuver (s)
248 * @since 9.2
249 */
250 public double getDuration() {
251 return ((DateBasedManeuverTriggers) (getManeuverTriggers())).getDuration();
252 }
253
254 /** Check if maneuvering is on.
255 * @param s current state
256 * @return true if maneuver is on at this state
257 * @since 10.1
258 */
259 public boolean isFiring(final SpacecraftState s) {
260 return isFiring(s.getDate());
261 }
262
263 /** Check if maneuvering is on.
264 * @param s current state
265 * @param <T> type of the field elements
266 * @return true if maneuver is on at this state
267 * @since 10.1
268 */
269 public <T extends CalculusFieldElement<T>> boolean isFiring(final FieldSpacecraftState<T> s) {
270 return isFiring(s.getDate().toAbsoluteDate());
271 }
272
273 /** Check if maneuvering is on.
274 * @param date current date
275 * @return true if maneuver is on at this date
276 * @since 10.1
277 */
278 public boolean isFiring(final AbsoluteDate date) {
279 return getManeuverTriggers().isFiring(date, new double[] {});
280 }
281 }