Propagator.java

  1. /* Copyright 2002-2020 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.annotation.DefaultDataContext;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.attitudes.InertialProvider;
  24. import org.orekit.data.DataContext;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.frames.Frames;
  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.time.AbsoluteDate;
  31. import org.orekit.utils.PVCoordinatesProvider;

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

  56. public interface Propagator extends PVCoordinatesProvider {

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

  59.     /** Default attitude provider.
  60.      *
  61.      * <p>This field uses the {@link DataContext#getDefault() default data context}.
  62.      *
  63.      * @see InertialProvider#InertialProvider(Rotation, Frame)
  64.      * @see #getDefaultLaw(Frames)
  65.      */
  66.     @DefaultDataContext
  67.     AttitudeProvider DEFAULT_LAW = InertialProvider.EME2000_ALIGNED;

  68.     /** Indicator for slave mode. */
  69.     int SLAVE_MODE = 0;

  70.     /** Indicator for master mode. */
  71.     int MASTER_MODE = 1;

  72.     /** Indicator for ephemeris generation mode. */
  73.     int EPHEMERIS_GENERATION_MODE = 2;

  74.     /**
  75.      * Get a default law using the given frames. A data context aware replacement for
  76.      * {@link #DEFAULT_LAW}.
  77.      *
  78.      * @param frames the set of frames to use.
  79.      * @return attitude law.
  80.      */
  81.     static AttitudeProvider getDefaultLaw(final Frames frames) {
  82.         return new InertialProvider(Rotation.IDENTITY, frames.getEME2000());
  83.     }

  84.     /** Get the current operating mode of the propagator.
  85.      * @return one of {@link #SLAVE_MODE}, {@link #MASTER_MODE},
  86.      * {@link #EPHEMERIS_GENERATION_MODE}
  87.      * @see #setSlaveMode()
  88.      * @see #setMasterMode(double, OrekitFixedStepHandler)
  89.      * @see #setMasterMode(OrekitStepHandler)
  90.      * @see #setEphemerisMode()
  91.      */
  92.     int getMode();

  93.     /** Set the propagator to slave mode.
  94.      * <p>This mode is used when the user needs only the final orbit at the target time.
  95.      *  The (slave) propagator computes this result and return it to the calling
  96.      *  (master) application, without any intermediate feedback.
  97.      * <p>This is the default mode.</p>
  98.      * @see #setMasterMode(double, OrekitFixedStepHandler)
  99.      * @see #setMasterMode(OrekitStepHandler)
  100.      * @see #setEphemerisMode()
  101.      * @see #getMode()
  102.      * @see #SLAVE_MODE
  103.      */
  104.     void setSlaveMode();

  105.     /** Set the propagator to master mode with fixed steps.
  106.      * <p>This mode is used when the user needs to have some custom function called at the
  107.      * end of each finalized step during integration. The (master) propagator integration
  108.      * loop calls the (slave) application callback methods at each finalized step.</p>
  109.      * @param h fixed stepsize (s)
  110.      * @param handler handler called at the end of each finalized step
  111.      * @see #setSlaveMode()
  112.      * @see #setMasterMode(OrekitStepHandler)
  113.      * @see #setEphemerisMode()
  114.      * @see #getMode()
  115.      * @see #MASTER_MODE
  116.      */
  117.     void setMasterMode(double h, OrekitFixedStepHandler handler);

  118.     /** Set the propagator to master mode with variable steps.
  119.      * <p>This mode is used when the user needs to have some custom function called at the
  120.      * end of each finalized step during integration. The (master) propagator integration
  121.      * loop calls the (slave) application callback methods at each finalized step.</p>
  122.      * @param handler handler called at the end of each finalized step
  123.      * @see #setSlaveMode()
  124.      * @see #setMasterMode(double, OrekitFixedStepHandler)
  125.      * @see #setEphemerisMode()
  126.      * @see #getMode()
  127.      * @see #MASTER_MODE
  128.      */
  129.     void setMasterMode(OrekitStepHandler handler);

  130.     /** Set the propagator to ephemeris generation mode.
  131.      *  <p>This mode is used when the user needs random access to the orbit state at any time
  132.      *  between the initial and target times, and in no sequential order. A typical example is
  133.      *  the implementation of search and iterative algorithms that may navigate forward and
  134.      *  backward inside the propagation range before finding their result.</p>
  135.      *  <p>Beware that since this mode stores <strong>all</strong> intermediate results,
  136.      *  it may be memory intensive for long integration ranges and high precision/short
  137.      *  time steps.</p>
  138.      * @see #getGeneratedEphemeris()
  139.      * @see #setSlaveMode()
  140.      * @see #setMasterMode(double, OrekitFixedStepHandler)
  141.      * @see #setMasterMode(OrekitStepHandler)
  142.      * @see #getMode()
  143.      * @see #EPHEMERIS_GENERATION_MODE
  144.      */
  145.     void setEphemerisMode();

  146.     /**
  147.      * Set the propagator to ephemeris generation mode with the specified handler for each
  148.      * integration step.
  149.      *
  150.      * <p>This mode is used when the user needs random access to the orbit state at any
  151.      * time between the initial and target times, as well as access to the steps computed
  152.      * by the integrator as in Master Mode. A typical example is the implementation of
  153.      * search and iterative algorithms that may navigate forward and backward inside the
  154.      * propagation range before finding their result.</p>
  155.      *
  156.      * <p>Beware that since this mode stores <strong>all</strong> intermediate results, it
  157.      * may be memory intensive for long integration ranges and high precision/short time
  158.      * steps.</p>
  159.      *
  160.      * @param handler handler called at the end of each finalized step
  161.      * @see #setEphemerisMode()
  162.      * @see #getGeneratedEphemeris()
  163.      * @see #setSlaveMode()
  164.      * @see #setMasterMode(double, OrekitFixedStepHandler)
  165.      * @see #setMasterMode(OrekitStepHandler)
  166.      * @see #getMode()
  167.      * @see #EPHEMERIS_GENERATION_MODE
  168.      */
  169.     void setEphemerisMode(OrekitStepHandler handler);

  170.     /** Get the ephemeris generated during propagation.
  171.      * @return generated ephemeris
  172.      * @exception IllegalStateException if the propagator was not set in ephemeris
  173.      * generation mode before propagation
  174.      * @see #setEphemerisMode()
  175.      */
  176.     BoundedPropagator getGeneratedEphemeris() throws IllegalStateException;

  177.     /** Get the propagator initial state.
  178.      * @return initial state
  179.      */
  180.     SpacecraftState getInitialState();

  181.     /** Reset the propagator initial state.
  182.      * @param state new initial state to consider
  183.      */
  184.     void resetInitialState(SpacecraftState state);

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

  189.     /** Get an unmodifiable list of providers for additional state.
  190.      * @return providers for the additional states
  191.      */
  192.     List<AdditionalStateProvider> getAdditionalStateProviders();

  193.     /** Check if an additional state is managed.
  194.      * <p>
  195.      * Managed states are states for which the propagators know how to compute
  196.      * its evolution. They correspond to additional states for which an
  197.      * {@link AdditionalStateProvider additional state provider} has been registered
  198.      * by calling the {@link #addAdditionalStateProvider(AdditionalStateProvider)
  199.      * addAdditionalStateProvider} method. If the propagator is an {@link
  200.      * org.orekit.propagation.integration.AbstractIntegratedPropagator integrator-based
  201.      * propagator}, the states for which a set of {@link
  202.      * org.orekit.propagation.integration.AdditionalEquations additional equations} has
  203.      * been registered by calling the {@link
  204.      * org.orekit.propagation.integration.AbstractIntegratedPropagator#addAdditionalEquations(
  205.      * org.orekit.propagation.integration.AdditionalEquations) addAdditionalEquations}
  206.      * method are also counted as managed additional states.
  207.      * </p>
  208.      * <p>
  209.      * Additional states that are present in the {@link #getInitialState() initial state}
  210.      * but have no evolution method registered are <em>not</em> considered as managed states.
  211.      * These unmanaged additional states are not lost during propagation, though. Their
  212.      * value are piecewise constant between state resets that may change them if some
  213.      * event handler {@link
  214.      * org.orekit.propagation.events.handlers.EventHandler#resetState(EventDetector,
  215.      * SpacecraftState) resetState} method is called at an event occurrence and happens
  216.      * to change the unmanaged additional state.
  217.      * </p>
  218.      * @param name name of the additional state
  219.      * @return true if the additional state is managed
  220.      */
  221.     boolean isAdditionalStateManaged(String name);

  222.     /** Get all the names of all managed states.
  223.      * @return names of all managed states
  224.      */
  225.     String[] getManagedAdditionalStates();

  226.     /** Add an event detector.
  227.      * @param detector event detector to add
  228.      * @see #clearEventsDetectors()
  229.      * @see #getEventsDetectors()
  230.      * @param <T> class type for the generic version
  231.      */
  232.     <T extends EventDetector> void addEventDetector(T detector);

  233.     /** Get all the events detectors that have been added.
  234.      * @return an unmodifiable collection of the added detectors
  235.      * @see #addEventDetector(EventDetector)
  236.      * @see #clearEventsDetectors()
  237.      */
  238.     Collection<EventDetector> getEventsDetectors();

  239.     /** Remove all events detectors.
  240.      * @see #addEventDetector(EventDetector)
  241.      * @see #getEventsDetectors()
  242.      */
  243.     void clearEventsDetectors();

  244.     /** Get attitude provider.
  245.      * @return attitude provider
  246.      */
  247.     AttitudeProvider getAttitudeProvider();

  248.     /** Set attitude provider.
  249.      * @param attitudeProvider attitude provider
  250.      */
  251.     void setAttitudeProvider(AttitudeProvider attitudeProvider);

  252.     /** Get the frame in which the orbit is propagated.
  253.      * <p>
  254.      * The propagation frame is the definition frame of the initial
  255.      * state, so this method should be called after this state has
  256.      * been set, otherwise it may return null.
  257.      * </p>
  258.      * @return frame in which the orbit is propagated
  259.      * @see #resetInitialState(SpacecraftState)
  260.      */
  261.     Frame getFrame();

  262.     /** Propagate towards a target date.
  263.      * <p>Simple propagators use only the target date as the specification for
  264.      * computing the propagated state. More feature rich propagators can consider
  265.      * other information and provide different operating modes or G-stop
  266.      * facilities to stop at pinpointed events occurrences. In these cases, the
  267.      * target date is only a hint, not a mandatory objective.</p>
  268.      * @param target target date towards which orbit state should be propagated
  269.      * @return propagated state
  270.      */
  271.     SpacecraftState propagate(AbsoluteDate target);

  272.     /** Propagate from a start date towards a target date.
  273.      * <p>Those propagators use a start date and a target date to
  274.      * compute the propagated state. For propagators using event detection mechanism,
  275.      * if the provided start date is different from the initial state date, a first,
  276.      * simple propagation is performed, without processing any event computation.
  277.      * Then complete propagation is performed from start date to target date.</p>
  278.      * @param start start date from which orbit state should be propagated
  279.      * @param target target date to which orbit state should be propagated
  280.      * @return propagated state
  281.      */
  282.     SpacecraftState propagate(AbsoluteDate start, AbsoluteDate target);

  283. }