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
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
21 import org.hipparchus.geometry.euclidean.threed.Vector3D;
22 import org.hipparchus.util.FastMath;
23 import org.orekit.bodies.BodyShape;
24 import org.orekit.bodies.FieldGeodeticPoint;
25 import org.orekit.bodies.GeodeticPoint;
26 import org.orekit.frames.Frame;
27 import org.orekit.time.AbsoluteDate;
28 import org.orekit.time.FieldAbsoluteDate;
29
30
31 /** Simple exponential atmospheric model.
32 * <p>This model represents a simple atmosphere with an exponential
33 * density and rigidly bound to the underlying rotating body.</p>
34 * @author Fabien Maussion
35 * @author Luc Maisonobe
36 */
37 public class SimpleExponentialAtmosphere implements Atmosphere {
38
39 /** Serializable UID.*/
40 private static final long serialVersionUID = 2772347498196369601L;
41
42 /** Earth shape model. */
43 private BodyShape shape;
44
45 /** Reference density. */
46 private double rho0;
47
48 /** Reference altitude. */
49 private double h0;
50
51 /** Reference altitude scale. */
52 private double hscale;
53
54 /** Create an exponential atmosphere.
55 * @param shape body shape model
56 * @param rho0 Density at the altitude h0
57 * @param h0 Altitude of reference (m)
58 * @param hscale Scale factor
59 */
60 public SimpleExponentialAtmosphere(final BodyShape shape, final double rho0,
61 final double h0, final double hscale) {
62 this.shape = shape;
63 this.rho0 = rho0;
64 this.h0 = h0;
65 this.hscale = hscale;
66 }
67
68 /** {@inheritDoc} */
69 public Frame getFrame() {
70 return shape.getBodyFrame();
71 }
72
73 /** {@inheritDoc} */
74 public double getDensity(final AbsoluteDate date, final Vector3D position, final Frame frame) {
75 final GeodeticPoint gp = shape.transform(position, frame, date);
76 return rho0 * FastMath.exp((h0 - gp.getAltitude()) / hscale);
77 }
78
79 @Override
80 public <T extends CalculusFieldElement<T>> T
81 getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position,
82 final Frame frame) {
83 final FieldGeodeticPoint<T> gp = shape.transform(position, frame, date);
84 return gp.getAltitude().subtract(h0).divide(-hscale).exp().multiply(rho0);
85 }
86
87 }