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
19 import java.util.function.Supplier;
20
21 import org.orekit.propagation.SpacecraftState;
22 import org.orekit.time.AbsoluteDate;
23
24
25 /** Temporary adapter from {@link AdditionalEquations} to {@link AdditionalDerivativesProvider}.
26 * @since 11.1
27 * @deprecated must be removed in 12.0 when {@link AdditionalEquations} is removed
28 */
29 @Deprecated
30 public class AdditionalEquationsAdapter implements AdditionalDerivativesProvider {
31
32 /** Wrapped equations. */
33 private final AdditionalEquations equations;
34
35 /** Supplier for reference state. */
36 private final Supplier<SpacecraftState> stateSupplier;
37
38 /** Dimension. */
39 private int dimension;
40
41 /** Simple constructor.
42 * @param equations wrapped equations
43 * @param stateSupplier supplier for reference state
44 */
45 public AdditionalEquationsAdapter(final AdditionalEquations equations, final Supplier<SpacecraftState> stateSupplier) {
46 this.equations = equations;
47 this.stateSupplier = stateSupplier;
48 this.dimension = -1;
49 }
50
51 /** {@inheritDoc} */
52 @Override
53 public String getName() {
54 return equations.getName();
55 }
56
57 /** {@inheritDoc} */
58 @Override
59 public int getDimension() {
60 if (dimension < 0) {
61 // retrieve the dimension the first time we need it
62 dimension = stateSupplier.get().getAdditionalState(getName()).length;
63 }
64 return dimension;
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 public boolean yield(final SpacecraftState state) {
70 return false;
71 }
72
73 /** {@inheritDoc} */
74 @Override
75 public void init(final SpacecraftState initialState, final AbsoluteDate target) {
76 equations.init(initialState, target);
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 @Deprecated
82 public double[] derivatives(final SpacecraftState state) {
83 return combinedDerivatives(state).getAdditionalDerivatives();
84 }
85
86 /** {@inheritDoc} */
87 @Override
88 public CombinedDerivatives combinedDerivatives(final SpacecraftState state) {
89 final double[] pDot = new double[getDimension()];
90 final double[] mainDot = equations.computeDerivatives(state, pDot);
91 return new CombinedDerivatives(pDot, mainDot);
92 }
93
94 }