1   /* Copyright 2002-2021 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.numerical;
18  
19  import org.orekit.errors.OrekitException;
20  import org.orekit.errors.OrekitMessages;
21  import org.orekit.forces.ForceModel;
22  import org.orekit.propagation.SpacecraftState;
23  import org.orekit.propagation.integration.AdditionalEquations;
24  import org.orekit.utils.ParameterDriver;
25  
26  /** Set of {@link AdditionalEquations additional equations} computing the partial derivatives
27   * of the state (orbit) with respect to initial state and force models parameters.
28   * <p>
29   * This set of equations are automatically added to a {@link NumericalPropagator numerical propagator}
30   * in order to compute partial derivatives of the orbit along with the orbit itself. This is
31   * useful for example in orbit determination applications.
32   * </p>
33   * <p>
34   * The partial derivatives with respect to initial state can be either dimension 6
35   * (orbit only) or 7 (orbit and mass).
36   * </p>
37   * <p>
38   * The partial derivatives with respect to force models parameters has a dimension
39   * equal to the number of selected parameters. Parameters selection is implemented at
40   * {@link ForceModel force models} level. Users must retrieve a {@link ParameterDriver
41   * parameter driver} using {@link ForceModel#getParameterDriver(String)} and then
42   * select it by calling {@link ParameterDriver#setSelected(boolean) setSelected(true)}.
43   * </p>
44   * <p>
45   * If several force models provide different {@link ParameterDriver drivers} for the
46   * same parameter name, selecting any of these drivers has the side effect of
47   * selecting all the drivers for this shared parameter. In this case, the partial
48   * derivatives will be the sum of the partial derivatives contributed by the
49   * corresponding force models. This case typically arises for central attraction
50   * coefficient, which has an influence on {@link org.orekit.forces.gravity.NewtonianAttraction
51   * Newtonian attraction}, {@link org.orekit.forces.gravity.HolmesFeatherstoneAttractionModel
52   * gravity field}, and {@link org.orekit.forces.gravity.Relativity relativity}.
53   * </p>
54   * @author Vincent Mouraux
55   * @author Bryan Cazabonne
56   * @since 10.2
57   */
58  public class AbsolutePartialDerivativesEquations extends PartialDerivativesEquations {
59  
60      /** Name. */
61      private final String name;
62  
63      /** Simple constructor.
64       * <p>
65       * Upon construction, this set of equations is <em>automatically</em> added to
66       * the propagator by calling its {@link
67       * NumericalPropagator#addAdditionalEquations(AdditionalEquations)} method. So
68       * there is no need to call this method explicitly for these equations.
69       * </p>
70       * @param name name of the partial derivatives equations
71       * @param propagator the propagator that will handle the orbit propagation
72       */
73      public AbsolutePartialDerivativesEquations(final String name, final NumericalPropagator propagator) {
74          super(name, propagator);
75          this.name = name;
76      }
77  
78      /** Get a mapper between two-dimensional Jacobians and one-dimensional additional state.
79       * @return a mapper between two-dimensional Jacobians and one-dimensional additional state,
80       * with the same name as the instance
81       * @see #setInitialJacobians(SpacecraftState)
82       * @see #setInitialJacobians(SpacecraftState, double[][], double[][])
83       */
84      @Override
85      public AbsoluteJacobiansMapper getMapper() {
86          if (!isInitialize()) {
87              throw new OrekitException(OrekitMessages.STATE_JACOBIAN_NOT_INITIALIZED);
88          }
89          return new AbsoluteJacobiansMapper(name, getSelectedParameters());
90      }
91  
92  }
93