EcksteinHechlerPropagator.java

  1. /* Copyright 2002-2020 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.util.FastMath;
  23. import org.hipparchus.util.MathUtils;
  24. import org.hipparchus.util.SinCos;
  25. import org.orekit.annotation.DefaultDataContext;
  26. import org.orekit.attitudes.AttitudeProvider;
  27. import org.orekit.data.DataContext;
  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.PropagationType;
  38. import org.orekit.propagation.Propagator;
  39. import org.orekit.propagation.SpacecraftState;
  40. import org.orekit.time.AbsoluteDate;
  41. import org.orekit.utils.TimeSpanMap;
  42. import org.orekit.utils.TimeStampedPVCoordinates;

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

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

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

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

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

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

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

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

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

  171.     /** Build a propagator from orbit, mass and potential provider.
  172.      * <p>Attitude law is set to an unspecified non-null arbitrary value.</p>
  173.      *
  174.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  175.      *
  176.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  177.      *
  178.      * @param initialOrbit initial orbit
  179.      * @param mass spacecraft mass
  180.      * @param provider for un-normalized zonal coefficients
  181.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double,
  182.      * UnnormalizedSphericalHarmonicsProvider)
  183.      */
  184.     @DefaultDataContext
  185.     public EcksteinHechlerPropagator(final Orbit initialOrbit, final double mass,
  186.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  187.         this(initialOrbit, Propagator.getDefaultLaw(DataContext.getDefault().getFrames()),
  188.                 mass, provider, provider.onDate(initialOrbit.getDate()));
  189.     }

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

  226.     /** Build a propagator from orbit, attitude provider and potential provider.
  227.      * <p>Mass is set to an unspecified non-null arbitrary value.</p>
  228.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  229.      * @param initialOrbit initial orbit
  230.      * @param attitudeProv attitude provider
  231.      * @param provider for un-normalized zonal coefficients
  232.      */
  233.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  234.                                      final AttitudeProvider attitudeProv,
  235.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  236.         this(initialOrbit, attitudeProv, DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()));
  237.     }

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

  269.     /** Build a propagator from orbit, attitude provider, mass and potential provider.
  270.      * <p>Using this constructor, an initial osculating orbit is considered.</p>
  271.      * @param initialOrbit initial orbit
  272.      * @param attitudeProv attitude provider
  273.      * @param mass spacecraft mass
  274.      * @param provider for un-normalized zonal coefficients
  275.      * @see #EcksteinHechlerPropagator(Orbit, AttitudeProvider, double,
  276.      *                                 UnnormalizedSphericalHarmonicsProvider, PropagationType)
  277.      */
  278.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  279.                                      final AttitudeProvider attitudeProv,
  280.                                      final double mass,
  281.                                      final UnnormalizedSphericalHarmonicsProvider provider) {
  282.         this(initialOrbit, attitudeProv, mass, provider, provider.onDate(initialOrbit.getDate()));
  283.     }

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


  319.     /** Build a propagator from orbit and potential provider.
  320.      * <p>Mass and attitude provider are set to unspecified non-null arbitrary values.</p>
  321.      *
  322.      * <p>This constructor uses the {@link DataContext#getDefault() default data context}.
  323.      *
  324.      * <p>Using this constructor, it is possible to define the initial orbit as
  325.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  326.      *
  327.      * @param initialOrbit initial orbit
  328.      * @param provider for un-normalized zonal coefficients
  329.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  330.      * @since 10.2
  331.      */
  332.     @DefaultDataContext
  333.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  334.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  335.                                      final PropagationType initialType) {
  336.         this(initialOrbit, Propagator.getDefaultLaw(DataContext.getDefault().getFrames()),
  337.              DEFAULT_MASS, provider, provider.onDate(initialOrbit.getDate()), initialType);
  338.     }

  339.     /** Build a propagator from orbit, attitude provider, mass and potential provider.
  340.      * <p>Using this constructor, it is possible to define the initial orbit as
  341.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  342.      * @param initialOrbit initial orbit
  343.      * @param attitudeProv attitude provider
  344.      * @param mass spacecraft mass
  345.      * @param provider for un-normalized zonal coefficients
  346.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  347.      * @since 10.2
  348.      */
  349.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  350.                                      final AttitudeProvider attitudeProv,
  351.                                      final double mass,
  352.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  353.                                      final PropagationType initialType) {
  354.         this(initialOrbit, attitudeProv, mass, provider, provider.onDate(initialOrbit.getDate()), initialType);
  355.     }

  356.     /**
  357.      * Private helper constructor.
  358.      * <p>Using this constructor, it is possible to define the initial orbit as
  359.      * a mean Eckstein-Hechler orbit or an osculating one.</p>
  360.      * @param initialOrbit initial orbit
  361.      * @param attitude attitude provider
  362.      * @param mass spacecraft mass
  363.      * @param provider for un-normalized zonal coefficients
  364.      * @param harmonics {@code provider.onDate(initialOrbit.getDate())}
  365.      * @param initialType initial orbit type (mean Eckstein-Hechler orbit or osculating orbit)
  366.      * @since 10.2
  367.      */
  368.     public EcksteinHechlerPropagator(final Orbit initialOrbit,
  369.                                      final AttitudeProvider attitude,
  370.                                      final double mass,
  371.                                      final UnnormalizedSphericalHarmonicsProvider provider,
  372.                                      final UnnormalizedSphericalHarmonics harmonics,
  373.                                      final PropagationType initialType) {
  374.         this(initialOrbit, attitude, mass, provider.getAe(), provider.getMu(),
  375.              harmonics.getUnnormalizedCnm(2, 0),
  376.              harmonics.getUnnormalizedCnm(3, 0),
  377.              harmonics.getUnnormalizedCnm(4, 0),
  378.              harmonics.getUnnormalizedCnm(5, 0),
  379.              harmonics.getUnnormalizedCnm(6, 0),
  380.              initialType);
  381.     }

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

  416.         super(attitudeProv);

  417.         // store model coefficients
  418.         this.referenceRadius = referenceRadius;
  419.         this.mu  = mu;
  420.         this.ck0 = new double[] {
  421.             0.0, 0.0, c20, c30, c40, c50, c60
  422.         };

  423.         // compute mean parameters if needed
  424.         // transform into circular adapted parameters used by the Eckstein-Hechler model
  425.         resetInitialState(new SpacecraftState(initialOrbit,
  426.                                               attitudeProv.getAttitude(initialOrbit,
  427.                                                                        initialOrbit.getDate(),
  428.                                                                        initialOrbit.getFrame()),
  429.                                               mass),
  430.                           initialType);

  431.     }

  432.     /** {@inheritDoc}
  433.      * <p>The new initial state to consider
  434.      * must be defined with an osculating orbit.</p>
  435.      * @see #resetInitialState(SpacecraftState, PropagationType)
  436.      */
  437.     public void resetInitialState(final SpacecraftState state) {
  438.         resetInitialState(state, PropagationType.OSCULATING);
  439.     }

  440.     /** Reset the propagator initial state.
  441.      * @param state new initial state to consider
  442.      * @param stateType mean Eckstein-Hechler orbit or osculating orbit
  443.      * @since 10.2
  444.      */
  445.     public void resetInitialState(final SpacecraftState state, final PropagationType stateType) {
  446.         super.resetInitialState(state);
  447.         final CircularOrbit circular = (CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit());
  448.         this.initialModel = (stateType == PropagationType.MEAN) ?
  449.                              new EHModel(circular, state.getMass(), referenceRadius, mu, ck0) :
  450.                              computeMeanParameters(circular, state.getMass());
  451.         this.models = new TimeSpanMap<EHModel>(initialModel);
  452.     }

  453.     /** {@inheritDoc} */
  454.     protected void resetIntermediateState(final SpacecraftState state, final boolean forward) {
  455.         final EHModel newModel = computeMeanParameters((CircularOrbit) OrbitType.CIRCULAR.convertType(state.getOrbit()),
  456.                                                        state.getMass());
  457.         if (forward) {
  458.             models.addValidAfter(newModel, state.getDate());
  459.         } else {
  460.             models.addValidBefore(newModel, state.getDate());
  461.         }
  462.         stateChanged(state);
  463.     }

  464.     /** Compute mean parameters according to the Eckstein-Hechler analytical model.
  465.      * @param osculating osculating orbit
  466.      * @param mass constant mass
  467.      * @return Eckstein-Hechler mean model
  468.      */
  469.     private EHModel computeMeanParameters(final CircularOrbit osculating, final double mass) {

  470.         // sanity check
  471.         if (osculating.getA() < referenceRadius) {
  472.             throw new OrekitException(OrekitMessages.TRAJECTORY_INSIDE_BRILLOUIN_SPHERE,
  473.                                            osculating.getA());
  474.         }

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

  477.         // threshold for each parameter
  478.         final double epsilon         = 1.0e-13;
  479.         final double thresholdA      = epsilon * (1 + FastMath.abs(current.mean.getA()));
  480.         final double thresholdE      = epsilon * (1 + current.mean.getE());
  481.         final double thresholdAngles = epsilon * FastMath.PI;

  482.         int i = 0;
  483.         while (i++ < 100) {

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

  486.             // adapted parameters residuals
  487.             final double deltaA      = osculating.getA()          - parameters[0].getValue();
  488.             final double deltaEx     = osculating.getCircularEx() - parameters[1].getValue();
  489.             final double deltaEy     = osculating.getCircularEy() - parameters[2].getValue();
  490.             final double deltaI      = osculating.getI()          - parameters[3].getValue();
  491.             final double deltaRAAN   = MathUtils.normalizeAngle(osculating.getRightAscensionOfAscendingNode() -
  492.                                                                 parameters[4].getValue(),
  493.                                                                 0.0);
  494.             final double deltaAlphaM = MathUtils.normalizeAngle(osculating.getAlphaM() - parameters[5].getValue(), 0.0);

  495.             // update mean parameters
  496.             current = new EHModel(new CircularOrbit(current.mean.getA()          + deltaA,
  497.                                                     current.mean.getCircularEx() + deltaEx,
  498.                                                     current.mean.getCircularEy() + deltaEy,
  499.                                                     current.mean.getI()          + deltaI,
  500.                                                     current.mean.getRightAscensionOfAscendingNode() + deltaRAAN,
  501.                                                     current.mean.getAlphaM()     + deltaAlphaM,
  502.                                                     PositionAngle.MEAN,
  503.                                                     current.mean.getFrame(),
  504.                                                     current.mean.getDate(), mu),
  505.                                   mass, referenceRadius, mu, ck0);

  506.             // check convergence
  507.             if ((FastMath.abs(deltaA)      < thresholdA) &&
  508.                 (FastMath.abs(deltaEx)     < thresholdE) &&
  509.                 (FastMath.abs(deltaEy)     < thresholdE) &&
  510.                 (FastMath.abs(deltaI)      < thresholdAngles) &&
  511.                 (FastMath.abs(deltaRAAN)   < thresholdAngles) &&
  512.                 (FastMath.abs(deltaAlphaM) < thresholdAngles)) {
  513.                 return current;
  514.             }

  515.         }

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

  517.     }

  518.     /** {@inheritDoc} */
  519.     public CartesianOrbit propagateOrbit(final AbsoluteDate date) {
  520.         // compute Cartesian parameters, taking derivatives into account
  521.         // to make sure velocity and acceleration are consistent
  522.         final EHModel current = models.get(date);
  523.         return new CartesianOrbit(toCartesian(date, current.propagateParameters(date)),
  524.                                   current.mean.getFrame(), mu);
  525.     }

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

  528.         /** Serializable UID. */
  529.         private static final long serialVersionUID = 20160115L;

  530.         /** Mean orbit. */
  531.         private final CircularOrbit mean;

  532.         /** Constant mass. */
  533.         private final double mass;

  534.         // CHECKSTYLE: stop JavadocVariable check

  535.         // preprocessed values
  536.         private final double xnotDot;
  537.         private final double rdpom;
  538.         private final double rdpomp;
  539.         private final double eps1;
  540.         private final double eps2;
  541.         private final double xim;
  542.         private final double ommD;
  543.         private final double rdl;
  544.         private final double aMD;

  545.         private final double kh;
  546.         private final double kl;

  547.         private final double ax1;
  548.         private final double ay1;
  549.         private final double as1;
  550.         private final double ac2;
  551.         private final double axy3;
  552.         private final double as3;
  553.         private final double ac4;
  554.         private final double as5;
  555.         private final double ac6;

  556.         private final double ex1;
  557.         private final double exx2;
  558.         private final double exy2;
  559.         private final double ex3;
  560.         private final double ex4;

  561.         private final double ey1;
  562.         private final double eyx2;
  563.         private final double eyy2;
  564.         private final double ey3;
  565.         private final double ey4;

  566.         private final double rx1;
  567.         private final double ry1;
  568.         private final double r2;
  569.         private final double r3;
  570.         private final double rl;

  571.         private final double iy1;
  572.         private final double ix1;
  573.         private final double i2;
  574.         private final double i3;
  575.         private final double ih;

  576.         private final double lx1;
  577.         private final double ly1;
  578.         private final double l2;
  579.         private final double l3;
  580.         private final double ll;

  581.         // CHECKSTYLE: resume JavadocVariable check

  582.         /** Create a model for specified mean orbit.
  583.          * @param mean mean orbit
  584.          * @param mass constant mass
  585.          * @param referenceRadius reference radius of the central body attraction model (m)
  586.          * @param mu central attraction coefficient (m³/s²)
  587.          * @param ck0 un-normalized zonal coefficients
  588.          */
  589.         EHModel(final CircularOrbit mean, final double mass,
  590.                 final double referenceRadius, final double mu, final double[] ck0) {

  591.             this.mean            = mean;
  592.             this.mass            = mass;

  593.             // preliminary processing
  594.             double q = referenceRadius / mean.getA();
  595.             double ql = q * q;
  596.             final double g2 = ck0[2] * ql;
  597.             ql *= q;
  598.             final double g3 = ck0[3] * ql;
  599.             ql *= q;
  600.             final double g4 = ck0[4] * ql;
  601.             ql *= q;
  602.             final double g5 = ck0[5] * ql;
  603.             ql *= q;
  604.             final double g6 = ck0[6] * ql;

  605.             final SinCos sc    = FastMath.sinCos(mean.getI());
  606.             final double cosI1 = sc.cos();
  607.             final double sinI1 = sc.sin();
  608.             final double sinI2 = sinI1 * sinI1;
  609.             final double sinI4 = sinI2 * sinI2;
  610.             final double sinI6 = sinI2 * sinI4;

  611.             if (sinI2 < 1.0e-10) {
  612.                 throw new OrekitException(OrekitMessages.ALMOST_EQUATORIAL_ORBIT,
  613.                                           FastMath.toDegrees(mean.getI()));
  614.             }

  615.             if (FastMath.abs(sinI2 - 4.0 / 5.0) < 1.0e-3) {
  616.                 throw new OrekitException(OrekitMessages.ALMOST_CRITICALLY_INCLINED_ORBIT,
  617.                                           FastMath.toDegrees(mean.getI()));
  618.             }

  619.             if (mean.getE() > 0.1) {
  620.                 // if 0.005 < e < 0.1 no error is triggered, but accuracy is poor
  621.                 throw new OrekitException(OrekitMessages.TOO_LARGE_ECCENTRICITY_FOR_PROPAGATION_MODEL,
  622.                                           mean.getE());
  623.             }

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

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

  628.             q = 3.0 / (32.0 * rdpom);
  629.             eps1 = q * g4 * sinI2 * (30.0 - 35.0 * sinI2) -
  630.                     175.0 * q * g6 * sinI2 * (1.0 - 3.0 * sinI2 + 2.0625 * sinI4);
  631.             q = 3.0 * sinI1 / (8.0 * rdpom);
  632.             eps2 = q * g3 * (4.0 - 5.0 * sinI2) - q * g5 * (10.0 - 35.0 * sinI2 + 26.25 * sinI4);

  633.             xim = mean.getI();
  634.             ommD = cosI1 * (1.50    * g2 - 2.25 * g2 * g2 * (2.5 - 19.0 / 6.0 * sinI2) +
  635.                             0.9375  * g4 * (7.0 * sinI2 - 4.0) +
  636.                             3.28125 * g6 * (2.0 - 9.0 * sinI2 + 8.25 * sinI4));

  637.             rdl = 1.0 - 1.50 * g2 * (3.0 - 4.0 * sinI2);
  638.             aMD = rdl +
  639.                     2.25 * g2 * g2 * (9.0 - 263.0 / 12.0 * sinI2 + 341.0 / 24.0 * sinI4) +
  640.                     15.0 / 16.0 * g4 * (8.0 - 31.0 * sinI2 + 24.5 * sinI4) +
  641.                     105.0 / 32.0 * g6 * (-10.0 / 3.0 + 25.0 * sinI2 - 48.75 * sinI4 + 27.5 * sinI6);

  642.             final double qq = -1.5 * g2 / rdl;
  643.             final double qA   = 0.75 * g2 * g2 * sinI2;
  644.             final double qB   = 0.25 * g4 * sinI2;
  645.             final double qC   = 105.0 / 16.0 * g6 * sinI2;
  646.             final double qD   = -0.75 * g3 * sinI1;
  647.             final double qE   = 3.75 * g5 * sinI1;
  648.             kh = 0.375 / rdpom;
  649.             kl = kh / sinI1;

  650.             ax1 = qq * (2.0 - 3.5 * sinI2);
  651.             ay1 = qq * (2.0 - 2.5 * sinI2);
  652.             as1 = qD * (4.0 - 5.0 * sinI2) +
  653.                   qE * (2.625 * sinI4 - 3.5 * sinI2 + 1.0);
  654.             ac2 = qq * sinI2 +
  655.                   qA * 7.0 * (2.0 - 3.0 * sinI2) +
  656.                   qB * (15.0 - 17.5 * sinI2) +
  657.                   qC * (3.0 * sinI2 - 1.0 - 33.0 / 16.0 * sinI4);
  658.             axy3 = qq * 3.5 * sinI2;
  659.             as3 = qD * 5.0 / 3.0 * sinI2 +
  660.                   qE * 7.0 / 6.0 * sinI2 * (1.0 - 1.125 * sinI2);
  661.             ac4 = qA * sinI2 +
  662.                   qB * 4.375 * sinI2 +
  663.                   qC * 0.75 * (1.1 * sinI4 - sinI2);

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

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

  666.             ex1 = qq * (1.0 - 1.25 * sinI2);
  667.             exx2 = qq * 0.5 * (3.0 - 5.0 * sinI2);
  668.             exy2 = qq * (2.0 - 1.5 * sinI2);
  669.             ex3 = qq * 7.0 / 12.0 * sinI2;
  670.             ex4 = qq * 17.0 / 8.0 * sinI2;

  671.             ey1 = qq * (1.0 - 1.75 * sinI2);
  672.             eyx2 = qq * (1.0 - 3.0 * sinI2);
  673.             eyy2 = qq * (2.0 * sinI2 - 1.5);
  674.             ey3 = qq * 7.0 / 12.0 * sinI2;
  675.             ey4 = qq * 17.0 / 8.0 * sinI2;

  676.             q  = -qq * cosI1;
  677.             rx1 =  3.5 * q;
  678.             ry1 = -2.5 * q;
  679.             r2 = -0.5 * q;
  680.             r3 =  7.0 / 6.0 * q;
  681.             rl = g3 * cosI1 * (4.0 - 15.0 * sinI2) -
  682.                  2.5 * g5 * cosI1 * (4.0 - 42.0 * sinI2 + 52.5 * sinI4);

  683.             q = 0.5 * qq * sinI1 * cosI1;
  684.             iy1 =  q;
  685.             ix1 = -q;
  686.             i2 =  q;
  687.             i3 =  q * 7.0 / 3.0;
  688.             ih = -g3 * cosI1 * (4.0 - 5.0 * sinI2) +
  689.                  2.5 * g5 * cosI1 * (4.0 - 14.0 * sinI2 + 10.5 * sinI4);

  690.             lx1 = qq * (7.0 - 77.0 / 8.0 * sinI2);
  691.             ly1 = qq * (55.0 / 8.0 * sinI2 - 7.50);
  692.             l2 = qq * (1.25 * sinI2 - 0.5);
  693.             l3 = qq * (77.0 / 24.0 * sinI2 - 7.0 / 6.0);
  694.             ll = g3 * (53.0 * sinI2 - 4.0 - 57.5 * sinI4) +
  695.                  2.5 * g5 * (4.0 - 96.0 * sinI2 + 269.5 * sinI4 - 183.75 * sinI6);

  696.         }

  697.         /** Extrapolate an orbit up to a specific target date.
  698.          * @param date target date for the orbit
  699.          * @return propagated parameters
  700.          */
  701.         public UnivariateDerivative2[] propagateParameters(final AbsoluteDate date) {

  702.             // Keplerian evolution
  703.             final UnivariateDerivative2 dt = new UnivariateDerivative2(date.durationFrom(mean.getDate()), 1.0, 0.0);
  704.             final UnivariateDerivative2 xnot = dt.multiply(xnotDot);

  705.             // secular effects

  706.             // eccentricity
  707.             final UnivariateDerivative2 x   = xnot.multiply(rdpom + rdpomp);
  708.             final UnivariateDerivative2 cx  = x.cos();
  709.             final UnivariateDerivative2 sx  = x.sin();
  710.             final UnivariateDerivative2 exm = cx.multiply(mean.getCircularEx()).
  711.                                               add(sx.multiply(eps2 - (1.0 - eps1) * mean.getCircularEy()));
  712.             final UnivariateDerivative2 eym = sx.multiply((1.0 + eps1) * mean.getCircularEx()).
  713.                                               add(cx.multiply(mean.getCircularEy() - eps2)).
  714.                                               add(eps2);

  715.             // no secular effect on inclination

  716.             // right ascension of ascending node
  717.             final UnivariateDerivative2 omm = new UnivariateDerivative2(MathUtils.normalizeAngle(mean.getRightAscensionOfAscendingNode() + ommD * xnot.getValue(),
  718.                                                                                                FastMath.PI),
  719.                                                                       ommD * xnotDot,
  720.                                                                       0.0);

  721.             // latitude argument
  722.             final UnivariateDerivative2 xlm = new UnivariateDerivative2(MathUtils.normalizeAngle(mean.getAlphaM() + aMD * xnot.getValue(),
  723.                                                                                                  FastMath.PI),
  724.                                                                         aMD * xnotDot,
  725.                                                                         0.0);

  726.             // periodical terms
  727.             final UnivariateDerivative2 cl1 = xlm.cos();
  728.             final UnivariateDerivative2 sl1 = xlm.sin();
  729.             final UnivariateDerivative2 cl2 = cl1.multiply(cl1).subtract(sl1.multiply(sl1));
  730.             final UnivariateDerivative2 sl2 = cl1.multiply(sl1).add(sl1.multiply(cl1));
  731.             final UnivariateDerivative2 cl3 = cl2.multiply(cl1).subtract(sl2.multiply(sl1));
  732.             final UnivariateDerivative2 sl3 = cl2.multiply(sl1).add(sl2.multiply(cl1));
  733.             final UnivariateDerivative2 cl4 = cl3.multiply(cl1).subtract(sl3.multiply(sl1));
  734.             final UnivariateDerivative2 sl4 = cl3.multiply(sl1).add(sl3.multiply(cl1));
  735.             final UnivariateDerivative2 cl5 = cl4.multiply(cl1).subtract(sl4.multiply(sl1));
  736.             final UnivariateDerivative2 sl5 = cl4.multiply(sl1).add(sl4.multiply(cl1));
  737.             final UnivariateDerivative2 cl6 = cl5.multiply(cl1).subtract(sl5.multiply(sl1));

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

  740.             final UnivariateDerivative2 exmCl1 = exm.multiply(cl1);
  741.             final UnivariateDerivative2 exmSl1 = exm.multiply(sl1);
  742.             final UnivariateDerivative2 eymCl1 = eym.multiply(cl1);
  743.             final UnivariateDerivative2 eymSl1 = eym.multiply(sl1);
  744.             final UnivariateDerivative2 exmCl2 = exm.multiply(cl2);
  745.             final UnivariateDerivative2 exmSl2 = exm.multiply(sl2);
  746.             final UnivariateDerivative2 eymCl2 = eym.multiply(cl2);
  747.             final UnivariateDerivative2 eymSl2 = eym.multiply(sl2);
  748.             final UnivariateDerivative2 exmCl3 = exm.multiply(cl3);
  749.             final UnivariateDerivative2 exmSl3 = exm.multiply(sl3);
  750.             final UnivariateDerivative2 eymCl3 = eym.multiply(cl3);
  751.             final UnivariateDerivative2 eymSl3 = eym.multiply(sl3);
  752.             final UnivariateDerivative2 exmCl4 = exm.multiply(cl4);
  753.             final UnivariateDerivative2 exmSl4 = exm.multiply(sl4);
  754.             final UnivariateDerivative2 eymCl4 = eym.multiply(cl4);
  755.             final UnivariateDerivative2 eymSl4 = eym.multiply(sl4);

  756.             // semi major axis
  757.             final UnivariateDerivative2 rda = exmCl1.multiply(ax1).
  758.                                               add(eymSl1.multiply(ay1)).
  759.                                               add(sl1.multiply(as1)).
  760.                                               add(cl2.multiply(ac2)).
  761.                                               add(exmCl3.add(eymSl3).multiply(axy3)).
  762.                                               add(sl3.multiply(as3)).
  763.                                               add(cl4.multiply(ac4)).
  764.                                               add(sl5.multiply(as5)).
  765.                                               add(cl6.multiply(ac6));

  766.             // eccentricity
  767.             final UnivariateDerivative2 rdex = cl1.multiply(ex1).
  768.                                                add(exmCl2.multiply(exx2)).
  769.                                                add(eymSl2.multiply(exy2)).
  770.                                                add(cl3.multiply(ex3)).
  771.                                                add(exmCl4.add(eymSl4).multiply(ex4));
  772.             final UnivariateDerivative2 rdey = sl1.multiply(ey1).
  773.                                                add(exmSl2.multiply(eyx2)).
  774.                                                add(eymCl2.multiply(eyy2)).
  775.                                                add(sl3.multiply(ey3)).
  776.                                                add(exmSl4.subtract(eymCl4).multiply(ey4));

  777.             // ascending node
  778.             final UnivariateDerivative2 rdom = exmSl1.multiply(rx1).
  779.                                                add(eymCl1.multiply(ry1)).
  780.                                                add(sl2.multiply(r2)).
  781.                                                add(eymCl3.subtract(exmSl3).multiply(r3)).
  782.                                                add(ql.multiply(rl));

  783.             // inclination
  784.             final UnivariateDerivative2 rdxi = eymSl1.multiply(iy1).
  785.                                                add(exmCl1.multiply(ix1)).
  786.                                                add(cl2.multiply(i2)).
  787.                                                add(exmCl3.add(eymSl3).multiply(i3)).
  788.                                                add(qh.multiply(ih));

  789.             // latitude argument
  790.             final UnivariateDerivative2 rdxl = exmSl1.multiply(lx1).
  791.                                                add(eymCl1.multiply(ly1)).
  792.                                                add(sl2.multiply(l2)).
  793.                                                add(exmSl3.subtract(eymCl3).multiply(l3)).
  794.                                                add(ql.multiply(ll));

  795.             // osculating parameters
  796.             return new UnivariateDerivative2[] {
  797.                 rda.add(1.0).multiply(mean.getA()),
  798.                 rdex.add(exm),
  799.                 rdey.add(eym),
  800.                 rdxi.add(xim),
  801.                 rdom.add(omm),
  802.                 rdxl.add(xlm)
  803.             };

  804.         }

  805.     }

  806.     /** Convert circular parameters <em>with derivatives</em> to Cartesian coordinates.
  807.      * @param date date of the orbital parameters
  808.      * @param parameters circular parameters (a, ex, ey, i, raan, alphaM)
  809.      * @return Cartesian coordinates consistent with values and derivatives
  810.      */
  811.     private TimeStampedPVCoordinates toCartesian(final AbsoluteDate date, final UnivariateDerivative2[] parameters) {

  812.         // evaluate coordinates in the orbit canonical reference frame
  813.         final UnivariateDerivative2 cosOmega = parameters[4].cos();
  814.         final UnivariateDerivative2 sinOmega = parameters[4].sin();
  815.         final UnivariateDerivative2 cosI     = parameters[3].cos();
  816.         final UnivariateDerivative2 sinI     = parameters[3].sin();
  817.         final UnivariateDerivative2 alphaE   = meanToEccentric(parameters[5], parameters[1], parameters[2]);
  818.         final UnivariateDerivative2 cosAE    = alphaE.cos();
  819.         final UnivariateDerivative2 sinAE    = alphaE.sin();
  820.         final UnivariateDerivative2 ex2      = parameters[1].multiply(parameters[1]);
  821.         final UnivariateDerivative2 ey2      = parameters[2].multiply(parameters[2]);
  822.         final UnivariateDerivative2 exy      = parameters[1].multiply(parameters[2]);
  823.         final UnivariateDerivative2 q        = ex2.add(ey2).subtract(1).negate().sqrt();
  824.         final UnivariateDerivative2 beta     = q.add(1).reciprocal();
  825.         final UnivariateDerivative2 bx2      = beta.multiply(ex2);
  826.         final UnivariateDerivative2 by2      = beta.multiply(ey2);
  827.         final UnivariateDerivative2 bxy      = beta.multiply(exy);
  828.         final UnivariateDerivative2 u        = bxy.multiply(sinAE).subtract(parameters[1].add(by2.subtract(1).multiply(cosAE)));
  829.         final UnivariateDerivative2 v        = bxy.multiply(cosAE).subtract(parameters[2].add(bx2.subtract(1).multiply(sinAE)));
  830.         final UnivariateDerivative2 x        = parameters[0].multiply(u);
  831.         final UnivariateDerivative2 y        = parameters[0].multiply(v);

  832.         // canonical orbit reference frame
  833.         final FieldVector3D<UnivariateDerivative2> p =
  834.                 new FieldVector3D<>(x.multiply(cosOmega).subtract(y.multiply(cosI.multiply(sinOmega))),
  835.                                     x.multiply(sinOmega).add(y.multiply(cosI.multiply(cosOmega))),
  836.                                     y.multiply(sinI));

  837.         // dispatch derivatives
  838.         final Vector3D p0 = new Vector3D(p.getX().getValue(),
  839.                                          p.getY().getValue(),
  840.                                          p.getZ().getValue());
  841.         final Vector3D p1 = new Vector3D(p.getX().getFirstDerivative(),
  842.                                          p.getY().getFirstDerivative(),
  843.                                          p.getZ().getFirstDerivative());
  844.         final Vector3D p2 = new Vector3D(p.getX().getSecondDerivative(),
  845.                                          p.getY().getSecondDerivative(),
  846.                                          p.getZ().getSecondDerivative());
  847.         return new TimeStampedPVCoordinates(date, p0, p1, p2);

  848.     }

  849.     /** Computes the eccentric latitude argument from the mean latitude argument.
  850.      * @param alphaM = M + Ω mean latitude argument (rad)
  851.      * @param ex e cos(Ω), first component of circular eccentricity vector
  852.      * @param ey e sin(Ω), second component of circular eccentricity vector
  853.      * @return the eccentric latitude argument.
  854.      */
  855.     private UnivariateDerivative2 meanToEccentric(final UnivariateDerivative2 alphaM,
  856.                                                   final UnivariateDerivative2 ex,
  857.                                                   final UnivariateDerivative2 ey) {
  858.         // Generalization of Kepler equation to circular parameters
  859.         // with alphaE = PA + E and
  860.         //      alphaM = PA + M = alphaE - ex.sin(alphaE) + ey.cos(alphaE)
  861.         UnivariateDerivative2 alphaE        = alphaM;
  862.         UnivariateDerivative2 shift         = alphaM.getField().getZero();
  863.         UnivariateDerivative2 alphaEMalphaM = alphaM.getField().getZero();
  864.         UnivariateDerivative2 cosAlphaE     = alphaE.cos();
  865.         UnivariateDerivative2 sinAlphaE     = alphaE.sin();
  866.         int                 iter          = 0;
  867.         do {
  868.             final UnivariateDerivative2 f2 = ex.multiply(sinAlphaE).subtract(ey.multiply(cosAlphaE));
  869.             final UnivariateDerivative2 f1 = alphaM.getField().getOne().subtract(ex.multiply(cosAlphaE)).subtract(ey.multiply(sinAlphaE));
  870.             final UnivariateDerivative2 f0 = alphaEMalphaM.subtract(f2);

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

  873.             alphaEMalphaM  = alphaEMalphaM.subtract(shift);
  874.             alphaE         = alphaM.add(alphaEMalphaM);
  875.             cosAlphaE      = alphaE.cos();
  876.             sinAlphaE      = alphaE.sin();

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

  878.         return alphaE;

  879.     }

  880.     /** {@inheritDoc} */
  881.     protected double getMass(final AbsoluteDate date) {
  882.         return models.get(date).mass;
  883.     }

  884. }