PolynomialParametricAcceleration.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.orekit.attitudes.AttitudeProvider;
  22. import org.orekit.forces.empirical.PolynomialAccelerationModel;
  23. import org.orekit.propagation.FieldSpacecraftState;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.utils.ParameterDriver;

  27. /** This class implements a {@link AbstractParametricAcceleration parametric acceleration}
  28.  * with polynomial signed amplitude.
  29.  * @since 9.0
  30.  * @author Luc Maisonobe
  31.  * @deprecated as of 10.3, replaced by {@link PolynomialAccelerationModel}
  32.  */
  33. @Deprecated
  34. public class PolynomialParametricAcceleration extends AbstractParametricAcceleration {

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

  45.     /** Drivers for the polynomial coefficients. */
  46.     private final ParameterDriver[] drivers;

  47.     /** Reference date for computing polynomials. */
  48.     private AbsoluteDate referenceDate;

  49.     /** Simple constructor.
  50.      * <p>
  51.      * The signed amplitude of the acceleration is ∑pₙ(t-t₀)ⁿ, where
  52.      * pₙ is parameter {@code n}, t is current date and t₀ is reference date.
  53.      * The value t-t₀ is in seconds.
  54.      * </p>
  55.      * <p>
  56.      * The {@code degree + 1} parameters for this model are the polynomial
  57.      * coefficients in increasing degree order. Their reference values (used
  58.      * also as the initial values) are all set to 0. User can change them before
  59.      * starting the propagation (or orbit determination) by calling {@link
  60.      * #getParametersDrivers()} and {@link ParameterDriver#setValue(double)}.
  61.      * </p>
  62.      * @param direction acceleration direction in defining frame
  63.      * @param isInertial if true, direction is defined in the same inertial
  64.      * frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
  65.      * otherwise direction is defined in spacecraft frame (i.e. using the
  66.      * propagation {@link
  67.      * org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
  68.      * attitude law})
  69.      * @param prefix prefix to use for parameter drivers
  70.      * @param referenceDate reference date for computing polynomials, if null
  71.      * the reference date will be automatically set at propagation start
  72.      * @param degree polynomial degree (i.e. a value of 0 corresponds to a constant acceleration)
  73.      */
  74.     public PolynomialParametricAcceleration(final Vector3D direction, final boolean isInertial,
  75.                                             final String prefix, final AbsoluteDate referenceDate,
  76.                                             final int degree) {
  77.         this(direction, isInertial, null, prefix, referenceDate, degree);
  78.     }

  79.     /** Simple constructor.
  80.      * <p>
  81.      * The signed amplitude of the acceleration is ∑pₙ(t-t₀)ⁿ, where
  82.      * pₙ is parameter {@code n}, t is current date and t₀ is reference date.
  83.      * The value t-t₀ is in seconds.
  84.      * </p>
  85.      * <p>
  86.      * The {@code degree + 1} parameters for this model are the polynomial
  87.      * coefficients in increasing degree order. Their reference values (used
  88.      * also as the initial values) are all set to 0. User can change them before
  89.      * starting the propagation (or orbit determination) by calling {@link
  90.      * #getParametersDrivers()} and {@link ParameterDriver#setValue(double)}.
  91.      * </p>
  92.      * @param direction acceleration direction in overridden spacecraft frame
  93.      * @param attitudeOverride provider for attitude used to compute acceleration
  94.      * direction
  95.      * @param prefix prefix to use for parameter drivers
  96.      * @param referenceDate reference date for computing polynomials, if null
  97.      * the reference date will be automatically set at propagation start
  98.      * @param degree polynomial degree (i.e. a value of 0 corresponds to a constant acceleration)
  99.      */
  100.     public PolynomialParametricAcceleration(final Vector3D direction, final AttitudeProvider attitudeOverride,
  101.                                             final String prefix, final AbsoluteDate referenceDate,
  102.                                             final int degree) {
  103.         this(direction, false, attitudeOverride, prefix, referenceDate, degree);
  104.     }

  105.     /** Simple constructor.
  106.      * @param direction acceleration direction in overridden spacecraft frame
  107.      * @param isInertial if true, direction is defined in the same inertial
  108.      * frame used for propagation (i.e. {@link SpacecraftState#getFrame()}),
  109.      * otherwise direction is defined in spacecraft frame (i.e. using the
  110.      * propagation {@link
  111.      * org.orekit.propagation.Propagator#setAttitudeProvider(AttitudeProvider)
  112.      * attitude law})
  113.      * @param attitudeOverride provider for attitude used to compute acceleration
  114.      * direction
  115.      * @param prefix prefix to use for parameter drivers
  116.      * @param referenceDate reference date for computing polynomials, if null
  117.      * the reference date will be automatically set at propagation start
  118.      * @param degree polynomial degree (i.e. a value of 0 corresponds to a constant acceleration)
  119.      */
  120.     private PolynomialParametricAcceleration(final Vector3D direction, final boolean isInertial,
  121.                                              final AttitudeProvider attitudeOverride,
  122.                                              final String prefix, final AbsoluteDate referenceDate,
  123.                                              final int degree) {
  124.         super(direction, isInertial, attitudeOverride);
  125.         this.referenceDate = referenceDate;
  126.         this.drivers       = new ParameterDriver[degree + 1];
  127.         for (int i = 0; i < drivers.length; ++i) {
  128.             drivers[i] = new ParameterDriver(prefix + "[" + i + "]", 0.0, ACCELERATION_SCALE,
  129.                                              Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
  130.         }
  131.     }

  132.     /** {@inheritDoc} */
  133.     @Override
  134.     public boolean dependsOnPositionOnly() {
  135.         return isInertial();
  136.     }

  137.     /** {@inheritDoc} */
  138.     @Override
  139.     public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  140.         if (referenceDate == null) {
  141.             referenceDate = initialState.getDate();
  142.         }
  143.     }

  144.     /** {@inheritDoc} */
  145.     @Override
  146.     protected double signedAmplitude(final SpacecraftState state, final double[] parameters) {
  147.         final double dt = state.getDate().durationFrom(referenceDate);
  148.         double amplitude = 0;
  149.         for (int i = parameters.length - 1; i >= 0; --i) {
  150.             amplitude += amplitude * dt + parameters[i];
  151.         }
  152.         return amplitude;
  153.     }

  154.     /** {@inheritDoc} */
  155.     @Override
  156.     protected <T extends RealFieldElement<T>> T signedAmplitude(final FieldSpacecraftState<T> state, final T[] parameters) {
  157.         final T dt = state.getDate().durationFrom(referenceDate);
  158.         T amplitude = dt.getField().getZero();
  159.         for (int i = parameters.length - 1; i >= 0; --i) {
  160.             amplitude = amplitude.add(amplitude.multiply(dt).add(parameters[i]));
  161.         }
  162.         return amplitude;
  163.     }

  164.     /** {@inheritDoc} */
  165.     @Override
  166.     public ParameterDriver[] getParametersDrivers() {
  167.         return drivers.clone();
  168.     }

  169. }