EcksteinHechlerPropagator.java

  1. /* Copyright 2002-2022 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.propagation.analytical;

  18. import java.io.Serializable;

  19. import org.hipparchus.analysis.differentiation.UnivariateDerivative2;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.hipparchus.linear.RealMatrix;
  23. import org.hipparchus.util.FastMath;
  24. import org.hipparchus.util.MathUtils;
  25. import org.hipparchus.util.SinCos;
  26. import org.orekit.attitudes.AttitudeProvider;
  27. import org.orekit.attitudes.InertialProvider;
  28. import org.orekit.errors.OrekitException;
  29. import org.orekit.errors.OrekitMessages;
  30. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
  31. import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics;
  32. import org.orekit.orbits.CartesianOrbit;
  33. import org.orekit.orbits.CircularOrbit;
  34. import org.orekit.orbits.Orbit;
  35. import org.orekit.orbits.OrbitType;
  36. import org.orekit.orbits.PositionAngle;
  37. import org.orekit.propagation.AbstractMatricesHarvester;
  38. import org.orekit.propagation.PropagationType;
  39. import org.orekit.propagation.SpacecraftState;
  40. import org.orekit.time.AbsoluteDate;
  41. import org.orekit.utils.DoubleArrayDictionary;
  42. import org.orekit.utils.TimeSpanMap;
  43. import org.orekit.utils.TimeStampedPVCoordinates;

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

  81.     /** Initial Eckstein-Hechler model. */
  82.     private EHModel initialModel;

  83.     /** All models. */
  84.     private transient TimeSpanMap<EHModel> models;

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

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

  89.     /** Un-normalized zonal coefficients. */
  90.     private double[] ck0;

  91.     /** Build a propagator from orbit and potential provider.
  92.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  93.      *
  94.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  95.      *
  96.      * @param initialOrbit initial orbit
  97.      * @param provider for un-normalized zonal coefficients
  98.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider,
  99.      * UnnormalizedSphericalHarmonicsProvider)
  100.      * @see #EcksteinHechlerPropagator(Orbit, UnnormalizedSphericalHarmonicsProvider,
  101.      *                                 PropagationType)
  102.      */
  103.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  104.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  105.         this(initialOrbit, InertialProvider.of(initialOrbit.getFrame()),
  106.                 DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()));
  107.     }

  108.     /**
  109.      * Private helper constructor.
  110.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  111.      * @param initialOrbit initial orbit
  112.      * @param attitude attitude provider
  113.      * @param mass spacecraft mass
  114.      * @param provider for un-normalized zonal coefficients
  115.      * @param harmonics {@code provider.onDate(initialOrbit.getDate())}
  116.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double,
  117.      *                                 UnnormalizedSphericalHarmonicsProvider,
  118.      *                                 UnnormalizedSphericalHarmonicsProvider.UnnormalizedSphericalHarmonics,
  119.      *                                 PropagationType)
  120.      */
  121.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  122.                                      final AttitudeProvider attitude,
  123.                                      final double mass,
  124.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  125.                                      final UnnormalizedSphericalHarmonics harmonics) {
  126.         this(initialOrbit, attitude, mass, provider.getAe(), provider.getMu(),
  127.              harmonics.getUnnormalizedCnm(2, 0),
  128.              harmonics.getUnnormalizedCnm(3, 0),
  129.              harmonics.getUnnormalizedCnm(4, 0),
  130.              harmonics.getUnnormalizedCnm(5, 0),
  131.              harmonics.getUnnormalizedCnm(6, 0));
  132.     }

  133.     /** Build a propagator from orbit and potential.
  134.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  135.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  136.      * are related to both the normalized coefficients
  137.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  138.      *  and the J<sub>n</sub> one as follows:</p>
  139.      *
  140.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  141.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  142.      *
  143.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  144.      *
  145.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  146.      *
  147.      * @param initialOrbit initial orbit
  148.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  149.      * @param mu central attraction coefficient (m³/s²)
  150.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  151.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  152.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  153.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  154.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  155.      * @see org.orekit.utils.Constants
  156.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double, double, double,
  157.      * double, double, double, double, double)
  158.      */
  159.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  160.                                      final double referenceRadius, final double mu,
  161.                                      final double c20, final double c30, final double c40,
  162.                                      final double c50, final double c60) {
  163.         this(initialOrbit, InertialProvider.of(initialOrbit.getFrame()),
  164.                 DEFAULT_MASS, referenceRadius, mu, c20, c30, c40, c50, c60);
  165.     }

  166.     /** Build a propagator from orbit, mass and potential provider.
  167.      * <p>Attitude law is set to an unspecified non-null arbitrary value.</p>
  168.      *
  169.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  170.      *
  171.      * @param initialOrbit initial orbit
  172.      * @param mass spacecraft mass
  173.      * @param provider for un-normalized zonal coefficients
  174.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double,
  175.      * UnnormalizedSphericalHarmonicsProvider)
  176.      */
  177.     public EcksteinHechlerPropagator(final Orbit initialOrbit, final double mass,
  178.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  179.         this(initialOrbit, InertialProvider.of(initialOrbit.getFrame()),
  180.                 mass, provider, provider.onDate(initialOrbit.getDate()));
  181.     }

  182.     /** Build a propagator from orbit, mass and potential.
  183.      * <p>Attitude law is set to an unspecified non-null arbitrary value.</p>
  184.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  185.      * are related to both the normalized coefficients
  186.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  187.      *  and the J<sub>n</sub> one as follows:</p>
  188.      *
  189.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  190.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  191.      *
  192.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  193.      *
  194.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  195.      *
  196.      * @param initialOrbit initial orbit
  197.      * @param mass spacecraft mass
  198.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  199.      * @param mu central attraction coefficient (m³/s²)
  200.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  201.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  202.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  203.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  204.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  205.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double, double, double,
  206.      * double, double, double, double, double)
  207.      */
  208.     public EcksteinHechlerPropagator(final Orbit initialOrbit, final double mass,
  209.                                      final double referenceRadius, final double mu,
  210.                                      final double c20, final double c30, final double c40,
  211.                                      final double c50, final double c60) {
  212.         this(initialOrbit, InertialProvider.of(initialOrbit.getFrame()),
  213.                 mass, referenceRadius, mu, c20, c30, c40, c50, c60);
  214.     }

  215.     /** Build a propagator from orbit, attitude provider and potential provider.
  216.      * <p>Mass is set to an unspecified non-null arbitrary value.</p>
  217.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  218.      * @param initialOrbit initial orbit
  219.      * @param attitudeProv attitude provider
  220.      * @param provider for un-normalized zonal coefficients
  221.      */
  222.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  223.                                      final AttitudeProvider attitudeProv,
  224.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  225.         this(initialOrbit, attitudeProv, DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()));
  226.     }

  227.     /** Build a propagator from orbit, attitude provider and potential.
  228.      * <p>Mass is set to an unspecified non-null arbitrary value.</p>
  229.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  230.      * are related to both the normalized coefficients
  231.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  232.      *  and the J<sub>n</sub> one as follows:</p>
  233.      *
  234.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  235.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  236.      *
  237.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  238.      *
  239.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  240.      *
  241.      * @param initialOrbit initial orbit
  242.      * @param attitudeProv attitude provider
  243.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  244.      * @param mu central attraction coefficient (m³/s²)
  245.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  246.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  247.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  248.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  249.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  250.      */
  251.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  252.                                      final AttitudeProvider attitudeProv,
  253.                                      final double referenceRadius, final double mu,
  254.                                      final double c20, final double c30, final double c40,
  255.                                      final double c50, final double c60) {
  256.         this(initialOrbit, attitudeProv, DEFAULT_MASS, referenceRadius, mu, c20, c30, c40, c50, c60);
  257.     }

  258.     /** Build a propagator from orbit, attitude provider, mass and potential provider.
  259.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  260.      * @param initialOrbit initial orbit
  261.      * @param attitudeProv attitude provider
  262.      * @param mass spacecraft mass
  263.      * @param provider for un-normalized zonal coefficients
  264.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double,
  265.      *                                 UnnormalizedSphericalHarmonicsProvider, PropagationType)
  266.      */
  267.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  268.                                      final AttitudeProvider attitudeProv,
  269.                                      final double mass,
  270.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  271.         this(initialOrbit, attitudeProv, mass, provider, provider.onDate(initialOrbit.getDate()));
  272.     }

  273.     /** Build a propagator from orbit, attitude provider, mass and potential.
  274.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  275.      * are related to both the normalized coefficients
  276.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  277.      *  and the J<sub>n</sub> one as follows:</p>
  278.      *
  279.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  280.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  281.      *
  282.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  283.      *
  284.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  285.      *
  286.      * @param initialOrbit initial orbit
  287.      * @param attitudeProv attitude provider
  288.      * @param mass spacecraft mass
  289.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  290.      * @param mu central attraction coefficient (m³/s²)
  291.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  292.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  293.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  294.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  295.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  296.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double, double, double,
  297.      *                                 double, double, double, double, double, PropagationType)
  298.      */
  299.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  300.                                      final AttitudeProvider attitudeProv,
  301.                                      final double mass,
  302.                                      final double referenceRadius, final double mu,
  303.                                      final double c20, final double c30, final double c40,
  304.                                      final double c50, final double c60) {
  305.         this(initialOrbit, attitudeProv, mass, referenceRadius, mu, c20, c30, c40, c50, c60,
  306.              PropagationType.OSCULATING);
  307.     }


  308.     /** Build a propagator from orbit and potential provider.
  309.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  310.      *
  311.      * <p>Using this constructor, it is possible to define the initial orbit as
  312.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  313.      *
  314.      * @param initialOrbit initial orbit
  315.      * @param provider for un-normalized zonal coefficients
  316.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  317.      * @since 10.2
  318.      */
  319.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  320.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  321.                                      final PropagationType initialType) {
  322.         this(initialOrbit, InertialProvider.of(initialOrbit.getFrame()),
  323.              DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()), initialType);
  324.     }

  325.     /** Build a propagator from orbit, attitude provider, mass and potential provider.
  326.      * <p>Using this constructor, it is possible to define the initial orbit as
  327.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  328.      * @param initialOrbit initial orbit
  329.      * @param attitudeProv attitude provider
  330.      * @param mass spacecraft mass
  331.      * @param provider for un-normalized zonal coefficients
  332.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  333.      * @since 10.2
  334.      */
  335.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  336.                                      final AttitudeProvider attitudeProv,
  337.                                      final double mass,
  338.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  339.                                      final PropagationType initialType) {
  340.         this(initialOrbit, attitudeProv, mass, provider, provider.onDate(initialOrbit.getDate()), initialType);
  341.     }

  342.     /**
  343.      * Private helper constructor.
  344.      * <p>Using this constructor, it is possible to define the initial orbit as
  345.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  346.      * @param initialOrbit initial orbit
  347.      * @param attitude attitude provider
  348.      * @param mass spacecraft mass
  349.      * @param provider for un-normalized zonal coefficients
  350.      * @param harmonics {@code provider.onDate(initialOrbit.getDate())}
  351.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  352.      * @since 10.2
  353.      */
  354.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  355.                                      final AttitudeProvider attitude,
  356.                                      final double mass,
  357.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  358.                                      final UnnormalizedSphericalHarmonics harmonics,
  359.                                      final PropagationType initialType) {
  360.         this(initialOrbit, attitude, mass, provider.getAe(), provider.getMu(),
  361.              harmonics.getUnnormalizedCnm(2, 0),
  362.              harmonics.getUnnormalizedCnm(3, 0),
  363.              harmonics.getUnnormalizedCnm(4, 0),
  364.              harmonics.getUnnormalizedCnm(5, 0),
  365.              harmonics.getUnnormalizedCnm(6, 0),
  366.              initialType);
  367.     }

  368.     /** Build a propagator from orbit, attitude provider, mass and potential.
  369.      * <p>The C<sub>n,0</sub> coefficients are the denormalized zonal coefficients, they
  370.      * are related to both the normalized coefficients
  371.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  372.      *  and the J<sub>n</sub> one as follows:</p>
  373.      *
  374.      * <p> C<sub>n,0</sub> = [(2-δ<sub>0,m</sub>)(2n+1)(n-m)!/(n+m)!]<sup>½</sup>
  375.      * <span style="text-decoration: overline">C</span><sub>n,0</sub>
  376.      *
  377.      * <p> C<sub>n,0</sub> = -J<sub>n</sub>
  378.      *
  379.      * <p>Using this constructor, it is possible to define the initial orbit as
  380.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  381.      *
  382.      * @param initialOrbit initial orbit
  383.      * @param attitudeProv attitude provider
  384.      * @param mass spacecraft mass
  385.      * @param referenceRadius reference radius of the Earth for the potential model (m)
  386.      * @param mu central attraction coefficient (m³/s²)
  387.      * @param c20 un-normalized zonal coefficient (about -1.08e-3 for Earth)
  388.      * @param c30 un-normalized zonal coefficient (about +2.53e-6 for Earth)
  389.      * @param c40 un-normalized zonal coefficient (about +1.62e-6 for Earth)
  390.      * @param c50 un-normalized zonal coefficient (about +2.28e-7 for Earth)
  391.      * @param c60 un-normalized zonal coefficient (about -5.41e-7 for Earth)
  392.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  393.      * @since 10.2
  394.      */
  395.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  396.                                      final AttitudeProvider attitudeProv,
  397.                                      final double mass,
  398.                                      final double referenceRadius, final double mu,
  399.                                      final double c20, final double c30, final double c40,
  400.                                      final double c50, final double c60,
  401.                                      final PropagationType initialType) {

  402.         super(attitudeProv);

  403.         // store model coefficients
  404.         this.referenceRadius = referenceRadius;
  405.         this.mu  = mu;
  406.         this.ck0 = new double[] {
  407.             0.0, 0.0, c20, c30, c40, c50, c60
  408.         };

  409.         // compute mean parameters if needed
  410.         // transform into circular adapted parameters used by the Eckstein-Hechler model
  411.         resetInitialState(new SpacecraftState(initialOrbit,
  412.                                               attitudeProv.getAttitude(initialOrbit,
  413.                                                                        initialOrbit.getDate(),
  414.                                                                        initialOrbit.getFrame()),
  415.                                               mass),
  416.                           initialType);

  417.     }

  418.     /** {@inheritDoc}
  419.      * <p>The new initial state to consider
  420.      * must be defined with an osculating orbit.</p>
  421.      * @see #resetInitialState(SpacecraftState, PropagationType)
  422.      */
  423.     public void resetInitialState(final SpacecraftState state) {
  424.         resetInitialState(state, PropagationType.OSCULATING);
  425.     }

  426.     /** Reset the propagator initial state.
  427.      * @param state new initial state to consider
  428.      * @param stateType mean Eckstein-Hechler orbit or osculating orbit
  429.      * @since 10.2
  430.      */
  431.     public void resetInitialState(final SpacecraftState state, final PropagationType stateType) {
  432.         super.resetInitialState(state);
  433.         final CircularOrbit circular = (CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit());
  434.         this.initialModel = (stateType == PropagationType.MEAN) ?
  435.                              new EHModel(circular, state.getMass(), referenceRadius, mu, ck0) :
  436.                              computeMeanParameters(circular, state.getMass());
  437.         this.models = new TimeSpanMap<EHModel>(initialModel);
  438.     }

  439.     /** {@inheritDoc} */
  440.     protected void resetIntermediateState(final SpacecraftState state, final boolean forward) {
  441.         final EHModel newModel = computeMeanParameters((CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit()),
  442.                                                        state.getMass());
  443.         if (forward) {
  444.             models.addValidAfter(newModel, state.getDate(), false);
  445.         } else {
  446.             models.addValidBefore(newModel, state.getDate(), false);
  447.         }
  448.         stateChanged(state);
  449.     }

  450.     /** Compute mean parameters according to the Eckstein-Hechler analytical model.
  451.      * @param osculating osculating orbit
  452.      * @param mass constant mass
  453.      * @return Eckstein-Hechler mean model
  454.      */
  455.     private EHModel computeMeanParameters(final CircularOrbit osculating, final double mass) {

  456.         // sanity check
  457.         if (osculating.getA() < referenceRadius) {
  458.             throw new OrekitException(OrekitMessages.TRAJECTORY_INSIDE_BRILLOUIN_SPHERE,
  459.                                            osculating.getA());
  460.         }

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

  463.         // threshold for each parameter
  464.         final double epsilon         = 1.0e-13;
  465.         final double thresholdA      = epsilon * (1 + FastMath.abs(current.mean.getA()));
  466.         final double thresholdE      = epsilon * (1 + current.mean.getE());
  467.         final double thresholdAngles = epsilon * FastMath.PI;

  468.         int i = 0;
  469.         while (i++ < 100) {

  470.             // recompute the osculating parameters from the current mean parameters
  471.             final UnivariateDerivative2[] parameters = current.propagateParameters(current.mean.getDate());

  472.             // adapted parameters residuals
  473.             final double deltaA      = osculating.getA()          - parameters[0].getValue();
  474.             final double deltaEx     = osculating.getCircularEx() - parameters[1].getValue();
  475.             final double deltaEy     = osculating.getCircularEy() - parameters[2].getValue();
  476.             final double deltaI      = osculating.getI()          - parameters[3].getValue();
  477.             final double deltaRAAN   = MathUtils.normalizeAngle(osculating.getRightAscensionOfAscendingNode() -
  478.                                                                 parameters[4].getValue(),
  479.                                                                 0.0);
  480.             final double deltaAlphaM = MathUtils.normalizeAngle(osculating.getAlphaM() - parameters[5].getValue(), 0.0);

  481.             // update mean parameters
  482.             current = new EHModel(new CircularOrbit(current.mean.getA()          + deltaA,
  483.                                                     current.mean.getCircularEx() + deltaEx,
  484.                                                     current.mean.getCircularEy() + deltaEy,
  485.                                                     current.mean.getI()          + deltaI,
  486.                                                     current.mean.getRightAscensionOfAscendingNode() + deltaRAAN,
  487.                                                     current.mean.getAlphaM()     + deltaAlphaM,
  488.                                                     PositionAngle.MEAN,
  489.                                                     current.mean.getFrame(),
  490.                                                     current.mean.getDate(), mu),
  491.                                   mass, referenceRadius, mu, ck0);

  492.             // check convergence
  493.             if (FastMath.abs(deltaA)      < thresholdA &&
  494.                 FastMath.abs(deltaEx)     < thresholdE &&
  495.                 FastMath.abs(deltaEy)     < thresholdE &&
  496.                 FastMath.abs(deltaI)      < thresholdAngles &&
  497.                 FastMath.abs(deltaRAAN)   < thresholdAngles &&
  498.                 FastMath.abs(deltaAlphaM) < thresholdAngles) {
  499.                 return current;
  500.             }

  501.         }

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

  503.     }

  504.     /** {@inheritDoc} */
  505.     public CartesianOrbit propagateOrbit(final AbsoluteDate date) {
  506.         // compute Cartesian parameters, taking derivatives into account
  507.         // to make sure velocity and acceleration are consistent
  508.         final EHModel current = models.get(date);
  509.         return new CartesianOrbit(toCartesian(date, current.propagateParameters(date)),
  510.                                   current.mean.getFrame(), mu);
  511.     }

  512.     /**
  513.      * Get the central attraction coefficient μ.
  514.      * @return mu central attraction coefficient (m³/s²)
  515.      * @since 11.1
  516.      */
  517.     public double getMu() {
  518.         return mu;
  519.     }

  520.     /**
  521.      * Get the un-normalized zonal coefficients.
  522.      * @return the un-normalized zonal coefficients
  523.      * @since 11.1
  524.      */
  525.     public double[] getCk0() {
  526.         return ck0.clone();
  527.     }

  528.     /**
  529.      * Get the reference radius of the central body attraction model.
  530.      * @return the reference radius in meters
  531.      * @since 11.1
  532.      */
  533.     public double getReferenceRadius() {
  534.         return referenceRadius;
  535.     }

  536.     /** {@inheritDoc} */
  537.     @Override
  538.     protected AbstractMatricesHarvester createHarvester(final String stmName, final RealMatrix initialStm,
  539.                                                         final DoubleArrayDictionary initialJacobianColumns) {
  540.         return new EcksteinHechlerHarvester(this, stmName, initialStm, initialJacobianColumns);
  541.     }

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

  544.         /** Serializable UID. */
  545.         private static final long serialVersionUID = 20160115L;

  546.         /** Mean orbit. */
  547.         private final CircularOrbit mean;

  548.         /** Constant mass. */
  549.         private final double mass;

  550.         // CHECKSTYLE: stop JavadocVariable check

  551.         // preprocessed values
  552.         private final double xnotDot;
  553.         private final double rdpom;
  554.         private final double rdpomp;
  555.         private final double eps1;
  556.         private final double eps2;
  557.         private final double xim;
  558.         private final double ommD;
  559.         private final double rdl;
  560.         private final double aMD;

  561.         private final double kh;
  562.         private final double kl;

  563.         private final double ax1;
  564.         private final double ay1;
  565.         private final double as1;
  566.         private final double ac2;
  567.         private final double axy3;
  568.         private final double as3;
  569.         private final double ac4;
  570.         private final double as5;
  571.         private final double ac6;

  572.         private final double ex1;
  573.         private final double exx2;
  574.         private final double exy2;
  575.         private final double ex3;
  576.         private final double ex4;

  577.         private final double ey1;
  578.         private final double eyx2;
  579.         private final double eyy2;
  580.         private final double ey3;
  581.         private final double ey4;

  582.         private final double rx1;
  583.         private final double ry1;
  584.         private final double r2;
  585.         private final double r3;
  586.         private final double rl;

  587.         private final double iy1;
  588.         private final double ix1;
  589.         private final double i2;
  590.         private final double i3;
  591.         private final double ih;

  592.         private final double lx1;
  593.         private final double ly1;
  594.         private final double l2;
  595.         private final double l3;
  596.         private final double ll;

  597.         // CHECKSTYLE: resume JavadocVariable check

  598.         /** Create a model for specified mean orbit.
  599.          * @param mean mean orbit
  600.          * @param mass constant mass
  601.          * @param referenceRadius reference radius of the central body attraction model (m)
  602.          * @param mu central attraction coefficient (m³/s²)
  603.          * @param ck0 un-normalized zonal coefficients
  604.          */
  605.         EHModel(final CircularOrbit mean, final double mass,
  606.                 final double referenceRadius, final double mu, final double[] ck0) {

  607.             this.mean            = mean;
  608.             this.mass            = mass;

  609.             // preliminary processing
  610.             double q = referenceRadius / mean.getA();
  611.             double ql = q * q;
  612.             final double g2 = ck0[2] * ql;
  613.             ql *= q;
  614.             final double g3 = ck0[3] * ql;
  615.             ql *= q;
  616.             final double g4 = ck0[4] * ql;
  617.             ql *= q;
  618.             final double g5 = ck0[5] * ql;
  619.             ql *= q;
  620.             final double g6 = ck0[6] * ql;

  621.             final SinCos sc    = FastMath.sinCos(mean.getI());
  622.             final double cosI1 = sc.cos();
  623.             final double sinI1 = sc.sin();
  624.             final double sinI2 = sinI1 * sinI1;
  625.             final double sinI4 = sinI2 * sinI2;
  626.             final double sinI6 = sinI2 * sinI4;

  627.             if (sinI2 < 1.0e-10) {
  628.                 throw new OrekitException(OrekitMessages.ALMOST_EQUATORIAL_ORBIT,
  629.                                           FastMath.toDegrees(mean.getI()));
  630.             }

  631.             if (FastMath.abs(sinI2 - 4.0 / 5.0) < 1.0e-3) {
  632.                 throw new OrekitException(OrekitMessages.ALMOST_CRITICALLY_INCLINED_ORBIT,
  633.                                           FastMath.toDegrees(mean.getI()));
  634.             }

  635.             if (mean.getE() > 0.1) {
  636.                 // if 0.005 < e < 0.1 no error is triggered, but accuracy is poor
  637.                 throw new OrekitException(OrekitMessages.TOO_LARGE_ECCENTRICITY_FOR_PROPAGATION_MODEL,
  638.                                           mean.getE());
  639.             }

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

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

  644.             q = 3.0 / (32.0 * rdpom);
  645.             eps1 = q * g4 * sinI2 * (30.0 - 35.0 * sinI2) -
  646.                     175.0 * q * g6 * sinI2 * (1.0 - 3.0 * sinI2 + 2.0625 * sinI4);
  647.             q = 3.0 * sinI1 / (8.0 * rdpom);
  648.             eps2 = q * g3 * (4.0 - 5.0 * sinI2) - q * g5 * (10.0 - 35.0 * sinI2 + 26.25 * sinI4);

  649.             xim = mean.getI();
  650.             ommD = cosI1 * (1.50    * g2 - 2.25 * g2 * g2 * (2.5 - 19.0 / 6.0 * sinI2) +
  651.                             0.9375  * g4 * (7.0 * sinI2 - 4.0) +
  652.                             3.28125 * g6 * (2.0 - 9.0 * sinI2 + 8.25 * sinI4));

  653.             rdl = 1.0 - 1.50 * g2 * (3.0 - 4.0 * sinI2);
  654.             aMD = rdl +
  655.                     2.25 * g2 * g2 * (9.0 - 263.0 / 12.0 * sinI2 + 341.0 / 24.0 * sinI4) +
  656.                     15.0 / 16.0 * g4 * (8.0 - 31.0 * sinI2 + 24.5 * sinI4) +
  657.                     105.0 / 32.0 * g6 * (-10.0 / 3.0 + 25.0 * sinI2 - 48.75 * sinI4 + 27.5 * sinI6);

  658.             final double qq = -1.5 * g2 / rdl;
  659.             final double qA   = 0.75 * g2 * g2 * sinI2;
  660.             final double qB   = 0.25 * g4 * sinI2;
  661.             final double qC   = 105.0 / 16.0 * g6 * sinI2;
  662.             final double qD   = -0.75 * g3 * sinI1;
  663.             final double qE   = 3.75 * g5 * sinI1;
  664.             kh = 0.375 / rdpom;
  665.             kl = kh / sinI1;

  666.             ax1 = qq * (2.0 - 3.5 * sinI2);
  667.             ay1 = qq * (2.0 - 2.5 * sinI2);
  668.             as1 = qD * (4.0 - 5.0 * sinI2) +
  669.                   qE * (2.625 * sinI4 - 3.5 * sinI2 + 1.0);
  670.             ac2 = qq * sinI2 +
  671.                   qA * 7.0 * (2.0 - 3.0 * sinI2) +
  672.                   qB * (15.0 - 17.5 * sinI2) +
  673.                   qC * (3.0 * sinI2 - 1.0 - 33.0 / 16.0 * sinI4);
  674.             axy3 = qq * 3.5 * sinI2;
  675.             as3 = qD * 5.0 / 3.0 * sinI2 +
  676.                   qE * 7.0 / 6.0 * sinI2 * (1.0 - 1.125 * sinI2);
  677.             ac4 = qA * sinI2 +
  678.                   qB * 4.375 * sinI2 +
  679.                   qC * 0.75 * (1.1 * sinI4 - sinI2);

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

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

  682.             ex1 = qq * (1.0 - 1.25 * sinI2);
  683.             exx2 = qq * 0.5 * (3.0 - 5.0 * sinI2);
  684.             exy2 = qq * (2.0 - 1.5 * sinI2);
  685.             ex3 = qq * 7.0 / 12.0 * sinI2;
  686.             ex4 = qq * 17.0 / 8.0 * sinI2;

  687.             ey1 = qq * (1.0 - 1.75 * sinI2);
  688.             eyx2 = qq * (1.0 - 3.0 * sinI2);
  689.             eyy2 = qq * (2.0 * sinI2 - 1.5);
  690.             ey3 = qq * 7.0 / 12.0 * sinI2;
  691.             ey4 = qq * 17.0 / 8.0 * sinI2;

  692.             q  = -qq * cosI1;
  693.             rx1 =  3.5 * q;
  694.             ry1 = -2.5 * q;
  695.             r2 = -0.5 * q;
  696.             r3 =  7.0 / 6.0 * q;
  697.             rl = g3 * cosI1 * (4.0 - 15.0 * sinI2) -
  698.                  2.5 * g5 * cosI1 * (4.0 - 42.0 * sinI2 + 52.5 * sinI4);

  699.             q = 0.5 * qq * sinI1 * cosI1;
  700.             iy1 =  q;
  701.             ix1 = -q;
  702.             i2 =  q;
  703.             i3 =  q * 7.0 / 3.0;
  704.             ih = -g3 * cosI1 * (4.0 - 5.0 * sinI2) +
  705.                  2.5 * g5 * cosI1 * (4.0 - 14.0 * sinI2 + 10.5 * sinI4);

  706.             lx1 = qq * (7.0 - 77.0 / 8.0 * sinI2);
  707.             ly1 = qq * (55.0 / 8.0 * sinI2 - 7.50);
  708.             l2 = qq * (1.25 * sinI2 - 0.5);
  709.             l3 = qq * (77.0 / 24.0 * sinI2 - 7.0 / 6.0);
  710.             ll = g3 * (53.0 * sinI2 - 4.0 - 57.5 * sinI4) +
  711.                  2.5 * g5 * (4.0 - 96.0 * sinI2 + 269.5 * sinI4 - 183.75 * sinI6);

  712.         }

  713.         /** Extrapolate an orbit up to a specific target date.
  714.          * @param date target date for the orbit
  715.          * @return propagated parameters
  716.          */
  717.         public UnivariateDerivative2[] propagateParameters(final AbsoluteDate date) {

  718.             // Keplerian evolution
  719.             final UnivariateDerivative2 dt = new UnivariateDerivative2(date.durationFrom(mean.getDate()), 1.0, 0.0);
  720.             final UnivariateDerivative2 xnot = dt.multiply(xnotDot);

  721.             // secular effects

  722.             // eccentricity
  723.             final UnivariateDerivative2 x   = xnot.multiply(rdpom + rdpomp);
  724.             final UnivariateDerivative2 cx  = x.cos();
  725.             final UnivariateDerivative2 sx  = x.sin();
  726.             final UnivariateDerivative2 exm = cx.multiply(mean.getCircularEx()).
  727.                                               add(sx.multiply(eps2 - (1.0 - eps1) * mean.getCircularEy()));
  728.             final UnivariateDerivative2 eym = sx.multiply((1.0 + eps1) * mean.getCircularEx()).
  729.                                               add(cx.multiply(mean.getCircularEy() - eps2)).
  730.                                               add(eps2);

  731.             // no secular effect on inclination

  732.             // right ascension of ascending node
  733.             final UnivariateDerivative2 omm = new UnivariateDerivative2(MathUtils.normalizeAngle(mean.getRightAscensionOfAscendingNode() + ommD * xnot.getValue(),
  734.                                                                                                FastMath.PI),
  735.                                                                       ommD * xnotDot,
  736.                                                                       0.0);

  737.             // latitude argument
  738.             final UnivariateDerivative2 xlm = new UnivariateDerivative2(MathUtils.normalizeAngle(mean.getAlphaM() + aMD * xnot.getValue(),
  739.                                                                                                  FastMath.PI),
  740.                                                                         aMD * xnotDot,
  741.                                                                         0.0);

  742.             // periodical terms
  743.             final UnivariateDerivative2 cl1 = xlm.cos();
  744.             final UnivariateDerivative2 sl1 = xlm.sin();
  745.             final UnivariateDerivative2 cl2 = cl1.multiply(cl1).subtract(sl1.multiply(sl1));
  746.             final UnivariateDerivative2 sl2 = cl1.multiply(sl1).add(sl1.multiply(cl1));
  747.             final UnivariateDerivative2 cl3 = cl2.multiply(cl1).subtract(sl2.multiply(sl1));
  748.             final UnivariateDerivative2 sl3 = cl2.multiply(sl1).add(sl2.multiply(cl1));
  749.             final UnivariateDerivative2 cl4 = cl3.multiply(cl1).subtract(sl3.multiply(sl1));
  750.             final UnivariateDerivative2 sl4 = cl3.multiply(sl1).add(sl3.multiply(cl1));
  751.             final UnivariateDerivative2 cl5 = cl4.multiply(cl1).subtract(sl4.multiply(sl1));
  752.             final UnivariateDerivative2 sl5 = cl4.multiply(sl1).add(sl4.multiply(cl1));
  753.             final UnivariateDerivative2 cl6 = cl5.multiply(cl1).subtract(sl5.multiply(sl1));

  754.             final UnivariateDerivative2 qh  = eym.subtract(eps2).multiply(kh);
  755.             final UnivariateDerivative2 ql  = exm.multiply(kl);

  756.             final UnivariateDerivative2 exmCl1 = exm.multiply(cl1);
  757.             final UnivariateDerivative2 exmSl1 = exm.multiply(sl1);
  758.             final UnivariateDerivative2 eymCl1 = eym.multiply(cl1);
  759.             final UnivariateDerivative2 eymSl1 = eym.multiply(sl1);
  760.             final UnivariateDerivative2 exmCl2 = exm.multiply(cl2);
  761.             final UnivariateDerivative2 exmSl2 = exm.multiply(sl2);
  762.             final UnivariateDerivative2 eymCl2 = eym.multiply(cl2);
  763.             final UnivariateDerivative2 eymSl2 = eym.multiply(sl2);
  764.             final UnivariateDerivative2 exmCl3 = exm.multiply(cl3);
  765.             final UnivariateDerivative2 exmSl3 = exm.multiply(sl3);
  766.             final UnivariateDerivative2 eymCl3 = eym.multiply(cl3);
  767.             final UnivariateDerivative2 eymSl3 = eym.multiply(sl3);
  768.             final UnivariateDerivative2 exmCl4 = exm.multiply(cl4);
  769.             final UnivariateDerivative2 exmSl4 = exm.multiply(sl4);
  770.             final UnivariateDerivative2 eymCl4 = eym.multiply(cl4);
  771.             final UnivariateDerivative2 eymSl4 = eym.multiply(sl4);

  772.             // semi major axis
  773.             final UnivariateDerivative2 rda = exmCl1.multiply(ax1).
  774.                                               add(eymSl1.multiply(ay1)).
  775.                                               add(sl1.multiply(as1)).
  776.                                               add(cl2.multiply(ac2)).
  777.                                               add(exmCl3.add(eymSl3).multiply(axy3)).
  778.                                               add(sl3.multiply(as3)).
  779.                                               add(cl4.multiply(ac4)).
  780.                                               add(sl5.multiply(as5)).
  781.                                               add(cl6.multiply(ac6));

  782.             // eccentricity
  783.             final UnivariateDerivative2 rdex = cl1.multiply(ex1).
  784.                                                add(exmCl2.multiply(exx2)).
  785.                                                add(eymSl2.multiply(exy2)).
  786.                                                add(cl3.multiply(ex3)).
  787.                                                add(exmCl4.add(eymSl4).multiply(ex4));
  788.             final UnivariateDerivative2 rdey = sl1.multiply(ey1).
  789.                                                add(exmSl2.multiply(eyx2)).
  790.                                                add(eymCl2.multiply(eyy2)).
  791.                                                add(sl3.multiply(ey3)).
  792.                                                add(exmSl4.subtract(eymCl4).multiply(ey4));

  793.             // ascending node
  794.             final UnivariateDerivative2 rdom = exmSl1.multiply(rx1).
  795.                                                add(eymCl1.multiply(ry1)).
  796.                                                add(sl2.multiply(r2)).
  797.                                                add(eymCl3.subtract(exmSl3).multiply(r3)).
  798.                                                add(ql.multiply(rl));

  799.             // inclination
  800.             final UnivariateDerivative2 rdxi = eymSl1.multiply(iy1).
  801.                                                add(exmCl1.multiply(ix1)).
  802.                                                add(cl2.multiply(i2)).
  803.                                                add(exmCl3.add(eymSl3).multiply(i3)).
  804.                                                add(qh.multiply(ih));

  805.             // latitude argument
  806.             final UnivariateDerivative2 rdxl = exmSl1.multiply(lx1).
  807.                                                add(eymCl1.multiply(ly1)).
  808.                                                add(sl2.multiply(l2)).
  809.                                                add(exmSl3.subtract(eymCl3).multiply(l3)).
  810.                                                add(ql.multiply(ll));

  811.             // osculating parameters
  812.             return new UnivariateDerivative2[] {
  813.                 rda.add(1.0).multiply(mean.getA()),
  814.                 rdex.add(exm),
  815.                 rdey.add(eym),
  816.                 rdxi.add(xim),
  817.                 rdom.add(omm),
  818.                 rdxl.add(xlm)
  819.             };

  820.         }

  821.     }

  822.     /** Convert circular parameters <em>with derivatives</em> to Cartesian coordinates.
  823.      * @param date date of the orbital parameters
  824.      * @param parameters circular parameters (a, ex, ey, i, raan, alphaM)
  825.      * @return Cartesian coordinates consistent with values and derivatives
  826.      */
  827.     private TimeStampedPVCoordinates toCartesian(final AbsoluteDate date, final UnivariateDerivative2[] parameters) {

  828.         // evaluate coordinates in the orbit canonical reference frame
  829.         final UnivariateDerivative2 cosOmega = parameters[4].cos();
  830.         final UnivariateDerivative2 sinOmega = parameters[4].sin();
  831.         final UnivariateDerivative2 cosI     = parameters[3].cos();
  832.         final UnivariateDerivative2 sinI     = parameters[3].sin();
  833.         final UnivariateDerivative2 alphaE   = meanToEccentric(parameters[5], parameters[1], parameters[2]);
  834.         final UnivariateDerivative2 cosAE    = alphaE.cos();
  835.         final UnivariateDerivative2 sinAE    = alphaE.sin();
  836.         final UnivariateDerivative2 ex2      = parameters[1].multiply(parameters[1]);
  837.         final UnivariateDerivative2 ey2      = parameters[2].multiply(parameters[2]);
  838.         final UnivariateDerivative2 exy      = parameters[1].multiply(parameters[2]);
  839.         final UnivariateDerivative2 q        = ex2.add(ey2).subtract(1).negate().sqrt();
  840.         final UnivariateDerivative2 beta     = q.add(1).reciprocal();
  841.         final UnivariateDerivative2 bx2      = beta.multiply(ex2);
  842.         final UnivariateDerivative2 by2      = beta.multiply(ey2);
  843.         final UnivariateDerivative2 bxy      = beta.multiply(exy);
  844.         final UnivariateDerivative2 u        = bxy.multiply(sinAE).subtract(parameters[1].add(by2.subtract(1).multiply(cosAE)));
  845.         final UnivariateDerivative2 v        = bxy.multiply(cosAE).subtract(parameters[2].add(bx2.subtract(1).multiply(sinAE)));
  846.         final UnivariateDerivative2 x        = parameters[0].multiply(u);
  847.         final UnivariateDerivative2 y        = parameters[0].multiply(v);

  848.         // canonical orbit reference frame
  849.         final FieldVector3D<UnivariateDerivative2> p =
  850.                 new FieldVector3D<>(x.multiply(cosOmega).subtract(y.multiply(cosI.multiply(sinOmega))),
  851.                                     x.multiply(sinOmega).add(y.multiply(cosI.multiply(cosOmega))),
  852.                                     y.multiply(sinI));

  853.         // dispatch derivatives
  854.         final Vector3D p0 = new Vector3D(p.getX().getValue(),
  855.                                          p.getY().getValue(),
  856.                                          p.getZ().getValue());
  857.         final Vector3D p1 = new Vector3D(p.getX().getFirstDerivative(),
  858.                                          p.getY().getFirstDerivative(),
  859.                                          p.getZ().getFirstDerivative());
  860.         final Vector3D p2 = new Vector3D(p.getX().getSecondDerivative(),
  861.                                          p.getY().getSecondDerivative(),
  862.                                          p.getZ().getSecondDerivative());
  863.         return new TimeStampedPVCoordinates(date, p0, p1, p2);

  864.     }

  865.     /** Computes the eccentric latitude argument from the mean latitude argument.
  866.      * @param alphaM = M + Ω mean latitude argument (rad)
  867.      * @param ex e cos(Ω), first component of circular eccentricity vector
  868.      * @param ey e sin(Ω), second component of circular eccentricity vector
  869.      * @return the eccentric latitude argument.
  870.      */
  871.     private UnivariateDerivative2 meanToEccentric(final UnivariateDerivative2 alphaM,
  872.                                                   final UnivariateDerivative2 ex,
  873.                                                   final UnivariateDerivative2 ey) {
  874.         // Generalization of Kepler equation to circular parameters
  875.         // with alphaE = PA + E and
  876.         //      alphaM = PA + M = alphaE - ex.sin(alphaE) + ey.cos(alphaE)
  877.         UnivariateDerivative2 alphaE        = alphaM;
  878.         UnivariateDerivative2 shift         = alphaM.getField().getZero();
  879.         UnivariateDerivative2 alphaEMalphaM = alphaM.getField().getZero();
  880.         UnivariateDerivative2 cosAlphaE     = alphaE.cos();
  881.         UnivariateDerivative2 sinAlphaE     = alphaE.sin();
  882.         int                 iter          = 0;
  883.         do {
  884.             final UnivariateDerivative2 f2 = ex.multiply(sinAlphaE).subtract(ey.multiply(cosAlphaE));
  885.             final UnivariateDerivative2 f1 = alphaM.getField().getOne().subtract(ex.multiply(cosAlphaE)).subtract(ey.multiply(sinAlphaE));
  886.             final UnivariateDerivative2 f0 = alphaEMalphaM.subtract(f2);

  887.             final UnivariateDerivative2 f12 = f1.multiply(2);
  888.             shift = f0.multiply(f12).divide(f1.multiply(f12).subtract(f0.multiply(f2)));

  889.             alphaEMalphaM  = alphaEMalphaM.subtract(shift);
  890.             alphaE         = alphaM.add(alphaEMalphaM);
  891.             cosAlphaE      = alphaE.cos();
  892.             sinAlphaE      = alphaE.sin();

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

  894.         return alphaE;

  895.     }

  896.     /** {@inheritDoc} */
  897.     protected double getMass(final AbsoluteDate date) {
  898.         return models.get(date).mass;
  899.     }

  900. }