SimpleExponentialAtmosphere.java

  1. /* Copyright 2002-2013 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;

  18. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  19. import org.apache.commons.math3.util.FastMath;
  20. import org.orekit.bodies.BodyShape;
  21. import org.orekit.bodies.GeodeticPoint;
  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.utils.PVCoordinates;


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

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

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

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

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

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

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

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

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

  67.     /** {@inheritDoc} */
  68.     public Vector3D getVelocity(final AbsoluteDate date,
  69.                                 final Vector3D position, final Frame frame)
  70.         throws OrekitException {
  71.         final Transform bodyToFrame = shape.getBodyFrame().getTransformTo(frame, date);
  72.         final Vector3D posInBody = bodyToFrame.getInverse().transformPosition(position);
  73.         final PVCoordinates pvBody = new PVCoordinates(posInBody, new Vector3D(0, 0, 0));
  74.         final PVCoordinates pvFrame = bodyToFrame.transformPVCoordinates(pvBody);
  75.         return pvFrame.getVelocity();
  76.     }

  77. }