EcksteinHechlerPropagator.java

  1. /* Copyright 2002-2019 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.analytical;

  18. import java.io.NotSerializableException;
  19. import java.io.Serializable;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import java.util.SortedSet;

  23. import org.hipparchus.analysis.differentiation.DSFactory;
  24. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  25. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  26. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  27. import org.hipparchus.util.FastMath;
  28. import org.hipparchus.util.MathUtils;
  29. import org.orekit.attitudes.AttitudeProvider;
  30. import org.orekit.errors.OrekitException;
  31. import org.orekit.errors.OrekitInternalError;
  32. import org.orekit.errors.OrekitMessages;
  33. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
  34. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics;
  35. import org.orekit.orbits.CartesianOrbit;
  36. import org.orekit.orbits.CircularOrbit;
  37. import org.orekit.orbits.Orbit;
  38. import org.orekit.orbits.OrbitType;
  39. import org.orekit.orbits.PositionAngle;
  40. import org.orekit.propagation.AdditionalStateProvider;
  41. import org.orekit.propagation.SpacecraftState;
  42. import org.orekit.time.AbsoluteDate;
  43. import org.orekit.utils.TimeSpanMap;
  44. import org.orekit.utils.TimeStampedPVCoordinates;

  45. /** This class propagates a {@link org.orekit.propagation.SpacecraftState}
  46.  *  using the analytical Eckstein-Hechler model.
  47.  * <p>The Eckstein-Hechler model is suited for near circular orbits
  48.  * (e &lt; 0.1, with poor accuracy between 0.005 and 0.1) and inclination
  49.  * neither equatorial (direct or retrograde) nor critical (direct or
  50.  * retrograde).</p>
  51.  * <p>
  52.  * Note that before version 7.0, there was a large inconsistency in the generated
  53.  * orbits, and it was fixed as of version 7.0 of Orekit, with a visible side effect.
  54.  * The problems is that if the circular parameters produced by the Eckstein-Hechler
  55.  * model are used to build an orbit considered to be osculating, the velocity deduced
  56.  * from this orbit was <em>inconsistent with the position evolution</em>! The reason is
  57.  * that the model includes non-Keplerian effects but it does not include a corresponding
  58.  * circular/Cartesian conversion. As a consequence, all subsequent computation involving
  59.  * velocity were wrong. This includes attitude modes like yaw compensation and Doppler
  60.  * effect. As this effect was considered serious enough and as accurate velocities were
  61.  * considered important, the propagator now generates {@link CartesianOrbit Cartesian
  62.  * orbits} which are built in a special way to ensure consistency throughout propagation.
  63.  * A side effect is that if circular parameters are rebuilt by user from these propagated
  64.  * Cartesian orbit, the circular parameters will generally <em>not</em> match the initial
  65.  * orbit (differences in semi-major axis can exceed 120 m). The position however <em>will</em>
  66.  * match to sub-micrometer level, and this position will be identical to the positions
  67.  * that were generated by previous versions (in other words, the internals of the models
  68.  * have not been changed, only the output parameters have been changed). The correctness
  69.  * of the initialization has been assessed and is good, as it allows the subsequent orbit
  70.  * to remain close to a numerical reference orbit.
  71.  * </p>
  72.  * <p>
  73.  * If users need a more definitive initialization of an Eckstein-Hechler propagator, they
  74.  * should consider using a {@link org.orekit.propagation.conversion.PropagatorConverter
  75.  * propagator converter} to initialize their Eckstein-Hechler propagator using a complete
  76.  * sample instead of just a single initial orbit.
  77.  * </p>
  78.  * @see Orbit
  79.  * @author Guylaine Prat
  80.  */
  81. public class EcksteinHechlerPropagator extends AbstractAnalyticalPropagator implements Serializable {

  82.     /** Serializable UID. */
  83.     private static final long serialVersionUID = 20151202L;

  84.     /** Initial Eckstein-Hechler model. */
  85.     private EHModel initialModel;

  86.     /** All models. */
  87.     private transient TimeSpanMap<EHModel> models;

  88.     /** Reference radius of the central body attraction model (m). */
  89.     private double referenceRadius;

  90.     /** Central attraction coefficient (m³/s²). */
  91.     private double mu;

  92.     /** Un-normalized zonal coefficients. */
  93.     private double[] ck0;

  94.     /** Build a propagator from orbit and potential provider.
  95.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  96.      * @param initialOrbit initial orbit
  97.      * @param provider for un-normalized zonal coefficients
  98.      */
  99.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  100.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  101.         this(initialOrbit, DEFAULT_LAW, DEFAULT_MASS, provider,
  102.              provider.onDate(initialOrbit.getDate()));
  103.     }

  104.     /**
  105.      * Private helper constructor.
  106.      * @param initialOrbit initial orbit
  107.      * @param attitude attitude provider
  108.      * @param mass spacecraft mass
  109.      * @param provider for un-normalized zonal coefficients
  110.      * @param harmonics {@code provider.onDate(initialOrbit.getDate())}
  111.      */
  112.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  113.                                      final AttitudeProvider attitude,
  114.                                      final double mass,
  115.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  116.                                      final UnnormalizedSphericalHarmonics harmonics) {
  117.         this(initialOrbit, attitude, mass, provider.getAe(), provider.getMu(),
  118.              harmonics.getUnnormalizedCnm(2, 0),
  119.              harmonics.getUnnormalizedCnm(3, 0),
  120.              harmonics.getUnnormalizedCnm(4, 0),
  121.              harmonics.getUnnormalizedCnm(5, 0),
  122.              harmonics.getUnnormalizedCnm(6, 0));
  123.     }

  124.     /** Build a propagator from orbit and potential.
  125.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  126.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  127.      * are related to both the normalized coefficients
  128.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  129.      *  and the J<sub>n</sub> one as follows:</p>
  130.      *
  131.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  132.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  133.      *
  134.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  135.      *
  136.      * @param initialOrbit initial orbit
  137.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  138.      * @param mu central attraction coefficient (m³/s²)
  139.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  140.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  141.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  142.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  143.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  144.           * @see org.orekit.utils.Constants
  145.      */
  146.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  147.                                      final double referenceRadius, final double mu,
  148.                                      final double c20, final double c30, final double c40,
  149.                                      final double c50, final double c60) {
  150.         this(initialOrbit, DEFAULT_LAW, DEFAULT_MASS, referenceRadius, mu, c20, c30, c40, c50, c60);
  151.     }

  152.     /** Build a propagator from orbit, mass and potential provider.
  153.      * <p>Attitude law is set to an unspecified non-null arbitrary value.</p>
  154.      * @param initialOrbit initial orbit
  155.      * @param mass spacecraft mass
  156.      * @param provider for un-normalized zonal coefficients
  157.      */
  158.     public EcksteinHechlerPropagator(final Orbit initialOrbit, final double mass,
  159.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  160.         this(initialOrbit, DEFAULT_LAW, mass, provider, provider.onDate(initialOrbit.getDate()));
  161.     }

  162.     /** Build a propagator from orbit, mass and potential.
  163.      * <p>Attitude law is set to an unspecified non-null arbitrary value.</p>
  164.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  165.      * are related to both the normalized coefficients
  166.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  167.      *  and the J<sub>n</sub> one as follows:</p>
  168.      *
  169.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  170.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  171.      *
  172.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  173.      *
  174.      * @param initialOrbit initial orbit
  175.      * @param mass spacecraft mass
  176.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  177.      * @param mu central attraction coefficient (m³/s²)
  178.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  179.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  180.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  181.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  182.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  183.      */
  184.     public EcksteinHechlerPropagator(final Orbit initialOrbit, final double mass,
  185.                                      final double referenceRadius, final double mu,
  186.                                      final double c20, final double c30, final double c40,
  187.                                      final double c50, final double c60) {
  188.         this(initialOrbit, DEFAULT_LAW, mass, referenceRadius, mu, c20, c30, c40, c50, c60);
  189.     }

  190.     /** Build a propagator from orbit, attitude provider and potential provider.
  191.      * <p>Mass is set to an unspecified non-null arbitrary value.</p>
  192.      * @param initialOrbit initial orbit
  193.      * @param attitudeProv attitude provider
  194.      * @param provider for un-normalized zonal coefficients
  195.      */
  196.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  197.                                      final AttitudeProvider attitudeProv,
  198.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  199.         this(initialOrbit, attitudeProv, DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()));
  200.     }

  201.     /** Build a propagator from orbit, attitude provider and potential.
  202.      * <p>Mass is set to an unspecified non-null arbitrary value.</p>
  203.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  204.      * are related to both the normalized coefficients
  205.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  206.      *  and the J<sub>n</sub> one as follows:</p>
  207.      *
  208.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  209.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  210.      *
  211.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  212.      *
  213.      * @param initialOrbit initial orbit
  214.      * @param attitudeProv attitude provider
  215.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  216.      * @param mu central attraction coefficient (m³/s²)
  217.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  218.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  219.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  220.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  221.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  222.      */
  223.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  224.                                      final AttitudeProvider attitudeProv,
  225.                                      final double referenceRadius, final double mu,
  226.                                      final double c20, final double c30, final double c40,
  227.                                      final double c50, final double c60) {
  228.         this(initialOrbit, attitudeProv, DEFAULT_MASS, referenceRadius, mu, c20, c30, c40, c50, c60);
  229.     }

  230.     /** Build a propagator from orbit, attitude provider, mass and potential provider.
  231.      * @param initialOrbit initial orbit
  232.      * @param attitudeProv attitude provider
  233.      * @param mass spacecraft mass
  234.      * @param provider for un-normalized zonal coefficients
  235.      */
  236.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  237.                                      final AttitudeProvider attitudeProv,
  238.                                      final double mass,
  239.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  240.         this(initialOrbit, attitudeProv, mass, provider, provider.onDate(initialOrbit.getDate()));
  241.     }

  242.     /** Build a propagator from orbit, attitude provider, mass and potential.
  243.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  244.      * are related to both the normalized coefficients
  245.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  246.      *  and the J<sub>n</sub> one as follows:</p>
  247.      *
  248.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  249.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  250.      *
  251.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  252.      *
  253.      * @param initialOrbit initial orbit
  254.      * @param attitudeProv attitude provider
  255.      * @param mass spacecraft mass
  256.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  257.      * @param mu central attraction coefficient (m³/s²)
  258.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  259.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  260.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  261.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  262.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  263.      */
  264.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  265.                                      final AttitudeProvider attitudeProv,
  266.                                      final double mass,
  267.                                      final double referenceRadius, final double mu,
  268.                                      final double c20, final double c30, final double c40,
  269.                                      final double c50, final double c60) {

  270.         super(attitudeProv);

  271.         // store model coefficients
  272.         this.referenceRadius = referenceRadius;
  273.         this.mu  = mu;
  274.         this.ck0 = new double[] {
  275.             0.0, 0.0, c20, c30, c40, c50, c60
  276.         };

  277.         // compute mean parameters
  278.         // transform into circular adapted parameters used by the Eckstein-Hechler model
  279.         resetInitialState(new SpacecraftState(initialOrbit,
  280.                                               attitudeProv.getAttitude(initialOrbit,
  281.                                                                        initialOrbit.getDate(),
  282.                                                                        initialOrbit.getFrame()),
  283.                                               mass));

  284.     }

  285.     /** {@inheritDoc} */
  286.     public void resetInitialState(final SpacecraftState state) {
  287.         super.resetInitialState(state);
  288.         this.initialModel = computeMeanParameters((CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit()),
  289.                                                   state.getMass());
  290.         this.models       = new TimeSpanMap<EHModel>(initialModel);
  291.     }

  292.     /** {@inheritDoc} */
  293.     protected void resetIntermediateState(final SpacecraftState state, final boolean forward) {
  294.         final EHModel newModel = computeMeanParameters((CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit()),
  295.                                                        state.getMass());
  296.         if (forward) {
  297.             models.addValidAfter(newModel, state.getDate());
  298.         } else {
  299.             models.addValidBefore(newModel, state.getDate());
  300.         }
  301.     }

  302.     /** Compute mean parameters according to the Eckstein-Hechler analytical model.
  303.      * @param osculating osculating orbit
  304.      * @param mass constant mass
  305.      * @return Eckstein-Hechler mean model
  306.      */
  307.     private EHModel computeMeanParameters(final CircularOrbit osculating, final double mass) {

  308.         // sanity check
  309.         if (osculating.getA() < referenceRadius) {
  310.             throw new OrekitException(OrekitMessages.TRAJECTORY_INSIDE_BRILLOUIN_SPHERE,
  311.                                            osculating.getA());
  312.         }

  313.         // rough initialization of the mean parameters
  314.         EHModel current = new EHModel(osculating, mass, referenceRadius, mu, ck0);

  315.         // threshold for each parameter
  316.         final double epsilon         = 1.0e-13;
  317.         final double thresholdA      = epsilon * (1 + FastMath.abs(current.mean.getA()));
  318.         final double thresholdE      = epsilon * (1 + current.mean.getE());
  319.         final double thresholdAngles = epsilon * FastMath.PI;

  320.         int i = 0;
  321.         while (i++ < 100) {

  322.             // recompute the osculating parameters from the current mean parameters
  323.             final DerivativeStructure[] parameters = current.propagateParameters(current.mean.getDate());

  324.             // adapted parameters residuals
  325.             final double deltaA      = osculating.getA()          - parameters[0].getValue();
  326.             final double deltaEx     = osculating.getCircularEx() - parameters[1].getValue();
  327.             final double deltaEy     = osculating.getCircularEy() - parameters[2].getValue();
  328.             final double deltaI      = osculating.getI()          - parameters[3].getValue();
  329.             final double deltaRAAN   = MathUtils.normalizeAngle(osculating.getRightAscensionOfAscendingNode() -
  330.                                                                 parameters[4].getValue(),
  331.                                                                 0.0);
  332.             final double deltaAlphaM = MathUtils.normalizeAngle(osculating.getAlphaM() - parameters[5].getValue(), 0.0);

  333.             // update mean parameters
  334.             current = new EHModel(new CircularOrbit(current.mean.getA()          + deltaA,
  335.                                                     current.mean.getCircularEx() + deltaEx,
  336.                                                     current.mean.getCircularEy() + deltaEy,
  337.                                                     current.mean.getI()          + deltaI,
  338.                                                     current.mean.getRightAscensionOfAscendingNode() + deltaRAAN,
  339.                                                     current.mean.getAlphaM()     + deltaAlphaM,
  340.                                                     PositionAngle.MEAN,
  341.                                                     current.mean.getFrame(),
  342.                                                     current.mean.getDate(), mu),
  343.                                   mass, referenceRadius, mu, ck0);

  344.             // check convergence
  345.             if ((FastMath.abs(deltaA)      < thresholdA) &&
  346.                 (FastMath.abs(deltaEx)     < thresholdE) &&
  347.                 (FastMath.abs(deltaEy)     < thresholdE) &&
  348.                 (FastMath.abs(deltaI)      < thresholdAngles) &&
  349.                 (FastMath.abs(deltaRAAN)   < thresholdAngles) &&
  350.                 (FastMath.abs(deltaAlphaM) < thresholdAngles)) {
  351.                 return current;
  352.             }

  353.         }

  354.         throw new OrekitException(OrekitMessages.UNABLE_TO_COMPUTE_ECKSTEIN_HECHLER_MEAN_PARAMETERS, i);

  355.     }

  356.     /** {@inheritDoc} */
  357.     public CartesianOrbit propagateOrbit(final AbsoluteDate date) {
  358.         // compute Cartesian parameters, taking derivatives into account
  359.         // to make sure velocity and acceleration are consistent
  360.         final EHModel current = models.get(date);
  361.         return new CartesianOrbit(toCartesian(date, current.propagateParameters(date)),
  362.                                   current.mean.getFrame(), mu);
  363.     }

  364.     /** Local class for Eckstein-Hechler model, with fixed mean parameters. */
  365.     private static class EHModel implements Serializable {

  366.         /** Serializable UID. */
  367.         private static final long serialVersionUID = 20160115L;

  368.         /** Factory for derivatives. */
  369.         private static final DSFactory FACTORY = new DSFactory(1, 2);

  370.         /** Mean orbit. */
  371.         private final CircularOrbit mean;

  372.         /** Constant mass. */
  373.         private final double mass;

  374.         // CHECKSTYLE: stop JavadocVariable check

  375.         // preprocessed values
  376.         private final double xnotDot;
  377.         private final double rdpom;
  378.         private final double rdpomp;
  379.         private final double eps1;
  380.         private final double eps2;
  381.         private final double xim;
  382.         private final double ommD;
  383.         private final double rdl;
  384.         private final double aMD;

  385.         private final double kh;
  386.         private final double kl;

  387.         private final double ax1;
  388.         private final double ay1;
  389.         private final double as1;
  390.         private final double ac2;
  391.         private final double axy3;
  392.         private final double as3;
  393.         private final double ac4;
  394.         private final double as5;
  395.         private final double ac6;

  396.         private final double ex1;
  397.         private final double exx2;
  398.         private final double exy2;
  399.         private final double ex3;
  400.         private final double ex4;

  401.         private final double ey1;
  402.         private final double eyx2;
  403.         private final double eyy2;
  404.         private final double ey3;
  405.         private final double ey4;

  406.         private final double rx1;
  407.         private final double ry1;
  408.         private final double r2;
  409.         private final double r3;
  410.         private final double rl;

  411.         private final double iy1;
  412.         private final double ix1;
  413.         private final double i2;
  414.         private final double i3;
  415.         private final double ih;

  416.         private final double lx1;
  417.         private final double ly1;
  418.         private final double l2;
  419.         private final double l3;
  420.         private final double ll;

  421.         // CHECKSTYLE: resume JavadocVariable check

  422.         /** Create a model for specified mean orbit.
  423.          * @param mean mean orbit
  424.          * @param mass constant mass
  425.          * @param referenceRadius reference radius of the central body attraction model (m)
  426.          * @param mu central attraction coefficient (m³/s²)
  427.          * @param ck0 un-normalized zonal coefficients
  428.          */
  429.         EHModel(final CircularOrbit mean, final double mass,
  430.                 final double referenceRadius, final double mu, final double[] ck0) {

  431.             this.mean            = mean;
  432.             this.mass            = mass;

  433.             // preliminary processing
  434.             double q = referenceRadius / mean.getA();
  435.             double ql = q * q;
  436.             final double g2 = ck0[2] * ql;
  437.             ql *= q;
  438.             final double g3 = ck0[3] * ql;
  439.             ql *= q;
  440.             final double g4 = ck0[4] * ql;
  441.             ql *= q;
  442.             final double g5 = ck0[5] * ql;
  443.             ql *= q;
  444.             final double g6 = ck0[6] * ql;

  445.             final double cosI1 = FastMath.cos(mean.getI());
  446.             final double sinI1 = FastMath.sin(mean.getI());
  447.             final double sinI2 = sinI1 * sinI1;
  448.             final double sinI4 = sinI2 * sinI2;
  449.             final double sinI6 = sinI2 * sinI4;

  450.             if (sinI2 < 1.0e-10) {
  451.                 throw new OrekitException(OrekitMessages.ALMOST_EQUATORIAL_ORBIT,
  452.                                           FastMath.toDegrees(mean.getI()));
  453.             }

  454.             if (FastMath.abs(sinI2 - 4.0 / 5.0) < 1.0e-3) {
  455.                 throw new OrekitException(OrekitMessages.ALMOST_CRITICALLY_INCLINED_ORBIT,
  456.                                           FastMath.toDegrees(mean.getI()));
  457.             }

  458.             if (mean.getE() > 0.1) {
  459.                 // if 0.005 < e < 0.1 no error is triggered, but accuracy is poor
  460.                 throw new OrekitException(OrekitMessages.TOO_LARGE_ECCENTRICITY_FOR_PROPAGATION_MODEL,
  461.                                           mean.getE());
  462.             }

  463.             xnotDot = FastMath.sqrt(mu / mean.getA()) / mean.getA();

  464.             rdpom = -0.75 * g2 * (4.0 - 5.0 * sinI2);
  465.             rdpomp = 7.5 * g4 * (1.0 - 31.0 / 8.0 * sinI2 + 49.0 / 16.0 * sinI4) -
  466.                     13.125 * g6 * (1.0 - 8.0 * sinI2 + 129.0 / 8.0 * sinI4 - 297.0 / 32.0 * sinI6);

  467.             q = 3.0 / (32.0 * rdpom);
  468.             eps1 = q * g4 * sinI2 * (30.0 - 35.0 * sinI2) -
  469.                     175.0 * q * g6 * sinI2 * (1.0 - 3.0 * sinI2 + 2.0625 * sinI4);
  470.             q = 3.0 * sinI1 / (8.0 * rdpom);
  471.             eps2 = q * g3 * (4.0 - 5.0 * sinI2) - q * g5 * (10.0 - 35.0 * sinI2 + 26.25 * sinI4);

  472.             xim = mean.getI();
  473.             ommD = cosI1 * (1.50    * g2 - 2.25 * g2 * g2 * (2.5 - 19.0 / 6.0 * sinI2) +
  474.                             0.9375  * g4 * (7.0 * sinI2 - 4.0) +
  475.                             3.28125 * g6 * (2.0 - 9.0 * sinI2 + 8.25 * sinI4));

  476.             rdl = 1.0 - 1.50 * g2 * (3.0 - 4.0 * sinI2);
  477.             aMD = rdl +
  478.                     2.25 * g2 * g2 * (9.0 - 263.0 / 12.0 * sinI2 + 341.0 / 24.0 * sinI4) +
  479.                     15.0 / 16.0 * g4 * (8.0 - 31.0 * sinI2 + 24.5 * sinI4) +
  480.                     105.0 / 32.0 * g6 * (-10.0 / 3.0 + 25.0 * sinI2 - 48.75 * sinI4 + 27.5 * sinI6);

  481.             final double qq = -1.5 * g2 / rdl;
  482.             final double qA   = 0.75 * g2 * g2 * sinI2;
  483.             final double qB   = 0.25 * g4 * sinI2;
  484.             final double qC   = 105.0 / 16.0 * g6 * sinI2;
  485.             final double qD   = -0.75 * g3 * sinI1;
  486.             final double qE   = 3.75 * g5 * sinI1;
  487.             kh = 0.375 / rdpom;
  488.             kl = kh / sinI1;

  489.             ax1 = qq * (2.0 - 3.5 * sinI2);
  490.             ay1 = qq * (2.0 - 2.5 * sinI2);
  491.             as1 = qD * (4.0 - 5.0 * sinI2) +
  492.                   qE * (2.625 * sinI4 - 3.5 * sinI2 + 1.0);
  493.             ac2 = qq * sinI2 +
  494.                   qA * 7.0 * (2.0 - 3.0 * sinI2) +
  495.                   qB * (15.0 - 17.5 * sinI2) +
  496.                   qC * (3.0 * sinI2 - 1.0 - 33.0 / 16.0 * sinI4);
  497.             axy3 = qq * 3.5 * sinI2;
  498.             as3 = qD * 5.0 / 3.0 * sinI2 +
  499.                   qE * 7.0 / 6.0 * sinI2 * (1.0 - 1.125 * sinI2);
  500.             ac4 = qA * sinI2 +
  501.                   qB * 4.375 * sinI2 +
  502.                   qC * 0.75 * (1.1 * sinI4 - sinI2);

  503.             as5 = qE * 21.0 / 80.0 * sinI4;

  504.             ac6 = qC * -11.0 / 80.0 * sinI4;

  505.             ex1 = qq * (1.0 - 1.25 * sinI2);
  506.             exx2 = qq * 0.5 * (3.0 - 5.0 * sinI2);
  507.             exy2 = qq * (2.0 - 1.5 * sinI2);
  508.             ex3 = qq * 7.0 / 12.0 * sinI2;
  509.             ex4 = qq * 17.0 / 8.0 * sinI2;

  510.             ey1 = qq * (1.0 - 1.75 * sinI2);
  511.             eyx2 = qq * (1.0 - 3.0 * sinI2);
  512.             eyy2 = qq * (2.0 * sinI2 - 1.5);
  513.             ey3 = qq * 7.0 / 12.0 * sinI2;
  514.             ey4 = qq * 17.0 / 8.0 * sinI2;

  515.             q  = -qq * cosI1;
  516.             rx1 =  3.5 * q;
  517.             ry1 = -2.5 * q;
  518.             r2 = -0.5 * q;
  519.             r3 =  7.0 / 6.0 * q;
  520.             rl = g3 * cosI1 * (4.0 - 15.0 * sinI2) -
  521.                  2.5 * g5 * cosI1 * (4.0 - 42.0 * sinI2 + 52.5 * sinI4);

  522.             q = 0.5 * qq * sinI1 * cosI1;
  523.             iy1 =  q;
  524.             ix1 = -q;
  525.             i2 =  q;
  526.             i3 =  q * 7.0 / 3.0;
  527.             ih = -g3 * cosI1 * (4.0 - 5.0 * sinI2) +
  528.                  2.5 * g5 * cosI1 * (4.0 - 14.0 * sinI2 + 10.5 * sinI4);

  529.             lx1 = qq * (7.0 - 77.0 / 8.0 * sinI2);
  530.             ly1 = qq * (55.0 / 8.0 * sinI2 - 7.50);
  531.             l2 = qq * (1.25 * sinI2 - 0.5);
  532.             l3 = qq * (77.0 / 24.0 * sinI2 - 7.0 / 6.0);
  533.             ll = g3 * (53.0 * sinI2 - 4.0 - 57.5 * sinI4) +
  534.                  2.5 * g5 * (4.0 - 96.0 * sinI2 + 269.5 * sinI4 - 183.75 * sinI6);

  535.         }

  536.         /** Extrapolate an orbit up to a specific target date.
  537.          * @param date target date for the orbit
  538.          * @return propagated parameters
  539.          */
  540.         public DerivativeStructure[] propagateParameters(final AbsoluteDate date) {

  541.             // Keplerian evolution
  542.             final DerivativeStructure dt = FACTORY.variable(0, date.durationFrom(mean.getDate()));
  543.             final DerivativeStructure xnot = dt.multiply(xnotDot);

  544.             // secular effects

  545.             // eccentricity
  546.             final DerivativeStructure x   = xnot.multiply(rdpom + rdpomp);
  547.             final DerivativeStructure cx  = x.cos();
  548.             final DerivativeStructure sx  = x.sin();
  549.             final DerivativeStructure exm = cx.multiply(mean.getCircularEx()).
  550.                                             add(sx.multiply(eps2 - (1.0 - eps1) * mean.getCircularEy()));
  551.             final DerivativeStructure eym = sx.multiply((1.0 + eps1) * mean.getCircularEx()).
  552.                                             add(cx.multiply(mean.getCircularEy() - eps2)).
  553.                                             add(eps2);

  554.             // no secular effect on inclination

  555.             // right ascension of ascending node
  556.             final DerivativeStructure omm =
  557.                             FACTORY.build(MathUtils.normalizeAngle(mean.getRightAscensionOfAscendingNode() + ommD * xnot.getValue(),
  558.                                                            FastMath.PI),
  559.                                   ommD * xnotDot,
  560.                                   0.0);

  561.             // latitude argument
  562.             final DerivativeStructure xlm =
  563.                             FACTORY.build(MathUtils.normalizeAngle(mean.getAlphaM() + aMD * xnot.getValue(), FastMath.PI),
  564.                                   aMD * xnotDot,
  565.                                   0.0);

  566.             // periodical terms
  567.             final DerivativeStructure cl1 = xlm.cos();
  568.             final DerivativeStructure sl1 = xlm.sin();
  569.             final DerivativeStructure cl2 = cl1.multiply(cl1).subtract(sl1.multiply(sl1));
  570.             final DerivativeStructure sl2 = cl1.multiply(sl1).add(sl1.multiply(cl1));
  571.             final DerivativeStructure cl3 = cl2.multiply(cl1).subtract(sl2.multiply(sl1));
  572.             final DerivativeStructure sl3 = cl2.multiply(sl1).add(sl2.multiply(cl1));
  573.             final DerivativeStructure cl4 = cl3.multiply(cl1).subtract(sl3.multiply(sl1));
  574.             final DerivativeStructure sl4 = cl3.multiply(sl1).add(sl3.multiply(cl1));
  575.             final DerivativeStructure cl5 = cl4.multiply(cl1).subtract(sl4.multiply(sl1));
  576.             final DerivativeStructure sl5 = cl4.multiply(sl1).add(sl4.multiply(cl1));
  577.             final DerivativeStructure cl6 = cl5.multiply(cl1).subtract(sl5.multiply(sl1));

  578.             final DerivativeStructure qh  = eym.subtract(eps2).multiply(kh);
  579.             final DerivativeStructure ql  = exm.multiply(kl);

  580.             final DerivativeStructure exmCl1 = exm.multiply(cl1);
  581.             final DerivativeStructure exmSl1 = exm.multiply(sl1);
  582.             final DerivativeStructure eymCl1 = eym.multiply(cl1);
  583.             final DerivativeStructure eymSl1 = eym.multiply(sl1);
  584.             final DerivativeStructure exmCl2 = exm.multiply(cl2);
  585.             final DerivativeStructure exmSl2 = exm.multiply(sl2);
  586.             final DerivativeStructure eymCl2 = eym.multiply(cl2);
  587.             final DerivativeStructure eymSl2 = eym.multiply(sl2);
  588.             final DerivativeStructure exmCl3 = exm.multiply(cl3);
  589.             final DerivativeStructure exmSl3 = exm.multiply(sl3);
  590.             final DerivativeStructure eymCl3 = eym.multiply(cl3);
  591.             final DerivativeStructure eymSl3 = eym.multiply(sl3);
  592.             final DerivativeStructure exmCl4 = exm.multiply(cl4);
  593.             final DerivativeStructure exmSl4 = exm.multiply(sl4);
  594.             final DerivativeStructure eymCl4 = eym.multiply(cl4);
  595.             final DerivativeStructure eymSl4 = eym.multiply(sl4);

  596.             // semi major axis
  597.             final DerivativeStructure rda = exmCl1.multiply(ax1).
  598.                                             add(eymSl1.multiply(ay1)).
  599.                                             add(sl1.multiply(as1)).
  600.                                             add(cl2.multiply(ac2)).
  601.                                             add(exmCl3.add(eymSl3).multiply(axy3)).
  602.                                             add(sl3.multiply(as3)).
  603.                                             add(cl4.multiply(ac4)).
  604.                                             add(sl5.multiply(as5)).
  605.                                             add(cl6.multiply(ac6));

  606.             // eccentricity
  607.             final DerivativeStructure rdex = cl1.multiply(ex1).
  608.                                              add(exmCl2.multiply(exx2)).
  609.                                              add(eymSl2.multiply(exy2)).
  610.                                              add(cl3.multiply(ex3)).
  611.                                              add(exmCl4.add(eymSl4).multiply(ex4));
  612.             final DerivativeStructure rdey = sl1.multiply(ey1).
  613.                                              add(exmSl2.multiply(eyx2)).
  614.                                              add(eymCl2.multiply(eyy2)).
  615.                                              add(sl3.multiply(ey3)).
  616.                                              add(exmSl4.subtract(eymCl4).multiply(ey4));

  617.             // ascending node
  618.             final DerivativeStructure rdom = exmSl1.multiply(rx1).
  619.                                              add(eymCl1.multiply(ry1)).
  620.                                              add(sl2.multiply(r2)).
  621.                                              add(eymCl3.subtract(exmSl3).multiply(r3)).
  622.                                              add(ql.multiply(rl));

  623.             // inclination
  624.             final DerivativeStructure rdxi = eymSl1.multiply(iy1).
  625.                                              add(exmCl1.multiply(ix1)).
  626.                                              add(cl2.multiply(i2)).
  627.                                              add(exmCl3.add(eymSl3).multiply(i3)).
  628.                                              add(qh.multiply(ih));

  629.             // latitude argument
  630.             final DerivativeStructure rdxl = exmSl1.multiply(lx1).
  631.                                              add(eymCl1.multiply(ly1)).
  632.                                              add(sl2.multiply(l2)).
  633.                                              add(exmSl3.subtract(eymCl3).multiply(l3)).
  634.                                              add(ql.multiply(ll));

  635.             // osculating parameters
  636.             return new DerivativeStructure[] {
  637.                 rda.add(1.0).multiply(mean.getA()),
  638.                 rdex.add(exm),
  639.                 rdey.add(eym),
  640.                 rdxi.add(xim),
  641.                 rdom.add(omm),
  642.                 rdxl.add(xlm)
  643.             };

  644.         }

  645.     }

  646.     /** Convert circular parameters <em>with derivatives</em> to Cartesian coordinates.
  647.      * @param date date of the orbital parameters
  648.      * @param parameters circular parameters (a, ex, ey, i, raan, alphaM)
  649.      * @return Cartesian coordinates consistent with values and derivatives
  650.      */
  651.     private TimeStampedPVCoordinates toCartesian(final AbsoluteDate date, final DerivativeStructure[] parameters) {

  652.         // evaluate coordinates in the orbit canonical reference frame
  653.         final DerivativeStructure cosOmega = parameters[4].cos();
  654.         final DerivativeStructure sinOmega = parameters[4].sin();
  655.         final DerivativeStructure cosI     = parameters[3].cos();
  656.         final DerivativeStructure sinI     = parameters[3].sin();
  657.         final DerivativeStructure alphaE   = meanToEccentric(parameters[5], parameters[1], parameters[2]);
  658.         final DerivativeStructure cosAE    = alphaE.cos();
  659.         final DerivativeStructure sinAE    = alphaE.sin();
  660.         final DerivativeStructure ex2      = parameters[1].multiply(parameters[1]);
  661.         final DerivativeStructure ey2      = parameters[2].multiply(parameters[2]);
  662.         final DerivativeStructure exy      = parameters[1].multiply(parameters[2]);
  663.         final DerivativeStructure q        = ex2.add(ey2).subtract(1).negate().sqrt();
  664.         final DerivativeStructure beta     = q.add(1).reciprocal();
  665.         final DerivativeStructure bx2      = beta.multiply(ex2);
  666.         final DerivativeStructure by2      = beta.multiply(ey2);
  667.         final DerivativeStructure bxy      = beta.multiply(exy);
  668.         final DerivativeStructure u        = bxy.multiply(sinAE).subtract(parameters[1].add(by2.subtract(1).multiply(cosAE)));
  669.         final DerivativeStructure v        = bxy.multiply(cosAE).subtract(parameters[2].add(bx2.subtract(1).multiply(sinAE)));
  670.         final DerivativeStructure x        = parameters[0].multiply(u);
  671.         final DerivativeStructure y        = parameters[0].multiply(v);

  672.         // canonical orbit reference frame
  673.         final FieldVector3D<DerivativeStructure> p =
  674.                 new FieldVector3D<>(x.multiply(cosOmega).subtract(y.multiply(cosI.multiply(sinOmega))),
  675.                                     x.multiply(sinOmega).add(y.multiply(cosI.multiply(cosOmega))),
  676.                                     y.multiply(sinI));

  677.         // dispatch derivatives
  678.         final Vector3D p0 = new Vector3D(p.getX().getValue(),
  679.                                          p.getY().getValue(),
  680.                                          p.getZ().getValue());
  681.         final Vector3D p1 = new Vector3D(p.getX().getPartialDerivative(1),
  682.                                          p.getY().getPartialDerivative(1),
  683.                                          p.getZ().getPartialDerivative(1));
  684.         final Vector3D p2 = new Vector3D(p.getX().getPartialDerivative(2),
  685.                                          p.getY().getPartialDerivative(2),
  686.                                          p.getZ().getPartialDerivative(2));
  687.         return new TimeStampedPVCoordinates(date, p0, p1, p2);

  688.     }

  689.     /** Computes the eccentric latitude argument from the mean latitude argument.
  690.      * @param alphaM = M + Ω mean latitude argument (rad)
  691.      * @param ex e cos(Ω), first component of circular eccentricity vector
  692.      * @param ey e sin(Ω), second component of circular eccentricity vector
  693.      * @return the eccentric latitude argument.
  694.      */
  695.     private DerivativeStructure meanToEccentric(final DerivativeStructure alphaM,
  696.                                                 final DerivativeStructure ex,
  697.                                                 final DerivativeStructure ey) {
  698.         // Generalization of Kepler equation to circular parameters
  699.         // with alphaE = PA + E and
  700.         //      alphaM = PA + M = alphaE - ex.sin(alphaE) + ey.cos(alphaE)
  701.         DerivativeStructure alphaE        = alphaM;
  702.         DerivativeStructure shift         = alphaM.getField().getZero();
  703.         DerivativeStructure alphaEMalphaM = alphaM.getField().getZero();
  704.         DerivativeStructure cosAlphaE     = alphaE.cos();
  705.         DerivativeStructure sinAlphaE     = alphaE.sin();
  706.         int                 iter          = 0;
  707.         do {
  708.             final DerivativeStructure f2 = ex.multiply(sinAlphaE).subtract(ey.multiply(cosAlphaE));
  709.             final DerivativeStructure f1 = alphaM.getField().getOne().subtract(ex.multiply(cosAlphaE)).subtract(ey.multiply(sinAlphaE));
  710.             final DerivativeStructure f0 = alphaEMalphaM.subtract(f2);

  711.             final DerivativeStructure f12 = f1.multiply(2);
  712.             shift = f0.multiply(f12).divide(f1.multiply(f12).subtract(f0.multiply(f2)));

  713.             alphaEMalphaM  = alphaEMalphaM.subtract(shift);
  714.             alphaE         = alphaM.add(alphaEMalphaM);
  715.             cosAlphaE      = alphaE.cos();
  716.             sinAlphaE      = alphaE.sin();

  717.         } while ((++iter < 50) && (FastMath.abs(shift.getValue()) > 1.0e-12));

  718.         return alphaE;

  719.     }

  720.     /** {@inheritDoc} */
  721.     protected double getMass(final AbsoluteDate date) {
  722.         return models.get(date).mass;
  723.     }

  724.     /** Replace the instance with a data transfer object for serialization.
  725.      * @return data transfer object that will be serialized
  726.      * @exception NotSerializableException if an additional state provider is not serializable
  727.      */
  728.     private Object writeReplace() throws NotSerializableException {
  729.         try {
  730.             // managed states providers
  731.             final List<AdditionalStateProvider> serializableProviders = new ArrayList<AdditionalStateProvider>();
  732.             for (final AdditionalStateProvider provider : getAdditionalStateProviders()) {
  733.                 if (provider instanceof Serializable) {
  734.                     serializableProviders.add(provider);
  735.                 } else {
  736.                     throw new NotSerializableException(provider.getClass().getName());
  737.                 }
  738.             }

  739.             // states transitions
  740.             final AbsoluteDate[]  transitionDates;
  741.             final CircularOrbit[] allOrbits;
  742.             final double[]        allMasses;
  743.             final SortedSet<TimeSpanMap.Transition<EHModel>> transitions = models.getTransitions();
  744.             if (transitions.size() == 1  && transitions.first().getBefore() == transitions.first().getAfter()) {
  745.                 // the single entry is a dummy one, without a real transition
  746.                 // we ignore it completely
  747.                 transitionDates = null;
  748.                 allOrbits       = null;
  749.                 allMasses       = null;
  750.             } else {
  751.                 transitionDates = new AbsoluteDate[transitions.size()];
  752.                 allOrbits       = new CircularOrbit[transitions.size() + 1];
  753.                 allMasses       = new double[transitions.size() + 1];
  754.                 int i = 0;
  755.                 for (final TimeSpanMap.Transition<EHModel> transition : transitions) {
  756.                     if (i == 0) {
  757.                         // model before the first transition
  758.                         allOrbits[i] = transition.getBefore().mean;
  759.                         allMasses[i] = transition.getBefore().mass;
  760.                     }
  761.                     transitionDates[i] = transition.getDate();
  762.                     allOrbits[++i]     = transition.getAfter().mean;
  763.                     allMasses[i]       = transition.getAfter().mass;
  764.                 }
  765.             }

  766.             return new DataTransferObject(getInitialState().getOrbit(), initialModel.mass,
  767.                                           referenceRadius, mu, ck0, getAttitudeProvider(),
  768.                                           transitionDates, allOrbits, allMasses,
  769.                                           serializableProviders.toArray(new AdditionalStateProvider[serializableProviders.size()]));
  770.         } catch (OrekitException orekitException) {
  771.             // this should never happen
  772.             throw new OrekitInternalError(null);
  773.         }

  774.     }

  775.     /** Internal class used only for serialization. */
  776.     private static class DataTransferObject implements Serializable {

  777.         /** Serializable UID. */
  778.         private static final long serialVersionUID = 20151202L;

  779.         /** Initial orbit. */
  780.         private final Orbit orbit;

  781.         /** Attitude provider. */
  782.         private final AttitudeProvider attitudeProvider;

  783.         /** Mass and gravity field. */
  784.         private double[] g;

  785.         /** Transition dates (may be null). */
  786.         private final AbsoluteDate[] transitionDates;

  787.         /** Orbits before and after transitions (may be null). */
  788.         private final CircularOrbit[] allOrbits;

  789.         /** Masses before and after transitions (may be null). */
  790.         private final double[] allMasses;

  791.         /** Providers for additional states. */
  792.         private final AdditionalStateProvider[] providers;

  793.         /** Simple constructor.
  794.          * @param orbit initial orbit
  795.          * @param mass spacecraft mass
  796.          * @param referenceRadius reference radius of the Earth for the potential model (m)
  797.          * @param mu central attraction coefficient (m³/s²)
  798.          * @param ck0 un-normalized zonal coefficients
  799.          * @param attitudeProvider attitude provider
  800.          * @param transitionDates transition dates (may be null)
  801.          * @param allOrbits orbits before and after transitions (may be null)
  802.          * @param allMasses masses before and after transitions (may be null)
  803.          * @param providers providers for additional states
  804.          */
  805.         DataTransferObject(final Orbit orbit, final double mass,
  806.                            final double referenceRadius, final double mu,
  807.                            final double[] ck0,
  808.                            final AttitudeProvider attitudeProvider,
  809.                            final AbsoluteDate[] transitionDates,
  810.                            final CircularOrbit[] allOrbits,
  811.                            final double[] allMasses,
  812.                            final AdditionalStateProvider[] providers) {
  813.             this.orbit            = orbit;
  814.             this.attitudeProvider = attitudeProvider;
  815.             this.g = new double[] {
  816.                 mass, referenceRadius, mu,
  817.                 ck0[2], ck0[3], ck0[4], ck0[5], ck0[6] // ck0[0] and ck0[1] are both zero so not serialized
  818.             };
  819.             this.transitionDates  = transitionDates;
  820.             this.allOrbits        = allOrbits;
  821.             this.allMasses        = allMasses;
  822.             this.providers        = providers;
  823.         }

  824.         /** Replace the deserialized data transfer object with a {@link EcksteinHechlerPropagator}.
  825.          * @return replacement {@link EcksteinHechlerPropagator}
  826.          */
  827.         private Object readResolve() {
  828.             try {
  829.                 final EcksteinHechlerPropagator propagator =
  830.                                 new EcksteinHechlerPropagator(orbit, attitudeProvider,
  831.                                                               g[0], g[1], g[2],              // mass, referenceRadius, mu
  832.                                                               g[3], g[4], g[5], g[6], g[7]); // c20, c30, c40, c50, c60
  833.                 for (final AdditionalStateProvider provider : providers) {
  834.                     propagator.addAdditionalStateProvider(provider);

  835.                 }
  836.                 if (transitionDates != null) {
  837.                     // override the state transitions
  838.                     final double[] ck0 = new double[] {
  839.                         0, 0, g[3], g[4], g[5], g[6], g[7]
  840.                     };
  841.                     propagator.models = new TimeSpanMap<EHModel>(new EHModel(allOrbits[0], allMasses[0],
  842.                                                                              g[1], g[2], ck0));
  843.                     for (int i = 0; i < transitionDates.length; ++i) {
  844.                         propagator.models.addValidAfter(new EHModel(allOrbits[i + 1], allMasses[i + 1],
  845.                                                                     g[1], g[2], ck0),
  846.                                                         transitionDates[i]);
  847.                     }
  848.                 }

  849.                 return propagator;
  850.             } catch (OrekitException oe) {
  851.                 throw new OrekitInternalError(oe);
  852.             }
  853.         }

  854.     }

  855. }