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.Field;
22  import org.hipparchus.CalculusFieldElement;
23  import org.hipparchus.exception.MathIllegalStateException;
24  import org.hipparchus.exception.MathIllegalArgumentException;
25  import org.hipparchus.util.Binary64Field;
26  import org.junit.Test;
27  
28  public class AdamsMoultonFieldIntegratorTest extends AdamsFieldIntegratorAbstractTest {
29  
30      protected <T extends CalculusFieldElement<T>> AdamsFieldIntegrator<T>
31      createIntegrator(Field<T> field, final int nSteps, final double minStep, final double maxStep,
32                       final double scalAbsoluteTolerance, final double scalRelativeTolerance) {
33          return new AdamsMoultonFieldIntegrator<T>(field, nSteps, minStep, maxStep,
34                          scalAbsoluteTolerance, scalRelativeTolerance);
35      }
36  
37      protected <T extends CalculusFieldElement<T>> AdamsFieldIntegrator<T>
38      createIntegrator(Field<T> field, final int nSteps, final double minStep, final double maxStep,
39                       final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) {
40          return new AdamsMoultonFieldIntegrator<T>(field, nSteps, minStep, maxStep,
41                          vecAbsoluteTolerance, vecRelativeTolerance);
42      }
43  
44      @Test
45      public void testNbPoints() {
46          doNbPointsTest();
47      }
48  
49      @Test(expected=MathIllegalArgumentException.class)
50      public void testMinStep() {
51          doDimensionCheck(Binary64Field.getInstance());
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(Binary64Field.getInstance(), 0.45, 8.69);
60      }
61  
62      @Test(expected = MathIllegalStateException.class)
63      public void exceedMaxEvaluations() {
64          doExceedMaxEvaluations(Binary64Field.getInstance(), 650);
65      }
66  
67      @Test
68      public void backward() {
69          doBackward(Binary64Field.getInstance(), 3.0e-9, 3.0e-9, 1.0e-16, "Adams-Moulton");
70      }
71  
72      @Test
73      public void polynomial() {
74          doPolynomial(Binary64Field.getInstance(), 5, 2.2e-05, 2.0e-11);
75      }
76  
77      @Test
78      public void testSecondaryEquations() {
79          doTestSecondaryEquations(Binary64Field.getInstance(), 1.9e-11, 1.1e-14);
80      }
81  
82      @Test(expected=MathIllegalStateException.class)
83      public void testStartFailure() {
84          doTestStartFailure(Binary64Field.getInstance());
85      }
86  
87  }