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

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

  20. import org.hipparchus.CalculusFieldElement;
  21. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  22. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  23. import org.hipparchus.geometry.euclidean.threed.Rotation;
  24. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  25. import org.hipparchus.util.FastMath;
  26. import org.orekit.frames.Frame;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.ParameterDriver;

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

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

  48.     /** Drivers for drag coefficient parameter. */
  49.     private final ParameterDriver dragParametersDrivers;

  50.     /** Cross section (m²). */
  51.     private final double crossSection;

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

  59.     /** Constructor with drag coefficient min/max set by user.
  60.      * @param crossSection Surface (m²)
  61.      * @param dragCoeff drag coefficient
  62.      * @param dragCoeffMin Minimum value of drag coefficient
  63.      * @param dragCoeffMax Maximum value of drag coefficient
  64.      */
  65.     public IsotropicDrag(final double crossSection, final double dragCoeff,
  66.                          final double dragCoeffMin, final double dragCoeffMax) {
  67.         // in some corner cases (unknown spacecraft, fuel leaks, active piloting ...)
  68.         // the single coefficient may be arbitrary, and even negative
  69.         this.dragParametersDrivers = new ParameterDriver(DragSensitive.DRAG_COEFFICIENT,
  70.                                                          dragCoeff, SCALE,
  71.                                                          dragCoeffMin, dragCoeffMax);
  72.         this.crossSection = crossSection;
  73.     }

  74.     /** {@inheritDoc} */
  75.     @Override
  76.     public List<ParameterDriver> getDragParametersDrivers() {
  77.         return Collections.singletonList(dragParametersDrivers);
  78.     }

  79.     /** {@inheritDoc} */
  80.     @Override
  81.     public Vector3D dragAcceleration(final AbsoluteDate date, final Frame frame, final Vector3D position,
  82.                                      final Rotation rotation, final double mass,
  83.                                      final double density, final Vector3D relativeVelocity,
  84.                                      final double[] parameters) {
  85.         final double dragCoeff = parameters[0];
  86.         return new Vector3D(relativeVelocity.getNorm() * density * dragCoeff * crossSection / (2 * mass),
  87.                             relativeVelocity);
  88.     }

  89.     /** {@inheritDoc} */
  90.     @Override
  91.     public <T extends CalculusFieldElement<T>> FieldVector3D<T>
  92.         dragAcceleration(final FieldAbsoluteDate<T> date, final Frame frame,
  93.                          final FieldVector3D<T> position, final FieldRotation<T> rotation,
  94.                          final T mass, final T density,
  95.                          final FieldVector3D<T> relativeVelocity,
  96.                          final T[] parameters) {
  97.         final T dragCoeff = parameters[0];
  98.         return new FieldVector3D<>(relativeVelocity.getNorm().multiply(density.multiply(dragCoeff).multiply(crossSection / 2)).divide(mass),
  99.                                    relativeVelocity);
  100.     }
  101. }