DragForce.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.List;

  19. import org.hipparchus.CalculusFieldElement;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.models.earth.atmosphere.Atmosphere;
  24. import org.orekit.propagation.FieldSpacecraftState;
  25. import org.orekit.propagation.SpacecraftState;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.time.FieldAbsoluteDate;
  28. import org.orekit.utils.ParameterDriver;


  29. /** Atmospheric drag force model.
  30.  * The drag acceleration is computed as follows :
  31.  * γ = (1/2 * ρ * V² * S / Mass) * DragCoefVector
  32.  * With DragCoefVector = {C<sub>x</sub>, C<sub>y</sub>, C<sub>z</sub>} and S given by the user through the interface
  33.  * {@link DragSensitive}
  34.  *
  35.  * @author &Eacute;douard Delente
  36.  * @author Fabien Maussion
  37.  * @author V&eacute;ronique Pommier-Maurussane
  38.  * @author Pascal Parraud
  39.  * @author Melina Vanel
  40.  */

  41. public class DragForce extends AbstractDragForceModel {

  42.     /** Spacecraft. */
  43.     private final DragSensitive spacecraft;

  44.     /** Constructor with default flag for finite differences.
  45.      * @param atmosphere atmospheric model
  46.      * @param spacecraft the object physical and geometrical information
  47.      */
  48.     public DragForce(final Atmosphere atmosphere, final DragSensitive spacecraft) {
  49.         super(atmosphere);
  50.         this.spacecraft = spacecraft;
  51.     }

  52.     /** Simple constructor.
  53.      * @param atmosphere atmospheric model
  54.      * @param spacecraft the object physical and geometrical information
  55.      * @param useFiniteDifferencesOnDensityWrtPosition flag to use finite differences to compute density derivatives w.r.t.
  56.      *                                                 position (is less accurate but can be faster depending on model)
  57.      * @since 12.1
  58.      */
  59.     public DragForce(final Atmosphere atmosphere, final DragSensitive spacecraft,
  60.                      final boolean useFiniteDifferencesOnDensityWrtPosition) {
  61.         super(atmosphere, useFiniteDifferencesOnDensityWrtPosition);
  62.         this.spacecraft = spacecraft;
  63.     }

  64.     /** {@inheritDoc} */
  65.     @Override
  66.     public boolean dependsOnAttitudeRate() {
  67.         return getSpacecraft().dependsOnAttitudeRate();
  68.     }

  69.     /** {@inheritDoc} */
  70.     @Override
  71.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {

  72.         final AbsoluteDate date     = s.getDate();
  73.         final Frame        frame    = s.getFrame();
  74.         final Vector3D     position = s.getPosition();

  75.         final double rho    = getAtmosphere().getDensity(date, position, frame);
  76.         final Vector3D vAtm = getAtmosphere().getVelocity(date, position, frame);
  77.         final Vector3D relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());

  78.         return spacecraft.dragAcceleration(s, rho, relativeVelocity, parameters);

  79.     }

  80.     /** {@inheritDoc} */
  81.     @Override
  82.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(final FieldSpacecraftState<T> s,
  83.                                                                              final T[] parameters) {
  84.         // Density and its derivatives
  85.         final T rho = getFieldDensity(s);

  86.         // Spacecraft relative velocity with respect to the atmosphere
  87.         final FieldAbsoluteDate<T> date     = s.getDate();
  88.         final Frame                frame    = s.getFrame();
  89.         final FieldVector3D<T>     position = s.getPosition();
  90.         final FieldVector3D<T> vAtm = getAtmosphere().getVelocity(date, position, frame);
  91.         final FieldVector3D<T> relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());

  92.         // Drag acceleration along with its derivatives
  93.         return spacecraft.dragAcceleration(s, rho, relativeVelocity, parameters);

  94.     }

  95.     /** {@inheritDoc} */
  96.     @Override
  97.     public List<ParameterDriver> getParametersDrivers() {
  98.         return spacecraft.getDragParametersDrivers();
  99.     }

  100.     /** Get spacecraft that are sensitive to atmospheric drag forces.
  101.      * @return drag sensitive spacecraft model
  102.      */
  103.     public DragSensitive getSpacecraft() {
  104.         return spacecraft;
  105.     }

  106. }