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.utilities;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.BeforeEach;
21  import org.junit.jupiter.api.Test;
22  import org.orekit.Utils;
23  
24  public class NewcombOperatorTest {
25  
26      @Test
27      public void recursionTest() {
28  
29          for (int n = 2; n < 10; n++) {
30              final int mnm1 = -n - 1;
31              for (int s = 0; s < 10; s++) {
32                  final double newcomb10 = NewcombOperators.getValue(1, 0, mnm1, s);
33                  final double newcalc10 = (s - mnm1 / 2.);
34                  Assertions.assertEquals(newcalc10, newcomb10, 0.);
35                  final double newcomb11 = NewcombOperators.getValue(1, 1, mnm1, s);
36                  final double newcalc11 = (-8 * s * s + 2 * mnm1 * mnm1 + 10 * mnm1 + 12) / 8.;
37                  Assertions.assertEquals(newcalc11, newcomb11, 0.);
38                  final double newcomb20 = NewcombOperators.getValue(2, 0, mnm1, s);
39                  final double newcalc20 = (4. * s * s + 5 * s - 4 * mnm1 * s + mnm1 * mnm1 - 3 * mnm1) / 8.;
40                  Assertions.assertEquals(newcalc20, newcomb20, 0.);
41                  final double newcomb02 = NewcombOperators.getValue(0, 2, mnm1, s);
42                  final double newcalc02 = (4. * s * s - 5 * s + 4 * mnm1 * s + mnm1 * mnm1 - 3 * mnm1) / 8.;
43                  Assertions.assertEquals(newcalc02, newcomb02, 0.);
44                  final double newcomb21 = NewcombOperators.getValue(2, 1, mnm1, s);
45                  final double newcalc21 = -s*s*s/2. + (mnm1*s*s)/4. - (5.*s*s)/8. + (mnm1*mnm1*s)/8. + (21.*mnm1*s)/16. + (11*s)/8. - mnm1*mnm1*mnm1/16. - (7.*mnm1*mnm1)/16. - (9.*mnm1)/16.;
46                  Assertions.assertEquals(newcalc21, newcomb21, 1.e-14);
47                  final double newcomb12 = NewcombOperators.getValue(1, 2, mnm1, s);
48                  final double newcalc12 =  s*s*s/2. + (mnm1*s*s)/4. - (5.*s*s)/8. - (mnm1*mnm1*s)/8. - (21.*mnm1*s)/16. - (11*s)/8. - mnm1*mnm1*mnm1/16. - (7.*mnm1*mnm1)/16. - (9.*mnm1)/16.;
49                  Assertions.assertEquals(newcalc12, newcomb12, 1.e-14);
50                  final double newcomb22 = NewcombOperators.getValue(2, 2, mnm1, s);
51                  final double newcalc22 = s*s*s*s/4. - (mnm1*mnm1*s*s)/8. - mnm1*s*s - (105.*s*s)/64. + mnm1*mnm1*mnm1*mnm1/64. + (7.*mnm1*mnm1*mnm1)/32. + (71.*mnm1*mnm1)/64. + (77.*mnm1)/32. + 15./8.;
52                  Assertions.assertEquals(newcalc22, newcomb22, 1.e-14);
53              }
54          }
55      }
56  
57      @Test
58      public void valueRefTest() {
59          final int n   = -17;
60          final int s   = 14;
61          final int rho = 12;
62          final int sig = 12;
63          final double value = NewcombOperators.getValue(rho, sig, n, s);
64          Assertions.assertEquals(value, 90061805802.16286, 0.1);
65      }
66  
67      @BeforeEach
68      public void setUp() {
69          Utils.clearFactories();
70      }
71  
72  }