IntegrableJacobianColumnGenerator.java

  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.numerical;

  18. import org.orekit.propagation.SpacecraftState;
  19. import org.orekit.propagation.integration.AdditionalDerivativesProvider;

  20. /** Generator for one column of a Jacobian matrix.
  21.  * <p>
  22.  * This generator is based on variational equations, so
  23.  * it implements {@link AdditionalDerivativesProvider} and
  24.  * computes only the derivative of the Jacobian column, to
  25.  * be integrated by the propagator alongside the primary state.
  26.  * </p>
  27.  * @author Luc Maisonobe
  28.  * @since 11.1
  29.  */
  30. class IntegrableJacobianColumnGenerator
  31.     implements AdditionalDerivativesProvider, StateTransitionMatrixGenerator.PartialsObserver {

  32.     /** Name of the state for State Transition Matrix. */
  33.     private final String stmName;

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

  36.     /** Last value computed for the partial derivatives. */
  37.     private final double[] pDot;

  38.     /** Simple constructor.
  39.      * <p>
  40.      * The generator for State Transition Matrix <em>must</em> be registered as
  41.      * an integrable generator to the same propagator as the instance, as it
  42.      * must be scheduled to update the state before the instance
  43.      * </p>
  44.      * @param stmGenerator generator for State Transition Matrix
  45.      * @param columnName name of the parameter corresponding to the column
  46.      */
  47.     IntegrableJacobianColumnGenerator(final StateTransitionMatrixGenerator stmGenerator, final String columnName) {
  48.         this.stmName    = stmGenerator.getName();
  49.         this.columnName = columnName;
  50.         this.pDot       = new double[getDimension()];
  51.         stmGenerator.addObserver(columnName, this);
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public String getName() {
  56.         return columnName;
  57.     }

  58.     /** Get the dimension of the generated column.
  59.      * @return dimension of the generated column
  60.      */
  61.     public int getDimension() {
  62.         return 6;
  63.     }

  64.     /** {@inheritDoc}
  65.      * <p>
  66.      * The column derivative can be computed only if the State Transition Matrix derivatives
  67.      * are available, as it implies the STM generator has already been run.
  68.      * </p>
  69.      */
  70.     @Override
  71.     public boolean yield(final SpacecraftState state) {
  72.         return !state.hasAdditionalStateDerivative(stmName);
  73.     }

  74.     /** {@inheritDoc} */
  75.     @Override
  76.     public void partialsComputed(final SpacecraftState state, final double[] factor, final double[] accelerationPartials) {
  77.         // retrieve current Jacobian column
  78.         final double[] p = state.getAdditionalState(getName());

  79.         // compute time derivative of the Jacobian column
  80.         StateTransitionMatrixGenerator.multiplyMatrix(factor, p, pDot, 1);
  81.         pDot[3] += accelerationPartials[0];
  82.         pDot[4] += accelerationPartials[1];
  83.         pDot[5] += accelerationPartials[2];
  84.     }

  85.     /** {@inheritDoc} */
  86.     @Override
  87.     public double[] derivatives(final SpacecraftState s) {
  88.         return pDot;
  89.     }

  90. }