Atmosphere.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.atmosphere;

  18. import java.io.Serializable;

  19. import org.hipparchus.RealFieldElement;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  22. import org.orekit.errors.OrekitException;
  23. import org.orekit.frames.Frame;
  24. import org.orekit.frames.Transform;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.FieldAbsoluteDate;
  27. import org.orekit.utils.FieldPVCoordinates;
  28. import org.orekit.utils.PVCoordinates;


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

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

  38.     /** Get the local density.
  39.      * @param date current date
  40.      * @param position current position in frame
  41.      * @param frame the frame in which is defined the position
  42.      * @return local density (kg/m³)
  43.      * @exception OrekitException if date is out of range of solar activity model
  44.      * or if some frame conversion cannot be performed
  45.      */
  46.     double getDensity(AbsoluteDate date, Vector3D position, Frame frame)
  47.         throws OrekitException;

  48.     /** Get the local density.
  49.      * @param date current date
  50.      * @param position current position in frame
  51.      * @param frame the frame in which is defined the position
  52.      * @param <T> instance of RealFieldElement
  53.      * @return local density (kg/m³)
  54.      * @exception OrekitException if date is out of range of solar activity model
  55.      * or if some frame conversion cannot be performed
  56.      */
  57.     <T extends RealFieldElement<T>> T getDensity(FieldAbsoluteDate<T> date, FieldVector3D<T> position, Frame frame)
  58.         throws OrekitException;

  59.     /** Get the inertial velocity of atmosphere molecules.
  60.      * <p>By default, atmosphere is supposed to have a null
  61.      * velocity in the central body frame.</p>
  62.      *
  63.      * @param date current date
  64.      * @param position current position in frame
  65.      * @param frame the frame in which is defined the position
  66.      * @return velocity (m/s) (defined in the same frame as the position)
  67.      * @exception OrekitException if some conversion cannot be performed
  68.      */
  69.     default Vector3D getVelocity(AbsoluteDate date, Vector3D position, Frame frame)
  70.         throws OrekitException {
  71.         final Transform     bodyToFrame = getFrame().getTransformTo(frame, date);
  72.         final Vector3D      posInBody   = bodyToFrame.getInverse().transformPosition(position);
  73.         final PVCoordinates pvBody      = new PVCoordinates(posInBody, Vector3D.ZERO);
  74.         final PVCoordinates pvFrame     = bodyToFrame.transformPVCoordinates(pvBody);
  75.         return pvFrame.getVelocity();
  76.     }

  77.     /** Get the inertial velocity of atmosphere molecules.
  78.      * @param date current date
  79.      * @param position current position in frame
  80.      * @param frame the frame in which is defined the position
  81.      * @param <T> instance of RealFieldElement
  82.      * @return velocity (m/s) (defined in the same frame as the position)
  83.      * @exception OrekitException if some conversion cannot be performed
  84.      */
  85.     default <T extends RealFieldElement<T>> FieldVector3D<T> getVelocity(FieldAbsoluteDate<T> date, FieldVector3D<T> position, Frame frame)
  86.         throws OrekitException {
  87.         final Transform             bodyToFrame = getFrame().getTransformTo(frame, date.toAbsoluteDate());
  88.         final FieldVector3D<T>      posInBody   = bodyToFrame.getInverse().transformPosition(position);
  89.         final FieldPVCoordinates<T> pvBody      = new FieldPVCoordinates<>(posInBody, FieldVector3D.getZero(position.getX().getField()));
  90.         final FieldPVCoordinates<T> pvFrame     = bodyToFrame.transformPVCoordinates(pvBody);
  91.         return pvFrame.getVelocity();
  92.     }

  93. }