DragForce.java

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

  44. public class DragForce extends AbstractDragForceModel {

  45.     /** Spacecraft. */
  46.     private final DragSensitive spacecraft;

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

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

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public boolean dependsOnAttitudeRate() {
  70.         return getSpacecraft().dependsOnAttitudeRate();
  71.     }

  72.     /** {@inheritDoc} */
  73.     @Override
  74.     public Vector3D acceleration(final SpacecraftState s, final double[] parameters) {

  75.         final AbsoluteDate date     = s.getDate();
  76.         final Frame        frame    = s.getFrame();
  77.         final Vector3D     position = s.getPosition();

  78.         final double rho    = getAtmosphere().getDensity(date, position, frame);
  79.         final Vector3D vAtm = getAtmosphere().getVelocity(date, position, frame);
  80.         final Vector3D relativeVelocity = vAtm.subtract(s.getPVCoordinates().getVelocity());

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

  82.     }

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

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

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

  97.     }

  98.     /** {@inheritDoc} */
  99.     @Override
  100.     public List<ParameterDriver> getParametersDrivers() {
  101.         return spacecraft.getDragParametersDrivers();
  102.     }

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

  109. }