FieldAdditionalDerivativesProvider.java

  1. /* Copyright 2002-2022 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.integration;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.orekit.propagation.FieldSpacecraftState;
  20. import org.orekit.time.FieldAbsoluteDate;

  21. /** Provider for additional derivatives.
  22. *
  23. * <p>
  24. * In some cases users may need to integrate some problem-specific equations along with
  25. * classical spacecraft equations of motions. One example is optimal control in low
  26. * thrust where adjoint parameters linked to the minimized Hamiltonian must be integrated.
  27. * Another example is formation flying or rendez-vous which use the Clohessy-Whiltshire
  28. * equations for the relative motion.
  29. * </p>
  30. * <p>
  31. * This interface allows users to add such equations to a {@link
  32. * org.orekit.propagation.numerical.FieldNumericalPropagator numerical propagator} or a {@link
  33. * org.orekit.propagation.semianalytical.dsst.FieldDSSTPropagator DSST propagator}. Users provide the
  34. * equations as an implementation of this interface and register it to the propagator thanks to
  35. * its {@link FieldAbstractIntegratedPropagator#addAdditionalDerivativesProvider(FieldAdditionalDerivativesProvider)}
  36. * method. Several such objects can be registered with each numerical propagator, but it is
  37. * recommended to gather in the same object the sets of parameters which equations can interact
  38. * on each others states.
  39. * </p>
  40. * <p>
  41. * This interface is the numerical (read not already integrated) counterpart of
  42. * the {@link org.orekit.propagation.FieldAdditionalStateProvider} interface.
  43. * It allows to append various additional state parameters to any {@link
  44. * org.orekit.propagation.numerical.FieldNumericalPropagator numerical propagator} or {@link
  45. * org.orekit.propagation.semianalytical.dsst.FieldDSSTPropagator DSST propagator}.
  46. * </p>
  47. * @see org.orekit.propagation.integration.FieldAbstractIntegratedPropagator
  48. * @author Luc Maisonobe
  49. * @since 11.1
  50. */
  51. public interface FieldAdditionalDerivativesProvider<T extends CalculusFieldElement<T>> {

  52.     /** Get the name of the additional derivatives (which will become state once integrated).
  53.      * @return name of the additional state (names containing "orekit"
  54.      * with any case are reserved for the library internal use)
  55.      */
  56.     String getName();

  57.     /** Get the dimension of the generated derivative.
  58.      * @return dimension of the generated
  59.      */
  60.     int getDimension();

  61.     /** Initialize the generator at the start of propagation.
  62.      * @param initialState initial state information at the start of propagation
  63.      * @param target       date of propagation
  64.      */
  65.     default void init(final FieldSpacecraftState<T> initialState, final FieldAbsoluteDate<T> target) {
  66.         // nothing by default
  67.     }

  68.     /** Check if this provider should yield so another provider has an opportunity to add missing parts.
  69.      * <p>
  70.      * Decision to yield is often based on an additional state being {@link FieldSpacecraftState#hasAdditionalState(String)
  71.      * already available} in the provided {@code state} (but it could theoretically also depend on
  72.      * an additional state derivative being {@link FieldSpacecraftState#hasAdditionalStateDerivative(String)
  73.      * already available}, or any other criterion). If for example a provider needs the state transition
  74.      * matrix, it could implement this method as:
  75.      * </p>
  76.      * <pre>{@code
  77.      * public boolean yield(final FieldSpacecraftState<T> state) {
  78.      *     return !state.getAdditionalStates().containsKey("STM");
  79.      * }
  80.      * }</pre>
  81.      * <p>
  82.      * The default implementation returns {@code false}, meaning that derivative data can be
  83.      * {@link #derivatives(FieldSpacecraftState) computed} immediately.
  84.      * </p>
  85.      * @param state state to handle
  86.      * @return true if this provider should yield so another provider has an opportunity to add missing parts
  87.      * as the state is incrementally built up
  88.      */
  89.     default boolean yield(FieldSpacecraftState<T> state) {
  90.         return false;
  91.     }

  92.     /** Compute the derivatives related to the additional state parameters.
  93.      * @param s current state information: date, kinematics, attitude, and
  94.      * additional states this equations depend on (according to the
  95.      * {@link #yield(FieldSpacecraftState) yield} method)
  96.      * @return computed derivatives
  97.      * @deprecated as of 11.2, replaced by {@link #combinedDerivatives(FieldSpacecraftState)}
  98.      */
  99.     @Deprecated
  100.     T[] derivatives(FieldSpacecraftState<T> s);

  101.     /** Compute the derivatives related to the additional state (and optionally main state increments).
  102.      * <p>
  103.      * As of 11.2, there is a default implementation that calls the deprecated
  104.      * {@link #derivatives(FieldSpacecraftState)} method. This has been done for
  105.      * backward compatibility only and will be removed in 12.0.
  106.      * </p>
  107.      * @param s current state information: date, kinematics, attitude, and
  108.      * additional states this equations depend on (according to the
  109.      * {@link #yield(FieldSpacecraftState) yield} method)
  110.      * @return computed combined derivatives, which may include some incremental
  111.      * coupling effect to add to main state derivatives
  112.      * @since 11.2
  113.      */
  114.     default FieldCombinedDerivatives<T> combinedDerivatives(FieldSpacecraftState<T> s) {
  115.         // this default implementation will be removed
  116.         // when the deprecated derivatives method above is removed
  117.         return new FieldCombinedDerivatives<>(derivatives(s), null);
  118.     }

  119. }