NumericalPropagator.java

  1. /* Copyright 2002-2013 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.io.NotSerializableException;
  19. import java.io.Serializable;
  20. import java.util.ArrayList;
  21. import java.util.Arrays;
  22. import java.util.List;

  23. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  24. import org.apache.commons.math3.ode.AbstractIntegrator;
  25. import org.apache.commons.math3.util.FastMath;
  26. import org.orekit.attitudes.Attitude;
  27. import org.orekit.attitudes.AttitudeProvider;
  28. import org.orekit.errors.OrekitException;
  29. import org.orekit.errors.OrekitMessages;
  30. import org.orekit.errors.PropagationException;
  31. import org.orekit.forces.ForceModel;
  32. import org.orekit.forces.gravity.NewtonianAttraction;
  33. import org.orekit.frames.Frame;
  34. import org.orekit.frames.Transform;
  35. import org.orekit.orbits.Orbit;
  36. import org.orekit.orbits.OrbitType;
  37. import org.orekit.orbits.PositionAngle;
  38. import org.orekit.propagation.SpacecraftState;
  39. import org.orekit.propagation.events.EventDetector;
  40. import org.orekit.propagation.integration.AbstractIntegratedPropagator;
  41. import org.orekit.propagation.integration.StateMapper;
  42. import org.orekit.time.AbsoluteDate;
  43. import org.orekit.utils.PVCoordinates;

  44. /** This class propagates {@link org.orekit.orbits.Orbit orbits} using
  45.  * numerical integration.
  46.  * <p>Numerical propagation is much more accurate than analytical propagation
  47.  * like for example {@link org.orekit.propagation.analytical.KeplerianPropagator
  48.  * keplerian} or {@link org.orekit.propagation.analytical.EcksteinHechlerPropagator
  49.  * Eckstein-Hechler}, but requires a few more steps to set up to be used properly.
  50.  * Whereas analytical propagators are configured only thanks to their various
  51.  * constructors and can be used immediately after construction, numerical propagators
  52.  * configuration involve setting several parameters between construction time
  53.  * and propagation time.</p>
  54.  * <p>The configuration parameters that can be set are:</p>
  55.  * <ul>
  56.  *   <li>the initial spacecraft state ({@link #setInitialState(SpacecraftState)})</li>
  57.  *   <li>the central attraction coefficient ({@link #setMu(double)})</li>
  58.  *   <li>the various force models ({@link #addForceModel(ForceModel)},
  59.  *   {@link #removeForceModels()})</li>
  60.  *   <li>the {@link OrbitType type} of orbital parameters to be used for propagation
  61.  *   ({@link #setOrbitType(OrbitType)}),
  62.  *   <li>the {@link PositionAngle type} of position angle to be used in orbital parameters
  63.  *   to be used for propagation where it is relevant ({@link
  64.  *   #setPositionAngleType(PositionAngle)}),
  65.  *   <li>whether {@link org.orekit.propagation.integration.AdditionalEquations additional equations}
  66.  *   (for example {@link PartialDerivativesEquations Jacobians}) should be propagated along with orbital state
  67.  *   ({@link #addAdditionalEquations(org.orekit.propagation.integration.AdditionalEquations)}),
  68.  *   <li>the discrete events that should be triggered during propagation
  69.  *   ({@link #addEventDetector(EventDetector)},
  70.  *   {@link #clearEventsDetectors()})</li>
  71.  *   <li>the binding logic with the rest of the application ({@link #setSlaveMode()},
  72.  *   {@link #setMasterMode(double, org.orekit.propagation.sampling.OrekitFixedStepHandler)},
  73.  *   {@link #setMasterMode(org.orekit.propagation.sampling.OrekitStepHandler)},
  74.  *   {@link #setEphemerisMode()}, {@link #getGeneratedEphemeris()})</li>
  75.  * </ul>
  76.  * <p>From these configuration parameters, only the initial state is mandatory. The default
  77.  * propagation settings are in {@link OrbitType#EQUINOCTIAL equinoctial} parameters with
  78.  * {@link PositionAngle#TRUE true} longitude argument. If the central attraction coefficient
  79.  * is not explicitly specified, the one used to define the initial orbit will be used.
  80.  * However, specifying only the initial state and perhaps the central attraction coefficient
  81.  * would mean the propagator would use only keplerian forces. In this case, the simpler {@link
  82.  * org.orekit.propagation.analytical.KeplerianPropagator KeplerianPropagator} class would
  83.  * perhaps be more effective.</p>
  84.  * <p>The underlying numerical integrator set up in the constructor may also have its own
  85.  * configuration parameters. Typical configuration parameters for adaptive stepsize integrators
  86.  * are the min, max and perhaps start step size as well as the absolute and/or relative errors
  87.  * thresholds.</p>
  88.  * <p>The state that is seen by the integrator is a simple seven elements double array.
  89.  * The six first elements are either:
  90.  * <ul>
  91.  *   <li>the {@link org.orekit.orbits.EquinoctialOrbit equinoctial orbit parameters} (a, e<sub>x</sub>,
  92.  *   e<sub>y</sub>, h<sub>x</sub>, h<sub>y</sub>, &lambda;<sub>M</sub> or &lambda;<sub>E</sub>
  93.  *   or &lambda;<sub>v</sub>) in meters and radians,</li>
  94.  *   <li>the {@link org.orekit.orbits.KeplerianOrbit Keplerian orbit parameters} (a, e, i, &omega;, &Omega;,
  95.  *   M or E or v) in meters and radians,</li>
  96.  *   <li>the {@link org.orekit.orbits.CircularOrbit circular orbit parameters} (a, e<sub>x</sub>, e<sub>y</sub>, i,
  97.  *   &Omega;, &alpha;<sub>M</sub> or &alpha;<sub>E</sub> or &alpha;<sub>v</sub>) in meters
  98.  *   and radians,</li>
  99.  *   <li>the {@link org.orekit.orbits.CartesianOrbit Cartesian orbit parameters} (x, y, z, v<sub>x</sub>,
  100.  *   v<sub>y</sub>, v<sub>z</sub>) in meters and meters per seconds.
  101.  * </ul>
  102.  * The last element is the mass in kilograms.
  103.  * </p>
  104.  * <p>The following code snippet shows a typical setting for Low Earth Orbit propagation in
  105.  * equinoctial parameters and true longitude argument:</p>
  106.  * <pre>
  107.  * final double dP       = 0.001;
  108.  * final double minStep  = 0.001;
  109.  * final double maxStep  = 500;
  110.  * final double initStep = 60;
  111.  * final double[][] tolerance = NumericalPropagator.tolerances(dP, orbit, OrbitType.EQUINOCTIAL);
  112.  * AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tolerance[0], tolerance[1]);
  113.  * integrator.setInitialStepSize(initStep);
  114.  * propagator = new NumericalPropagator(integrator);
  115.  * </pre>
  116.  * <p>The same propagator can be reused for several orbit extrapolations, by resetting
  117.  * the initial state without modifying the other configuration parameters. However, the
  118.  * same instance cannot be used simultaneously by different threads, the class is <em>not</em>
  119.  * thread-safe.</p>

  120.  * @see SpacecraftState
  121.  * @see ForceModel
  122.  * @see org.orekit.propagation.sampling.OrekitStepHandler
  123.  * @see org.orekit.propagation.sampling.OrekitFixedStepHandler
  124.  * @see org.orekit.propagation.integration.IntegratedEphemeris
  125.  * @see TimeDerivativesEquations
  126.  *
  127.  * @author Mathieu Rom&eacute;ro
  128.  * @author Luc Maisonobe
  129.  * @author Guylaine Prat
  130.  * @author Fabien Maussion
  131.  * @author V&eacute;ronique Pommier-Maurussane
  132.  */
  133. public class NumericalPropagator extends AbstractIntegratedPropagator {

  134.     /** Central body attraction. */
  135.     private NewtonianAttraction newtonianAttraction;

  136.     /** Force models used during the extrapolation of the Orbit, without jacobians. */
  137.     private final List<ForceModel> forceModels;

  138.     /** Create a new instance of NumericalPropagator, based on orbit definition mu.
  139.      * After creation, the instance is empty, i.e. the attitude provider is set to an
  140.      * unspecified default law and there are no perturbing forces at all.
  141.      * This means that if {@link #addForceModel addForceModel} is not
  142.      * called after creation, the integrated orbit will follow a keplerian
  143.      * evolution only. The defaults are {@link OrbitType#EQUINOCTIAL}
  144.      * for {@link #setOrbitType(OrbitType) propagation
  145.      * orbit type} and {@link PositionAngle#TRUE} for {@link
  146.      * #setPositionAngleType(PositionAngle) position angle type}.
  147.      * @param integrator numerical integrator to use for propagation.
  148.      */
  149.     public NumericalPropagator(final AbstractIntegrator integrator) {
  150.         super(integrator);
  151.         forceModels = new ArrayList<ForceModel>();
  152.         initMapper();
  153.         setAttitudeProvider(DEFAULT_LAW);
  154.         setMu(Double.NaN);
  155.         setSlaveMode();
  156.         setOrbitType(OrbitType.EQUINOCTIAL);
  157.         setPositionAngleType(PositionAngle.TRUE);
  158.     }

  159.      /** Set the central attraction coefficient &mu;.
  160.      * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  161.      * @see #addForceModel(ForceModel)
  162.      */
  163.     public void setMu(final double mu) {
  164.         super.setMu(mu);
  165.         newtonianAttraction = new NewtonianAttraction(mu);
  166.     }

  167.     /** Set the attitude provider.
  168.      * @param provider attitude provider
  169.      * @deprecated as of 6.0 replaced by {@link #setAttitudeProvider(AttitudeProvider)}
  170.      */
  171.     @Deprecated
  172.     public void setAttitudeLaw(final AttitudeProvider provider) {
  173.         setAttitudeProvider(provider);
  174.     }

  175.     /** Add a force model to the global perturbation model.
  176.      * <p>If this method is not called at all, the integrated orbit will follow
  177.      * a keplerian evolution only.</p>
  178.      * @param model perturbing {@link ForceModel} to add
  179.      * @see #removeForceModels()
  180.      * @see #setMu(double)
  181.      */
  182.     public void addForceModel(final ForceModel model) {
  183.         forceModels.add(model);
  184.     }

  185.     /** Remove all perturbing force models from the global perturbation model.
  186.      * <p>Once all perturbing forces have been removed (and as long as no new force
  187.      * model is added), the integrated orbit will follow a keplerian evolution
  188.      * only.</p>
  189.      * @see #addForceModel(ForceModel)
  190.      */
  191.     public void removeForceModels() {
  192.         forceModels.clear();
  193.     }

  194.     /** Get perturbing force models list.
  195.      * @return list of perturbing force models
  196.      * @see #addForceModel(ForceModel)
  197.      * @see #getNewtonianAttractionForceModel()
  198.      */
  199.     public List<ForceModel> getForceModels() {
  200.         return forceModels;
  201.     }

  202.     /** Get the Newtonian attraction from the central body force model.
  203.      * @return Newtonian attraction force model
  204.      * @see #setMu(double)
  205.      * @see #getForceModels()
  206.      */
  207.     public NewtonianAttraction getNewtonianAttractionForceModel() {
  208.         return newtonianAttraction;
  209.     }

  210.     /** Set propagation orbit type.
  211.      * @param orbitType orbit type to use for propagation
  212.      */
  213.     public void setOrbitType(final OrbitType orbitType) {
  214.         super.setOrbitType(orbitType);
  215.     }

  216.     /** Get propagation parameter type.
  217.      * @return orbit type used for propagation
  218.      */
  219.     public OrbitType getOrbitType() {
  220.         return super.getOrbitType();
  221.     }

  222.     /** Set position angle type.
  223.      * <p>
  224.      * The position parameter type is meaningful only if {@link
  225.      * #getOrbitType() propagation orbit type}
  226.      * support it. As an example, it is not meaningful for propagation
  227.      * in {@link OrbitType#CARTESIAN Cartesian} parameters.
  228.      * </p>
  229.      * @param positionAngleType angle type to use for propagation
  230.      */
  231.     public void setPositionAngleType(final PositionAngle positionAngleType) {
  232.         super.setPositionAngleType(positionAngleType);
  233.     }

  234.     /** Get propagation parameter type.
  235.      * @return angle type to use for propagation
  236.      */
  237.     public PositionAngle getPositionAngleType() {
  238.         return super.getPositionAngleType();
  239.     }

  240.     /** Set the initial state.
  241.      * @param initialState initial state
  242.      * @exception PropagationException if initial state cannot be set
  243.      */
  244.     public void setInitialState(final SpacecraftState initialState) throws PropagationException {
  245.         resetInitialState(initialState);
  246.     }

  247.     /** {@inheritDoc} */
  248.     public void resetInitialState(final SpacecraftState state) throws PropagationException {
  249.         super.resetInitialState(state);
  250.         if (newtonianAttraction == null) {
  251.             setMu(state.getMu());
  252.         }
  253.         setStartDate(null);
  254.     }

  255.     /** {@inheritDoc} */
  256.     public PVCoordinates getPVCoordinates(final AbsoluteDate date, final Frame frame)
  257.         throws OrekitException {
  258.         return propagate(date).getPVCoordinates(frame);
  259.     }

  260.     /** {@inheritDoc} */
  261.     protected StateMapper createMapper(final AbsoluteDate referenceDate, final double mu,
  262.                                        final OrbitType orbitType, final PositionAngle positionAngleType,
  263.                                        final AttitudeProvider attitudeProvider, final Frame frame) {
  264.         return new OsculatingMapper(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
  265.     }

  266.     /** Internal mapper using directly osculating parameters. */
  267.     private static class OsculatingMapper extends StateMapper implements Serializable {

  268.         /** Serializable UID. */
  269.         private static final long serialVersionUID = 20130621L;

  270.         /** Simple constructor.
  271.          * <p>
  272.          * The position parameter type is meaningful only if {@link
  273.          * #getOrbitType() propagation orbit type}
  274.          * support it. As an example, it is not meaningful for propagation
  275.          * in {@link OrbitType#CARTESIAN Cartesian} parameters.
  276.          * </p>
  277.          * @param referenceDate reference date
  278.          * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  279.          * @param orbitType orbit type to use for mapping
  280.          * @param positionAngleType angle type to use for propagation
  281.          * @param attitudeProvider attitude provider
  282.          * @param frame inertial frame
  283.          */
  284.         public OsculatingMapper(final AbsoluteDate referenceDate, final double mu,
  285.                                 final OrbitType orbitType, final PositionAngle positionAngleType,
  286.                                 final AttitudeProvider attitudeProvider, final Frame frame) {
  287.             super(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
  288.         }

  289.         /** {@inheritDoc} */
  290.         public SpacecraftState mapArrayToState(final double t, final double[] y)
  291.             throws OrekitException {

  292.             final double mass = y[6];
  293.             if (mass <= 0.0) {
  294.                 throw new PropagationException(OrekitMessages.SPACECRAFT_MASS_BECOMES_NEGATIVE, mass);
  295.             }

  296.             final AbsoluteDate date = mapDoubleToDate(t);
  297.             final Orbit orbit       = getOrbitType().mapArrayToOrbit(y, getPositionAngleType(), date, getMu(), getFrame());
  298.             final Attitude attitude = getAttitudeProvider().getAttitude(orbit, date, getFrame());

  299.             return new SpacecraftState(orbit, attitude, mass);

  300.         }

  301.         /** {@inheritDoc} */
  302.         public void mapStateToArray(final SpacecraftState state, final double[] y) {
  303.             getOrbitType().mapOrbitToArray(state.getOrbit(), getPositionAngleType(), y);
  304.             y[6] = state.getMass();
  305.         }

  306.         /** Replace the instance with a data transfer object for serialization.
  307.          * @return data transfer object that will be serialized
  308.          * @exception NotSerializableException if the state mapper cannot be serialized (typically for DSST propagator)
  309.          */
  310.         private Object writeReplace() throws NotSerializableException {
  311.             return new DataTransferObject(getReferenceDate(), getMu(), getOrbitType(),
  312.                                           getPositionAngleType(), getAttitudeProvider(), getFrame());
  313.         }

  314.         /** Internal class used only for serialization. */
  315.         private static class DataTransferObject implements Serializable {

  316.             /** Serializable UID. */
  317.             private static final long serialVersionUID = 20130621L;

  318.             /** Reference date. */
  319.             private final AbsoluteDate referenceDate;

  320.             /** Central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>). */
  321.             private final double mu;

  322.             /** Orbit type to use for mapping. */
  323.             private final OrbitType orbitType;

  324.             /** Angle type to use for propagation. */
  325.             private final PositionAngle positionAngleType;

  326.             /** Attitude provider. */
  327.             private final AttitudeProvider attitudeProvider;

  328.             /** Inertial frame. */
  329.             private final Frame frame;

  330.             /** Simple constructor.
  331.              * @param referenceDate reference date
  332.              * @param mu central attraction coefficient (m<sup>3</sup>/s<sup>2</sup>)
  333.              * @param orbitType orbit type to use for mapping
  334.              * @param positionAngleType angle type to use for propagation
  335.              * @param attitudeProvider attitude provider
  336.              * @param frame inertial frame
  337.              */
  338.             public DataTransferObject(final AbsoluteDate referenceDate, final double mu,
  339.                                       final OrbitType orbitType, final PositionAngle positionAngleType,
  340.                                       final AttitudeProvider attitudeProvider, final Frame frame) {
  341.                 this.referenceDate     = referenceDate;
  342.                 this.mu                = mu;
  343.                 this.orbitType         = orbitType;
  344.                 this.positionAngleType = positionAngleType;
  345.                 this.attitudeProvider  = attitudeProvider;
  346.                 this.frame             = frame;
  347.             }

  348.             /** Replace the deserialized data transfer object with a {@link OsculatingMapper}.
  349.              * @return replacement {@link OsculatingMapper}
  350.              */
  351.             private Object readResolve() {
  352.                 return new OsculatingMapper(referenceDate, mu, orbitType, positionAngleType, attitudeProvider, frame);
  353.             }
  354.         }

  355.     }

  356.     /** {@inheritDoc} */
  357.     protected MainStateEquations getMainStateEquations(final AbstractIntegrator integrator) {
  358.         return new Main(integrator);
  359.     }

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

  362.         /** Derivatives array. */
  363.         private final double[] yDot;

  364.         /** Current orbit. */
  365.         private Orbit orbit;

  366.         /** Jacobian of the orbital parameters with respect to the cartesian parameters. */
  367.         private double[][] jacobian;

  368.         /** Simple constructor.
  369.          * @param integrator numerical integrator to use for propagation.
  370.          */
  371.         public Main(final AbstractIntegrator integrator) {

  372.             this.yDot     = new double[7];
  373.             this.jacobian = new double[6][6];

  374.             for (final ForceModel forceModel : forceModels) {
  375.                 final EventDetector[] modelDetectors = forceModel.getEventsDetectors();
  376.                 if (modelDetectors != null) {
  377.                     for (final EventDetector detector : modelDetectors) {
  378.                         setUpEventDetector(integrator, detector);
  379.                     }
  380.                 }
  381.             }

  382.         }

  383.         /** {@inheritDoc} */
  384.         public double[] computeDerivatives(final SpacecraftState state) throws OrekitException {

  385.             orbit = state.getOrbit();
  386.             Arrays.fill(yDot, 0.0);
  387.             orbit.getJacobianWrtCartesian(getPositionAngleType(), jacobian);

  388.             // compute the contributions of all perturbing forces
  389.             for (final ForceModel forceModel : forceModels) {
  390.                 forceModel.addContribution(state, this);
  391.             }

  392.             // finalize derivatives by adding the Kepler contribution
  393.             newtonianAttraction.addContribution(state, this);

  394.             return yDot.clone();

  395.         }

  396.         /** {@inheritDoc} */
  397.         public void addKeplerContribution(final double mu) {
  398.             orbit.addKeplerContribution(getPositionAngleType(), mu, yDot);
  399.         }

  400.         /** {@inheritDoc} */
  401.         public void addXYZAcceleration(final double x, final double y, final double z) {
  402.             for (int i = 0; i < 6; ++i) {
  403.                 final double[] jRow = jacobian[i];
  404.                 yDot[i] += jRow[3] * x + jRow[4] * y + jRow[5] * z;
  405.             }
  406.         }

  407.         /** {@inheritDoc} */
  408.         public void addAcceleration(final Vector3D gamma, final Frame frame)
  409.             throws OrekitException {
  410.             final Transform t = frame.getTransformTo(orbit.getFrame(), orbit.getDate());
  411.             final Vector3D gammInRefFrame = t.transformVector(gamma);
  412.             addXYZAcceleration(gammInRefFrame.getX(), gammInRefFrame.getY(), gammInRefFrame.getZ());
  413.         }

  414.         /** {@inheritDoc} */
  415.         public void addMassDerivative(final double q) {
  416.             if (q > 0) {
  417.                 throw OrekitException.createIllegalArgumentException(OrekitMessages.POSITIVE_FLOW_RATE, q);
  418.             }
  419.             yDot[6] += q;
  420.         }

  421.     }

  422.     /** Estimate tolerance vectors for integrators.
  423.      * <p>
  424.      * The errors are estimated from partial derivatives properties of orbits,
  425.      * starting from a scalar position error specified by the user.
  426.      * Considering the energy conservation equation V = sqrt(mu (2/r - 1/a)),
  427.      * we get at constant energy (i.e. on a Keplerian trajectory):
  428.      * <pre>
  429.      * V<sup>2</sup> r |dV| = mu |dr|
  430.      * </pre>
  431.      * So we deduce a scalar velocity error consistent with the position error.
  432.      * From here, we apply orbits Jacobians matrices to get consistent errors
  433.      * on orbital parameters.
  434.      * </p>
  435.      * <p>
  436.      * The tolerances are only <em>orders of magnitude</em>, and integrator tolerances
  437.      * are only local estimates, not global ones. So some care must be taken when using
  438.      * these tolerances. Setting 1mm as a position error does NOT mean the tolerances
  439.      * will guarantee a 1mm error position after several orbits integration.
  440.      * </p>
  441.      * @param dP user specified position error
  442.      * @param orbit reference orbit
  443.      * @param type propagation type for the meaning of the tolerance vectors elements
  444.      * (it may be different from {@code orbit.getType()})
  445.      * @return a two rows array, row 0 being the absolute tolerance error and row 1
  446.      * being the relative tolerance error
  447.      * @exception PropagationException if Jacobian is singular
  448.      */
  449.     public static double[][] tolerances(final double dP, final Orbit orbit, final OrbitType type)
  450.         throws PropagationException {

  451.         // estimate the scalar velocity error
  452.         final PVCoordinates pv = orbit.getPVCoordinates();
  453.         final double r2 = pv.getPosition().getNormSq();
  454.         final double v  = pv.getVelocity().getNorm();
  455.         final double dV = orbit.getMu() * dP / (v * r2);

  456.         final double[] absTol = new double[7];
  457.         final double[] relTol = new double[7];

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

  461.         if (type == OrbitType.CARTESIAN) {
  462.             absTol[0] = dP;
  463.             absTol[1] = dP;
  464.             absTol[2] = dP;
  465.             absTol[3] = dV;
  466.             absTol[4] = dV;
  467.             absTol[5] = dV;
  468.         } else {

  469.             // convert the orbit to the desired type
  470.             final double[][] jacobian = new double[6][6];
  471.             final Orbit converted = type.convertType(orbit);
  472.             converted.getJacobianWrtCartesian(PositionAngle.TRUE, jacobian);

  473.             for (int i = 0; i < 6; ++i) {
  474.                 final double[] row = jacobian[i];
  475.                 absTol[i] = FastMath.abs(row[0]) * dP +
  476.                             FastMath.abs(row[1]) * dP +
  477.                             FastMath.abs(row[2]) * dP +
  478.                             FastMath.abs(row[3]) * dV +
  479.                             FastMath.abs(row[4]) * dV +
  480.                             FastMath.abs(row[5]) * dV;
  481.                 if (Double.isNaN(absTol[i])) {
  482.                     throw new PropagationException(OrekitMessages.SINGULAR_JACOBIAN_FOR_ORBIT_TYPE, type);
  483.                 }
  484.             }

  485.         }

  486.         Arrays.fill(relTol, dP / FastMath.sqrt(r2));

  487.         return new double[][] {
  488.             absTol, relTol
  489.         };

  490.     }

  491. }