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  
24  public class HighamHall54FieldIntegratorTest extends EmbeddedRungeKuttaFieldIntegratorAbstractTest {
25  
26      @Override
27      protected <T extends RealFieldElement<T>> EmbeddedRungeKuttaFieldIntegrator<T>
28      createIntegrator(Field<T> field, final double minStep, final double maxStep,
29                       final double scalAbsoluteTolerance, final double scalRelativeTolerance) {
30          return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
31      }
32  
33      @Override
34      protected <T extends RealFieldElement<T>> EmbeddedRungeKuttaFieldIntegrator<T>
35      createIntegrator(Field<T> field, final double minStep, final double maxStep,
36                       final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) {
37          return new HighamHall54FieldIntegrator<>(field, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
38      }
39  
40      @Override
41      public void testNonFieldIntegratorConsistency() {
42          doTestNonFieldIntegratorConsistency(Decimal64Field.getInstance());
43      }
44  
45      @Override
46      public void testSanityChecks() {
47          doTestSanityChecks(Decimal64Field.getInstance());
48      }
49  
50      @Override
51      public void testBackward() {
52          doTestBackward(Decimal64Field.getInstance(), 5.0e-7, 5.0e-7, 1.0e-12, "Higham-Hall 5(4)");
53      }
54  
55      @Override
56      public void testKepler() {
57          doTestKepler(Decimal64Field.getInstance(), 1.5e-4);
58      }
59  
60      @Override
61      public void testForwardBackwardExceptions() {
62          doTestForwardBackwardExceptions(Decimal64Field.getInstance());
63      }
64  
65      @Override
66      public void testMinStep() {
67          doTestMinStep(Decimal64Field.getInstance());
68      }
69  
70      @Override
71      public void testIncreasingTolerance() {
72          // the 1.3 factor is only valid for this test
73          // and has been obtained from trial and error
74          // there is no general relation between local and global errors
75          doTestIncreasingTolerance(Decimal64Field.getInstance(), 1.3, 1.0e-12);
76      }
77  
78      @Override
79      public void testEvents() {
80          doTestEvents(Decimal64Field.getInstance(), 1.0e-7, "Higham-Hall 5(4)");
81      }
82  
83      @Override
84      public void testEventsErrors() {
85          doTestEventsErrors(Decimal64Field.getInstance());
86      }
87  
88      @Override
89      public void testEventsNoConvergence() {
90          doTestEventsNoConvergence(Decimal64Field.getInstance());
91      }
92  
93      @Override
94      public void testPartialDerivatives() {
95          doTestPartialDerivatives(1.2e-11, new double[] { 6.4e-11, 1.8e-11, 2.4e-12, 2.2e-12, 1.8e-11 });
96      }
97  }