SimpleExponentialAtmosphere.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.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.hipparchus.util.FastMath;
  22. import org.orekit.bodies.BodyShape;
  23. import org.orekit.bodies.FieldGeodeticPoint;
  24. import org.orekit.bodies.GeodeticPoint;
  25. import org.orekit.frames.Frame;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.time.FieldAbsoluteDate;


  28. /** Simple exponential atmospheric model.
  29.  * <p>This model represents a simple atmosphere with an exponential
  30.  * density and rigidly bound to the underlying rotating body.</p>
  31.  * @author Fabien Maussion
  32.  * @author Luc Maisonobe
  33.  */
  34. public class SimpleExponentialAtmosphere implements Atmosphere {

  35.     /** Serializable UID.*/
  36.     private static final long serialVersionUID = 2772347498196369601L;

  37.     /** Earth shape model. */
  38.     private BodyShape    shape;

  39.     /** Reference density. */
  40.     private double       rho0;

  41.     /** Reference altitude. */
  42.     private double       h0;

  43.     /** Reference altitude scale. */
  44.     private double       hscale;

  45.     /** Create an exponential atmosphere.
  46.      * @param shape body shape model
  47.      * @param rho0 Density at the altitude h0
  48.      * @param h0 Altitude of reference (m)
  49.      * @param hscale Scale factor
  50.      */
  51.     public SimpleExponentialAtmosphere(final BodyShape shape, final double rho0,
  52.                                        final double h0, final double hscale) {
  53.         this.shape  = shape;
  54.         this.rho0   = rho0;
  55.         this.h0     = h0;
  56.         this.hscale = hscale;
  57.     }

  58.     /** {@inheritDoc} */
  59.     public Frame getFrame() {
  60.         return shape.getBodyFrame();
  61.     }

  62.     /** {@inheritDoc} */
  63.     public double getDensity(final AbsoluteDate date, final Vector3D position, final Frame frame) {
  64.         final GeodeticPoint gp = shape.transform(position, frame, date);
  65.         return rho0 * FastMath.exp((h0 - gp.getAltitude()) / hscale);
  66.     }

  67.     @Override
  68.     public <T extends CalculusFieldElement<T>> T
  69.         getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position,
  70.                    final Frame frame) {
  71.         final FieldGeodeticPoint<T> gp = shape.transform(position, frame, date);
  72.         return gp.getAltitude().subtract(h0).divide(-hscale).exp().multiply(rho0);
  73.     }

  74. }