Duration.java

  1. /* Copyright 2002-2024 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. import org.orekit.propagation.AdditionalStateProvider;
  19. import org.orekit.propagation.SpacecraftState;

  20. /** Generator for one column of a Jacobian matrix for special case of maneuver duration.
  21.  * <p>
  22.  * Typical use cases for this are estimation of maneuver duration during
  23.  * either orbit determination or maneuver optimization.
  24.  * </p>
  25.  * @author Luc Maisonobe
  26.  * @since 11.1
  27.  * @see MedianDate
  28.  * @see TriggerDate
  29.  */
  30. public class Duration implements AdditionalStateProvider {

  31.     /** Name of the parameter corresponding to the start date. */
  32.     private final String startName;

  33.     /** Name of the parameter corresponding to the stop date. */
  34.     private final String stopName;

  35.     /** Name of the parameter corresponding to the column. */
  36.     private final String columnName;

  37.     /** Simple constructor.
  38.      * @param startName name of the parameter corresponding to the start date
  39.      * @param stopName name of the parameter corresponding to the stop date
  40.      * @param columnName name of the parameter corresponding to the column
  41.      */
  42.     public Duration(final String startName, final String stopName, final String columnName) {
  43.         this.startName  = startName;
  44.         this.stopName   = stopName;
  45.         this.columnName = columnName;
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public String getName() {
  50.         return columnName;
  51.     }

  52.     /** {@inheritDoc}
  53.      * <p>
  54.      * The column state can be computed only if the start and stop dates columns are available.
  55.      * </p>
  56.      */
  57.     @Override
  58.     public boolean yields(final SpacecraftState state) {
  59.         return !(state.hasAdditionalState(startName) && state.hasAdditionalState(stopName));
  60.     }

  61.     /** {@inheritDoc} */
  62.     @Override
  63.     public double[] getAdditionalState(final SpacecraftState state) {

  64.         // compute partial derivatives with respect to start and stop dates
  65.         final double[] dYdT0 = state.getAdditionalState(startName);
  66.         final double[] dYdT1 = state.getAdditionalState(stopName);

  67.         // combine derivatives to get partials with respect to duration
  68.         final double[] dYdTm = new double[dYdT0.length];
  69.         for (int i = 0; i < dYdTm.length; ++i) {
  70.             dYdTm[i] = 0.5 * (dYdT1[i] - dYdT0[i]);
  71.         }
  72.         return dYdTm;

  73.     }

  74. }