Propagator.java

  1. /* Copyright 2002-2023 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.FrameAlignedProvider;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.frames.Frames;
  26. import org.orekit.orbits.PositionAngleType;
  27. import org.orekit.propagation.events.EventDetector;
  28. import org.orekit.propagation.sampling.OrekitFixedStepHandler;
  29. import org.orekit.propagation.sampling.OrekitStepHandler;
  30. import org.orekit.propagation.sampling.StepHandlerMultiplexer;
  31. import org.orekit.time.AbsoluteDate;
  32. import org.orekit.utils.DoubleArrayDictionary;
  33. import org.orekit.utils.PVCoordinatesProvider;

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

  58. public interface Propagator extends PVCoordinatesProvider {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  268. }