IsotropicDrag.java

  1. /* Copyright 2002-2020 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 org.hipparchus.RealFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Rotation;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.frames.Frame;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.FieldAbsoluteDate;
  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 of
  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 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.         this.dragParametersDrivers = new ParameterDriver[1];
  66.         // in some corner cases (unknown spacecraft, fuel leaks, active piloting ...)
  67.         // the single coefficient may be arbitrary, and even negative
  68.         dragParametersDrivers[0]   = new ParameterDriver(DragSensitive.DRAG_COEFFICIENT,
  69.                                                          dragCoeff, SCALE,
  70.                                                          dragCoeffMin, dragCoeffMax);
  71.         this.crossSection = crossSection;
  72.     }

  73.     /** {@inheritDoc} */
  74.     @Override
  75.     public ParameterDriver[] getDragParametersDrivers() {
  76.         return dragParametersDrivers.clone();
  77.     }

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

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