Propagator.java

  1. /* Copyright 2002-2021 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.orekit.attitudes.AttitudeProvider;
  22. import org.orekit.attitudes.InertialProvider;
  23. import org.orekit.frames.Frame;
  24. import org.orekit.frames.Frames;
  25. import org.orekit.propagation.events.EventDetector;
  26. import org.orekit.propagation.sampling.OrekitFixedStepHandler;
  27. import org.orekit.propagation.sampling.OrekitStepHandler;
  28. import org.orekit.propagation.sampling.StepHandlerMultiplexer;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.utils.PVCoordinatesProvider;

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

  55. public interface Propagator extends PVCoordinatesProvider {

  56.     /** Default mass. */
  57.     double DEFAULT_MASS = 1000.0;

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

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

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

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

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

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

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

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

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

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

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

  186.     /** Get all the names of all managed states.
  187.      * @return names of all managed states
  188.      */
  189.     String[] getManagedAdditionalStates();

  190.     /** Add an event detector.
  191.      * @param detector event detector to add
  192.      * @see #clearEventsDetectors()
  193.      * @see #getEventsDetectors()
  194.      * @param <T> class type for the generic version
  195.      */
  196.     <T extends EventDetector> void addEventDetector(T detector);

  197.     /** Get all the events detectors that have been added.
  198.      * @return an unmodifiable collection of the added detectors
  199.      * @see #addEventDetector(EventDetector)
  200.      * @see #clearEventsDetectors()
  201.      */
  202.     Collection<EventDetector> getEventsDetectors();

  203.     /** Remove all events detectors.
  204.      * @see #addEventDetector(EventDetector)
  205.      * @see #getEventsDetectors()
  206.      */
  207.     void clearEventsDetectors();

  208.     /** Get attitude provider.
  209.      * @return attitude provider
  210.      */
  211.     AttitudeProvider getAttitudeProvider();

  212.     /** Set attitude provider.
  213.      * @param attitudeProvider attitude provider
  214.      */
  215.     void setAttitudeProvider(AttitudeProvider attitudeProvider);

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

  226.     /** Propagate towards a target date.
  227.      * <p>Simple propagators use only the target date as the specification for
  228.      * computing the propagated state. More feature rich propagators can consider
  229.      * other information and provide different operating modes or G-stop
  230.      * facilities to stop at pinpointed events occurrences. In these cases, the
  231.      * target date is only a hint, not a mandatory objective.</p>
  232.      * @param target target date towards which orbit state should be propagated
  233.      * @return propagated state
  234.      */
  235.     SpacecraftState propagate(AbsoluteDate target);

  236.     /** Propagate from a start date towards a target date.
  237.      * <p>Those propagators use a start date and a target date to
  238.      * compute the propagated state. For propagators using event detection mechanism,
  239.      * if the provided start date is different from the initial state date, a first,
  240.      * simple propagation is performed, without processing any event computation.
  241.      * Then complete propagation is performed from start date to target date.</p>
  242.      * @param start start date from which orbit state should be propagated
  243.      * @param target target date to which orbit state should be propagated
  244.      * @return propagated state
  245.      */
  246.     SpacecraftState propagate(AbsoluteDate start, AbsoluteDate target);

  247. }