1   /* Copyright 2002-2025 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  
19  import org.hipparchus.exception.LocalizedCoreFormats;
20  import org.hipparchus.geometry.euclidean.threed.Vector3D;
21  import org.hipparchus.linear.MatrixUtils;
22  import org.hipparchus.linear.QRDecomposition;
23  import org.hipparchus.linear.RealMatrix;
24  import org.hipparchus.ode.ODEIntegrator;
25  import org.hipparchus.util.FastMath;
26  import org.hipparchus.util.Precision;
27  import org.orekit.annotation.DefaultDataContext;
28  import org.orekit.attitudes.Attitude;
29  import org.orekit.attitudes.AttitudeProvider;
30  import org.orekit.attitudes.AttitudeProviderModifier;
31  import org.orekit.data.DataContext;
32  import org.orekit.errors.OrekitException;
33  import org.orekit.errors.OrekitIllegalArgumentException;
34  import org.orekit.errors.OrekitInternalError;
35  import org.orekit.errors.OrekitMessages;
36  import org.orekit.forces.ForceModel;
37  import org.orekit.forces.gravity.NewtonianAttraction;
38  import org.orekit.forces.inertia.InertialForces;
39  import org.orekit.forces.maneuvers.Maneuver;
40  import org.orekit.forces.maneuvers.jacobians.Duration;
41  import org.orekit.forces.maneuvers.jacobians.MedianDate;
42  import org.orekit.forces.maneuvers.jacobians.TriggerDate;
43  import org.orekit.forces.maneuvers.trigger.ManeuverTriggerDetector;
44  import org.orekit.forces.maneuvers.trigger.ResettableManeuverTriggers;
45  import org.orekit.frames.Frame;
46  import org.orekit.orbits.Orbit;
47  import org.orekit.orbits.OrbitType;
48  import org.orekit.orbits.PositionAngleType;
49  import org.orekit.propagation.AbstractMatricesHarvester;
50  import org.orekit.propagation.AdditionalDataProvider;
51  import org.orekit.propagation.CartesianToleranceProvider;
52  import org.orekit.propagation.MatricesHarvester;
53  import org.orekit.propagation.PropagationType;
54  import org.orekit.propagation.Propagator;
55  import org.orekit.propagation.SpacecraftState;
56  import org.orekit.propagation.ToleranceProvider;
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.ParameterDriver;
66  import org.orekit.utils.ParameterDriversList;
67  import org.orekit.utils.ParameterDriversList.DelegatingDriver;
68  import org.orekit.utils.ParameterObserver;
69  import org.orekit.utils.TimeSpanMap;
70  import org.orekit.utils.TimeSpanMap.Span;
71  import org.orekit.utils.TimeStampedPVCoordinates;
72  
73  import java.util.ArrayList;
74  import java.util.Arrays;
75  import java.util.Collection;
76  import java.util.Collections;
77  import java.util.List;
78  import java.util.stream.Collectors;
79  
80  /** This class propagates {@link org.orekit.orbits.Orbit orbits} using
81   * numerical integration.
82   * <p>Numerical propagation is much more accurate than analytical propagation
83   * like for example {@link org.orekit.propagation.analytical.KeplerianPropagator
84   * Keplerian} or {@link org.orekit.propagation.analytical.EcksteinHechlerPropagator
85   * Eckstein-Hechler}, but requires a few more steps to set up to be used properly.
86   * Whereas analytical propagators are configured only thanks to their various
87   * constructors and can be used immediately after construction, numerical propagators
88   * configuration involve setting several parameters between construction time
89   * and propagation time.</p>
90   * <p>The configuration parameters that can be set are:</p>
91   * <ul>
92   *   <li>the initial spacecraft state ({@link #setInitialState(SpacecraftState)})</li>
93   *   <li>the central attraction coefficient ({@link #setMu(double)})</li>
94   *   <li>the various force models ({@link #addForceModel(ForceModel)},
95   *   {@link #removeForceModels()})</li>
96   *   <li>the {@link OrbitType type} of orbital parameters to be used for propagation
97   *   ({@link #setOrbitType(OrbitType)}),</li>
98   *   <li>the {@link PositionAngleType type} of position angle to be used in orbital parameters
99   *   to be used for propagation where it is relevant ({@link
100  *   #setPositionAngleType(PositionAngleType)}),</li>
101  *   <li>whether {@link MatricesHarvester state transition matrices and Jacobians matrices}
102  *   should be propagated along with orbital state ({@link
103  *   #setupMatricesComputation(String, RealMatrix, DoubleArrayDictionary)}),</li>
104  *   <li>whether {@link org.orekit.propagation.integration.AdditionalDerivativesProvider additional derivatives}
105  *   should be propagated along with orbital state ({@link
106  *   #addAdditionalDerivativesProvider(AdditionalDerivativesProvider)}),</li>
107  *   <li>the discrete events that should be triggered during propagation
108  *   ({@link #addEventDetector(EventDetector)},
109  *   {@link #clearEventsDetectors()})</li>
110  *   <li>the binding logic with the rest of the application ({@link #getMultiplexer()})</li>
111  * </ul>
112  * <p>From these configuration parameters, only the initial state is mandatory. The default
113  * propagation settings are in {@link OrbitType#EQUINOCTIAL equinoctial} parameters with
114  * {@link PositionAngleType#ECCENTRIC} longitude argument. If the central attraction coefficient
115  * is not explicitly specified, the one used to define the initial orbit will be used.
116  * However, specifying only the initial state and perhaps the central attraction coefficient
117  * would mean the propagator would use only Keplerian forces. In this case, the simpler {@link
118  * org.orekit.propagation.analytical.KeplerianPropagator KeplerianPropagator} class would
119  * perhaps be more effective.</p>
120  * <p>The underlying numerical integrator set up in the constructor may also have its own
121  * configuration parameters. Typical configuration parameters for adaptive stepsize integrators
122  * are the min, max and perhaps start step size as well as the absolute and/or relative errors
123  * thresholds.</p>
124  * <p>The state that is seen by the integrator is a simple seven elements double array.
125  * The six first elements are either:
126  * <ul>
127  *   <li>the {@link org.orekit.orbits.EquinoctialOrbit equinoctial orbit parameters} (a, e<sub>x</sub>,
128  *   e<sub>y</sub>, h<sub>x</sub>, h<sub>y</sub>, λ<sub>M</sub> or λ<sub>E</sub>
129  *   or λ<sub>v</sub>) in meters and radians,</li>
130  *   <li>the {@link org.orekit.orbits.KeplerianOrbit Keplerian orbit parameters} (a, e, i, ω, Ω,
131  *   M or E or v) in meters and radians,</li>
132  *   <li>the {@link org.orekit.orbits.CircularOrbit circular orbit parameters} (a, e<sub>x</sub>, e<sub>y</sub>, i,
133  *   Ω, α<sub>M</sub> or α<sub>E</sub> or α<sub>v</sub>) in meters
134  *   and radians,</li>
135  *   <li>the {@link org.orekit.orbits.CartesianOrbit Cartesian orbit parameters} (x, y, z, v<sub>x</sub>,
136  *   v<sub>y</sub>, v<sub>z</sub>) in meters and meters per seconds.
137  * </ul>
138  * <p> The last element is the mass in kilograms and changes only during thrusters firings
139  *
140  * <p>The following code snippet shows a typical setting for Low Earth Orbit propagation in
141  * equinoctial parameters and true longitude argument:</p>
142  * <pre>
143  * final double dP       = 0.001;
144  * final double minStep  = 0.001;
145  * final double maxStep  = 500;
146  * final double initStep = 60;
147  * final double[][] tolerance = ToleranceProvider.getDefaultToleranceProvider(dP).getTolerances(orbit, OrbitType.EQUINOCTIAL);
148  * AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerance[0], tolerance[1]);
149  * integrator.setInitialStepSize(initStep);
150  * propagator = new NumericalPropagator(integrator);
151  * </pre>
152  * <p>By default, at the end of the propagation, the propagator resets the initial state to the final state,
153  * thus allowing a new propagation to be started from there without recomputing the part already performed.
154  * This behaviour can be changed by calling {@link #setResetAtEnd(boolean)}.
155  * </p>
156  * <p>Beware the same instance cannot be used simultaneously by different threads, the class is <em>not</em>
157  * thread-safe.</p>
158  *
159  * @see SpacecraftState
160  * @see ForceModel
161  * @see org.orekit.propagation.sampling.OrekitStepHandler
162  * @see org.orekit.propagation.sampling.OrekitFixedStepHandler
163  * @see org.orekit.propagation.integration.IntegratedEphemeris
164  * @see TimeDerivativesEquations
165  *
166  * @author Mathieu Rom&eacute;ro
167  * @author Luc Maisonobe
168  * @author Guylaine Prat
169  * @author Fabien Maussion
170  * @author V&eacute;ronique Pommier-Maurussane
171  */
172 public class NumericalPropagator extends AbstractIntegratedPropagator {
173 
174     /** Default orbit type. */
175     public static final OrbitType DEFAULT_ORBIT_TYPE = OrbitType.EQUINOCTIAL;
176 
177     /** Default position angle type. */
178     public static final PositionAngleType DEFAULT_POSITION_ANGLE_TYPE = PositionAngleType.ECCENTRIC;
179 
180     /** Space dimension. */
181     private static final int SPACE_DIMENSION = 3;
182 
183     /** State dimension. */
184     private static final int STATE_DIMENSION = 2 * SPACE_DIMENSION;
185 
186     /** Threshold for matrix solving. */
187     private static final double THRESHOLD = Precision.SAFE_MIN;
188 
189     /** Force models used during the extrapolation of the orbit. */
190     private final List<ForceModel> forceModels;
191 
192     /** boolean to ignore or not the creation of a NewtonianAttraction. */
193     private boolean ignoreCentralAttraction;
194 
195     /**
196      * boolean to know if a full attitude (with rates) is needed when computing derivatives for the ODE.
197      * since 12.1
198      */
199     private boolean needFullAttitudeForDerivatives = true;
200 
201     /** Create a new instance of NumericalPropagator, based on orbit definition mu.
202      * After creation, the instance is empty, i.e. the attitude provider is set to an
203      * unspecified default law and there are no perturbing forces at all.
204      * This means that if {@link #addForceModel addForceModel} is not
205      * called after creation, the integrated orbit will follow a Keplerian
206      * evolution only. The defaults are {@link OrbitType#EQUINOCTIAL}
207      * for {@link #setOrbitType(OrbitType) propagation
208      * orbit type} and {@link PositionAngleType#ECCENTRIC} for {@link
209      * #setPositionAngleType(PositionAngleType) position angle type}.
210      *
211      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
212      *
213      * @param integrator numerical integrator to use for propagation.
214      * @see #NumericalPropagator(ODEIntegrator, AttitudeProvider)
215      */
216     @DefaultDataContext
217     public NumericalPropagator(final ODEIntegrator integrator) {
218         this(integrator,
219                 Propagator.getDefaultLaw(DataContext.getDefault().getFrames()));
220     }
221 
222     /** Create a new instance of NumericalPropagator, based on orbit definition mu.
223      * After creation, the instance is empty, i.e. the attitude provider is set to an
224      * unspecified default law and there are no perturbing forces at all.
225      * This means that if {@link #addForceModel addForceModel} is not
226      * called after creation, the integrated orbit will follow a Keplerian
227      * evolution only. The defaults are {@link OrbitType#EQUINOCTIAL}
228      * for {@link #setOrbitType(OrbitType) propagation
229      * orbit type} and {@link PositionAngleType#ECCENTRIC} for {@link
230      * #setPositionAngleType(PositionAngleType) position angle type}.
231      * @param integrator numerical integrator to use for propagation.
232      * @param attitudeProvider the attitude law.
233      * @since 10.1
234      */
235     public NumericalPropagator(final ODEIntegrator integrator,
236                                final AttitudeProvider attitudeProvider) {
237         super(integrator, PropagationType.OSCULATING);
238         forceModels             = new ArrayList<>();
239         ignoreCentralAttraction = false;
240         initMapper();
241         setAttitudeProvider(attitudeProvider);
242         clearStepHandlers();
243         setOrbitType(DEFAULT_ORBIT_TYPE);
244         setPositionAngleType(DEFAULT_POSITION_ANGLE_TYPE);
245     }
246 
247     /** Set the flag to ignore or not the creation of a {@link NewtonianAttraction}.
248      * @param ignoreCentralAttraction if true, {@link NewtonianAttraction} is <em>not</em>
249      * added automatically if missing
250      */
251     public void setIgnoreCentralAttraction(final boolean ignoreCentralAttraction) {
252         this.ignoreCentralAttraction = ignoreCentralAttraction;
253     }
254 
255      /** Set the central attraction coefficient μ.
256       * <p>
257       * Setting the central attraction coefficient is
258       * equivalent to {@link #addForceModel(ForceModel) add}
259       * a {@link NewtonianAttraction} force model.
260       * * </p>
261       * @param mu central attraction coefficient (m³/s²)
262       * @see #addForceModel(ForceModel)
263       * @see #getAllForceModels()
264       */
265     @Override
266     public void setMu(final double mu) {
267         if (ignoreCentralAttraction) {
268             superSetMu(mu);
269         } else {
270             addForceModel(new NewtonianAttraction(mu));
271             superSetMu(mu);
272         }
273     }
274 
275     /** Set the central attraction coefficient μ only in upper class.
276      * @param mu central attraction coefficient (m³/s²)
277      */
278     private void superSetMu(final double mu) {
279         super.setMu(mu);
280     }
281 
282     /** Check if Newtonian attraction force model is available.
283      * <p>
284      * Newtonian attraction is always the last force model in the list.
285      * </p>
286      * @return true if Newtonian attraction force model is available
287      */
288     private boolean hasNewtonianAttraction() {
289         final int last = forceModels.size() - 1;
290         return last >= 0 && forceModels.get(last) instanceof NewtonianAttraction;
291     }
292 
293     /** Add a force model.
294      * <p>If this method is not called at all, the integrated orbit will follow
295      * a Keplerian evolution only.</p>
296      * @param model {@link ForceModel} to add (it can be either a perturbing force
297      * model or an instance of {@link NewtonianAttraction})
298      * @see #removeForceModels()
299      * @see #setMu(double)
300      */
301     public void addForceModel(final ForceModel model) {
302 
303         if (model instanceof NewtonianAttraction) {
304             // we want to add the central attraction force model
305 
306             try {
307                 // ensure we are notified of any mu change
308                 model.getParametersDrivers().get(0).addObserver(new ParameterObserver() {
309                     /** {@inheritDoc} */
310                     @Override
311                     public void valueSpanMapChanged(final TimeSpanMap<Double> previousValue, final ParameterDriver driver) {
312                         superSetMu(driver.getValue());
313                     }
314                     /** {@inheritDoc} */
315                     @Override
316                     public void valueChanged(final double previousValue, final ParameterDriver driver, final AbsoluteDate date) {
317                         superSetMu(driver.getValue());
318                     }
319                 });
320             } catch (OrekitException oe) {
321                 // this should never happen
322                 throw new OrekitInternalError(oe);
323             }
324 
325             if (hasNewtonianAttraction()) {
326                 // there is already a central attraction model, replace it
327                 forceModels.set(forceModels.size() - 1, model);
328             } else {
329                 // there are no central attraction model yet, add it at the end of the list
330                 forceModels.add(model);
331             }
332         } else {
333             // we want to add a perturbing force model
334             if (hasNewtonianAttraction()) {
335                 // insert the new force model before Newtonian attraction,
336                 // which should always be the last one in the list
337                 forceModels.add(forceModels.size() - 1, model);
338             } else {
339                 // we only have perturbing force models up to now, just append at the end of the list
340                 forceModels.add(model);
341             }
342         }
343 
344     }
345 
346     /** Remove all force models (except central attraction).
347      * <p>Once all perturbing forces have been removed (and as long as no new force
348      * model is added), the integrated orbit will follow a Keplerian evolution
349      * only.</p>
350      * @see #addForceModel(ForceModel)
351      */
352     public void removeForceModels() {
353         final int last = forceModels.size() - 1;
354         if (hasNewtonianAttraction()) {
355             // preserve the Newtonian attraction model at the end
356             final ForceModel newton = forceModels.get(last);
357             forceModels.clear();
358             forceModels.add(newton);
359         } else {
360             forceModels.clear();
361         }
362     }
363 
364     /** Get all the force models, perturbing forces and Newtonian attraction included.
365      * @return list of perturbing force models, with Newtonian attraction being the
366      * last one
367      * @see #addForceModel(ForceModel)
368      * @see #setMu(double)
369      */
370     public List<ForceModel> getAllForceModels() {
371         return Collections.unmodifiableList(forceModels);
372     }
373 
374     /** Set propagation orbit type.
375      * @param orbitType orbit type to use for propagation, null for
376      * propagating using {@link org.orekit.utils.AbsolutePVCoordinates} rather than {@link Orbit}
377      */
378     @Override
379     public void setOrbitType(final OrbitType orbitType) {
380         super.setOrbitType(orbitType);
381     }
382 
383     /** Get propagation parameter type.
384      * @return orbit type used for propagation, null for
385      * propagating using {@link org.orekit.utils.AbsolutePVCoordinates} rather than {@link Orbit}
386      */
387     @Override
388     public OrbitType getOrbitType() {
389         return super.getOrbitType();
390     }
391 
392     /** Set position angle type.
393      * <p>
394      * The position parameter type is meaningful only if {@link
395      * #getOrbitType() propagation orbit type}
396      * support it. As an example, it is not meaningful for propagation
397      * in {@link OrbitType#CARTESIAN Cartesian} parameters.
398      * </p>
399      * @param positionAngleType angle type to use for propagation
400      */
401     @Override
402     public void setPositionAngleType(final PositionAngleType positionAngleType) {
403         super.setPositionAngleType(positionAngleType);
404     }
405 
406     /** Get propagation parameter type.
407      * @return angle type to use for propagation
408      */
409     @Override
410     public PositionAngleType getPositionAngleType() {
411         return super.getPositionAngleType();
412     }
413 
414     /** Set the initial state.
415      * @param initialState initial state
416      */
417     public void setInitialState(final SpacecraftState initialState) {
418         resetInitialState(initialState);
419     }
420 
421     /** {@inheritDoc} */
422     @Override
423     public void resetInitialState(final SpacecraftState state) {
424         super.resetInitialState(state);
425         if (!hasNewtonianAttraction()) {
426             // use the state to define central attraction
427             setMu(state.isOrbitDefined() ? state.getOrbit().getMu() : Double.NaN);
428         }
429         setStartDate(state.getDate());
430     }
431 
432     /** Get the names of the parameters in the matrix returned by {@link MatricesHarvester#getParametersJacobian}.
433      * @return names of the parameters (i.e. columns) of the Jacobian matrix
434      */
435     List<String> getJacobiansColumnsNames() {
436         final List<String> columnsNames = new ArrayList<>();
437         for (final ForceModel forceModel : getAllForceModels()) {
438             for (final ParameterDriver driver : forceModel.getParametersDrivers()) {
439                 if (driver.isSelected() && !columnsNames.contains(driver.getNamesSpanMap().getFirstSpan().getData())) {
440                     // As driver with same name should have same NamesSpanMap we only check if the first span is present,
441                     // if not we add all span names to columnsNames
442                     for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
443                         columnsNames.add(span.getData());
444                     }
445                 }
446             }
447         }
448         Collections.sort(columnsNames);
449         return columnsNames;
450     }
451 
452     /** {@inheritDoc} */
453     @Override
454     protected AbstractMatricesHarvester createHarvester(final String stmName, final RealMatrix initialStm,
455                                                         final DoubleArrayDictionary initialJacobianColumns) {
456         return new NumericalPropagationHarvester(this, stmName, initialStm, initialJacobianColumns);
457     }
458 
459     /** {@inheritDoc} */
460     @Override
461     protected void setUpStmAndJacobianGenerators() {
462 
463         final AbstractMatricesHarvester harvester = getHarvester();
464         if (harvester != null) {
465 
466             // set up the additional equations and additional state providers
467             final StateTransitionMatrixGenerator stmGenerator = setUpStmGenerator();
468             final List<String> triggersDates = setUpTriggerDatesJacobiansColumns(stmGenerator.getName());
469             setUpRegularParametersJacobiansColumns(stmGenerator, triggersDates);
470 
471             // as we are now starting the propagation, everything is configured
472             // we can freeze the names in the harvester
473             harvester.freezeColumnsNames();
474 
475         }
476 
477     }
478 
479     /** Set up the State Transition Matrix Generator.
480      * @return State Transition Matrix Generator
481      * @since 11.1
482      */
483     private StateTransitionMatrixGenerator setUpStmGenerator() {
484 
485         final AbstractMatricesHarvester harvester = getHarvester();
486 
487         // add the STM generator corresponding to the current settings, and setup state accordingly
488         StateTransitionMatrixGenerator stmGenerator = null;
489         for (final AdditionalDerivativesProvider equations : getAdditionalDerivativesProviders()) {
490             if (equations instanceof StateTransitionMatrixGenerator &&
491                 equations.getName().equals(harvester.getStmName())) {
492                 // the STM generator has already been set up in a previous propagation
493                 stmGenerator = (StateTransitionMatrixGenerator) equations;
494                 break;
495             }
496         }
497         if (stmGenerator == null) {
498             // this is the first time we need the STM generate, create it
499             stmGenerator = new StateTransitionMatrixGenerator(harvester.getStmName(), getAllForceModels(), getAttitudeProvider());
500             addAdditionalDerivativesProvider(stmGenerator);
501         }
502 
503         if (!getInitialIntegrationState().hasAdditionalData(harvester.getStmName())) {
504             // add the initial State Transition Matrix if it is not already there
505             // (perhaps due to a previous propagation)
506             setInitialState(stmGenerator.setInitialStateTransitionMatrix(getInitialState(),
507                                                                          harvester.getInitialStateTransitionMatrix(),
508                                                                          getOrbitType(),
509                                                                          getPositionAngleType()));
510         }
511 
512         return stmGenerator;
513 
514     }
515 
516     /** Set up the Jacobians columns generator dedicated to trigger dates.
517      * @param stmName name of the State Transition Matrix state
518      * @return names of the columns corresponding to trigger dates
519      * @since 11.1
520      */
521     private List<String> setUpTriggerDatesJacobiansColumns(final String stmName) {
522 
523         final List<String> names = new ArrayList<>();
524         for (final ForceModel forceModel : getAllForceModels()) {
525             if (forceModel instanceof Maneuver && ((Maneuver) forceModel).getManeuverTriggers() instanceof ResettableManeuverTriggers) {
526                 final Maneuver maneuver = (Maneuver) forceModel;
527                 final ResettableManeuverTriggers maneuverTriggers = (ResettableManeuverTriggers) maneuver.getManeuverTriggers();
528 
529                 final Collection<EventDetector> selectedDetectors = maneuverTriggers.getEventDetectors().
530                         filter(ManeuverTriggerDetector.class::isInstance).
531                         map(triggerDetector -> ((ManeuverTriggerDetector<?>) triggerDetector).getDetector())
532                         .collect(Collectors.toList());
533                 for (final EventDetector detector: selectedDetectors) {
534                     if (detector instanceof ParameterDrivenDateIntervalDetector) {
535                         final ParameterDrivenDateIntervalDetector d = (ParameterDrivenDateIntervalDetector) detector;
536                         TriggerDate start;
537                         TriggerDate stop;
538 
539                         if (d.getStartDriver().isSelected() || d.getMedianDriver().isSelected() || d.getDurationDriver().isSelected()) {
540                             // normally datedriver should have only 1 span but just in case the user defines several span, there will
541                             // be no problem here
542                             for (Span<String> span = d.getStartDriver().getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
543                                 start = manageTriggerDate(stmName, maneuver, maneuverTriggers, span.getData(), true, d.getThreshold());
544                                 names.add(start.getName());
545                                 start = null;
546                             }
547                         }
548                         if (d.getStopDriver().isSelected() || d.getMedianDriver().isSelected() || d.getDurationDriver().isSelected()) {
549                             // normally datedriver should have only 1 span but just in case the user defines several span, there will
550                             // be no problem here
551                             for (Span<String> span = d.getStopDriver().getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
552                                 stop = manageTriggerDate(stmName, maneuver, maneuverTriggers, span.getData(), false, d.getThreshold());
553                                 names.add(stop.getName());
554                                 stop = null;
555                             }
556                         }
557                         if (d.getMedianDriver().isSelected()) {
558                             // for first span
559                             Span<String> currentMedianNameSpan = d.getMedianDriver().getNamesSpanMap().getFirstSpan();
560                             MedianDate median =
561                                     manageMedianDate(d.getStartDriver().getNamesSpanMap().getFirstSpan().getData(),
562                                             d.getStopDriver().getNamesSpanMap().getFirstSpan().getData(), currentMedianNameSpan.getData());
563                             names.add(median.getName());
564                             // for all span
565                             // normally datedriver should have only 1 span but just in case the user defines several span, there will
566                             // be no problem here. /!\ medianDate driver, startDate driver and stopDate driver must have same span number
567                             for (int spanNumber = 1; spanNumber < d.getMedianDriver().getNamesSpanMap().getSpansNumber(); ++spanNumber) {
568                                 currentMedianNameSpan = d.getMedianDriver().getNamesSpanMap().getSpan(currentMedianNameSpan.getEnd());
569                                 median =
570                                         manageMedianDate(d.getStartDriver().getNamesSpanMap().getSpan(currentMedianNameSpan.getStart()).getData(),
571                                                 d.getStopDriver().getNamesSpanMap().getSpan(currentMedianNameSpan.getStart()).getData(),
572                                                 currentMedianNameSpan.getData());
573                                 names.add(median.getName());
574 
575                             }
576 
577                         }
578                         if (d.getDurationDriver().isSelected()) {
579                             // for first span
580                             Span<String> currentDurationNameSpan = d.getDurationDriver().getNamesSpanMap().getFirstSpan();
581                             Duration duration =
582                                     manageManeuverDuration(d.getStartDriver().getNamesSpanMap().getFirstSpan().getData(),
583                                             d.getStopDriver().getNamesSpanMap().getFirstSpan().getData(), currentDurationNameSpan.getData());
584                             names.add(duration.getName());
585                             // for all span
586                             for (int spanNumber = 1; spanNumber < d.getDurationDriver().getNamesSpanMap().getSpansNumber(); ++spanNumber) {
587                                 currentDurationNameSpan = d.getDurationDriver().getNamesSpanMap().getSpan(currentDurationNameSpan.getEnd());
588                                 duration =
589                                         manageManeuverDuration(d.getStartDriver().getNamesSpanMap().getSpan(currentDurationNameSpan.getStart()).getData(),
590                                                 d.getStopDriver().getNamesSpanMap().getSpan(currentDurationNameSpan.getStart()).getData(),
591                                                 currentDurationNameSpan.getData());
592                                 names.add(duration.getName());
593 
594                             }
595                         }
596                     }
597                 }
598             }
599         }
600 
601         return names;
602 
603     }
604 
605     /** Manage a maneuver trigger date.
606      * @param stmName name of the State Transition Matrix state
607      * @param maneuver maneuver force model
608      * @param mt trigger to which the driver is bound
609      * @param driverName name of the date driver
610      * @param start if true, the driver is a maneuver start
611      * @param threshold event detector threshold
612      * @return generator for the date driver
613      * @since 11.1
614      */
615     private TriggerDate manageTriggerDate(final String stmName,
616                                           final Maneuver maneuver,
617                                           final ResettableManeuverTriggers mt,
618                                           final String driverName,
619                                           final boolean start,
620                                           final double threshold) {
621 
622         TriggerDate triggerGenerator = null;
623 
624         // check if we already have set up the provider
625         for (final AdditionalDataProvider<?> provider : getAdditionalDataProviders()) {
626             if (provider instanceof TriggerDate &&
627                 provider.getName().equals(driverName)) {
628                 // the Jacobian column generator has already been set up in a previous propagation
629                 triggerGenerator = (TriggerDate) provider;
630                 break;
631             }
632         }
633 
634         if (triggerGenerator == null) {
635             // this is the first time we need the Jacobian column generator, create it
636             triggerGenerator = new TriggerDate(stmName, driverName, start, maneuver, threshold);
637             mt.addResetter(triggerGenerator);
638             addAdditionalDerivativesProvider(triggerGenerator.getMassDepletionDelay());
639             addAdditionalDataProvider(triggerGenerator);
640         }
641 
642         if (!getInitialIntegrationState().hasAdditionalData(driverName)) {
643             // add the initial Jacobian column if it is not already there
644             // (perhaps due to a previous propagation)
645             setInitialColumn(triggerGenerator.getMassDepletionDelay().getName(), new double[6]);
646             setInitialColumn(driverName, getHarvester().getInitialJacobianColumn(driverName));
647         }
648 
649         return triggerGenerator;
650 
651     }
652 
653     /** Manage a maneuver median date.
654      * @param startName name of the start driver
655      * @param stopName name of the stop driver
656      * @param medianName name of the median driver
657      * @return generator for the median driver
658      * @since 11.1
659      */
660     private MedianDate manageMedianDate(final String startName, final String stopName, final String medianName) {
661 
662         MedianDate medianGenerator = null;
663 
664         // check if we already have set up the provider
665         for (final AdditionalDataProvider<?> provider : getAdditionalDataProviders()) {
666             if (provider instanceof MedianDate &&
667                 provider.getName().equals(medianName)) {
668                 // the Jacobian column generator has already been set up in a previous propagation
669                 medianGenerator = (MedianDate) provider;
670                 break;
671             }
672         }
673 
674         if (medianGenerator == null) {
675             // this is the first time we need the Jacobian column generator, create it
676             medianGenerator = new MedianDate(startName, stopName, medianName);
677             addAdditionalDataProvider(medianGenerator);
678         }
679 
680         if (!getInitialIntegrationState().hasAdditionalData(medianName)) {
681             // add the initial Jacobian column if it is not already there
682             // (perhaps due to a previous propagation)
683             setInitialColumn(medianName, getHarvester().getInitialJacobianColumn(medianName));
684         }
685 
686         return medianGenerator;
687 
688     }
689 
690     /** Manage a maneuver duration.
691      * @param startName name of the start driver
692      * @param stopName name of the stop driver
693      * @param durationName name of the duration driver
694      * @return generator for the median driver
695      * @since 11.1
696      */
697     private Duration manageManeuverDuration(final String startName, final String stopName, final String durationName) {
698 
699         Duration durationGenerator = null;
700 
701         // check if we already have set up the provider
702         for (final AdditionalDataProvider<?> provider : getAdditionalDataProviders()) {
703             if (provider instanceof Duration &&
704                 provider.getName().equals(durationName)) {
705                 // the Jacobian column generator has already been set up in a previous propagation
706                 durationGenerator = (Duration) provider;
707                 break;
708             }
709         }
710 
711         if (durationGenerator == null) {
712             // this is the first time we need the Jacobian column generator, create it
713             durationGenerator = new Duration(startName, stopName, durationName);
714             addAdditionalDataProvider(durationGenerator);
715         }
716 
717         if (!getInitialIntegrationState().hasAdditionalData(durationName)) {
718             // add the initial Jacobian column if it is not already there
719             // (perhaps due to a previous propagation)
720             setInitialColumn(durationName, getHarvester().getInitialJacobianColumn(durationName));
721         }
722 
723         return durationGenerator;
724 
725     }
726 
727     /** Set up the Jacobians columns generator for regular parameters.
728      * @param stmGenerator generator for the State Transition Matrix
729      * @param triggerDates names of the columns already managed as trigger dates
730      * @since 11.1
731      */
732     private void setUpRegularParametersJacobiansColumns(final StateTransitionMatrixGenerator stmGenerator,
733                                                         final List<String> triggerDates) {
734 
735         // first pass: gather all parameters (excluding trigger dates), binding similar names together
736         final ParameterDriversList selected = new ParameterDriversList();
737         for (final ForceModel forceModel : getAllForceModels()) {
738             for (final ParameterDriver driver : forceModel.getParametersDrivers()) {
739                 if (!triggerDates.contains(driver.getNamesSpanMap().getFirstSpan().getData())) {
740                     // if the first span is not in triggerDates,
741                     // it means that the driver is not a trigger date and can be selected here
742                     selected.add(driver);
743                 }
744             }
745         }
746 
747         // second pass: now that shared parameter names are bound together,
748         // their selections status have been synchronized, we can filter them
749         selected.filter(true);
750 
751         // third pass: sort parameters lexicographically
752         selected.sort();
753 
754         // add the Jacobians column generators corresponding to parameters, and setup state accordingly
755         // a new column is needed for each value estimated so for each span of the parameterDriver
756         for (final DelegatingDriver driver : selected.getDrivers()) {
757 
758             for (Span<String> currentNameSpan = driver.getNamesSpanMap().getFirstSpan(); currentNameSpan != null; currentNameSpan = currentNameSpan.next()) {
759 
760                 IntegrableJacobianColumnGenerator generator = null;
761                 // check if we already have set up the providers
762                 for (final AdditionalDerivativesProvider provider : getAdditionalDerivativesProviders()) {
763                     if (provider instanceof IntegrableJacobianColumnGenerator &&
764                         provider.getName().equals(currentNameSpan.getData())) {
765                         // the Jacobian column generator has already been set up in a previous propagation
766                         generator = (IntegrableJacobianColumnGenerator) provider;
767                         break;
768                     }
769 
770                 }
771 
772                 if (generator == null) {
773                     // this is the first time we need the Jacobian column generator, create it
774                     generator = new IntegrableJacobianColumnGenerator(stmGenerator, currentNameSpan.getData());
775                     addAdditionalDerivativesProvider(generator);
776                 }
777 
778                 if (!getInitialIntegrationState().hasAdditionalData(currentNameSpan.getData())) {
779                     // add the initial Jacobian column if it is not already there
780                     // (perhaps due to a previous propagation)
781                     setInitialColumn(currentNameSpan.getData(), getHarvester().getInitialJacobianColumn(currentNameSpan.getData()));
782                 }
783 
784             }
785 
786         }
787 
788     }
789 
790     /** Add the initial value of the column to the initial state.
791      * <p>
792      * The initial state must already contain the Cartesian State Transition Matrix.
793      * </p>
794      * @param columnName name of the column
795      * @param dYdQ column of the Jacobian ∂Y/∂qₘ with respect to propagation type,
796      * if null (which is the most frequent case), assumed to be 0
797      * @since 11.1
798      */
799     private void setInitialColumn(final String columnName, final double[] dYdQ) {
800 
801         final SpacecraftState state = getInitialState();
802 
803         if (dYdQ.length != STATE_DIMENSION) {
804             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH,
805                                       dYdQ.length, STATE_DIMENSION);
806         }
807 
808         // convert to Cartesian Jacobian
809         final double[][] dYdC = new double[STATE_DIMENSION][STATE_DIMENSION];
810         getOrbitType().convertType(state.getOrbit()).getJacobianWrtCartesian(getPositionAngleType(), dYdC);
811         final double[] column = new QRDecomposition(MatrixUtils.createRealMatrix(dYdC), THRESHOLD).
812                         getSolver().
813                         solve(MatrixUtils.createRealVector(dYdQ)).
814                         toArray();
815 
816         // set additional state
817         setInitialState(state.addAdditionalData(columnName, column));
818 
819     }
820 
821     /** {@inheritDoc} */
822     @Override
823     protected AttitudeProvider initializeAttitudeProviderForDerivatives() {
824         final AttitudeProvider attitudeProvider = getAttitudeProvider();
825         return needFullAttitudeForDerivatives ? attitudeProvider :
826                 AttitudeProviderModifier.getFrozenAttitudeProvider(attitudeProvider);
827     }
828 
829     /** {@inheritDoc} */
830     @Override
831     protected StateMapper createMapper(final AbsoluteDate referenceDate, final double mu,
832                                        final OrbitType orbitType, final PositionAngleType positionAngleType,
833                                        final AttitudeProvider attitudeProvider, final Frame frame) {
834         return new OsculatingMapper(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
835     }
836 
837     /** Internal mapper using directly osculating parameters. */
838     private static class OsculatingMapper extends StateMapper {
839 
840         /** Simple constructor.
841          * <p>
842          * The position parameter type is meaningful only if {@link
843          * #getOrbitType() propagation orbit type}
844          * support it. As an example, it is not meaningful for propagation
845          * in {@link OrbitType#CARTESIAN Cartesian} parameters.
846          * </p>
847          * @param referenceDate reference date
848          * @param mu central attraction coefficient (m³/s²)
849          * @param orbitType orbit type to use for mapping (can be null for {@link AbsolutePVCoordinates})
850          * @param positionAngleType angle type to use for propagation
851          * @param attitudeProvider attitude provider
852          * @param frame inertial frame
853          */
854         OsculatingMapper(final AbsoluteDate referenceDate, final double mu,
855                          final OrbitType orbitType, final PositionAngleType positionAngleType,
856                          final AttitudeProvider attitudeProvider, final Frame frame) {
857             super(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
858         }
859 
860         /** {@inheritDoc} */
861         public SpacecraftState mapArrayToState(final AbsoluteDate date, final double[] y, final double[] yDot,
862                                                final PropagationType type) {
863             // the parameter type is ignored for the Numerical Propagator
864 
865             final double mass = y[6];
866             if (mass <= 0.0) {
867                 throw new OrekitException(OrekitMessages.NOT_POSITIVE_SPACECRAFT_MASS, mass);
868             }
869 
870             if (getOrbitType() == null) {
871                 // propagation uses absolute position-velocity-acceleration
872                 final Vector3D p = new Vector3D(y[0],    y[1],    y[2]);
873                 final Vector3D v = new Vector3D(y[3],    y[4],    y[5]);
874                 final Vector3D a;
875                 final AbsolutePVCoordinates absPva;
876                 if (yDot == null) {
877                     absPva = new AbsolutePVCoordinates(getFrame(), new TimeStampedPVCoordinates(date, p, v));
878                 } else {
879                     a = new Vector3D(yDot[3], yDot[4], yDot[5]);
880                     absPva = new AbsolutePVCoordinates(getFrame(), new TimeStampedPVCoordinates(date, p, v, a));
881                 }
882 
883                 final Attitude attitude = getAttitudeProvider().getAttitude(absPva, date, getFrame());
884                 return new SpacecraftState(absPva, attitude).withMass(mass);
885             } else {
886                 // propagation uses regular orbits
887                 final Orbit orbit       = getOrbitType().mapArrayToOrbit(y, yDot, getPositionAngleType(), date, getMu(), getFrame());
888                 final Attitude attitude = getAttitudeProvider().getAttitude(orbit, date, getFrame());
889 
890                 return new SpacecraftState(orbit, attitude).withMass(mass);
891             }
892 
893         }
894 
895         /** {@inheritDoc} */
896         public void mapStateToArray(final SpacecraftState state, final double[] y, final double[] yDot) {
897             if (getOrbitType() == null) {
898                 // propagation uses absolute position-velocity-acceleration
899                 final Vector3D p = state.getAbsPVA().getPosition();
900                 final Vector3D v = state.getAbsPVA().getVelocity();
901                 y[0] = p.getX();
902                 y[1] = p.getY();
903                 y[2] = p.getZ();
904                 y[3] = v.getX();
905                 y[4] = v.getY();
906                 y[5] = v.getZ();
907                 y[6] = state.getMass();
908             }
909             else {
910                 getOrbitType().mapOrbitToArray(state.getOrbit(), getPositionAngleType(), y, yDot);
911                 y[6] = state.getMass();
912             }
913         }
914 
915     }
916 
917     /** {@inheritDoc} */
918     protected MainStateEquations getMainStateEquations(final ODEIntegrator integrator) {
919         return new Main(integrator);
920     }
921 
922     /** Internal class for osculating parameters integration. */
923     private class Main implements MainStateEquations, TimeDerivativesEquations {
924 
925         /** Derivatives array. */
926         private final double[] yDot;
927 
928         /** Current state. */
929         private SpacecraftState currentState;
930 
931         /** Jacobian of the orbital parameters with respect to the Cartesian parameters. */
932         private final double[][] jacobian;
933 
934         /** Flag keeping track whether Jacobian matrix needs to be recomputed or not. */
935         private boolean recomputingJacobian;
936 
937         /** Simple constructor.
938          * @param integrator numerical integrator to use for propagation.
939          */
940         Main(final ODEIntegrator integrator) {
941 
942             this.yDot     = new double[7];
943             this.jacobian = new double[6][6];
944             this.recomputingJacobian = true;
945 
946             // feed internal event detectors
947             for (final ForceModel forceModel : forceModels) {
948                 forceModel.getEventDetectors().forEach(detector -> setUpEventDetector(integrator, detector));
949             }
950             getAttitudeProvider().getEventDetectors().forEach(detector -> setUpEventDetector(integrator, detector));
951 
952             // default value for Jacobian is identity
953             for (int i = 0; i < jacobian.length; ++i) {
954                 Arrays.fill(jacobian[i], 0.0);
955                 jacobian[i][i] = 1.0;
956             }
957 
958         }
959 
960         /** {@inheritDoc} */
961         @Override
962         public void init(final SpacecraftState initialState, final AbsoluteDate target) {
963             needFullAttitudeForDerivatives = forceModels.stream().anyMatch(ForceModel::dependsOnAttitudeRate);
964 
965             forceModels.forEach(fm -> fm.init(initialState, target));
966 
967             final int numberOfForces = forceModels.size();
968             final OrbitType orbitType = getOrbitType();
969             if (orbitType != null && orbitType != OrbitType.CARTESIAN && numberOfForces > 0) {
970                 if (numberOfForces > 1) {
971                     recomputingJacobian = true;
972                 } else {
973                     recomputingJacobian = !(forceModels.get(0) instanceof NewtonianAttraction);
974                 }
975             } else {
976                 recomputingJacobian = false;
977             }
978         }
979 
980         /** {@inheritDoc} */
981         @Override
982         public double[] computeDerivatives(final SpacecraftState state) {
983 
984             currentState = state;
985             Arrays.fill(yDot, 0.0);
986             if (recomputingJacobian) {
987                 // propagation uses Jacobian matrix of orbital parameters w.r.t. Cartesian ones
988                 currentState.getOrbit().getJacobianWrtCartesian(getPositionAngleType(), jacobian);
989             }
990 
991             // compute the contributions of all perturbing forces,
992             // using the Kepler contribution at the end since
993             // NewtonianAttraction is always the last instance in the list
994             for (final ForceModel forceModel : forceModels) {
995                 forceModel.addContribution(state, this);
996             }
997 
998             if (getOrbitType() == null) {
999                 // position derivative is velocity, and was not added above in the force models
1000                 // (it is added when orbit type is non-null because NewtonianAttraction considers it)
1001                 final Vector3D velocity = currentState.getPVCoordinates().getVelocity();
1002                 yDot[0] += velocity.getX();
1003                 yDot[1] += velocity.getY();
1004                 yDot[2] += velocity.getZ();
1005             }
1006 
1007 
1008             return yDot.clone();
1009 
1010         }
1011 
1012         /** {@inheritDoc} */
1013         @Override
1014         public void addKeplerContribution(final double mu) {
1015             if (getOrbitType() == null) {
1016                 // if mu is neither 0 nor NaN, we want to include Newtonian acceleration
1017                 if (mu > 0) {
1018                     // velocity derivative is Newtonian acceleration
1019                     final Vector3D position = currentState.getPosition();
1020                     final double r2         = position.getNormSq();
1021                     final double coeff      = -mu / (r2 * FastMath.sqrt(r2));
1022                     yDot[3] += coeff * position.getX();
1023                     yDot[4] += coeff * position.getY();
1024                     yDot[5] += coeff * position.getZ();
1025                 }
1026 
1027             } else {
1028                 // propagation uses regular orbits
1029                 currentState.getOrbit().addKeplerContribution(getPositionAngleType(), mu, yDot);
1030             }
1031         }
1032 
1033         /** {@inheritDoc} */
1034         public void addNonKeplerianAcceleration(final Vector3D gamma) {
1035             for (int i = 0; i < 6; ++i) {
1036                 final double[] jRow = jacobian[i];
1037                 yDot[i] += jRow[3] * gamma.getX() + jRow[4] * gamma.getY() + jRow[5] * gamma.getZ();
1038             }
1039         }
1040 
1041         /** {@inheritDoc} */
1042         @Override
1043         public void addMassDerivative(final double q) {
1044             if (q > 0) {
1045                 throw new OrekitIllegalArgumentException(OrekitMessages.POSITIVE_FLOW_RATE, q);
1046             }
1047             yDot[6] += q;
1048         }
1049 
1050     }
1051 
1052     /** Estimate tolerance vectors for integrators when propagating in absolute position-velocity-acceleration.
1053      * @param dP user specified position error
1054      * @param absPva reference absolute position-velocity-acceleration
1055      * @return a two rows array, row 0 being the absolute tolerance error and row 1
1056      * being the relative tolerance error
1057      * @deprecated since 13.0. Use {@link ToleranceProvider} for default and custom tolerances.
1058      */
1059     @Deprecated
1060     public static double[][] tolerances(final double dP, final AbsolutePVCoordinates absPva) {
1061         return ToleranceProvider.of(CartesianToleranceProvider.of(dP)).getTolerances(absPva);
1062     }
1063 
1064     /** Estimate tolerance vectors for integrators when propagating in orbits.
1065      * <p>
1066      * The errors are estimated from partial derivatives properties of orbits,
1067      * starting from a scalar position error specified by the user.
1068      * Considering the energy conservation equation V = sqrt(mu (2/r - 1/a)),
1069      * we get at constant energy (i.e. on a Keplerian trajectory):
1070      * <pre>
1071      * V r² |dV| = mu |dr|
1072      * </pre>
1073      * <p> So we deduce a scalar velocity error consistent with the position error.
1074      * From here, we apply orbits Jacobians matrices to get consistent errors
1075      * on orbital parameters.
1076      *
1077      * <p>
1078      * The tolerances are only <em>orders of magnitude</em>, and integrator tolerances
1079      * are only local estimates, not global ones. So some care must be taken when using
1080      * these tolerances. Setting 1mm as a position error does NOT mean the tolerances
1081      * will guarantee a 1mm error position after several orbits integration.
1082      * </p>
1083      * @param dP user specified position error
1084      * @param orbit reference orbit
1085      * @param type propagation type for the meaning of the tolerance vectors elements
1086      * (it may be different from {@code orbit.getType()})
1087      * @return a two rows array, row 0 being the absolute tolerance error and row 1
1088      * being the relative tolerance error
1089      * @deprecated since 13.0. Use {@link ToleranceProvider} for default and custom tolerances.
1090      */
1091     @Deprecated
1092     public static double[][] tolerances(final double dP, final Orbit orbit, final OrbitType type) {
1093         return ToleranceProvider.getDefaultToleranceProvider(dP).getTolerances(orbit, type, PositionAngleType.TRUE);
1094     }
1095 
1096     /** Estimate tolerance vectors for integrators when propagating in orbits.
1097      * <p>
1098      * The errors are estimated from partial derivatives properties of orbits,
1099      * starting from scalar position and velocity errors specified by the user.
1100      * <p>
1101      * The tolerances are only <em>orders of magnitude</em>, and integrator tolerances
1102      * are only local estimates, not global ones. So some care must be taken when using
1103      * these tolerances. Setting 1mm as a position error does NOT mean the tolerances
1104      * will guarantee a 1mm error position after several orbits integration.
1105      * </p>
1106      * @param dP user specified position error
1107      * @param dV user specified velocity error
1108      * @param orbit reference orbit
1109      * @param type propagation type for the meaning of the tolerance vectors elements
1110      * (it may be different from {@code orbit.getType()})
1111      * @return a two rows array, row 0 being the absolute tolerance error and row 1
1112      * being the relative tolerance error
1113      * @since 10.3
1114      * @deprecated since 13.0. Use {@link ToleranceProvider} for default and custom tolerances.
1115      */
1116     @Deprecated
1117     public static double[][] tolerances(final double dP, final double dV,
1118                                         final Orbit orbit, final OrbitType type) {
1119 
1120         return ToleranceProvider.of(CartesianToleranceProvider.of(dP, dV, CartesianToleranceProvider.DEFAULT_ABSOLUTE_MASS_TOLERANCE))
1121                 .getTolerances(orbit, type, PositionAngleType.TRUE);
1122     }
1123 
1124     /** {@inheritDoc} */
1125     @Override
1126     protected void beforeIntegration(final SpacecraftState initialState, final AbsoluteDate tEnd) {
1127 
1128         if (!getFrame().isPseudoInertial()) {
1129 
1130             // inspect all force models to find InertialForces
1131             for (ForceModel force : forceModels) {
1132                 if (force instanceof InertialForces) {
1133                     return;
1134                 }
1135             }
1136 
1137             // throw exception if no inertial forces found
1138             throw new OrekitException(OrekitMessages.INERTIAL_FORCE_MODEL_MISSING, getFrame().getName());
1139 
1140         }
1141 
1142     }
1143 
1144 }