1 /* Copyright 2002-2026 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 base initial state without additional data.
160 * @return base initial state without additional data
161 * @see #getInitialState()
162 * @since 14.0
163 */
164 SpacecraftState getBaseInitialState();
165
166 /** Get the propagator initial state.
167 * <p>
168 * If additional data has been {@link #addAdditionalDataProvider(AdditionalDataProvider) added}
169 * to the propagator, the initial state returned here includes it.
170 * </p>
171 * @return initial state, ultimately with additional data
172 * @see #getBaseInitialState()
173 */
174 SpacecraftState getInitialState();
175
176 /** Reset the propagator initial state.
177 * @param state new initial state to consider (without additional data)
178 */
179 void resetInitialState(SpacecraftState state);
180
181 /** Add a set of user-specified data to be computed along with the orbit propagation.
182 * @param additionalDataProvider provider for additional data
183 */
184 void addAdditionalDataProvider(AdditionalDataProvider<?> additionalDataProvider);
185
186 /** Get an unmodifiable list of providers for additional data.
187 * @return providers for the additional data
188 */
189 List<AdditionalDataProvider<?>> getAdditionalDataProviders();
190
191 /** Check if an additional data is managed.
192 * <p>
193 * Managed data are the ones for which the propagators know how to compute
194 * its evolution. They correspond to additional data for which a
195 * {@link AdditionalDataProvider provider} has been registered by calling the
196 * {@link #addAdditionalDataProvider(AdditionalDataProvider) addAdditionalDataProvider} method.
197 * </p>
198 * <p>
199 * Additional data that are present in the {@link #getInitialState() initial state}
200 * but have no evolution method registered are <em>not</em> considered as managed data.
201 * These unmanaged additional data are not lost during propagation, though. Their
202 * value are piecewise constant between state resets that may change them if some
203 * event handler {@link
204 * org.orekit.propagation.events.handlers.EventHandler#resetState(EventDetector,
205 * SpacecraftState) resetState} method is called at an event occurrence and happens
206 * to change the unmanaged additional data.
207 * </p>
208 * @param name name of the additional data
209 * @return true if the additional data is managed
210 */
211 boolean isAdditionalDataManaged(String name);
212
213 /** Get all the names of all managed additional data.
214 * @return names of all managed additional data
215 */
216 String[] getManagedAdditionalData();
217
218 /** Add an event detector.
219 * @param detector event detector to add
220 * @see #clearEventsDetectors()
221 * @see #getEventDetectors()
222 * @param <T> class type for the generic version
223 */
224 <T extends EventDetector> void addEventDetector(T detector);
225
226 /** Get all the events detectors that have been added.
227 * @return an unmodifiable collection of the added detectors
228 * @see #addEventDetector(EventDetector)
229 * @see #clearEventsDetectors()
230 */
231 Collection<EventDetector> getEventDetectors();
232
233 /** Remove all events detectors.
234 * @see #addEventDetector(EventDetector)
235 * @see #getEventDetectors()
236 */
237 void clearEventsDetectors();
238
239 /** Get attitude provider.
240 * @return attitude provider
241 */
242 AttitudeProvider getAttitudeProvider();
243
244 /** Set attitude provider.
245 * @param attitudeProvider attitude provider
246 */
247 void setAttitudeProvider(AttitudeProvider attitudeProvider);
248
249 /** Get the frame in which the orbit is propagated.
250 * <p>
251 * The propagation frame is the definition frame of the initial
252 * state, so this method should be called after this state has
253 * been set, otherwise it may return null.
254 * </p>
255 * @return frame in which the orbit is propagated
256 * @see #resetInitialState(SpacecraftState)
257 */
258 Frame getFrame();
259
260 /** Set up computation of State Transition Matrix and Jacobians matrix with respect to parameters.
261 * <p>
262 * If this method is called, both State Transition Matrix and Jacobians with respect to the
263 * force models parameters that will be selected when propagation starts will be automatically
264 * computed, and the harvester will allow to retrieve them.
265 * </p>
266 * <p>
267 * The arguments for initial matrices <em>must</em> be compatible with the {@link org.orekit.orbits.OrbitType
268 * orbit type} and {@link PositionAngleType position angle} that will be used by the propagator.
269 * </p>
270 * @param stmName State Transition Matrix state name
271 * @param initialStm initial State Transition Matrix ∂Y/∂Y₀,
272 * if null (which is the most frequent case), assumed to be 6x6 identity
273 * @param initialJacobianColumns initial columns of the Jacobians matrix with respect to parameters,
274 * if null or if some selected parameters are missing from the dictionary, the corresponding
275 * initial column is assumed to be 0
276 * @return harvester to retrieve computed matrices during and after propagation
277 * @since 11.1
278 */
279 MatricesHarvester setupMatricesComputation(String stmName, RealMatrix initialStm,
280 DoubleArrayDictionary initialJacobianColumns);
281
282 /** Propagate towards a target date.
283 * <p>Simple propagators use only the target date as the specification for
284 * computing the propagated state. More feature rich propagators can consider
285 * other information and provide different operating modes or G-stop
286 * facilities to stop at pinpointed events occurrences. In these cases, the
287 * target date is only a hint, not a mandatory objective.</p>
288 * @param target target date towards which orbit state should be propagated
289 * @return propagated state
290 */
291 SpacecraftState propagate(AbsoluteDate target);
292
293 /** Propagate from a start date towards a target date.
294 * <p>Those propagators use a start date and a target date to
295 * compute the propagated state. For propagators using event detection mechanism,
296 * if the provided start date is different from the initial state date, a first,
297 * simple propagation is performed, without processing any event computation.
298 * Then complete propagation is performed from start date to target date.</p>
299 * @param start start date from which orbit state should be propagated
300 * @param target target date to which orbit state should be propagated
301 * @return propagated state
302 */
303 SpacecraftState propagate(AbsoluteDate start, AbsoluteDate target);
304
305 /** {@inheritDoc} */
306 @Override
307 default TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
308 return propagate(date).getPVCoordinates(frame);
309 }
310
311 /** {@inheritDoc} */
312 @Override
313 default Vector3D getVelocity(final AbsoluteDate date, final Frame frame) {
314 final SpacecraftState state = propagate(date);
315 final KinematicTransform transform = getFrame().getKinematicTransformTo(frame, date);
316 return transform.transformOnlyPV(state.getPVCoordinates()).getVelocity();
317 }
318
319 /** {@inheritDoc} */
320 @Override
321 default Vector3D getPosition(final AbsoluteDate date, final Frame frame) {
322 return propagate(date).getPosition(frame);
323 }
324
325 }