DSSTForceModel.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.semianalytical.dsst.forces;

  18. import java.util.List;

  19. import org.hipparchus.Field;
  20. import org.hipparchus.RealFieldElement;
  21. import org.hipparchus.util.MathArrays;
  22. import org.orekit.attitudes.AttitudeProvider;
  23. import org.orekit.propagation.FieldSpacecraftState;
  24. import org.orekit.propagation.PropagationType;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.propagation.events.EventDetector;
  27. import org.orekit.propagation.events.FieldEventDetector;
  28. import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
  29. import org.orekit.propagation.semianalytical.dsst.utilities.FieldAuxiliaryElements;
  30. import org.orekit.utils.ParameterDriver;

  31. /** This interface represents a force modifying spacecraft motion for a {@link
  32.  *  org.orekit.propagation.semianalytical.dsst.DSSTPropagator DSSTPropagator}.
  33.  *  <p>
  34.  *  Objects implementing this interface are intended to be added to a {@link
  35.  *  org.orekit.propagation.semianalytical.dsst.DSSTPropagator DSST propagator}
  36.  *  before the propagation is started.
  37.  *  </p>
  38.  *  <p>
  39.  *  The propagator will call at the very beginning of a propagation the {@link
  40.  *  #initialize(AuxiliaryElements, PropagationType, double[])} method allowing
  41.  *  preliminary computation such as truncation if needed.
  42.  *  </p>
  43.  *  <p>
  44.  *  Then the propagator will call at each step:
  45.  *  <ol>
  46.  *  <li>the {@link #getMeanElementRate(SpacecraftState, AuxiliaryElements, double[])} method.
  47.  *  The force model instance will extract all the state data needed to compute
  48.  *  the mean element rates that contribute to the mean state derivative.</li>
  49.  *  <li>the {@link #updateShortPeriodTerms(double[], SpacecraftState...)} method,
  50.  *  if osculating parameters are desired, on a sample of points within the
  51.  *  last step.</li>
  52.  *  </ol>
  53.  *
  54.  * @author Romain Di Constanzo
  55.  * @author Pascal Parraud
  56.  */
  57. public interface DSSTForceModel {

  58.     /** Performs initialization prior to propagation for the current force model.
  59.      *  <p>
  60.      *  This method aims at being called at the very beginning of a propagation.
  61.      *  </p>
  62.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  63.      *  @param type type of the elements used during the propagation
  64.      *  @param parameters values of the force model parameters
  65.      *  @return a list of objects that will hold short period terms (the objects
  66.      *  are also retained by the force model, which will update them during propagation)
  67.      */
  68.     List<ShortPeriodTerms> initialize(AuxiliaryElements auxiliaryElements,
  69.                                       PropagationType type, double[] parameters);

  70.     /** Performs initialization prior to propagation for the current force model.
  71.      *  <p>
  72.      *  This method aims at being called at the very beginning of a propagation.
  73.      *  </p>
  74.      *  @param <T> type of the elements
  75.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  76.      *  @param type type of the elements used during the propagation
  77.      *  @param parameters values of the force model parameters
  78.      *  @return a list of objects that will hold short period terms (the objects
  79.      *  are also retained by the force model, which will update them during propagation)
  80.      */
  81.     <T extends RealFieldElement<T>> List<FieldShortPeriodTerms<T>> initialize(FieldAuxiliaryElements<T> auxiliaryElements,
  82.                                                                               PropagationType type, T[] parameters);

  83.     /** Get force model parameters.
  84.      * @return force model parameters
  85.      * @since 9.0
  86.      */
  87.     default double[] getParameters() {
  88.         final ParameterDriver[] drivers = getParametersDrivers();
  89.         final double[] parameters = new double[drivers.length];
  90.         for (int i = 0; i < drivers.length; ++i) {
  91.             parameters[i] = drivers[i].getValue();
  92.         }
  93.         return parameters;
  94.     }

  95.     /** Get force model parameters.
  96.      * @param field field to which the elements belong
  97.      * @param <T> type of the elements
  98.      * @return force model parameters
  99.      * @since 9.0
  100.      */
  101.     default <T extends RealFieldElement<T>> T[] getParameters(final Field<T> field) {
  102.         final ParameterDriver[] drivers = getParametersDrivers();
  103.         final T[] parameters = MathArrays.buildArray(field, drivers.length);
  104.         for (int i = 0; i < drivers.length; ++i) {
  105.             parameters[i] = field.getZero().add(drivers[i].getValue());
  106.         }
  107.         return parameters;
  108.     }

  109.     /** Computes the mean equinoctial elements rates da<sub>i</sub> / dt.
  110.      *
  111.      *  @param state current state information: date, kinematics, attitude
  112.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  113.      *  @param parameters values of the force model parameters
  114.      *  @return the mean element rates dai/dt
  115.      */
  116.     double[] getMeanElementRate(SpacecraftState state,
  117.                                 AuxiliaryElements auxiliaryElements, double[] parameters);

  118.     /** Computes the mean equinoctial elements rates da<sub>i</sub> / dt.
  119.      *
  120.      *  @param <T> type of the elements
  121.      *  @param state current state information: date, kinematics, attitude
  122.      *  @param auxiliaryElements auxiliary elements related to the current orbit
  123.      *  @param parameters values of the force model parameters
  124.      *  @return the mean element rates dai/dt
  125.      */
  126.     <T extends RealFieldElement<T>> T[] getMeanElementRate(FieldSpacecraftState<T> state,
  127.                                                            FieldAuxiliaryElements<T> auxiliaryElements, T[] parameters);


  128.     /** Get the discrete events related to the model.
  129.      * @return array of events detectors or null if the model is not
  130.      * related to any discrete events
  131.      */
  132.     EventDetector[] getEventsDetectors();

  133.     /** Get the discrete events related to the model.
  134.      * @param <T> type of the elements
  135.      * @param field field used by default
  136.      * @return array of events detectors or null if the model is not
  137.      * related to any discrete events
  138.      */
  139.     <T extends RealFieldElement<T>> FieldEventDetector<T>[] getFieldEventsDetectors(Field<T> field);

  140.     /** Register an attitude provider.
  141.      * <p>
  142.      * Register an attitude provider that can be used by the force model.
  143.      * </p>
  144.      * @param provider the {@link AttitudeProvider}
  145.      */
  146.     void registerAttitudeProvider(AttitudeProvider provider);

  147.     /** Update the short period terms.
  148.      * <p>
  149.      * The {@link ShortPeriodTerms short period terms} that will be updated
  150.      * are the ones that were returned during the call to {@link
  151.      * #initialize(AuxiliaryElements, PropagationType, double[])}.
  152.      * </p>
  153.      * @param parameters values of the force model parameters
  154.      * @param meanStates mean states information: date, kinematics, attitude
  155.      */
  156.     void updateShortPeriodTerms(double[] parameters, SpacecraftState... meanStates);

  157.     /** Update the short period terms.
  158.      * <p>
  159.      * The {@link ShortPeriodTerms short period terms} that will be updated
  160.      * are the ones that were returned during the call to {@link
  161.      * #initialize(AuxiliaryElements, PropagationType, double[])}.
  162.      * </p>
  163.      * @param <T> type of the elements
  164.      * @param parameters values of the force model parameters
  165.      * @param meanStates mean states information: date, kinematics, attitude
  166.      */
  167.     @SuppressWarnings("unchecked")
  168.     <T extends RealFieldElement<T>> void updateShortPeriodTerms(T[] parameters, FieldSpacecraftState<T>... meanStates);

  169.     /** Get the drivers for force model parameters.
  170.      * @return drivers for force model parameters
  171.      */
  172.     ParameterDriver[] getParametersDrivers();

  173. }