NumericalPropagator.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.numerical;

  18. import java.util.ArrayList;
  19. import java.util.Arrays;
  20. import java.util.Collections;
  21. import java.util.List;

  22. import org.hipparchus.exception.LocalizedCoreFormats;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.hipparchus.linear.MatrixUtils;
  25. import org.hipparchus.linear.QRDecomposition;
  26. import org.hipparchus.linear.RealMatrix;
  27. import org.hipparchus.ode.ODEIntegrator;
  28. import org.hipparchus.util.FastMath;
  29. import org.hipparchus.util.Precision;
  30. import org.orekit.annotation.DefaultDataContext;
  31. import org.orekit.attitudes.Attitude;
  32. import org.orekit.attitudes.AttitudeProvider;
  33. import org.orekit.data.DataContext;
  34. import org.orekit.errors.OrekitException;
  35. import org.orekit.errors.OrekitIllegalArgumentException;
  36. import org.orekit.errors.OrekitInternalError;
  37. import org.orekit.errors.OrekitMessages;
  38. import org.orekit.forces.ForceModel;
  39. import org.orekit.forces.gravity.NewtonianAttraction;
  40. import org.orekit.forces.inertia.InertialForces;
  41. import org.orekit.forces.maneuvers.Maneuver;
  42. import org.orekit.forces.maneuvers.jacobians.Duration;
  43. import org.orekit.forces.maneuvers.jacobians.MedianDate;
  44. import org.orekit.forces.maneuvers.jacobians.TriggerDate;
  45. import org.orekit.forces.maneuvers.trigger.AbstractManeuverTriggers;
  46. import org.orekit.forces.maneuvers.trigger.ManeuverTriggers;
  47. import org.orekit.frames.Frame;
  48. import org.orekit.orbits.Orbit;
  49. import org.orekit.orbits.OrbitType;
  50. import org.orekit.orbits.PositionAngle;
  51. import org.orekit.propagation.AbstractMatricesHarvester;
  52. import org.orekit.propagation.AdditionalStateProvider;
  53. import org.orekit.propagation.MatricesHarvester;
  54. import org.orekit.propagation.PropagationType;
  55. import org.orekit.propagation.Propagator;
  56. import org.orekit.propagation.SpacecraftState;
  57. import org.orekit.propagation.events.EventDetector;
  58. import org.orekit.propagation.events.ParameterDrivenDateIntervalDetector;
  59. import org.orekit.propagation.integration.AbstractIntegratedPropagator;
  60. import org.orekit.propagation.integration.AdditionalDerivativesProvider;
  61. import org.orekit.propagation.integration.StateMapper;
  62. import org.orekit.time.AbsoluteDate;
  63. import org.orekit.utils.AbsolutePVCoordinates;
  64. import org.orekit.utils.DoubleArrayDictionary;
  65. import org.orekit.utils.PVCoordinates;
  66. import org.orekit.utils.ParameterDriver;
  67. import org.orekit.utils.ParameterDriversList;
  68. import org.orekit.utils.ParameterDriversList.DelegatingDriver;
  69. import org.orekit.utils.ParameterObserver;
  70. import org.orekit.utils.TimeStampedPVCoordinates;

  71. /** This class propagates {@link org.orekit.orbits.Orbit orbits} using
  72.  * numerical integration.
  73.  * <p>Numerical propagation is much more accurate than analytical propagation
  74.  * like for example {@link org.orekit.propagation.analytical.KeplerianPropagator
  75.  * Keplerian} or {@link org.orekit.propagation.analytical.EcksteinHechlerPropagator
  76.  * Eckstein-Hechler}, but requires a few more steps to set up to be used properly.
  77.  * Whereas analytical propagators are configured only thanks to their various
  78.  * constructors and can be used immediately after construction, numerical propagators
  79.  * configuration involve setting several parameters between construction time
  80.  * and propagation time.</p>
  81.  * <p>The configuration parameters that can be set are:</p>
  82.  * <ul>
  83.  *   <li>the initial spacecraft state ({@link #setInitialState(SpacecraftState)})</li>
  84.  *   <li>the central attraction coefficient ({@link #setMu(double)})</li>
  85.  *   <li>the various force models ({@link #addForceModel(ForceModel)},
  86.  *   {@link #removeForceModels()})</li>
  87.  *   <li>the {@link OrbitType type} of orbital parameters to be used for propagation
  88.  *   ({@link #setOrbitType(OrbitType)}),</li>
  89.  *   <li>the {@link PositionAngle type} of position angle to be used in orbital parameters
  90.  *   to be used for propagation where it is relevant ({@link
  91.  *   #setPositionAngleType(PositionAngle)}),</li>
  92.  *   <li>whether {@link MatricesHarvester state transition matrices and Jacobians matrices}
  93.  *   should be propagated along with orbital state ({@link
  94.  *   #setupMatricesComputation(String, RealMatrix, DoubleArrayDictionary)}),</li>
  95.  *   <li>whether {@link org.orekit.propagation.integration.AdditionalDerivativesProvider additional derivatives}
  96.  *   should be propagated along with orbital state ({@link
  97.  *   #addAdditionalDerivativesProvider(AdditionalDerivativesProvider)}),</li>
  98.  *   <li>the discrete events that should be triggered during propagation
  99.  *   ({@link #addEventDetector(EventDetector)},
  100.  *   {@link #clearEventsDetectors()})</li>
  101.  *   <li>the binding logic with the rest of the application ({@link #getMultiplexer()})</li>
  102.  * </ul>
  103.  * <p>From these configuration parameters, only the initial state is mandatory. The default
  104.  * propagation settings are in {@link OrbitType#EQUINOCTIAL equinoctial} parameters with
  105.  * {@link PositionAngle#TRUE true} longitude argument. If the central attraction coefficient
  106.  * is not explicitly specified, the one used to define the initial orbit will be used.
  107.  * However, specifying only the initial state and perhaps the central attraction coefficient
  108.  * would mean the propagator would use only Keplerian forces. In this case, the simpler {@link
  109.  * org.orekit.propagation.analytical.KeplerianPropagator KeplerianPropagator} class would
  110.  * perhaps be more effective.</p>
  111.  * <p>The underlying numerical integrator set up in the constructor may also have its own
  112.  * configuration parameters. Typical configuration parameters for adaptive stepsize integrators
  113.  * are the min, max and perhaps start step size as well as the absolute and/or relative errors
  114.  * thresholds.</p>
  115.  * <p>The state that is seen by the integrator is a simple seven elements double array.
  116.  * The six first elements are either:
  117.  * <ul>
  118.  *   <li>the {@link org.orekit.orbits.EquinoctialOrbit equinoctial orbit parameters} (a, e<sub>x</sub>,
  119.  *   e<sub>y</sub>, h<sub>x</sub>, h<sub>y</sub>, λ<sub>M</sub> or λ<sub>E</sub>
  120.  *   or λ<sub>v</sub>) in meters and radians,</li>
  121.  *   <li>the {@link org.orekit.orbits.KeplerianOrbit Keplerian orbit parameters} (a, e, i, ω, Ω,
  122.  *   M or E or v) in meters and radians,</li>
  123.  *   <li>the {@link org.orekit.orbits.CircularOrbit circular orbit parameters} (a, e<sub>x</sub>, e<sub>y</sub>, i,
  124.  *   Ω, α<sub>M</sub> or α<sub>E</sub> or α<sub>v</sub>) in meters
  125.  *   and radians,</li>
  126.  *   <li>the {@link org.orekit.orbits.CartesianOrbit Cartesian orbit parameters} (x, y, z, v<sub>x</sub>,
  127.  *   v<sub>y</sub>, v<sub>z</sub>) in meters and meters per seconds.
  128.  * </ul>
  129.  * <p> The last element is the mass in kilograms and changes only during thrusters firings
  130.  *
  131.  * <p>The following code snippet shows a typical setting for Low Earth Orbit propagation in
  132.  * equinoctial parameters and true longitude argument:</p>
  133.  * <pre>
  134.  * final double dP       = 0.001;
  135.  * final double minStep  = 0.001;
  136.  * final double maxStep  = 500;
  137.  * final double initStep = 60;
  138.  * final double[][] tolerance = NumericalPropagator.tolerances(dP, orbit, OrbitType.EQUINOCTIAL);
  139.  * AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerance[0], tolerance[1]);
  140.  * integrator.setInitialStepSize(initStep);
  141.  * propagator = new NumericalPropagator(integrator);
  142.  * </pre>
  143.  * <p>By default, at the end of the propagation, the propagator resets the initial state to the final state,
  144.  * thus allowing a new propagation to be started from there without recomputing the part already performed.
  145.  * This behaviour can be chenged by calling {@link #setResetAtEnd(boolean)}.
  146.  * </p>
  147.  * <p>Beware the same instance cannot be used simultaneously by different threads, the class is <em>not</em>
  148.  * thread-safe.</p>
  149.  *
  150.  * @see SpacecraftState
  151.  * @see ForceModel
  152.  * @see org.orekit.propagation.sampling.OrekitStepHandler
  153.  * @see org.orekit.propagation.sampling.OrekitFixedStepHandler
  154.  * @see org.orekit.propagation.integration.IntegratedEphemeris
  155.  * @see TimeDerivativesEquations
  156.  *
  157.  * @author Mathieu Rom&eacute;ro
  158.  * @author Luc Maisonobe
  159.  * @author Guylaine Prat
  160.  * @author Fabien Maussion
  161.  * @author V&eacute;ronique Pommier-Maurussane
  162.  */
  163. public class NumericalPropagator extends AbstractIntegratedPropagator {

  164.     /** Space dimension. */
  165.     private static final int SPACE_DIMENSION = 3;

  166.     /** State dimension. */
  167.     private static final int STATE_DIMENSION = 2 * SPACE_DIMENSION;

  168.     /** Threshold for matrix solving. */
  169.     private static final double THRESHOLD = Precision.SAFE_MIN;

  170.     /** Force models used during the extrapolation of the orbit. */
  171.     private final List<ForceModel> forceModels;

  172.     /** boolean to ignore or not the creation of a NewtonianAttraction. */
  173.     private boolean ignoreCentralAttraction;

  174.     /** Create a new instance of NumericalPropagator, based on orbit definition mu.
  175.      * After creation, the instance is empty, i.e. the attitude provider is set to an
  176.      * unspecified default law and there are no perturbing forces at all.
  177.      * This means that if {@link #addForceModel addForceModel} is not
  178.      * called after creation, the integrated orbit will follow a Keplerian
  179.      * evolution only. The defaults are {@link OrbitType#EQUINOCTIAL}
  180.      * for {@link #setOrbitType(OrbitType) propagation
  181.      * orbit type} and {@link PositionAngle#TRUE} for {@link
  182.      * #setPositionAngleType(PositionAngle) position angle type}.
  183.      *
  184.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  185.      *
  186.      * @param integrator numerical integrator to use for propagation.
  187.      * @see #NumericalPropagator(ODEIntegrator, AttitudeProvider)
  188.      */
  189.     @DefaultDataContext
  190.     public NumericalPropagator(final ODEIntegrator integrator) {
  191.         this(integrator,
  192.                 Propagator.getDefaultLaw(DataContext.getDefault().getFrames()));
  193.     }

  194.     /** Create a new instance of NumericalPropagator, based on orbit definition mu.
  195.      * After creation, the instance is empty, i.e. the attitude provider is set to an
  196.      * unspecified default law and there are no perturbing forces at all.
  197.      * This means that if {@link #addForceModel addForceModel} is not
  198.      * called after creation, the integrated orbit will follow a Keplerian
  199.      * evolution only. The defaults are {@link OrbitType#EQUINOCTIAL}
  200.      * for {@link #setOrbitType(OrbitType) propagation
  201.      * orbit type} and {@link PositionAngle#TRUE} for {@link
  202.      * #setPositionAngleType(PositionAngle) position angle type}.
  203.      * @param integrator numerical integrator to use for propagation.
  204.      * @param attitudeProvider the attitude law.
  205.      * @since 10.1
  206.      */
  207.     public NumericalPropagator(final ODEIntegrator integrator,
  208.                                final AttitudeProvider attitudeProvider) {
  209.         super(integrator, PropagationType.OSCULATING);
  210.         forceModels             = new ArrayList<ForceModel>();
  211.         ignoreCentralAttraction = false;
  212.         initMapper();
  213.         setAttitudeProvider(attitudeProvider);
  214.         clearStepHandlers();
  215.         setOrbitType(OrbitType.EQUINOCTIAL);
  216.         setPositionAngleType(PositionAngle.TRUE);
  217.     }

  218.     /** Set the flag to ignore or not the creation of a {@link NewtonianAttraction}.
  219.      * @param ignoreCentralAttraction if true, {@link NewtonianAttraction} is <em>not</em>
  220.      * added automatically if missing
  221.      */
  222.     public void setIgnoreCentralAttraction(final boolean ignoreCentralAttraction) {
  223.         this.ignoreCentralAttraction = ignoreCentralAttraction;
  224.     }

  225.      /** Set the central attraction coefficient μ.
  226.       * <p>
  227.       * Setting the central attraction coefficient is
  228.       * equivalent to {@link #addForceModel(ForceModel) add}
  229.       * a {@link NewtonianAttraction} force model.
  230.       * </p>
  231.      * @param mu central attraction coefficient (m³/s²)
  232.      * @see #addForceModel(ForceModel)
  233.      * @see #getAllForceModels()
  234.      */
  235.     public void setMu(final double mu) {
  236.         if (ignoreCentralAttraction) {
  237.             superSetMu(mu);
  238.         } else {
  239.             addForceModel(new NewtonianAttraction(mu));
  240.         }
  241.     }

  242.     /** Set the central attraction coefficient μ only in upper class.
  243.      * @param mu central attraction coefficient (m³/s²)
  244.      */
  245.     private void superSetMu(final double mu) {
  246.         super.setMu(mu);
  247.     }

  248.     /** Check if Newtonian attraction force model is available.
  249.      * <p>
  250.      * Newtonian attraction is always the last force model in the list.
  251.      * </p>
  252.      * @return true if Newtonian attraction force model is available
  253.      */
  254.     private boolean hasNewtonianAttraction() {
  255.         final int last = forceModels.size() - 1;
  256.         return last >= 0 && forceModels.get(last) instanceof NewtonianAttraction;
  257.     }

  258.     /** Add a force model.
  259.      * <p>If this method is not called at all, the integrated orbit will follow
  260.      * a Keplerian evolution only.</p>
  261.      * @param model {@link ForceModel} to add (it can be either a perturbing force
  262.      * model or an instance of {@link NewtonianAttraction})
  263.      * @see #removeForceModels()
  264.      * @see #setMu(double)
  265.      */
  266.     public void addForceModel(final ForceModel model) {

  267.         if (model instanceof NewtonianAttraction) {
  268.             // we want to add the central attraction force model

  269.             try {
  270.                 // ensure we are notified of any mu change
  271.                 model.getParametersDrivers().get(0).addObserver(new ParameterObserver() {
  272.                     /** {@inheritDoc} */
  273.                     @Override
  274.                     public void valueChanged(final double previousValue, final ParameterDriver driver) {
  275.                         superSetMu(driver.getValue());
  276.                     }
  277.                 });
  278.             } catch (OrekitException oe) {
  279.                 // this should never happen
  280.                 throw new OrekitInternalError(oe);
  281.             }

  282.             if (hasNewtonianAttraction()) {
  283.                 // there is already a central attraction model, replace it
  284.                 forceModels.set(forceModels.size() - 1, model);
  285.             } else {
  286.                 // there are no central attraction model yet, add it at the end of the list
  287.                 forceModels.add(model);
  288.             }
  289.         } else {
  290.             // we want to add a perturbing force model
  291.             if (hasNewtonianAttraction()) {
  292.                 // insert the new force model before Newtonian attraction,
  293.                 // which should always be the last one in the list
  294.                 forceModels.add(forceModels.size() - 1, model);
  295.             } else {
  296.                 // we only have perturbing force models up to now, just append at the end of the list
  297.                 forceModels.add(model);
  298.             }
  299.         }

  300.     }

  301.     /** Remove all force models (except central attraction).
  302.      * <p>Once all perturbing forces have been removed (and as long as no new force
  303.      * model is added), the integrated orbit will follow a Keplerian evolution
  304.      * only.</p>
  305.      * @see #addForceModel(ForceModel)
  306.      */
  307.     public void removeForceModels() {
  308.         final int last = forceModels.size() - 1;
  309.         if (hasNewtonianAttraction()) {
  310.             // preserve the Newtonian attraction model at the end
  311.             final ForceModel newton = forceModels.get(last);
  312.             forceModels.clear();
  313.             forceModels.add(newton);
  314.         } else {
  315.             forceModels.clear();
  316.         }
  317.     }

  318.     /** Get all the force models, perturbing forces and Newtonian attraction included.
  319.      * @return list of perturbing force models, with Newtonian attraction being the
  320.      * last one
  321.      * @see #addForceModel(ForceModel)
  322.      * @see #setMu(double)
  323.      */
  324.     public List<ForceModel> getAllForceModels() {
  325.         return Collections.unmodifiableList(forceModels);
  326.     }

  327.     /** Set propagation orbit type.
  328.      * @param orbitType orbit type to use for propagation, null for
  329.      * propagating using {@link org.orekit.utils.AbsolutePVCoordinates} rather than {@link Orbit}
  330.      */
  331.     public void setOrbitType(final OrbitType orbitType) {
  332.         super.setOrbitType(orbitType);
  333.     }

  334.     /** Get propagation parameter type.
  335.      * @return orbit type used for propagation, null for
  336.      * propagating using {@link org.orekit.utils.AbsolutePVCoordinates} rather than {@link Orbit}
  337.      */
  338.     public OrbitType getOrbitType() {
  339.         return super.getOrbitType();
  340.     }

  341.     /** Set position angle type.
  342.      * <p>
  343.      * The position parameter type is meaningful only if {@link
  344.      * #getOrbitType() propagation orbit type}
  345.      * support it. As an example, it is not meaningful for propagation
  346.      * in {@link OrbitType#CARTESIAN Cartesian} parameters.
  347.      * </p>
  348.      * @param positionAngleType angle type to use for propagation
  349.      */
  350.     public void setPositionAngleType(final PositionAngle positionAngleType) {
  351.         super.setPositionAngleType(positionAngleType);
  352.     }

  353.     /** Get propagation parameter type.
  354.      * @return angle type to use for propagation
  355.      */
  356.     public PositionAngle getPositionAngleType() {
  357.         return super.getPositionAngleType();
  358.     }

  359.     /** Set the initial state.
  360.      * @param initialState initial state
  361.      */
  362.     public void setInitialState(final SpacecraftState initialState) {
  363.         resetInitialState(initialState);
  364.     }

  365.     /** {@inheritDoc} */
  366.     public void resetInitialState(final SpacecraftState state) {
  367.         super.resetInitialState(state);
  368.         if (!hasNewtonianAttraction()) {
  369.             // use the state to define central attraction
  370.             setMu(state.getMu());
  371.         }
  372.         setStartDate(state.getDate());
  373.     }

  374.     /** Get the names of the parameters in the matrix returned by {@link MatricesHarvester#getParametersJacobian}.
  375.      * @return names of the parameters (i.e. columns) of the Jacobian matrix
  376.      */
  377.     List<String> getJacobiansColumnsNames() {
  378.         final List<String> columnsNames = new ArrayList<>();
  379.         for (final ForceModel forceModel : getAllForceModels()) {
  380.             for (final ParameterDriver driver : forceModel.getParametersDrivers()) {
  381.                 if (driver.isSelected() && !columnsNames.contains(driver.getName())) {
  382.                     columnsNames.add(driver.getName());
  383.                 }
  384.             }
  385.         }
  386.         Collections.sort(columnsNames);
  387.         return columnsNames;
  388.     }

  389.     /** {@inheritDoc} */
  390.     @Override
  391.     protected AbstractMatricesHarvester createHarvester(final String stmName, final RealMatrix initialStm,
  392.                                                         final DoubleArrayDictionary initialJacobianColumns) {
  393.         return new NumericalPropagationHarvester(this, stmName, initialStm, initialJacobianColumns);
  394.     }

  395.     /** {@inheritDoc} */
  396.     @Override
  397.     protected void setUpStmAndJacobianGenerators() {

  398.         final AbstractMatricesHarvester harvester = getHarvester();
  399.         if (harvester != null) {

  400.             // set up the additional equations and additional state providers
  401.             final StateTransitionMatrixGenerator stmGenerator = setUpStmGenerator();
  402.             final List<String> triggersDates = setUpTriggerDatesJacobiansColumns(stmGenerator.getName());
  403.             setUpRegularParametersJacobiansColumns(stmGenerator, triggersDates);

  404.             // as we are now starting the propagation, everything is configured
  405.             // we can freeze the names in the harvester
  406.             harvester.freezeColumnsNames();

  407.         }

  408.     }

  409.     /** Set up the State Transition Matrix Generator.
  410.      * @return State Transition Matrix Generator
  411.      * @since 11.1
  412.      */
  413.     private StateTransitionMatrixGenerator setUpStmGenerator() {

  414.         final AbstractMatricesHarvester harvester = getHarvester();

  415.         // add the STM generator corresponding to the current settings, and setup state accordingly
  416.         StateTransitionMatrixGenerator stmGenerator = null;
  417.         for (final AdditionalDerivativesProvider equations : getAdditionalDerivativesProviders()) {
  418.             if (equations instanceof StateTransitionMatrixGenerator &&
  419.                 equations.getName().equals(harvester.getStmName())) {
  420.                 // the STM generator has already been set up in a previous propagation
  421.                 stmGenerator = (StateTransitionMatrixGenerator) equations;
  422.                 break;
  423.             }
  424.         }
  425.         if (stmGenerator == null) {
  426.             // this is the first time we need the STM generate, create it
  427.             stmGenerator = new StateTransitionMatrixGenerator(harvester.getStmName(), getAllForceModels(), getAttitudeProvider());
  428.             addAdditionalDerivativesProvider(stmGenerator);
  429.         }

  430.         if (!getInitialIntegrationState().hasAdditionalState(harvester.getStmName())) {
  431.             // add the initial State Transition Matrix if it is not already there
  432.             // (perhaps due to a previous propagation)
  433.             setInitialState(stmGenerator.setInitialStateTransitionMatrix(getInitialState(),
  434.                                                                          harvester.getInitialStateTransitionMatrix(),
  435.                                                                          getOrbitType(),
  436.                                                                          getPositionAngleType()));
  437.         }

  438.         return stmGenerator;

  439.     }

  440.     /** Set up the Jacobians columns generator dedicated to trigger dates.
  441.      * @param stmName name of the State Transition Matrix state
  442.      * @return names of the columns corresponding to trigger dates
  443.      * @since 11.1
  444.      */
  445.     private List<String> setUpTriggerDatesJacobiansColumns(final String stmName) {

  446.         final List<String> names = new ArrayList<>();
  447.         for (final ForceModel forceModel : getAllForceModels()) {
  448.             if (forceModel instanceof Maneuver) {
  449.                 final Maneuver         maneuver         = (Maneuver) forceModel;
  450.                 final ManeuverTriggers maneuverTriggers = maneuver.getManeuverTriggers();
  451.                 if (maneuverTriggers instanceof AbstractManeuverTriggers) {

  452.                     // FIXME: when issue https://gitlab.orekit.org/orekit/orekit/-/issues/854 is solved
  453.                     // the previous if statement and the following cast should be removed as the following
  454.                     // code should really be done for all ManeuverTriggers and not only AbstractManeuverTriggers
  455.                     final AbstractManeuverTriggers amt = (AbstractManeuverTriggers) maneuverTriggers;

  456.                     amt.getEventsDetectors().
  457.                         filter(d -> d instanceof ParameterDrivenDateIntervalDetector).
  458.                         map (d -> (ParameterDrivenDateIntervalDetector) d).
  459.                         forEach(d -> {
  460.                             if (d.getStartDriver().isSelected() || d.getMedianDriver().isSelected() || d.getDurationDriver().isSelected()) {
  461.                                 final TriggerDate start =
  462.                                                 manageTriggerDate(stmName, maneuver, amt, d.getStartDriver().getName(), true,  d.getThreshold());
  463.                                 names.add(start.getName());
  464.                             }
  465.                             if (d.getStopDriver().isSelected() || d.getMedianDriver().isSelected() || d.getDurationDriver().isSelected()) {
  466.                                 final TriggerDate stop =
  467.                                                 manageTriggerDate(stmName, maneuver, amt, d.getStopDriver().getName(),  false, d.getThreshold());
  468.                                 names.add(stop.getName());
  469.                             }
  470.                             if (d.getMedianDriver().isSelected()) {
  471.                                 final MedianDate median =
  472.                                                 manageMedianDate(d.getStartDriver().getName(), d.getStopDriver().getName(), d.getMedianDriver().getName());
  473.                                 names.add(median.getName());
  474.                             }
  475.                             if (d.getDurationDriver().isSelected()) {
  476.                                 final Duration duration =
  477.                                                 manageManeuverDuration(d.getStartDriver().getName(), d.getStopDriver().getName(), d.getDurationDriver().getName());
  478.                                 names.add(duration.getName());
  479.                             }
  480.                         });

  481.                 }
  482.             }
  483.         }

  484.         return names;

  485.     }

  486.     /** Manage a maneuver trigger date.
  487.      * @param stmName name of the State Transition Matrix state
  488.      * @param maneuver maneuver force model
  489.      * @param amt trigger to which the driver is bound
  490.      * @param driverName name of the date driver
  491.      * @param start if true, the driver is a maneuver start
  492.      * @param threshold event detector threshold
  493.      * @return generator for the date driver
  494.      * @since 11.1
  495.      */
  496.     private TriggerDate manageTriggerDate(final String stmName,
  497.                                           final Maneuver maneuver,
  498.                                           final AbstractManeuverTriggers amt,
  499.                                           final String driverName,
  500.                                           final boolean start,
  501.                                           final double threshold) {

  502.         TriggerDate triggerGenerator = null;

  503.         // check if we already have set up the provider
  504.         for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
  505.             if (provider instanceof TriggerDate &&
  506.                 provider.getName().equals(driverName)) {
  507.                 // the Jacobian column generator has already been set up in a previous propagation
  508.                 triggerGenerator = (TriggerDate) provider;
  509.                 break;
  510.             }
  511.         }

  512.         if (triggerGenerator == null) {
  513.             // this is the first time we need the Jacobian column generator, create it
  514.             triggerGenerator = new TriggerDate(stmName, driverName, start, maneuver, threshold);
  515.             amt.addResetter(triggerGenerator);
  516.             addAdditionalDerivativesProvider(triggerGenerator.getMassDepletionDelay());
  517.             addAdditionalStateProvider(triggerGenerator);
  518.         }

  519.         if (!getInitialIntegrationState().hasAdditionalState(driverName)) {
  520.             // add the initial Jacobian column if it is not already there
  521.             // (perhaps due to a previous propagation)
  522.             setInitialColumn(triggerGenerator.getMassDepletionDelay().getName(), new double[6]);
  523.             setInitialColumn(driverName, getHarvester().getInitialJacobianColumn(driverName));
  524.         }

  525.         return triggerGenerator;

  526.     }

  527.     /** Manage a maneuver median date.
  528.      * @param startName name of the start driver
  529.      * @param stopName name of the stop driver
  530.      * @param medianName name of the median driver
  531.      * @return generator for the median driver
  532.      * @since 11.1
  533.      */
  534.     private MedianDate manageMedianDate(final String startName, final String stopName, final String medianName) {

  535.         MedianDate medianGenerator = null;

  536.         // check if we already have set up the provider
  537.         for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
  538.             if (provider instanceof MedianDate &&
  539.                 provider.getName().equals(medianName)) {
  540.                 // the Jacobian column generator has already been set up in a previous propagation
  541.                 medianGenerator = (MedianDate) provider;
  542.                 break;
  543.             }
  544.         }

  545.         if (medianGenerator == null) {
  546.             // this is the first time we need the Jacobian column generator, create it
  547.             medianGenerator = new MedianDate(startName, stopName, medianName);
  548.             addAdditionalStateProvider(medianGenerator);
  549.         }

  550.         if (!getInitialIntegrationState().hasAdditionalState(medianName)) {
  551.             // add the initial Jacobian column if it is not already there
  552.             // (perhaps due to a previous propagation)
  553.             setInitialColumn(medianName, getHarvester().getInitialJacobianColumn(medianName));
  554.         }

  555.         return medianGenerator;

  556.     }

  557.     /** Manage a maneuver duration.
  558.      * @param startName name of the start driver
  559.      * @param stopName name of the stop driver
  560.      * @param durationName name of the duration driver
  561.      * @return generator for the median driver
  562.      * @since 11.1
  563.      */
  564.     private Duration manageManeuverDuration(final String startName, final String stopName, final String durationName) {

  565.         Duration durationGenerator = null;

  566.         // check if we already have set up the provider
  567.         for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
  568.             if (provider instanceof Duration &&
  569.                 provider.getName().equals(durationName)) {
  570.                 // the Jacobian column generator has already been set up in a previous propagation
  571.                 durationGenerator = (Duration) provider;
  572.                 break;
  573.             }
  574.         }

  575.         if (durationGenerator == null) {
  576.             // this is the first time we need the Jacobian column generator, create it
  577.             durationGenerator = new Duration(startName, stopName, durationName);
  578.             addAdditionalStateProvider(durationGenerator);
  579.         }

  580.         if (!getInitialIntegrationState().hasAdditionalState(durationName)) {
  581.             // add the initial Jacobian column if it is not already there
  582.             // (perhaps due to a previous propagation)
  583.             setInitialColumn(durationName, getHarvester().getInitialJacobianColumn(durationName));
  584.         }

  585.         return durationGenerator;

  586.     }

  587.     /** Set up the Jacobians columns generator for regular parameters.
  588.      * @param stmGenerator generator for the State Transition Matrix
  589.      * @param triggerDates names of the columns already managed as trigger dates
  590.      * @since 11.1
  591.      */
  592.     private void setUpRegularParametersJacobiansColumns(final StateTransitionMatrixGenerator stmGenerator,
  593.                                                         final List<String> triggerDates) {

  594.         // first pass: gather all parameters (excluding trigger dates), binding similar names together
  595.         final ParameterDriversList selected = new ParameterDriversList();
  596.         for (final ForceModel forceModel : getAllForceModels()) {
  597.             for (final ParameterDriver driver : forceModel.getParametersDrivers()) {
  598.                 if (!triggerDates.contains(driver.getName())) {
  599.                     selected.add(driver);
  600.                 }
  601.             }
  602.         }

  603.         // second pass: now that shared parameter names are bound together,
  604.         // their selections status have been synchronized, we can filter them
  605.         selected.filter(true);

  606.         // third pass: sort parameters lexicographically
  607.         selected.sort();

  608.         // add the Jacobians column generators corresponding to parameters, and setup state accordingly
  609.         for (final DelegatingDriver driver : selected.getDrivers()) {

  610.             IntegrableJacobianColumnGenerator generator = null;

  611.             // check if we already have set up the providers
  612.             for (final AdditionalDerivativesProvider provider : getAdditionalDerivativesProviders()) {
  613.                 if (provider instanceof IntegrableJacobianColumnGenerator &&
  614.                     provider.getName().equals(driver.getName())) {
  615.                     // the Jacobian column generator has already been set up in a previous propagation
  616.                     generator = (IntegrableJacobianColumnGenerator) provider;
  617.                     break;
  618.                 }
  619.             }

  620.             if (generator == null) {
  621.                 // this is the first time we need the Jacobian column generator, create it
  622.                 generator = new IntegrableJacobianColumnGenerator(stmGenerator, driver.getName());
  623.                 addAdditionalDerivativesProvider(generator);
  624.             }

  625.             if (!getInitialIntegrationState().hasAdditionalState(driver.getName())) {
  626.                 // add the initial Jacobian column if it is not already there
  627.                 // (perhaps due to a previous propagation)
  628.                 setInitialColumn(driver.getName(), getHarvester().getInitialJacobianColumn(driver.getName()));
  629.             }

  630.         }

  631.     }

  632.     /** Add the initial value of the column to the initial state.
  633.      * <p>
  634.      * The initial state must already contain the Cartesian State Transition Matrix.
  635.      * </p>
  636.      * @param columnName name of the column
  637.      * @param dYdQ column of the Jacobian ∂Y/∂qₘ with respect to propagation type,
  638.      * if null (which is the most frequent case), assumed to be 0
  639.      * @since 11.1
  640.      */
  641.     private void setInitialColumn(final String columnName, final double[] dYdQ) {

  642.         final SpacecraftState state = getInitialState();

  643.         if (dYdQ.length != STATE_DIMENSION) {
  644.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH,
  645.                                       dYdQ.length, STATE_DIMENSION);
  646.         }

  647.         // convert to Cartesian Jacobian
  648.         final double[][] dYdC = new double[STATE_DIMENSION][STATE_DIMENSION];
  649.         getOrbitType().convertType(state.getOrbit()).getJacobianWrtCartesian(getPositionAngleType(), dYdC);
  650.         final double[] column = new QRDecomposition(MatrixUtils.createRealMatrix(dYdC), THRESHOLD).
  651.                         getSolver().
  652.                         solve(MatrixUtils.createRealVector(dYdQ)).
  653.                         toArray();

  654.         // set additional state
  655.         setInitialState(state.addAdditionalState(columnName, column));

  656.     }

  657.     /** {@inheritDoc} */
  658.     @Override
  659.     public TimeStampedPVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame) {
  660.         return propagate(date).getPVCoordinates(frame);
  661.     }

  662.     /** {@inheritDoc} */
  663.     @Override
  664.     protected StateMapper createMapper(final AbsoluteDate referenceDate, final double mu,
  665.                                        final OrbitType orbitType, final PositionAngle positionAngleType,
  666.                                        final AttitudeProvider attitudeProvider, final Frame frame) {
  667.         return new OsculatingMapper(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
  668.     }

  669.     /** Internal mapper using directly osculating parameters. */
  670.     private static class OsculatingMapper extends StateMapper {

  671.         /** Simple constructor.
  672.          * <p>
  673.          * The position parameter type is meaningful only if {@link
  674.          * #getOrbitType() propagation orbit type}
  675.          * support it. As an example, it is not meaningful for propagation
  676.          * in {@link OrbitType#CARTESIAN Cartesian} parameters.
  677.          * </p>
  678.          * @param referenceDate reference date
  679.          * @param mu central attraction coefficient (m³/s²)
  680.          * @param orbitType orbit type to use for mapping (can be null for {@link AbsolutePVCoordinates})
  681.          * @param positionAngleType angle type to use for propagation
  682.          * @param attitudeProvider attitude provider
  683.          * @param frame inertial frame
  684.          */
  685.         OsculatingMapper(final AbsoluteDate referenceDate, final double mu,
  686.                          final OrbitType orbitType, final PositionAngle positionAngleType,
  687.                          final AttitudeProvider attitudeProvider, final Frame frame) {
  688.             super(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
  689.         }

  690.         /** {@inheritDoc} */
  691.         public SpacecraftState mapArrayToState(final AbsoluteDate date, final double[] y, final double[] yDot,
  692.                                                final PropagationType type) {
  693.             // the parameter type is ignored for the Numerical Propagator

  694.             final double mass = y[6];
  695.             if (mass <= 0.0) {
  696.                 throw new OrekitException(OrekitMessages.SPACECRAFT_MASS_BECOMES_NEGATIVE, mass);
  697.             }

  698.             if (getOrbitType() == null) {
  699.                 // propagation uses absolute position-velocity-acceleration
  700.                 final Vector3D p = new Vector3D(y[0],    y[1],    y[2]);
  701.                 final Vector3D v = new Vector3D(y[3],    y[4],    y[5]);
  702.                 final Vector3D a;
  703.                 final AbsolutePVCoordinates absPva;
  704.                 if (yDot == null) {
  705.                     absPva = new AbsolutePVCoordinates(getFrame(), new TimeStampedPVCoordinates(date, p, v));
  706.                 } else {
  707.                     a = new Vector3D(yDot[3], yDot[4], yDot[5]);
  708.                     absPva = new AbsolutePVCoordinates(getFrame(), new TimeStampedPVCoordinates(date, p, v, a));
  709.                 }

  710.                 final Attitude attitude = getAttitudeProvider().getAttitude(absPva, date, getFrame());
  711.                 return new SpacecraftState(absPva, attitude, mass);
  712.             } else {
  713.                 // propagation uses regular orbits
  714.                 final Orbit orbit       = getOrbitType().mapArrayToOrbit(y, yDot, getPositionAngleType(), date, getMu(), getFrame());
  715.                 final Attitude attitude = getAttitudeProvider().getAttitude(orbit, date, getFrame());

  716.                 return new SpacecraftState(orbit, attitude, mass);
  717.             }

  718.         }

  719.         /** {@inheritDoc} */
  720.         public void mapStateToArray(final SpacecraftState state, final double[] y, final double[] yDot) {
  721.             if (getOrbitType() == null) {
  722.                 // propagation uses absolute position-velocity-acceleration
  723.                 final Vector3D p = state.getAbsPVA().getPosition();
  724.                 final Vector3D v = state.getAbsPVA().getVelocity();
  725.                 y[0] = p.getX();
  726.                 y[1] = p.getY();
  727.                 y[2] = p.getZ();
  728.                 y[3] = v.getX();
  729.                 y[4] = v.getY();
  730.                 y[5] = v.getZ();
  731.                 y[6] = state.getMass();
  732.             }
  733.             else {
  734.                 getOrbitType().mapOrbitToArray(state.getOrbit(), getPositionAngleType(), y, yDot);
  735.                 y[6] = state.getMass();
  736.             }
  737.         }

  738.     }

  739.     /** {@inheritDoc} */
  740.     protected MainStateEquations getMainStateEquations(final ODEIntegrator integrator) {
  741.         return new Main(integrator);
  742.     }

  743.     /** Internal class for osculating parameters integration. */
  744.     private class Main implements MainStateEquations, TimeDerivativesEquations {

  745.         /** Derivatives array. */
  746.         private final double[] yDot;

  747.         /** Current state. */
  748.         private SpacecraftState currentState;

  749.         /** Jacobian of the orbital parameters with respect to the Cartesian parameters. */
  750.         private double[][] jacobian;

  751.         /** Simple constructor.
  752.          * @param integrator numerical integrator to use for propagation.
  753.          */
  754.         Main(final ODEIntegrator integrator) {

  755.             this.yDot     = new double[7];
  756.             this.jacobian = new double[6][6];

  757.             for (final ForceModel forceModel : forceModels) {
  758.                 forceModel.getEventsDetectors().forEach(detector -> setUpEventDetector(integrator, detector));
  759.             }

  760.             if (getOrbitType() == null) {
  761.                 // propagation uses absolute position-velocity-acceleration
  762.                 // we can set Jacobian once and for all
  763.                 for (int i = 0; i < jacobian.length; ++i) {
  764.                     Arrays.fill(jacobian[i], 0.0);
  765.                     jacobian[i][i] = 1.0;
  766.                 }
  767.             }

  768.         }

  769.         /** {@inheritDoc} */
  770.         @Override
  771.         public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  772.             forceModels.forEach(fm -> fm.init(initialState, target));
  773.         }

  774.         /** {@inheritDoc} */
  775.         @Override
  776.         public double[] computeDerivatives(final SpacecraftState state) {

  777.             currentState = state;
  778.             Arrays.fill(yDot, 0.0);
  779.             if (getOrbitType() != null) {
  780.                 // propagation uses regular orbits
  781.                 currentState.getOrbit().getJacobianWrtCartesian(getPositionAngleType(), jacobian);
  782.             }

  783.             // compute the contributions of all perturbing forces,
  784.             // using the Kepler contribution at the end since
  785.             // NewtonianAttraction is always the last instance in the list
  786.             for (final ForceModel forceModel : forceModels) {
  787.                 forceModel.addContribution(state, this);
  788.             }

  789.             if (getOrbitType() == null) {
  790.                 // position derivative is velocity, and was not added above in the force models
  791.                 // (it is added when orbit type is non-null because NewtonianAttraction considers it)
  792.                 final Vector3D velocity = currentState.getPVCoordinates().getVelocity();
  793.                 yDot[0] += velocity.getX();
  794.                 yDot[1] += velocity.getY();
  795.                 yDot[2] += velocity.getZ();
  796.             }


  797.             return yDot.clone();

  798.         }

  799.         /** {@inheritDoc} */
  800.         @Override
  801.         public void addKeplerContribution(final double mu) {
  802.             if (getOrbitType() == null) {

  803.                 // if mu is neither 0 nor NaN, we want to include Newtonian acceleration
  804.                 if (mu > 0) {
  805.                     // velocity derivative is Newtonian acceleration
  806.                     final Vector3D position = currentState.getPVCoordinates().getPosition();
  807.                     final double r2         = position.getNormSq();
  808.                     final double coeff      = -mu / (r2 * FastMath.sqrt(r2));
  809.                     yDot[3] += coeff * position.getX();
  810.                     yDot[4] += coeff * position.getY();
  811.                     yDot[5] += coeff * position.getZ();
  812.                 }

  813.             } else {
  814.                 // propagation uses regular orbits
  815.                 currentState.getOrbit().addKeplerContribution(getPositionAngleType(), mu, yDot);
  816.             }
  817.         }

  818.         /** {@inheritDoc} */
  819.         public void addNonKeplerianAcceleration(final Vector3D gamma) {
  820.             for (int i = 0; i < 6; ++i) {
  821.                 final double[] jRow = jacobian[i];
  822.                 yDot[i] += jRow[3] * gamma.getX() + jRow[4] * gamma.getY() + jRow[5] * gamma.getZ();
  823.             }
  824.         }

  825.         /** {@inheritDoc} */
  826.         @Override
  827.         public void addMassDerivative(final double q) {
  828.             if (q > 0) {
  829.                 throw new OrekitIllegalArgumentException(OrekitMessages.POSITIVE_FLOW_RATE, q);
  830.             }
  831.             yDot[6] += q;
  832.         }

  833.     }

  834.     /** Estimate tolerance vectors for integrators when propagating in absolute position-velocity-acceleration.
  835.      * @param dP user specified position error
  836.      * @param absPva reference absolute position-velocity-acceleration
  837.      * @return a two rows array, row 0 being the absolute tolerance error and row 1
  838.      * being the relative tolerance error
  839.      * @see NumericalPropagator#tolerances(double, Orbit, OrbitType)
  840.      */
  841.     public static double[][] tolerances(final double dP, final AbsolutePVCoordinates absPva) {

  842.         final double relative = dP / absPva.getPosition().getNorm();
  843.         final double dV = relative * absPva.getVelocity().getNorm();

  844.         final double[] absTol = new double[7];
  845.         final double[] relTol = new double[7];

  846.         absTol[0] = dP;
  847.         absTol[1] = dP;
  848.         absTol[2] = dP;
  849.         absTol[3] = dV;
  850.         absTol[4] = dV;
  851.         absTol[5] = dV;

  852.         // we set the mass tolerance arbitrarily to 1.0e-6 kg, as mass evolves linearly
  853.         // with trust, this often has no influence at all on propagation
  854.         absTol[6] = 1.0e-6;

  855.         Arrays.fill(relTol, relative);

  856.         return new double[][] {
  857.             absTol, relTol
  858.         };

  859.     }

  860.     /** Estimate tolerance vectors for integrators when propagating in orbits.
  861.      * <p>
  862.      * The errors are estimated from partial derivatives properties of orbits,
  863.      * starting from a scalar position error specified by the user.
  864.      * Considering the energy conservation equation V = sqrt(mu (2/r - 1/a)),
  865.      * we get at constant energy (i.e. on a Keplerian trajectory):
  866.      * <pre>
  867.      * V r² |dV| = mu |dr|
  868.      * </pre>
  869.      * <p> So we deduce a scalar velocity error consistent with the position error.
  870.      * From here, we apply orbits Jacobians matrices to get consistent errors
  871.      * on orbital parameters.
  872.      *
  873.      * <p>
  874.      * The tolerances are only <em>orders of magnitude</em>, and integrator tolerances
  875.      * are only local estimates, not global ones. So some care must be taken when using
  876.      * these tolerances. Setting 1mm as a position error does NOT mean the tolerances
  877.      * will guarantee a 1mm error position after several orbits integration.
  878.      * </p>
  879.      * @param dP user specified position error
  880.      * @param orbit reference orbit
  881.      * @param type propagation type for the meaning of the tolerance vectors elements
  882.      * (it may be different from {@code orbit.getType()})
  883.      * @return a two rows array, row 0 being the absolute tolerance error and row 1
  884.      * being the relative tolerance error
  885.      */
  886.     public static double[][] tolerances(final double dP, final Orbit orbit, final OrbitType type) {

  887.         // estimate the scalar velocity error
  888.         final PVCoordinates pv = orbit.getPVCoordinates();
  889.         final double r2 = pv.getPosition().getNormSq();
  890.         final double v  = pv.getVelocity().getNorm();
  891.         final double dV = orbit.getMu() * dP / (v * r2);

  892.         return tolerances(dP, dV, orbit, type);

  893.     }

  894.     /** Estimate tolerance vectors for integrators when propagating in orbits.
  895.      * <p>
  896.      * The errors are estimated from partial derivatives properties of orbits,
  897.      * starting from scalar position and velocity errors specified by the user.
  898.      * <p>
  899.      * The tolerances are only <em>orders of magnitude</em>, and integrator tolerances
  900.      * are only local estimates, not global ones. So some care must be taken when using
  901.      * these tolerances. Setting 1mm as a position error does NOT mean the tolerances
  902.      * will guarantee a 1mm error position after several orbits integration.
  903.      * </p>
  904.      * @param dP user specified position error
  905.      * @param dV user specified velocity error
  906.      * @param orbit reference orbit
  907.      * @param type propagation type for the meaning of the tolerance vectors elements
  908.      * (it may be different from {@code orbit.getType()})
  909.      * @return a two rows array, row 0 being the absolute tolerance error and row 1
  910.      * being the relative tolerance error
  911.      * @since 10.3
  912.      */
  913.     public static double[][] tolerances(final double dP, final double dV,
  914.                                         final Orbit orbit, final OrbitType type) {

  915.         final double[] absTol = new double[7];
  916.         final double[] relTol = new double[7];

  917.         // we set the mass tolerance arbitrarily to 1.0e-6 kg, as mass evolves linearly
  918.         // with trust, this often has no influence at all on propagation
  919.         absTol[6] = 1.0e-6;

  920.         if (type == OrbitType.CARTESIAN) {
  921.             absTol[0] = dP;
  922.             absTol[1] = dP;
  923.             absTol[2] = dP;
  924.             absTol[3] = dV;
  925.             absTol[4] = dV;
  926.             absTol[5] = dV;
  927.         } else {

  928.             // convert the orbit to the desired type
  929.             final double[][] jacobian = new double[6][6];
  930.             final Orbit converted = type.convertType(orbit);
  931.             converted.getJacobianWrtCartesian(PositionAngle.TRUE, jacobian);

  932.             for (int i = 0; i < 6; ++i) {
  933.                 final double[] row = jacobian[i];
  934.                 absTol[i] = FastMath.abs(row[0]) * dP +
  935.                             FastMath.abs(row[1]) * dP +
  936.                             FastMath.abs(row[2]) * dP +
  937.                             FastMath.abs(row[3]) * dV +
  938.                             FastMath.abs(row[4]) * dV +
  939.                             FastMath.abs(row[5]) * dV;
  940.                 if (Double.isNaN(absTol[i])) {
  941.                     throw new OrekitException(OrekitMessages.SINGULAR_JACOBIAN_FOR_ORBIT_TYPE, type);
  942.                 }
  943.             }

  944.         }

  945.         Arrays.fill(relTol, dP / FastMath.sqrt(orbit.getPVCoordinates().getPosition().getNormSq()));

  946.         return new double[][] {
  947.             absTol, relTol
  948.         };

  949.     }

  950.     /** {@inheritDoc} */
  951.     @Override
  952.     protected void beforeIntegration(final SpacecraftState initialState, final AbsoluteDate tEnd) {

  953.         if (!getFrame().isPseudoInertial()) {

  954.             // inspect all force models to find InertialForces
  955.             for (ForceModel force : forceModels) {
  956.                 if (force instanceof InertialForces) {
  957.                     return;
  958.                 }
  959.             }

  960.             // throw exception if no inertial forces found
  961.             throw new OrekitException(OrekitMessages.INERTIAL_FORCE_MODEL_MISSING, getFrame().getName());

  962.         }

  963.     }

  964. }