DSSTNewtonianAttraction.java

  1. /* Copyright 2002-2023 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.semianalytical.dsst.forces;

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

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.Field;
  22. import org.hipparchus.util.FastMath;
  23. import org.hipparchus.util.MathArrays;
  24. import org.orekit.attitudes.AttitudeProvider;
  25. import org.orekit.orbits.EquinoctialOrbit;
  26. import org.orekit.orbits.FieldEquinoctialOrbit;
  27. import org.orekit.orbits.OrbitType;
  28. import org.orekit.orbits.PositionAngleType;
  29. import org.orekit.propagation.FieldSpacecraftState;
  30. import org.orekit.propagation.PropagationType;
  31. import org.orekit.propagation.SpacecraftState;
  32. import org.orekit.propagation.semianalytical.dsst.DSSTPropagator;
  33. import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
  34. import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
  35. import org.orekit.time.AbsoluteDate;
  36. import org.orekit.utils.ParameterDriver;

  37. /** Force model for Newtonian central body attraction for the {@link DSSTPropagator DSST propagator}.
  38.  *  @author Bryan Cazabonne
  39.  *  @author Luc Maisonobe
  40.  *  @since 10.0
  41.  */
  42. public class DSSTNewtonianAttraction implements DSSTForceModel {

  43.     /** Name of the single parameter of this model: the central attraction coefficient. */
  44.     public static final String CENTRAL_ATTRACTION_COEFFICIENT = "central attraction coefficient";

  45.     /** Central attraction scaling factor.
  46.      * <p>
  47.      * We use a power of 2 to avoid numeric noise introduction
  48.      * in the multiplications/divisions sequences.
  49.      * </p>
  50.      */
  51.     private static final double MU_SCALE = FastMath.scalb(1.0, 32);

  52.     /** Driver for gravitational parameter. */
  53.     private final ParameterDriver gmParameterDriver;

  54.     /** Simple constructor.
  55.      * @param mu central attraction coefficient (m^3/s^2)
  56.      */
  57.     public DSSTNewtonianAttraction(final double mu) {
  58.         gmParameterDriver = new ParameterDriver(DSSTNewtonianAttraction.CENTRAL_ATTRACTION_COEFFICIENT,
  59.                                                 mu, MU_SCALE,
  60.                                                 0.0, Double.POSITIVE_INFINITY);
  61.     }

  62.     /** Get the central attraction coefficient μ at specific date.
  63.      * @param date date at which mu wants to be known
  64.      * @return mu central attraction coefficient (m³/s²)
  65.      */
  66.     public double getMu(final AbsoluteDate date) {
  67.         return gmParameterDriver.getValue(date);
  68.     }

  69.     /** {@inheritDoc} */
  70.     @Override
  71.     public List<ShortPeriodTerms> initializeShortPeriodTerms(final AuxiliaryElements auxiliaryElements,
  72.                                              final PropagationType type,
  73.                                              final double[] parameters) {
  74.         return Collections.emptyList();
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public <T extends CalculusFieldElement<T>> List<FieldShortPeriodTerms<T>> initializeShortPeriodTerms(final FieldAuxiliaryElements<T> auxiliaryElements,
  79.                                                                                      final PropagationType type,
  80.                                                                                      final T[] parameters) {
  81.         return Collections.emptyList();
  82.     }

  83.     /** Performs initialization at each integration step for the current force model.
  84.      *  <p>
  85.      *  This method aims at being called before mean elements rates computation.
  86.      *  </p>
  87.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  88.      *  @param parameters values of the force model parameters
  89.      *  @return new force model context
  90.      */
  91.     private DSSTNewtonianAttractionContext initializeStep(final AuxiliaryElements auxiliaryElements, final double[] parameters) {
  92.         return new DSSTNewtonianAttractionContext(auxiliaryElements, parameters);
  93.     }

  94.     /** Performs initialization at each integration step for the current force model.
  95.      *  <p>
  96.      *  This method aims at being called before mean elements rates computation.
  97.      *  </p>
  98.      *  @param <T> type of the elements
  99.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  100.      *  @param parameters values of the force model parameters
  101.      *  @return new force model context
  102.      */
  103.     private <T extends CalculusFieldElement<T>> FieldDSSTNewtonianAttractionContext<T> initializeStep(final FieldAuxiliaryElements<T> auxiliaryElements,
  104.                                                                                                   final T[] parameters) {
  105.         return new FieldDSSTNewtonianAttractionContext<>(auxiliaryElements, parameters);
  106.     }

  107.     /** {@inheritDoc} */
  108.     @Override
  109.     public double[] getMeanElementRate(final SpacecraftState state,
  110.                                        final AuxiliaryElements auxiliaryElements,
  111.                                        final double[] parameters) {

  112.         // Container for attributes
  113.         final DSSTNewtonianAttractionContext context = initializeStep(auxiliaryElements, parameters);

  114.         final double[] yDot = new double[7];
  115.         final EquinoctialOrbit orbit = (EquinoctialOrbit) OrbitType.EQUINOCTIAL.convertType(state.getOrbit());
  116.         orbit.addKeplerContribution(PositionAngleType.MEAN, context.getGM(), yDot);

  117.         return yDot;

  118.     }

  119.     /** {@inheritDoc} */
  120.     @Override
  121.     public <T extends CalculusFieldElement<T>> T[] getMeanElementRate(final FieldSpacecraftState<T> state,
  122.                                                                   final FieldAuxiliaryElements<T> auxiliaryElements,
  123.                                                                   final T[] parameters) {

  124.         // Field for array building
  125.         final Field<T> field = state.getMu().getField();
  126.         // Container for attributes
  127.         final FieldDSSTNewtonianAttractionContext<T> context = initializeStep(auxiliaryElements, parameters);

  128.         final T[] yDot = MathArrays.buildArray(field, 7);
  129.         final FieldEquinoctialOrbit<T> orbit = (FieldEquinoctialOrbit<T>) OrbitType.EQUINOCTIAL.convertType(state.getOrbit());
  130.         orbit.addKeplerContribution(PositionAngleType.MEAN, context.getGM(), yDot);

  131.         return yDot;
  132.     }

  133.     /** {@inheritDoc} */
  134.     @Override
  135.     public void registerAttitudeProvider(final AttitudeProvider provider) {
  136.       //nothing is done since this contribution is not sensitive to attitude
  137.     }

  138.     /** {@inheritDoc} */
  139.     @Override
  140.     public void updateShortPeriodTerms(final double[] parameters,
  141.                                        final SpacecraftState... meanStates) {
  142.     }

  143.     /** {@inheritDoc} */
  144.     @Override
  145.     @SuppressWarnings("unchecked")
  146.     public <T extends CalculusFieldElement<T>> void updateShortPeriodTerms(final T[] parameters,
  147.                                                                        final FieldSpacecraftState<T>... meanStates) {
  148.     }

  149.     /** {@inheritDoc} */
  150.     @Override
  151.     public List<ParameterDriver> getParametersDrivers() {
  152.         return Collections.singletonList(gmParameterDriver);
  153.     }

  154. }