Propagator.java

  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. import java.util.Collection;
  19. import java.util.List;

  20. import org.hipparchus.geometry.euclidean.threed.Rotation;
  21. import org.hipparchus.linear.RealMatrix;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.attitudes.InertialProvider;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.frames.Frames;
  26. import org.orekit.propagation.events.EventDetector;
  27. import org.orekit.propagation.sampling.OrekitFixedStepHandler;
  28. import org.orekit.propagation.sampling.OrekitStepHandler;
  29. import org.orekit.propagation.sampling.StepHandlerMultiplexer;
  30. import org.orekit.time.AbsoluteDate;
  31. import org.orekit.utils.DoubleArrayDictionary;
  32. import org.orekit.utils.PVCoordinatesProvider;

  33. /** This interface provides a way to propagate an orbit at any time.
  34.  *
  35.  * <p>This interface is the top-level abstraction for orbit propagation.
  36.  * It only allows propagation to a predefined date.
  37.  * It is implemented by analytical models which have no time limit,
  38.  * by orbit readers based on external data files, by numerical integrators
  39.  * using rich force models and by continuous models built after numerical
  40.  * integration has been completed and dense output data as been
  41.  * gathered.</p>
  42.  * <p>Note that one single propagator cannot be called from multiple threads.
  43.  * Its configuration can be changed as there is at least a {@link
  44.  * #resetInitialState(SpacecraftState)} method, and even propagators that do
  45.  * not support resetting state (like the {@link
  46.  * org.orekit.propagation.analytical.tle.TLEPropagator TLEPropagator} do
  47.  * cache some internal data during computation. However, as long as they
  48.  * are configured with independent building blocks (mainly event handlers
  49.  * and step handlers that may preserve some internal state), and as long
  50.  * as they are called from one thread only, they <em>can</em> be used in
  51.  * multi-threaded applications. Synchronizing several propagators to run in
  52.  * parallel is also possible using {@link PropagatorsParallelizer}.</p>
  53.  * @author Luc Maisonobe
  54.  * @author V&eacute;ronique Pommier-Maurussane
  55.  *
  56.  */

  57. public interface Propagator extends PVCoordinatesProvider {

  58.     /** Default mass. */
  59.     double DEFAULT_MASS = 1000.0;

  60.     /**
  61.      * Get a default law using the given frames.
  62.      *
  63.      * @param frames the set of frames to use.
  64.      * @return attitude law.
  65.      */
  66.     static AttitudeProvider getDefaultLaw(final Frames frames) {
  67.         return new InertialProvider(Rotation.IDENTITY, frames.getEME2000());
  68.     }

  69.     /** Get the multiplexer holding all step handlers.
  70.      * @return multiplexer holding all step handlers
  71.      * @since 11.0
  72.      */
  73.     StepHandlerMultiplexer getMultiplexer();

  74.     /** Remove all step handlers.
  75.      * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}</p>
  76.      * @see #getMultiplexer()
  77.      * @see StepHandlerMultiplexer#clear()
  78.      * @since 11.0
  79.      */
  80.     default void clearStepHandlers() {
  81.         getMultiplexer().clear();
  82.     }

  83.     /** Set a single handler for fixed stepsizes.
  84.      * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}
  85.      * followed by {@code getMultiplexer().add(h, handler)}</p>
  86.      * @param h fixed stepsize (s)
  87.      * @param handler handler called at the end of each finalized step
  88.      * @see #getMultiplexer()
  89.      * @see StepHandlerMultiplexer#add(double, OrekitFixedStepHandler)
  90.      * @since 11.0
  91.      */
  92.     default void setStepHandler(final double h, final OrekitFixedStepHandler handler) {
  93.         getMultiplexer().clear();
  94.         getMultiplexer().add(h, handler);
  95.     }

  96.     /** Set a single handler for variable stepsizes.
  97.      * <p>This convenience method is equivalent to call {@code getMultiplexer().clear()}
  98.      * followed by {@code getMultiplexer().add(handler)}</p>
  99.      * @param handler handler called at the end of each finalized step
  100.      * @see #getMultiplexer()
  101.      * @see StepHandlerMultiplexer#add(OrekitStepHandler)
  102.      * @since 11.0
  103.      */
  104.     default void setStepHandler(final OrekitStepHandler handler) {
  105.         getMultiplexer().clear();
  106.         getMultiplexer().add(handler);
  107.     }

  108.     /**
  109.      * Set up an ephemeris generator that will monitor the propagation for building
  110.      * an ephemeris from it once completed.
  111.      *
  112.      * <p>
  113.      * This generator can be used when the user needs fast random access to the orbit
  114.      * state at any time between the initial and target times. A typical example is the
  115.      * implementation of search and iterative algorithms that may navigate forward and
  116.      * backward inside the propagation range before finding their result even if the
  117.      * propagator used is integration-based and only goes from one initial time to one
  118.      * target time.
  119.      * </p>
  120.      * <p>
  121.      * Beware that when used with integration-based propagators, the generator will
  122.      * store <strong>all</strong> intermediate results. It is therefore memory intensive
  123.      * for long integration-based ranges and high precision/short time steps. When
  124.      * used with analytical propagators, the generator only stores start/stop time
  125.      * and a reference to the analytical propagator itself to call it back as needed,
  126.      * so it is less memory intensive.
  127.      * </p>
  128.      * <p>
  129.      * The returned ephemeris generator will be initially empty, it will be filled
  130.      * with propagation data when a subsequent call to either {@link #propagate(AbsoluteDate)
  131.      * propagate(target)} or {@link #propagate(AbsoluteDate, AbsoluteDate)
  132.      * propagate(start, target)} is called. The proper way to use this method is
  133.      * therefore to do:
  134.      * </p>
  135.      * <pre>
  136.      *   EphemerisGenerator generator = propagator.getEphemerisGenerator();
  137.      *   propagator.propagate(target);
  138.      *   BoundedPropagator ephemeris = generator.getGeneratedEphemeris();
  139.      * </pre>
  140.      * @return ephemeris generator
  141.      */
  142.     EphemerisGenerator getEphemerisGenerator();

  143.     /** Get the propagator initial state.
  144.      * @return initial state
  145.      */
  146.     SpacecraftState getInitialState();

  147.     /** Reset the propagator initial state.
  148.      * @param state new initial state to consider
  149.      */
  150.     void resetInitialState(SpacecraftState state);

  151.     /** Add a set of user-specified state parameters to be computed along with the orbit propagation.
  152.      * @param additionalStateProvider provider for additional state
  153.      */
  154.     void addAdditionalStateProvider(AdditionalStateProvider additionalStateProvider);

  155.     /** Get an unmodifiable list of providers for additional state.
  156.      * @return providers for the additional states
  157.      */
  158.     List<AdditionalStateProvider> getAdditionalStateProviders();

  159.     /** Check if an additional state is managed.
  160.      * <p>
  161.      * Managed states are states for which the propagators know how to compute
  162.      * its evolution. They correspond to additional states for which a
  163.      * {@link AdditionalStateProvider provider} has been registered by calling the
  164.      * {@link #addAdditionalStateProvider(AdditionalStateProvider) addAdditionalStateProvider} method.
  165.      * </p>
  166.      * <p>
  167.      * Additional states that are present in the {@link #getInitialState() initial state}
  168.      * but have no evolution method registered are <em>not</em> considered as managed states.
  169.      * These unmanaged additional states are not lost during propagation, though. Their
  170.      * value are piecewise constant between state resets that may change them if some
  171.      * event handler {@link
  172.      * org.orekit.propagation.events.handlers.EventHandler#resetState(EventDetector,
  173.      * SpacecraftState) resetState} method is called at an event occurrence and happens
  174.      * to change the unmanaged additional state.
  175.      * </p>
  176.      * @param name name of the additional state
  177.      * @return true if the additional state is managed
  178.      */
  179.     boolean isAdditionalStateManaged(String name);

  180.     /** Get all the names of all managed states.
  181.      * @return names of all managed states
  182.      */
  183.     String[] getManagedAdditionalStates();

  184.     /** Add an event detector.
  185.      * @param detector event detector to add
  186.      * @see #clearEventsDetectors()
  187.      * @see #getEventsDetectors()
  188.      * @param <T> class type for the generic version
  189.      */
  190.     <T extends EventDetector> void addEventDetector(T detector);

  191.     /** Get all the events detectors that have been added.
  192.      * @return an unmodifiable collection of the added detectors
  193.      * @see #addEventDetector(EventDetector)
  194.      * @see #clearEventsDetectors()
  195.      */
  196.     Collection<EventDetector> getEventsDetectors();

  197.     /** Remove all events detectors.
  198.      * @see #addEventDetector(EventDetector)
  199.      * @see #getEventsDetectors()
  200.      */
  201.     void clearEventsDetectors();

  202.     /** Get attitude provider.
  203.      * @return attitude provider
  204.      */
  205.     AttitudeProvider getAttitudeProvider();

  206.     /** Set attitude provider.
  207.      * @param attitudeProvider attitude provider
  208.      */
  209.     void setAttitudeProvider(AttitudeProvider attitudeProvider);

  210.     /** Get the frame in which the orbit is propagated.
  211.      * <p>
  212.      * The propagation frame is the definition frame of the initial
  213.      * state, so this method should be called after this state has
  214.      * been set, otherwise it may return null.
  215.      * </p>
  216.      * @return frame in which the orbit is propagated
  217.      * @see #resetInitialState(SpacecraftState)
  218.      */
  219.     Frame getFrame();

  220.     /** Set up computation of State Transition Matrix and Jacobians matrix with respect to parameters.
  221.      * <p>
  222.      * If this method is called, both State Transition Matrix and Jacobians with respect to the
  223.      * force models parameters that will be selected when propagation starts will be automatically
  224.      * computed, and the harvester will allow to retrieve them.
  225.      * </p>
  226.      * <p>
  227.      * The arguments for initial matrices <em>must</em> be compatible with the {@link org.orekit.orbits.OrbitType
  228.      * orbit type} and {@link org.orekit.orbits.PositionAngle position angle} that will be used by the propagator.
  229.      * </p>
  230.      * <p>
  231.      * The default implementation throws an exception as the method is not supported by all propagators.
  232.      * </p>
  233.      * @param stmName State Transition Matrix state name
  234.      * @param initialStm initial State Transition Matrix ∂Y/∂Y₀,
  235.      * if null (which is the most frequent case), assumed to be 6x6 identity
  236.      * @param initialJacobianColumns initial columns of the Jacobians matrix with respect to parameters,
  237.      * if null or if some selected parameters are missing from the dictionary, the corresponding
  238.      * initial column is assumed to be 0
  239.      * @return harvester to retrieve computed matrices during and after propagation
  240.      * @since 11.1
  241.      */
  242.     default MatricesHarvester setupMatricesComputation(final String stmName, final RealMatrix initialStm,
  243.                                                        final DoubleArrayDictionary initialJacobianColumns) {
  244.         throw new UnsupportedOperationException();
  245.     }

  246.     /** Propagate towards a target date.
  247.      * <p>Simple propagators use only the target date as the specification for
  248.      * computing the propagated state. More feature rich propagators can consider
  249.      * other information and provide different operating modes or G-stop
  250.      * facilities to stop at pinpointed events occurrences. In these cases, the
  251.      * target date is only a hint, not a mandatory objective.</p>
  252.      * @param target target date towards which orbit state should be propagated
  253.      * @return propagated state
  254.      */
  255.     SpacecraftState propagate(AbsoluteDate target);

  256.     /** Propagate from a start date towards a target date.
  257.      * <p>Those propagators use a start date and a target date to
  258.      * compute the propagated state. For propagators using event detection mechanism,
  259.      * if the provided start date is different from the initial state date, a first,
  260.      * simple propagation is performed, without processing any event computation.
  261.      * Then complete propagation is performed from start date to target date.</p>
  262.      * @param start start date from which orbit state should be propagated
  263.      * @param target target date to which orbit state should be propagated
  264.      * @return propagated state
  265.      */
  266.     SpacecraftState propagate(AbsoluteDate start, AbsoluteDate target);

  267. }