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;
18  
19  import org.hipparchus.util.FastMath;
20  import org.junit.jupiter.api.AfterEach;
21  import org.junit.jupiter.api.Assertions;
22  import org.junit.jupiter.api.BeforeEach;
23  import org.junit.jupiter.api.Test;
24  
25  public class EarthStandardAtmosphereTest {
26  
27      private final double epsilon = 1e-15;
28  
29      @BeforeEach
30      public void setUp()
31          throws Exception {
32      }
33  
34      @AfterEach
35      public void tearDown()
36          throws Exception {
37      }
38  
39      @Test
40      public void testEarthStandardAtmosphereRefraction() {
41          EarthStandardAtmosphereRefraction model = new EarthStandardAtmosphereRefraction();
42  
43          Assertions.assertEquals(model.getPressure(), EarthStandardAtmosphereRefraction.DEFAULT_PRESSURE, epsilon);
44          Assertions.assertEquals(model.getTemperature(), EarthStandardAtmosphereRefraction.DEFAULT_TEMPERATURE, epsilon);
45      }
46  
47      @Test
48      public void testEarthStandardAtmosphereRefractionDoubleDouble() {
49          final double pressure = 100e3;
50          final double temperature = 270;
51          EarthStandardAtmosphereRefraction model = new EarthStandardAtmosphereRefraction(pressure, temperature);
52  
53          Assertions.assertEquals(model.getPressure(), pressure, epsilon);
54          Assertions.assertEquals(model.getTemperature(), temperature, epsilon);
55      }
56  
57      @Test
58      public void testSetGetPressure() {
59          double pressure = 100e3;
60          double temperature = 270;
61          EarthStandardAtmosphereRefraction model = new EarthStandardAtmosphereRefraction(pressure, temperature);
62  
63          Assertions.assertEquals(model.getPressure(), pressure, epsilon);
64  
65          pressure = 105389.2;
66          model.setPressure(pressure);
67  
68          Assertions.assertEquals(model.getPressure(), pressure, epsilon);
69      }
70  
71      @Test
72      public void testSetGetTemperature() {
73          double pressure = 100e3;
74          double temperature = 270;
75          EarthStandardAtmosphereRefraction model = new EarthStandardAtmosphereRefraction(pressure, temperature);
76  
77          Assertions.assertEquals(model.getTemperature(), temperature, epsilon);
78  
79          temperature = 273;
80          model.setTemperature(temperature);
81  
82          Assertions.assertEquals(model.getTemperature(), temperature, epsilon);
83  
84      }
85  
86      @Test
87      public void testGetRefraction() {
88          double pressure = 101325;
89          double temperature = 290;
90          EarthStandardAtmosphereRefraction model = new EarthStandardAtmosphereRefraction(pressure, temperature);
91  
92          double refractedElevation = model.getRefraction(FastMath.toRadians(1.0));
93  
94          Assertions.assertEquals(0.0061922285, refractedElevation, 1e-9);
95      }
96  
97  }