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