AbstractVariableStepFieldIntegratorBuilder.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.propagation.conversion;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.orekit.orbits.Orbit;
  20. import org.orekit.orbits.OrbitType;
  21. import org.orekit.propagation.numerical.NumericalPropagator;

  22. /**
  23.  * Abstract class for integrator builder using variable step size.
  24.  *
  25.  * @param <T> type of the field elements
  26.  *
  27.  * @author Vincent Cucchietti
  28.  */
  29. public abstract class AbstractVariableStepFieldIntegratorBuilder<T extends CalculusFieldElement<T>>
  30.         extends AbstractFieldIntegratorBuilder<T> {

  31.     // CHECKSTYLE: stop VisibilityModifier check
  32.     /** Minimum step size (s). */
  33.     protected final double minStep;

  34.     /** Maximum step size (s). */
  35.     protected final double maxStep;

  36.     /** Position error (m). */
  37.     protected final double dP;

  38.     /** Velocity error (m/s). */
  39.     protected final double dV;
  40.     // CHECKSTYLE: resume VisibilityModifier check

  41.     /**
  42.      * Constructor. Should only use this constructor with {@link Orbit}.
  43.      *
  44.      * @param minStep minimum step size (s)
  45.      * @param maxStep maximum step size (s)
  46.      * @param dP position error (m)
  47.      */
  48.     AbstractVariableStepFieldIntegratorBuilder(final double minStep, final double maxStep, final double dP) {
  49.         this(minStep, maxStep, dP, Double.NaN);
  50.     }

  51.     /**
  52.      * Constructor with expected velocity error.
  53.      *
  54.      * @param minStep minimum step size (s)
  55.      * @param maxStep maximum step size (s)
  56.      * @param dP position error (m)
  57.      * @param dV velocity error (m/s)
  58.      * @since 12.2
  59.      */
  60.     AbstractVariableStepFieldIntegratorBuilder(final double minStep, final double maxStep, final double dP,
  61.                                                final double dV) {
  62.         this.minStep = minStep;
  63.         this.maxStep = maxStep;
  64.         this.dP      = dP;
  65.         this.dV      = dV;
  66.     }

  67.     /**
  68.      * Computes tolerances.
  69.      * @param orbit initial orbit
  70.      * @param orbitType orbit type for integration
  71.      * @return integrator tolerances
  72.      */
  73.     protected double[][] getTolerances(final Orbit orbit, final OrbitType orbitType) {
  74.         if (Double.isNaN(dV)) {
  75.             return NumericalPropagator.tolerances(dP, orbit, orbitType);
  76.         } else {
  77.             return NumericalPropagator.tolerances(dP, dV, orbit, orbitType);
  78.         }
  79.     }
  80. }