HarmonicParametricAcceleration.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.forces;

  18. import org.hipparchus.RealFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  20. import org.hipparchus.util.FastMath;
  21. import org.hipparchus.util.MathUtils;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.errors.OrekitInternalError;
  25. import org.orekit.forces.empirical.HarmonicAccelerationModel;
  26. import org.orekit.propagation.FieldSpacecraftState;
  27. import org.orekit.propagation.SpacecraftState;
  28. import org.orekit.time.AbsoluteDate;
  29. import org.orekit.utils.ParameterDriver;

  30. /** This class implements a {@link AbstractParametricAcceleration parametric acceleration}
  31.  * with harmonic signed amplitude.
  32.  * @since 9.0
  33.  * @author Luc Maisonobe
  34.  * @deprecated as of 10.3, replaced by {@link HarmonicAccelerationModel}
  35.  */
  36. @Deprecated
  37. public class HarmonicParametricAcceleration extends AbstractParametricAcceleration {

  38.     /** Amplitude scaling factor.
  39.      * <p>
  40.      * 2⁻²⁰ is the order of magnitude of third body perturbing acceleration.
  41.      * </p>
  42.      * <p>
  43.      * We use a power of 2 to avoid numeric noise introduction
  44.      * in the multiplications/divisions sequences.
  45.      * </p>
  46.      */
  47.     private static final double AMPLITUDE_SCALE = FastMath.scalb(1.0, -20);

  48.     /** Phase scaling factor.
  49.      * <p>
  50.      * 2⁻²³ is the order of magnitude of an angle corresponding to one meter along
  51.      * track for a Low Earth Orbiting satellite.
  52.      * </p>
  53.      * <p>
  54.      * We use a power of 2 to avoid numeric noise introduction
  55.      * in the multiplications/divisions sequences.
  56.      * </p>
  57.      */
  58.     private static final double PHASE_SCALE = FastMath.scalb(1.0, -23);

  59.     /** Drivers for the parameters. */
  60.     private final ParameterDriver[] drivers;

  61.     /** Reference date for computing phase. */
  62.     private AbsoluteDate referenceDate;

  63.     /** Angular frequency ω = 2kπ/T. */
  64.     private final double omega;

  65.     /** Simple constructor.
  66.      * <p>
  67.      * The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
  68.      * γ is parameter {@code 0} and represents the full amplitude, t is current
  69.      * date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
  70.      * harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
  71.      * The value t-t₀ is in seconds.
  72.      * </p>
  73.      * <p>
  74.      * The fundamental period {@code T} is often set to the Keplerian period of the
  75.      * orbit and the harmonic multiplier {@code k} is often set to 1 or 2. The model
  76.      * has two parameters, one for the full amplitude and one for the phase at reference
  77.      * date.
  78.      * </p>
  79.      * <p>
  80.      * The two parameters for this model are the full amplitude (parameter 0) and the
  81.      * phase at reference date (parameter 1). Their reference values (used also as the
  82.      * initial values) are both set to 0. User can change them before starting the
  83.      * propagation (or orbit determination) by calling {@link #getParametersDrivers()}
  84.      * and {@link ParameterDriver#setValue(double)}.
  85.      * </p>
  86.      * @param direction acceleration direction in defining frame
  87.      * @param isInertial if true, direction is defined in the same inertial
  88.      * frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
  89.      * otherwise direction is defined in spacecraft frame (i.e. using the
  90.      * propagation {@link
  91.      * org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
  92.      * attitude law})
  93.      * @param prefix prefix to use for parameter drivers
  94.      * @param referenceDate reference date for computing phase, if null
  95.      * the reference date will be automatically set at propagation start
  96.      * @param fundamentalPeriod fundamental period (typically set to initial orbit
  97.      * {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
  98.      * @param harmonicMultiplier multiplier to compute harmonic period from
  99.      * fundamental period)
  100.      */
  101.     public HarmonicParametricAcceleration(final Vector3D direction, final boolean isInertial,
  102.                                           final String prefix, final AbsoluteDate referenceDate,
  103.                                           final double fundamentalPeriod, final int harmonicMultiplier) {
  104.         this(direction, isInertial, null, prefix, referenceDate,
  105.              fundamentalPeriod, harmonicMultiplier);
  106.     }

  107.     /** Simple constructor.
  108.      * <p>
  109.      * The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
  110.      * γ is parameter {@code 0} and represents the full amplitude, t is current
  111.      * date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
  112.      * harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
  113.      * The value t-t₀ is in seconds.
  114.      * </p>
  115.      * <p>
  116.      * The fundamental period {@code T} is often set to the Keplerian period of the
  117.      * orbit and the harmonic multiplier {@code k} is often set to 1 or 2. The model
  118.      * has two parameters, one for the full amplitude and one for the phase at reference
  119.      * date.
  120.      * </p>
  121.      * <p>
  122.      * The two parameters for this model are the full amplitude (parameter 0) and the
  123.      * phase at reference date (parameter 1). Their reference values (used also as the
  124.      * initial values) are both set to 0. User can change them before starting the
  125.      * propagation (or orbit determination) by calling {@link #getParametersDrivers()}
  126.      * and {@link ParameterDriver#setValue(double)}.
  127.      * </p>
  128.      * @param direction acceleration direction in overridden spacecraft frame
  129.      * @param attitudeOverride provider for attitude used to compute acceleration
  130.      * direction
  131.      * @param prefix prefix to use for parameter drivers
  132.      * @param referenceDate reference date for computing phase, if null
  133.      * the reference date will be automatically set at propagation start
  134.      * @param fundamentalPeriod fundamental period (typically set to initial orbit
  135.      * {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
  136.      * @param harmonicMultiplier multiplier to compute harmonic period from
  137.      * fundamental period)
  138.      */
  139.     public HarmonicParametricAcceleration(final Vector3D direction, final AttitudeProvider attitudeOverride,
  140.                                           final String prefix, final AbsoluteDate referenceDate,
  141.                                           final double fundamentalPeriod, final int harmonicMultiplier) {
  142.         this(direction, false, attitudeOverride, prefix, referenceDate,
  143.              fundamentalPeriod, harmonicMultiplier);
  144.     }

  145.     /** Simple constructor.
  146.      * @param direction acceleration direction in overridden spacecraft frame
  147.      * @param isInertial if true, direction is defined in the same inertial
  148.      * frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
  149.      * otherwise direction is defined in spacecraft frame (i.e. using the
  150.      * propagation {@link
  151.      * org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
  152.      * attitude law})
  153.      * @param attitudeOverride provider for attitude used to compute acceleration
  154.      * direction
  155.      * @param prefix prefix to use for parameter drivers
  156.      * @param referenceDate reference date for computing polynomials, if null
  157.      * the reference date will be automatically set at propagation start
  158.      * @param fundamentalPeriod fundamental period (typically set to initial orbit
  159.      * {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
  160.      * @param harmonicMultiplier multiplier to compute harmonic period from
  161.      * fundamental period)
  162.      */
  163.     private HarmonicParametricAcceleration(final Vector3D direction, final boolean isInertial,
  164.                                            final AttitudeProvider attitudeOverride,
  165.                                            final String prefix, final AbsoluteDate referenceDate,
  166.                                            final double fundamentalPeriod, final int harmonicMultiplier) {
  167.         super(direction, isInertial, attitudeOverride);
  168.         this.referenceDate = referenceDate;
  169.         this.omega         = harmonicMultiplier * MathUtils.TWO_PI / fundamentalPeriod;
  170.         try {
  171.             drivers = new ParameterDriver[] {
  172.                 new ParameterDriver(prefix + " γ",
  173.                                     0.0, AMPLITUDE_SCALE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY),
  174.                 new ParameterDriver(prefix + " φ",
  175.                                     0.0, PHASE_SCALE, -MathUtils.TWO_PI, MathUtils.TWO_PI),
  176.             };
  177.         } catch (OrekitException oe) {
  178.             // this should never happen as scales are hard-coded
  179.             throw new OrekitInternalError(oe);
  180.         }
  181.     }

  182.     /** {@inheritDoc} */
  183.     @Override
  184.     public boolean dependsOnPositionOnly() {
  185.         return isInertial();
  186.     }

  187.     /** {@inheritDoc} */
  188.     @Override
  189.     public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  190.         if (referenceDate == null) {
  191.             referenceDate = initialState.getDate();
  192.         }
  193.     }

  194.     /** {@inheritDoc}.
  195.      * The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
  196.      * γ is parameter {@code 0} and represents the full amplitude, t is current
  197.      * date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
  198.      * harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
  199.      * The value t-t₀ is in seconds.
  200.      */
  201.     @Override
  202.     protected double signedAmplitude(final SpacecraftState state, final double[] parameters) {
  203.         final double dt = state.getDate().durationFrom(referenceDate);
  204.         return parameters[0] * FastMath.sin(dt * omega + parameters[1]);
  205.     }

  206.     /** {@inheritDoc}
  207.      * The signed amplitude of the acceleration is γ sin[2kπ(t-t₀)/T + φ], where
  208.      * γ is parameter {@code 0} and represents the full amplitude, t is current
  209.      * date, t₀ is reference date, {@code T} is fundamental period, {@code k} is
  210.      * harmonic multiplier, and φ is parameter {@code 1} and represents phase at t₀.
  211.      * The value t-t₀ is in seconds.
  212.      */
  213.     @Override
  214.     protected <T extends RealFieldElement<T>> T signedAmplitude(final FieldSpacecraftState<T> state, final T[] parameters) {
  215.         final T dt = state.getDate().durationFrom(referenceDate);
  216.         return parameters[0].multiply(dt.multiply(omega).add(parameters[1]).sin());
  217.     }

  218.     /** {@inheritDoc} */
  219.     @Override
  220.     public ParameterDriver[] getParametersDrivers() {
  221.         return drivers.clone();
  222.     }

  223. }