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 MidpointFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
25  
26      @Override
27      protected <T extends RealFieldElement<T>> RungeKuttaFieldIntegrator<T>
28      createIntegrator(Field<T> field, T step) {
29          return new MidpointFieldIntegrator<>(field, step);
30      }
31  
32      @Override
33      public void testNonFieldIntegratorConsistency() {
34          doTestNonFieldIntegratorConsistency(Decimal64Field.getInstance());
35      }
36  
37      @Override
38      public void testMissedEndEvent() {
39          doTestMissedEndEvent(Decimal64Field.getInstance(), 1.0e-15, 6.0e-5);
40      }
41  
42      @Override
43      public void testSanityChecks() {
44          doTestSanityChecks(Decimal64Field.getInstance());
45      }
46  
47      @Override
48      public void testDecreasingSteps() {
49          doTestDecreasingSteps(Decimal64Field.getInstance(), 1.0, 1.0, 1.0e-10);
50      }
51  
52      @Override
53      public void testSmallStep() {
54          doTestSmallStep(Decimal64Field.getInstance(), 2.0e-7, 1.0e-6, 1.0e-12, "midpoint");
55      }
56  
57      @Override
58      public void testBigStep() {
59          doTestBigStep(Decimal64Field.getInstance(), 0.01, 0.05, 1.0e-12, "midpoint");
60      }
61  
62      @Override
63      public void testBackward() {
64          doTestBackward(Decimal64Field.getInstance(), 6.0e-4, 6.0e-4, 1.0e-12, "midpoint");
65      }
66  
67      @Override
68      public void testKepler() {
69          doTestKepler(Decimal64Field.getInstance(), 1.19, 0.01);
70      }
71  
72      @Override
73      public void testStepSize() {
74          doTestStepSize(Decimal64Field.getInstance(), 1.0e-12);
75      }
76  
77      @Override
78      public void testSingleStep() {
79          doTestSingleStep(Decimal64Field.getInstance(), 0.21);
80      }
81  
82      @Override
83      public void testTooLargeFirstStep() {
84          doTestTooLargeFirstStep(Decimal64Field.getInstance());
85      }
86  
87      @Override
88      public void testUnstableDerivative() {
89          doTestUnstableDerivative(Decimal64Field.getInstance(), 1.0e-12);
90      }
91  
92      @Override
93      public void testDerivativesConsistency() {
94          doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-10);
95      }
96  
97      @Override
98      public void testPartialDerivatives() {
99          doTestPartialDerivatives(1.7e-4, new double[] { 1.0e-3, 2.8e-4, 3.8e-5, 2.8e-4, 2.8e-4 });
100     }
101 }