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