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.propagation.semianalytical.dsst.forces;
18  
19  import org.hipparchus.util.FastMath;
20  import org.junit.jupiter.api.Assertions;
21  import org.junit.jupiter.api.BeforeEach;
22  import org.junit.jupiter.api.Test;
23  import org.orekit.Utils;
24  import org.orekit.frames.Frame;
25  import org.orekit.frames.FramesFactory;
26  import org.orekit.orbits.EquinoctialOrbit;
27  import org.orekit.orbits.PositionAngleType;
28  import org.orekit.propagation.SpacecraftState;
29  import org.orekit.propagation.semianalytical.dsst.utilities.AuxiliaryElements;
30  import org.orekit.time.AbsoluteDate;
31  import org.orekit.time.TimeScalesFactory;
32  
33  import java.io.IOException;
34  import java.text.ParseException;
35  import java.util.Arrays;
36  
37  class DSSTNewtonianAttractionTest {
38  
39      private static final double eps  = 1.0e-19;
40  
41      @Test
42      void testGetMeanElementRate() throws IllegalArgumentException {
43  
44          final Frame earthFrame = FramesFactory.getEME2000();
45  
46          final AbsoluteDate date = new AbsoluteDate(2007, 04, 16, 0, 46, 42.400, TimeScalesFactory.getUTC());
47  
48          final double mu = 3.986004415E14;
49          final EquinoctialOrbit orbit = new EquinoctialOrbit(2.655989E7,
50                                                              2.719455286199036E-4,
51                                                              0.0041543085910249414,
52                                                              -0.3412974060023717,
53                                                              0.3960084733107685,
54                                                              FastMath.toRadians(44.2377),
55                                                              PositionAngleType.MEAN,
56                                                              earthFrame,
57                                                              date,
58                                                              mu);
59  
60          final SpacecraftState state = new SpacecraftState(orbit);
61  
62          final AuxiliaryElements auxiliaryElements = new AuxiliaryElements(state.getOrbit(), 1);
63  
64          final DSSTForceModel newton = new DSSTNewtonianAttraction(mu);
65  
66          final double[] elements = new double[7];
67          Arrays.fill(elements, 0.0);
68  
69          final double[] daidt = newton.getMeanElementRate(state, auxiliaryElements, newton.getParameters());
70  
71          for (int i = 0; i < daidt.length; i++) {
72              elements[i] = daidt[i];
73          }
74  
75          Assertions.assertEquals(0.0,                   elements[0], eps);
76          Assertions.assertEquals(0.0,                   elements[1], eps);
77          Assertions.assertEquals(0.0,                   elements[2], eps);
78          Assertions.assertEquals(0.0,                   elements[3], eps);
79          Assertions.assertEquals(0.0,                   elements[4], eps);
80          Assertions.assertEquals(1.4585773985530907E-4, elements[5], eps);
81  
82      }
83  
84      @BeforeEach
85      public void setUp() throws IOException, ParseException {
86          Utils.setDataRoot("regular-data");
87      }
88  
89  }