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  
21  import org.hipparchus.exception.MathIllegalArgumentException;
22  import org.hipparchus.exception.MathIllegalStateException;
23  import org.junit.Test;
24  
25  public class AdamsBashforthIntegratorTest extends AdamsIntegratorAbstractTest {
26  
27      protected AdamsIntegrator
28      createIntegrator(final int nSteps, final double minStep, final double maxStep,
29                       final double scalAbsoluteTolerance, final double scalRelativeTolerance) {
30          return new AdamsBashforthIntegrator(nSteps, minStep, maxStep,
31                          scalAbsoluteTolerance, scalRelativeTolerance);
32      }
33  
34      protected AdamsIntegrator
35      createIntegrator(final int nSteps, final double minStep, final double maxStep,
36                       final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) {
37          return new AdamsBashforthIntegrator(nSteps, minStep, maxStep,
38                          vecAbsoluteTolerance, vecRelativeTolerance);
39      }
40  
41      @Test
42      public void testNbPoints() {
43          doNbPointsTest();
44      }
45  
46      @Test(expected=MathIllegalArgumentException.class)
47      public void testMinStep() {
48          doDimensionCheck();
49      }
50  
51      @Test
52      public void testIncreasingTolerance() {
53          // the 2.6 and 122 factors are only valid for this test
54          // and has been obtained from trial and error
55          // there are no general relationship between local and global errors
56          doTestIncreasingTolerance(2.6, 122);
57      }
58  
59      @Test(expected = MathIllegalStateException.class)
60      public void exceedMaxEvaluations() {
61          doExceedMaxEvaluations(650);
62      }
63  
64      @Test
65      public void backward() {
66          doBackward(4.3e-8, 4.3e-8, 1.0e-16, "Adams-Bashforth");
67      }
68  
69      @Test
70      public void polynomial() {
71          doPolynomial(5, 9.0e-4, 9.3e-10);
72      }
73  
74      @Test(expected=MathIllegalStateException.class)
75      public void testStartFailure() {
76          doTestStartFailure();
77      }
78  
79      @Test
80      public void testSecondaryEquations() {
81          doTestSecondaryEquations(4.3e-10, 6.7e-16);
82      }
83  
84  
85  }