View Javadoc
1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The Hipparchus project 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    *      https://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  
18  package org.hipparchus.ode.nonstiff;
19  
20  import org.hipparchus.exception.MathIllegalArgumentException;
21  import org.hipparchus.exception.MathIllegalStateException;
22  import org.junit.jupiter.api.Test;
23  
24  import static org.junit.jupiter.api.Assertions.assertThrows;
25  
26  class AdamsMoultonIntegratorTest extends AdamsIntegratorAbstractTest {
27  
28      protected AdamsIntegrator
29      createIntegrator(final int nSteps, final double minStep, final double maxStep,
30                       final double scalAbsoluteTolerance, final double scalRelativeTolerance) {
31          return new AdamsMoultonIntegrator(nSteps, minStep, maxStep,
32                                            scalAbsoluteTolerance, scalRelativeTolerance);
33      }
34  
35      protected AdamsIntegrator
36      createIntegrator(final int nSteps, final double minStep, final double maxStep,
37                       final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) {
38          return new AdamsMoultonIntegrator(nSteps, minStep, maxStep,
39                                            vecAbsoluteTolerance, vecRelativeTolerance);
40      }
41  
42      @Test
43      void testNbPoints() {
44          doNbPointsTest();
45      }
46  
47      @Test
48      public void testMinStep() {
49          assertThrows(MathIllegalArgumentException.class, () -> {
50              doDimensionCheck();
51          });
52      }
53  
54      @Test
55      public void testIncreasingTolerance() {
56          // the 0.45 and 8.69 factors are only valid for this test
57          // and has been obtained from trial and error
58          // there are no general relationship between local and global errors
59          doTestIncreasingTolerance(0.45, 8.69);
60      }
61  
62      @Test
63      public void exceedMaxEvaluations() {
64          assertThrows(MathIllegalStateException.class, () -> {
65              doExceedMaxEvaluations(650);
66          });
67      }
68  
69      @Test
70      public void backward() {
71          doBackward(3.0e-9, 3.0e-9, 1.0e-16, "Adams-Moulton");
72      }
73  
74      @Test
75      public void polynomial() {
76          doPolynomial(5, 2.2e-05, 2.0e-11);
77      }
78  
79      @Test
80      public void testSecondaryEquations() {
81          doTestSecondaryEquations(1.9e-11, 7.2e-15);
82      }
83  
84      @Test
85      public void testStartFailure() {
86          assertThrows(MathIllegalStateException.class, () -> {
87              doTestStartFailure();
88          });
89      }
90  
91  }