HarmonicAccelerationModel.java

  1. /* Copyright 2002-2025 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.empirical;

  18. import java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.CalculusFieldElement;
  22. import org.hipparchus.util.FastMath;
  23. import org.hipparchus.util.MathUtils;
  24. import org.orekit.propagation.FieldSpacecraftState;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.ParameterDriver;

  28. /** Harmonic acceleration model.
  29.  * @since 10.3
  30.  * @author Luc Maisonobe
  31.  * @author Bryan Cazabonne
  32.  */
  33. public class HarmonicAccelerationModel implements AccelerationModel {

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

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

  55.     /** Drivers for the parameters. */
  56.     private final List<ParameterDriver> drivers;

  57.     /** Reference date for computing phase. */
  58.     private AbsoluteDate referenceDate;

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

  61.     /** Simple constructor.
  62.      * @param prefix prefix to use for parameter drivers
  63.      * @param referenceDate reference date for computing polynomials, if null
  64.      * the reference date will be automatically set at propagation start
  65.      * @param fundamentalPeriod fundamental period (typically set to initial orbit
  66.      * {@link org.orekit.orbits.Orbit#getKeplerianPeriod() Keplerian period})
  67.      * @param harmonicMultiplier multiplier to compute harmonic period from
  68.      * fundamental period)
  69.      */
  70.     public HarmonicAccelerationModel(final String prefix, final AbsoluteDate referenceDate,
  71.                                      final double fundamentalPeriod, final int harmonicMultiplier) {
  72.         this.referenceDate = referenceDate;
  73.         this.omega         = harmonicMultiplier * MathUtils.TWO_PI / fundamentalPeriod;
  74.         this.drivers       = new ArrayList<>(2);
  75.         drivers.add(new ParameterDriver(prefix + " γ",
  76.                                         0.0, AMPLITUDE_SCALE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
  77.         drivers.add(new ParameterDriver(prefix + " φ",
  78.                                         0.0, PHASE_SCALE, -MathUtils.TWO_PI, MathUtils.TWO_PI));
  79.     }

  80.     /** {@inheritDoc} */
  81.     @Override
  82.     public void init(final SpacecraftState initialState, final AbsoluteDate target) {
  83.         if (referenceDate == null) {
  84.             referenceDate = initialState.getDate();
  85.         }
  86.     }

  87.     /** {@inheritDoc} */
  88.     @Override
  89.     public double signedAmplitude(final SpacecraftState state,
  90.                                   final double[] parameters) {
  91.         final double dt = state.getDate().durationFrom(referenceDate);
  92.         return parameters[0] * FastMath.sin(dt * omega + parameters[1]);
  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public <T extends CalculusFieldElement<T>> T signedAmplitude(final FieldSpacecraftState<T> state,
  97.                                                              final T[] parameters) {
  98.         final T dt = state.getDate().durationFrom(referenceDate);
  99.         return parameters[0].multiply(dt.multiply(omega).add(parameters[1]).sin());
  100.     }

  101.     /** {@inheritDoc} */
  102.     @Override
  103.     public List<ParameterDriver> getParametersDrivers() {
  104.         return Collections.unmodifiableList(drivers);
  105.     }

  106. }