1 /* Copyright 2002-2025 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.forces.maneuvers.jacobians;
18
19 import org.orekit.propagation.AdditionalDataProvider;
20 import org.orekit.propagation.SpacecraftState;
21
22 /** Generator for one column of a Jacobian matrix for special case of maneuver duration.
23 * <p>
24 * Typical use cases for this are estimation of maneuver duration during
25 * either orbit determination or maneuver optimization.
26 * </p>
27 * @author Luc Maisonobe
28 * @since 11.1
29 * @see MedianDate
30 * @see TriggerDate
31 */
32 public class Duration implements AdditionalDataProvider<double[]> {
33
34 /** Name of the parameter corresponding to the start date. */
35 private final String startName;
36
37 /** Name of the parameter corresponding to the stop date. */
38 private final String stopName;
39
40 /** Name of the parameter corresponding to the column. */
41 private final String columnName;
42
43 /** Simple constructor.
44 * @param startName name of the parameter corresponding to the start date
45 * @param stopName name of the parameter corresponding to the stop date
46 * @param columnName name of the parameter corresponding to the column
47 */
48 public Duration(final String startName, final String stopName, final String columnName) {
49 this.startName = startName;
50 this.stopName = stopName;
51 this.columnName = columnName;
52 }
53
54 /** {@inheritDoc} */
55 @Override
56 public String getName() {
57 return columnName;
58 }
59
60 /** {@inheritDoc}
61 * <p>
62 * The column state can be computed only if the start and stop dates columns are available.
63 * </p>
64 */
65 @Override
66 public boolean yields(final SpacecraftState state) {
67 return !(state.hasAdditionalData(startName) && state.hasAdditionalData(stopName));
68 }
69
70 /** {@inheritDoc} */
71 @Override
72 public double[] getAdditionalData(final SpacecraftState state) {
73
74 // compute partial derivatives with respect to start and stop dates
75 final double[] dYdT0 = state.getAdditionalState(startName);
76 final double[] dYdT1 = state.getAdditionalState(stopName);
77
78 // combine derivatives to get partials with respect to duration
79 final double[] dYdTm = new double[dYdT0.length];
80 for (int i = 0; i < dYdTm.length; ++i) {
81 dYdTm[i] = 0.5 * (dYdT1[i] - dYdT0[i]);
82 }
83 return dYdTm;
84
85 }
86
87 }
88