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