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.propagation;
18
19 import java.util.Collection;
20 import java.util.List;
21
22 import org.hipparchus.geometry.euclidean.threed.Rotation;
23 import org.hipparchus.geometry.euclidean.threed.Vector3D;
24 import org.hipparchus.linear.RealMatrix;
25 import org.orekit.attitudes.AttitudeProvider;
26 import org.orekit.attitudes.FrameAlignedProvider;
27 import org.orekit.frames.Frame;
28 import org.orekit.frames.Frames;
29 import org.orekit.frames.KinematicTransform;
30 import org.orekit.orbits.PositionAngleType;
31 import org.orekit.propagation.events.EventDetector;
32 import org.orekit.propagation.sampling.OrekitFixedStepHandler;
33 import org.orekit.propagation.sampling.OrekitStepHandler;
34 import org.orekit.propagation.sampling.StepHandlerMultiplexer;
35 import org.orekit.time.AbsoluteDate;
36 import org.orekit.utils.DoubleArrayDictionary;
37 import org.orekit.utils.PVCoordinatesProvider;
38 import org.orekit.utils.TimeStampedPVCoordinates;
39
40 /** This interface provides a way to propagate an orbit at any time.
41 *
42 * <p>This interface is the top-level abstraction for orbit propagation.
43 * It only allows propagation to a predefined date.
44 * It is implemented by analytical models which have no time limit,
45 * by orbit readers based on external data files, by numerical integrators
46 * using rich force models and by continuous models built after numerical
47 * integration has been completed and dense output data as been
48 * gathered.</p>
49 * <p>Note that one single propagator cannot be called from multiple threads.
50 * Its configuration can be changed as there is at least a {@link
51 * #resetInitialState(SpacecraftState)} method, and even propagators that do
52 * not support resetting state (like the {@link
53 * org.orekit.propagation.analytical.tle.TLEPropagator TLEPropagator} do
54 * cache some internal data during computation. However, as long as they
55 * are configured with independent building blocks (mainly event handlers
56 * and step handlers that may preserve some internal state), and as long
57 * as they are called from one thread only, they <em>can</em> be used in
58 * multi-threaded applications. Synchronizing several propagators to run in
59 * parallel is also possible using {@link PropagatorsParallelizer}.</p>
60 * @author Luc Maisonobe
61 * @author Véronique Pommier-Maurussane
62 *
63 */
64
65 public interface Propagator extends PVCoordinatesProvider {
66
67 /** Default mass. */
68 double DEFAULT_MASS = 1000.0;
69
70 /**
71 * Get a default law using the given frames.
72 *
73 * @param frames the set of frames to use.
74 * @return attitude law.
75 */
76 static AttitudeProvider getDefaultLaw(final Frames frames) {
77 return new FrameAlignedProvider(Rotation.IDENTITY, frames.getEME2000());
78 }
79
80 /** Get the multiplexer holding all step handlers.
81 * @return multiplexer holding all step handlers
82 * @since 11.0
83 */
84 StepHandlerMultiplexer getMultiplexer();
85
86 /** Remove all step handlers.
87 * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}</p>
88 * @see #getMultiplexer()
89 * @see StepHandlerMultiplexer#clear()
90 * @since 11.0
91 */
92 default void clearStepHandlers() {
93 getMultiplexer().clear();
94 }
95
96 /** Set a single handler for fixed stepsizes.
97 * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}
98 * followed by {@code getMultiplexer().add(h, handler)}</p>
99 * @param h fixed stepsize (s)
100 * @param handler handler called at the end of each finalized step
101 * @see #getMultiplexer()
102 * @see StepHandlerMultiplexer#add(double, OrekitFixedStepHandler)
103 * @since 11.0
104 */
105 default void setStepHandler(final double h, final OrekitFixedStepHandler handler) {
106 getMultiplexer().clear();
107 getMultiplexer().add(h, handler);
108 }
109
110 /** Set a single handler for variable stepsizes.
111 * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}
112 * followed by {@code getMultiplexer().add(handler)}</p>
113 * @param handler handler called at the end of each finalized step
114 * @see #getMultiplexer()
115 * @see StepHandlerMultiplexer#add(OrekitStepHandler)
116 * @since 11.0
117 */
118 default void setStepHandler(final OrekitStepHandler handler) {
119 getMultiplexer().clear();
120 getMultiplexer().add(handler);
121 }
122
123 /**
124 * Set up an ephemeris generator that will monitor the propagation for building
125 * an ephemeris from it once completed.
126 *
127 * <p>
128 * This generator can be used when the user needs fast random access to the orbit
129 * state at any time between the initial and target times. A typical example is the
130 * implementation of search and iterative algorithms that may navigate forward and
131 * backward inside the propagation range before finding their result even if the
132 * propagator used is integration-based and only goes from one initial time to one
133 * target time.
134 * </p>
135 * <p>
136 * Beware that when used with integration-based propagators, the generator will
137 * store <strong>all</strong> intermediate results. It is therefore memory intensive
138 * for long integration-based ranges and high precision/short time steps. When
139 * used with analytical propagators, the generator only stores start/stop time
140 * and a reference to the analytical propagator itself to call it back as needed,
141 * so it is less memory intensive.
142 * </p>
143 * <p>
144 * The returned ephemeris generator will be initially empty, it will be filled
145 * with propagation data when a subsequent call to either {@link #propagate(AbsoluteDate)
146 * propagate(target)} or {@link #propagate(AbsoluteDate, AbsoluteDate)
147 * propagate(start, target)} is called. The proper way to use this method is
148 * therefore to do:
149 * </p>
150 * <pre>
151 * EphemerisGenerator generator = propagator.getEphemerisGenerator();
152 * propagator.propagate(target);
153 * BoundedPropagator ephemeris = generator.getGeneratedEphemeris();
154 * </pre>
155 * @return ephemeris generator
156 */
157 EphemerisGenerator getEphemerisGenerator();
158
159 /** Get the propagator initial state.
160 * @return initial state
161 */
162 SpacecraftState getInitialState();
163
164 /** Reset the propagator initial state.
165 * @param state new initial state to consider
166 */
167 void resetInitialState(SpacecraftState state);
168
169 /** Add a set of user-specified data to be computed along with the orbit propagation.
170 * @param additionalDataProvider provider for additional data
171 */
172 void addAdditionalDataProvider(AdditionalDataProvider<?> additionalDataProvider);
173
174 /** Get an unmodifiable list of providers for additional data.
175 * @return providers for the additional data
176 */
177 List<AdditionalDataProvider<?>> getAdditionalDataProviders();
178
179 /** Check if an additional data is managed.
180 * <p>
181 * Managed data are the ones for which the propagators know how to compute
182 * its evolution. They correspond to additional data for which a
183 * {@link AdditionalDataProvider provider} has been registered by calling the
184 * {@link #addAdditionalDataProvider(AdditionalDataProvider) addAdditionalDataProvider} method.
185 * </p>
186 * <p>
187 * Additional data that are present in the {@link #getInitialState() initial state}
188 * but have no evolution method registered are <em>not</em> considered as managed data.
189 * These unmanaged additional data are not lost during propagation, though. Their
190 * value are piecewise constant between state resets that may change them if some
191 * event handler {@link
192 * org.orekit.propagation.events.handlers.EventHandler#resetState(EventDetector,
193 * SpacecraftState) resetState} method is called at an event occurrence and happens
194 * to change the unmanaged additional data.
195 * </p>
196 * @param name name of the additional data
197 * @return true if the additional data is managed
198 */
199 boolean isAdditionalDataManaged(String name);
200
201 /** Get all the names of all managed additional data.
202 * @return names of all managed additional data
203 */
204 String[] getManagedAdditionalData();
205
206 /** Add an event detector.
207 * @param detector event detector to add
208 * @see #clearEventsDetectors()
209 * @see #getEventDetectors()
210 * @param <T> class type for the generic version
211 */
212 <T extends EventDetector> void addEventDetector(T detector);
213
214 /** Get all the events detectors that have been added.
215 * @return an unmodifiable collection of the added detectors
216 * @see #addEventDetector(EventDetector)
217 * @see #clearEventsDetectors()
218 */
219 Collection<EventDetector> getEventDetectors();
220
221 /** Remove all events detectors.
222 * @see #addEventDetector(EventDetector)
223 * @see #getEventDetectors()
224 */
225 void clearEventsDetectors();
226
227 /** Get attitude provider.
228 * @return attitude provider
229 */
230 AttitudeProvider getAttitudeProvider();
231
232 /** Set attitude provider.
233 * @param attitudeProvider attitude provider
234 */
235 void setAttitudeProvider(AttitudeProvider attitudeProvider);
236
237 /** Get the frame in which the orbit is propagated.
238 * <p>
239 * The propagation frame is the definition frame of the initial
240 * state, so this method should be called after this state has
241 * been set, otherwise it may return null.
242 * </p>
243 * @return frame in which the orbit is propagated
244 * @see #resetInitialState(SpacecraftState)
245 */
246 Frame getFrame();
247
248 /** Set up computation of State Transition Matrix and Jacobians matrix with respect to parameters.
249 * <p>
250 * If this method is called, both State Transition Matrix and Jacobians with respect to the
251 * force models parameters that will be selected when propagation starts will be automatically
252 * computed, and the harvester will allow to retrieve them.
253 * </p>
254 * <p>
255 * The arguments for initial matrices <em>must</em> be compatible with the {@link org.orekit.orbits.OrbitType
256 * orbit type} and {@link PositionAngleType position angle} that will be used by the propagator.
257 * </p>
258 * <p>
259 * The default implementation throws an exception as the method is not supported by all propagators.
260 * </p>
261 * @param stmName State Transition Matrix state name
262 * @param initialStm initial State Transition Matrix ∂Y/∂Y₀,
263 * if null (which is the most frequent case), assumed to be 6x6 identity
264 * @param initialJacobianColumns initial columns of the Jacobians matrix with respect to parameters,
265 * if null or if some selected parameters are missing from the dictionary, the corresponding
266 * initial column is assumed to be 0
267 * @return harvester to retrieve computed matrices during and after propagation
268 * @since 11.1
269 */
270 default MatricesHarvester setupMatricesComputation(final String stmName, final RealMatrix initialStm,
271 final DoubleArrayDictionary initialJacobianColumns) {
272 throw new UnsupportedOperationException();
273 }
274
275 /** Propagate towards a target date.
276 * <p>Simple propagators use only the target date as the specification for
277 * computing the propagated state. More feature rich propagators can consider
278 * other information and provide different operating modes or G-stop
279 * facilities to stop at pinpointed events occurrences. In these cases, the
280 * target date is only a hint, not a mandatory objective.</p>
281 * @param target target date towards which orbit state should be propagated
282 * @return propagated state
283 */
284 SpacecraftState propagate(AbsoluteDate target);
285
286 /** Propagate from a start date towards a target date.
287 * <p>Those propagators use a start date and a target date to
288 * compute the propagated state. For propagators using event detection mechanism,
289 * if the provided start date is different from the initial state date, a first,
290 * simple propagation is performed, without processing any event computation.
291 * Then complete propagation is performed from start date to target date.</p>
292 * @param start start date from which orbit state should be propagated
293 * @param target target date to which orbit state should be propagated
294 * @return propagated state
295 */
296 SpacecraftState propagate(AbsoluteDate start, AbsoluteDate target);
297
298 /** {@inheritDoc} */
299 @Override
300 default TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
301 return propagate(date).getPVCoordinates(frame);
302 }
303
304 /** {@inheritDoc} */
305 @Override
306 default Vector3D getVelocity(final AbsoluteDate date, final Frame frame) {
307 final SpacecraftState state = propagate(date);
308 final KinematicTransform transform = getFrame().getKinematicTransformTo(frame, date);
309 return transform.transformOnlyPV(state.getPVCoordinates()).getVelocity();
310 }
311
312 /** {@inheritDoc} */
313 @Override
314 default Vector3D getPosition(final AbsoluteDate date, final Frame frame) {
315 return propagate(date).getPosition(frame);
316 }
317
318 }