1 /* Copyright 2002-2021 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 java.io.Serializable;
20
21 import org.hipparchus.CalculusFieldElement;
22 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
23 import org.hipparchus.geometry.euclidean.threed.Vector3D;
24 import org.orekit.frames.Frame;
25 import org.orekit.frames.Transform;
26 import org.orekit.time.AbsoluteDate;
27 import org.orekit.time.FieldAbsoluteDate;
28 import org.orekit.utils.FieldPVCoordinates;
29 import org.orekit.utils.PVCoordinates;
30
31
32 /** Interface for atmospheric models.
33 * @author Luc Maisonobe
34 */
35 public interface Atmosphere extends Serializable {
36
37 /** Get the frame of the central body.
38 * @return frame of the central body.
39 * @since 6.0
40 */
41 Frame getFrame();
42
43 /** Get the local density.
44 * @param date current date
45 * @param position current position in frame
46 * @param frame the frame in which is defined the position
47 * @return local density (kg/m³)
48 */
49 double getDensity(AbsoluteDate date, Vector3D position, Frame frame);
50
51 /** Get the local density.
52 * @param date current date
53 * @param position current position in frame
54 * @param frame the frame in which is defined the position
55 * @param <T> instance of CalculusFieldElement
56 * @return local density (kg/m³)
57 */
58 <T extends CalculusFieldElement<T>> T getDensity(FieldAbsoluteDate<T> date, FieldVector3D<T> position, Frame frame);
59
60 /** Get the inertial velocity of atmosphere molecules.
61 * <p>By default, atmosphere is supposed to have a null
62 * velocity in the central body frame.</p>
63 *
64 * @param date current date
65 * @param position current position in frame
66 * @param frame the frame in which is defined the position
67 * @return velocity (m/s) (defined in the same frame as the position)
68 */
69 default Vector3D getVelocity(AbsoluteDate date, Vector3D position, Frame frame) {
70 final Transform bodyToFrame = getFrame().getTransformTo(frame, date);
71 final Vector3D posInBody = bodyToFrame.getInverse().transformPosition(position);
72 final PVCoordinates pvBody = new PVCoordinates(posInBody, Vector3D.ZERO);
73 final PVCoordinates pvFrame = bodyToFrame.transformPVCoordinates(pvBody);
74 return pvFrame.getVelocity();
75 }
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 CalculusFieldElement
82 * @return velocity (m/s) (defined in the same frame as the position)
83 */
84 default <T extends CalculusFieldElement<T>> FieldVector3D<T> getVelocity(FieldAbsoluteDate<T> date, FieldVector3D<T> position, Frame frame) {
85 final Transform bodyToFrame = getFrame().getTransformTo(frame, date.toAbsoluteDate());
86 final FieldVector3D<T> posInBody = bodyToFrame.getInverse().transformPosition(position);
87 final FieldPVCoordinates<T> pvBody = new FieldPVCoordinates<>(posInBody, FieldVector3D.getZero(position.getX().getField()));
88 final FieldPVCoordinates<T> pvFrame = bodyToFrame.transformPVCoordinates(pvBody);
89 return pvFrame.getVelocity();
90 }
91
92 }