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