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 EulerFieldIntegratorTest extends RungeKuttaFieldIntegratorAbstractTest {
25  
26      @Override
27      protected <T extends RealFieldElement<T>> RungeKuttaFieldIntegrator<T>
28      createIntegrator(Field<T> field, T step) {
29          return new EulerFieldIntegrator<>(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.5, 1.0e-10);
50      }
51  
52      @Override
53      public void testSmallStep() {
54          doTestSmallStep(Decimal64Field.getInstance(), 2.0e-4, 1.0e-3, 1.0e-12, "Euler");
55      }
56  
57      @Override
58      public void testBigStep() {
59          doTestBigStep(Decimal64Field.getInstance(), 0.01, 0.2, 1.0e-12, "Euler");
60      }
61  
62      @Override
63      public void testBackward() {
64          doTestBackward(Decimal64Field.getInstance(),0.45, 0.45, 1.0e-12, "Euler");
65      }
66  
67      @Override
68      public void testKepler() {
69          // Euler integrator is clearly not able to solve this problem
70          doTestKepler(Decimal64Field.getInstance(), 881.176, 0.001);
71      }
72  
73      @Override
74      public void testStepSize() {
75          doTestStepSize(Decimal64Field.getInstance(), 1.0e-12);
76      }
77  
78      @Override
79      public void testSingleStep() {
80          doTestSingleStep(Decimal64Field.getInstance(), 0.21);
81      }
82  
83      @Override
84      public void testTooLargeFirstStep() {
85          doTestTooLargeFirstStep(Decimal64Field.getInstance());
86      }
87  
88      @Override
89      public void testUnstableDerivative() {
90          doTestUnstableDerivative(Decimal64Field.getInstance(), 1.0e-12);
91      }
92  
93      @Override
94      public void testDerivativesConsistency() {
95          doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-10);
96      }
97  
98      @Override
99      public void testPartialDerivatives() {
100         doTestPartialDerivatives(0.085, new double[] { 0.47, 0.13, 0.019, 0.019, 0.13 });
101     }
102 }