AbstractVariableStepIntegratorBuilder.java

  1. /* Copyright 2022-2024 Romain Serra
  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.orekit.orbits.Orbit;
  19. import org.orekit.orbits.OrbitType;
  20. import org.orekit.propagation.numerical.NumericalPropagator;

  21. /**
  22.  * Abstract class for integrator builder using variable step size.
  23.  *
  24.  * @author Romain Serra
  25.  * @since 12.2
  26.  */
  27. public abstract class AbstractVariableStepIntegratorBuilder implements ODEIntegratorBuilder {

  28.     // CHECKSTYLE: stop VisibilityModifier check
  29.     /** Minimum step size (s). */
  30.     protected final double minStep;

  31.     /** Maximum step size (s). */
  32.     protected final double maxStep;

  33.     /** Position error (m). */
  34.     protected final double dP;

  35.     /** Velocity error (m/s). */
  36.     protected final double dV;
  37.     // CHECKSTYLE: resume VisibilityModifier check

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

  48.     /**
  49.      * Constructor with expected velocity error.
  50.      *
  51.      * @param minStep minimum step size (s)
  52.      * @param maxStep maximum step size (s)
  53.      * @param dP position error (m)
  54.      * @param dV velocity error (m/s)
  55.      */
  56.     protected AbstractVariableStepIntegratorBuilder(final double minStep, final double maxStep, final double dP,
  57.                                           final double dV) {
  58.         this.minStep = minStep;
  59.         this.maxStep = maxStep;
  60.         this.dP      = dP;
  61.         this.dV      = dV;
  62.     }

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