Atmosphere.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.models.earth.atmosphere;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.orekit.frames.FieldKinematicTransform;
  22. import org.orekit.frames.Frame;
  23. import org.orekit.frames.KinematicTransform;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.time.FieldAbsoluteDate;
  26. import org.orekit.utils.FieldPVCoordinates;
  27. import org.orekit.utils.PVCoordinates;


  28. /** Interface for atmospheric models.
  29.  * @author Luc Maisonobe
  30.  */
  31. public interface Atmosphere {

  32.     /** Get the frame of the central body.
  33.      * @return frame of the central body.
  34.      * @since 6.0
  35.      */
  36.     Frame getFrame();

  37.     /** Get the local density.
  38.      * @param date current date
  39.      * @param position current position in frame
  40.      * @param frame the frame in which is defined the position
  41.      * @return local density (kg/m³)
  42.      */
  43.     double getDensity(AbsoluteDate date, Vector3D position, Frame frame);

  44.     /** Get the local density.
  45.      * @param date current date
  46.      * @param position current position in frame
  47.      * @param frame the frame in which is defined the position
  48.      * @param <T> instance of CalculusFieldElement
  49.      * @return local density (kg/m³)
  50.      */
  51.     <T extends CalculusFieldElement<T>> T getDensity(FieldAbsoluteDate<T> date, FieldVector3D<T> position, Frame frame);

  52.     /** Get the inertial velocity of atmosphere molecules.
  53.      * <p>By default, atmosphere is supposed to have a null
  54.      * velocity in the central body frame.</p>
  55.      *
  56.      * @param date current date
  57.      * @param position current position in frame
  58.      * @param frame the frame in which is defined the position
  59.      * @return velocity (m/s) (defined in the same frame as the position)
  60.      */
  61.     default Vector3D getVelocity(AbsoluteDate date, Vector3D position, Frame frame) {
  62.         final KinematicTransform bodyToFrame = getFrame().getKinematicTransformTo(frame, date);
  63.         final Vector3D      posInBody   = bodyToFrame.getStaticInverse().transformPosition(position);
  64.         final PVCoordinates pvBody      = new PVCoordinates(posInBody, Vector3D.ZERO);
  65.         final PVCoordinates pvFrame     = bodyToFrame.transformOnlyPV(pvBody);
  66.         return pvFrame.getVelocity();
  67.     }

  68.     /** Get the inertial velocity of atmosphere molecules.
  69.      * @param date current date
  70.      * @param position current position in frame
  71.      * @param frame the frame in which is defined the position
  72.      * @param <T> instance of CalculusFieldElement
  73.      * @return velocity (m/s) (defined in the same frame as the position)
  74.      */
  75.     default <T extends CalculusFieldElement<T>> FieldVector3D<T> getVelocity(FieldAbsoluteDate<T> date,
  76.                                                                              FieldVector3D<T> position,
  77.                                                                              Frame frame) {
  78.         final FieldKinematicTransform<T> bodyToFrame = getFrame().getKinematicTransformTo(frame, date);
  79.         final FieldVector3D<T>      posInBody   = bodyToFrame.getStaticInverse().transformPosition(position);
  80.         final FieldPVCoordinates<T> pvBody      = new FieldPVCoordinates<>(posInBody,
  81.                 FieldVector3D.getZero(date.getField()));
  82.         final FieldPVCoordinates<T> pvFrame     = bodyToFrame.transformOnlyPV(pvBody);
  83.         return pvFrame.getVelocity();
  84.     }

  85. }