SimpleExponentialAtmosphere.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 org.hipparchus.RealFieldElement;
  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.errors.OrekitException;
  26. import org.orekit.frames.Frame;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;


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

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

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

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

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

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

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

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

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

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

  77. }