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.integration;
18  
19  import org.orekit.propagation.SpacecraftState;
20  import org.orekit.propagation.analytical.tle.TLEJacobiansMapper;
21  import org.orekit.propagation.numerical.JacobiansMapper;
22  import org.orekit.propagation.semianalytical.dsst.DSSTJacobiansMapper;
23  import org.orekit.utils.ParameterDriversList;
24  
25  /** Base class for jacobian mapper.
26   * @author Bryan Cazabonne
27   * @since 10.0
28   */
29  public abstract class AbstractJacobiansMapper {
30  
31      /** State dimension, fixed to 6.
32       * @since 9.0
33       */
34      public static final int STATE_DIMENSION = 6;
35  
36      /** Name. */
37      private String name;
38  
39      /** Selected parameters for Jacobian computation. */
40      private final ParameterDriversList parameters;
41  
42      /** Simple constructor.
43       * @param name name of the Jacobians
44       * @param parameters selected parameters for Jacobian computation
45       */
46      protected AbstractJacobiansMapper(final String name, final ParameterDriversList parameters) {
47          this.name = name;
48          this.parameters = parameters;
49      }
50  
51      /** Get the name of the partial Jacobians.
52       * @return name of the Jacobians
53       */
54      public String getName() {
55          return name;
56      }
57  
58      /** Get the number of parameters.
59       * @return number of parameters
60       */
61      public int getParameters() {
62          return parameters.getNbParams();
63      }
64  
65      /** Compute the length of the one-dimensional additional state array needed.
66       * @return length of the one-dimensional additional state array
67       */
68      public int getAdditionalStateDimension() {
69          return STATE_DIMENSION * (STATE_DIMENSION + parameters.getNbParams());
70      }
71  
72      /** Compute the derivatives needed by analytical orbit determination methods.
73       * <p>
74       * Analytical derivatives are used to calculate state transition matrix of
75       * analytical orbit propagators and short period derivatives of DSST orbit
76       * propagator. In other word, this method does nothing for the numerical propagator.
77       *
78       * @param s spacecraft state with respect to which calculate derivatives
79       */
80      public void analyticalDerivatives(final SpacecraftState s) {
81          // noting by default
82      }
83  
84      /** Set the Jacobian with respect to state into a one-dimensional additional state array.
85       * @param state spacecraft state
86       * @param dY1dY0 Jacobian of current state at time t₁
87       * with respect to state at some previous time t₀
88       * @param dY1dP Jacobian of current state at time t₁
89       * with respect to parameters (may be null if there are no parameters)
90       * @param p placeholder where to put the one-dimensional additional state
91       * @see #getStateJacobian(SpacecraftState, double[][])
92       */
93      public abstract void setInitialJacobians(SpacecraftState state, double[][] dY1dY0, double[][] dY1dP, double[] p);
94  
95      /** Get the Jacobian with respect to state from a one-dimensional additional state array.
96       * <p>
97       * This method extract the data from the {@code state} and put it in the
98       * {@code dYdY0} array.
99       * <p>
100      * For {@link JacobiansMapper} and {@link TLEJacobiansMapper}, the method provides
101      * the Jacobian with respect to Cartesian elements.
102      * For {@link DSSTJacobiansMapper} the method provides the Jacobian with respect to
103      * Equinoctial elements.
104      * @param state spacecraft state
105      * @param dYdY0 placeholder where to put the Jacobian with respect to state
106      * @see #getParametersJacobian(SpacecraftState, double[][])
107      */
108     public abstract void getStateJacobian(SpacecraftState state,  double[][] dYdY0);
109 
110     /** Get the Jacobian with respect to parameters from a one-dimensional additional state array.
111      * <p>
112      * This method extract the data from the {@code state} and put it in the
113      * {@code dYdP} array.
114      * </p>
115      * <p>
116      * If no parameters have been set in the constructor, the method returns immediately and
117      * does not reference {@code dYdP} which can safely be null in this case.
118      * </p>
119      * @param state spacecraft state
120      * @param dYdP placeholder where to put the Jacobian with respect to parameters
121      * @see #getStateJacobian(SpacecraftState, double[][])
122      */
123     public abstract void getParametersJacobian(SpacecraftState state, double[][] dYdP);
124 
125 }