IsotropicDrag.java

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

  18. import java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.CalculusFieldElement;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.hipparchus.util.FastMath;
  25. import org.orekit.propagation.FieldSpacecraftState;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.utils.ParameterDriver;

  28. /** This class models isotropic drag effects.
  29.  * <p>The model of this spacecraft is a simple spherical model, this
  30.  * means that all coefficients are constant and do not depend on
  31.  * the direction.</p>
  32.  *
  33.  * @see org.orekit.forces.BoxAndSolarArraySpacecraft
  34.  * @see org.orekit.forces.radiation.IsotropicRadiationCNES95Convention
  35.  * @author Luc Maisonobe
  36.  * @since 7.1
  37.  */
  38. public class IsotropicDrag implements DragSensitive {

  39.     /** Parameters scaling factor.
  40.      * <p>
  41.      * We use a power of 2 to avoid numeric noise introduction
  42.      * in the multiplications/divisions sequences.
  43.      * </p>
  44.      */
  45.     private final double SCALE = FastMath.scalb(1.0, -3);

  46.     /** Drivers for drag coefficient parameter. */
  47.     private final List<ParameterDriver> dragParametersDrivers;

  48.     /** Cross section (m²). */
  49.     private final double crossSection;

  50.     /** Constructor with drag coefficient min/max set to ±∞.
  51.      * @param crossSection Surface (m²)
  52.      * @param dragCoeff drag coefficient
  53.      */
  54.     public IsotropicDrag(final double crossSection, final double dragCoeff) {
  55.         this(crossSection, dragCoeff, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
  56.     }

  57.     /** Constructor with drag coefficient min/max set by user.
  58.      * @param crossSection Surface (m²)
  59.      * @param dragCoeff drag coefficient
  60.      * @param dragCoeffMin Minimum value of drag coefficient
  61.      * @param dragCoeffMax Maximum value of drag coefficient
  62.      */
  63.     public IsotropicDrag(final double crossSection, final double dragCoeff,
  64.                          final double dragCoeffMin, final double dragCoeffMax) {
  65.         // in some corner cases (unknown spacecraft, fuel leaks, active piloting ...)
  66.         // the single coefficient may be arbitrary, and even negative
  67.         // the DRAG_COEFFICIENT parameter should be sufficient, but GLOBAL_DRAG_FACTOR
  68.         // was added as of 12.0 for consistency with BoxAndSolarArraySpacecraft
  69.         // that only has a global multiplication factor, hence allowing this name
  70.         // to be used for both models
  71.         this.dragParametersDrivers = new ArrayList<>(2);
  72.         dragParametersDrivers.add(new ParameterDriver(DragSensitive.GLOBAL_DRAG_FACTOR,
  73.                                                       1.0, SCALE,
  74.                                                       0.0, Double.POSITIVE_INFINITY));
  75.         dragParametersDrivers.add(new ParameterDriver(DragSensitive.DRAG_COEFFICIENT,
  76.                                                       dragCoeff, SCALE,
  77.                                                       dragCoeffMin, dragCoeffMax));
  78.         this.crossSection = crossSection;
  79.     }

  80.     /** {@inheritDoc} */
  81.     @Override
  82.     public List<ParameterDriver> getDragParametersDrivers() {
  83.         return Collections.unmodifiableList(dragParametersDrivers);
  84.     }

  85.     /** {@inheritDoc} */
  86.     @Override
  87.     public Vector3D dragAcceleration(final SpacecraftState state,
  88.                                      final double density, final Vector3D relativeVelocity,
  89.                                      final double[] parameters) {
  90.         final double dragCoeff = parameters[0] * parameters[1];
  91.         return new Vector3D(relativeVelocity.getNorm() * density * dragCoeff * crossSection / (2 * state.getMass()),
  92.                             relativeVelocity);
  93.     }

  94.     /** {@inheritDoc} */
  95.     @Override
  96.     public <T extends CalculusFieldElement<T>> FieldVector3D<T>
  97.         dragAcceleration(final FieldSpacecraftState<T> state, final T density,
  98.                          final FieldVector3D<T> relativeVelocity,
  99.                          final T[] parameters) {
  100.         final T dragCoeff = parameters[0].multiply(parameters[1]);
  101.         return new FieldVector3D<>(relativeVelocity.getNorm().
  102.                                    multiply(density.multiply(dragCoeff).multiply(crossSection / 2)).
  103.                                    divide(state.getMass()),
  104.                                    relativeVelocity);
  105.     }
  106. }