View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) 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 ASF 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  
18  package org.apache.commons.math4.legacy.ode.nonstiff;
19  
20  
21  import org.apache.commons.math4.legacy.core.Field;
22  import org.apache.commons.math4.legacy.core.RealFieldElement;
23  import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
24  import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
25  import org.apache.commons.math4.legacy.exception.NoBracketingException;
26  import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
27  
28  public class LutherFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
29  
30      @Override
31      protected <T extends RealFieldElement<T>> RungeKuttaFieldIntegrator<T>
32      createIntegrator(Field<T> field, T step) {
33          return new LutherFieldIntegrator<>(field, step);
34      }
35  
36      @Override
37      public void testNonFieldIntegratorConsistency() {
38          doTestNonFieldIntegratorConsistency(Decimal64Field.getInstance());
39      }
40  
41      @Override
42      public void testMissedEndEvent()
43          throws DimensionMismatchException, NumberIsTooSmallException,
44                 MaxCountExceededException, NoBracketingException {
45          doTestMissedEndEvent(Decimal64Field.getInstance(), 1.0e-15, 1.0e-15);
46      }
47  
48      @Override
49      public void testSanityChecks()
50          throws DimensionMismatchException, NumberIsTooSmallException,
51                 MaxCountExceededException, NoBracketingException {
52          doTestSanityChecks(Decimal64Field.getInstance());
53      }
54  
55      @Override
56      public void testDecreasingSteps()
57          throws DimensionMismatchException, NumberIsTooSmallException,
58                 MaxCountExceededException, NoBracketingException {
59          doTestDecreasingSteps(Decimal64Field.getInstance(), 1.0, 1.0, 1.0e-10);
60      }
61  
62      @Override
63      public void testSmallStep()
64           throws DimensionMismatchException, NumberIsTooSmallException,
65                  MaxCountExceededException, NoBracketingException {
66          doTestSmallStep(Decimal64Field.getInstance(), 8.7e-17, 3.6e-15, 1.0e-12, "Luther");
67      }
68  
69      @Override
70      public void testBigStep()
71          throws DimensionMismatchException, NumberIsTooSmallException,
72                 MaxCountExceededException, NoBracketingException {
73          doTestBigStep(Decimal64Field.getInstance(), 2.7e-5, 1.7e-3, 1.0e-12, "Luther");
74      }
75  
76      @Override
77      public void testBackward()
78          throws DimensionMismatchException, NumberIsTooSmallException,
79                 MaxCountExceededException, NoBracketingException {
80          doTestBackward(Decimal64Field.getInstance(), 2.4e-13, 4.3e-13, 1.0e-12, "Luther");
81      }
82  
83      @Override
84      public void testKepler()
85          throws DimensionMismatchException, NumberIsTooSmallException,
86                 MaxCountExceededException, NoBracketingException {
87          doTestKepler(Decimal64Field.getInstance(), 2.18e-7, 4.0e-10);
88      }
89  
90      @Override
91      public void testStepSize()
92          throws DimensionMismatchException, NumberIsTooSmallException,
93                 MaxCountExceededException, NoBracketingException {
94          doTestStepSize(Decimal64Field.getInstance(), 1.0e-22);
95      }
96  
97      @Override
98      public void testSingleStep() {
99          doTestSingleStep(Decimal64Field.getInstance(), 6.0e-12);
100     }
101 
102     @Override
103     public void testTooLargeFirstStep() {
104         doTestTooLargeFirstStep(Decimal64Field.getInstance());
105     }
106 
107     @Override
108     public void testUnstableDerivative() {
109         doTestUnstableDerivative(Decimal64Field.getInstance(), 4.0e-15);
110     }
111 
112     @Override
113     public void testDerivativesConsistency() {
114         doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-20);
115     }
116 
117     @Override
118     public void testPartialDerivatives() {
119         doTestPartialDerivatives(4.3e-13, new double[] { 2.2e-12, 5.6e-13, 9.4e-14, 9.4e-14, 5.6e-13 });
120     }
121 }