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