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  import org.hipparchus.ode.EquationsMapper;
21  import org.hipparchus.ode.ODEStateAndDerivative;
22  import org.hipparchus.util.FastMath;
23  
24  
25  /**
26   * This class implements the Gill fourth order Runge-Kutta
27   * integrator for Ordinary Differential Equations .
28  
29   * <p>This method is an explicit Runge-Kutta method, its Butcher-array
30   * is the following one :</p>
31   * <pre>
32   *    0  |    0        0       0      0
33   *   1/2 |   1/2       0       0      0
34   *   1/2 | (q-1)/2  (2-q)/2    0      0
35   *    1  |    0       -q/2  (2+q)/2   0
36   *       |-------------------------------
37   *       |   1/6    (2-q)/6 (2+q)/6  1/6
38   * </pre>
39   * <p>where q = sqrt(2)</p>
40   *
41   * @see EulerIntegrator
42   * @see ClassicalRungeKuttaIntegrator
43   * @see MidpointIntegrator
44   * @see ThreeEighthesIntegrator
45   * @see LutherIntegrator
46   */
47  
48  public class GillIntegrator extends RungeKuttaIntegrator {
49  
50      /** Name of integration scheme. */
51      public static final String METHOD_NAME = "Gill";
52  
53      /** Simple constructor.
54       * Build a fourth-order Gill integrator with the given step.
55       * @param step integration step
56       */
57      public GillIntegrator(final double step) {
58          super(METHOD_NAME, step);
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public double[] getC() {
64          return new double[] {
65              1.0 / 2.0, 1.0 / 2.0, 1.0
66          };
67      }
68  
69      /** {@inheritDoc} */
70      @Override
71      public double[][] getA() {
72          return new double[][] {
73              { 1.0 / 2.0 },
74              { (FastMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - FastMath.sqrt(2.0)) / 2.0 },
75              { 0.0, -FastMath.sqrt(2.0) / 2.0, (2.0 + FastMath.sqrt(2.0)) / 2.0 }
76          };
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public double[] getB() {
82          return new double[] {
83              1.0 / 6.0, (2.0 - FastMath.sqrt(2.0)) / 6.0, (2.0 + FastMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
84          };
85      }
86  
87      /** {@inheritDoc} */
88      @Override
89      protected GillStateInterpolator
90      createInterpolator(final boolean forward, double[][] yDotK,
91                         final ODEStateAndDerivative globalPreviousState,
92                         final ODEStateAndDerivative globalCurrentState,
93                         final EquationsMapper mapper) {
94          return new GillStateInterpolator(forward, yDotK,
95                                          globalPreviousState, globalCurrentState,
96                                          globalPreviousState, globalCurrentState,
97                                          mapper);
98      }
99  
100 }