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 import org.apache.commons.math4.core.jdkmath.JdkMath;
21
22
23 /**
24 * This class implements the Gill fourth order Runge-Kutta
25 * integrator for Ordinary Differential Equations .
26
27 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
28 * is the following one :
29 * <pre>
30 * 0 | 0 0 0 0
31 * 1/2 | 1/2 0 0 0
32 * 1/2 | (q-1)/2 (2-q)/2 0 0
33 * 1 | 0 -q/2 (2+q)/2 0
34 * |-------------------------------
35 * | 1/6 (2-q)/6 (2+q)/6 1/6
36 * </pre>
37 * where q = sqrt(2)
38 *
39 * @see EulerIntegrator
40 * @see ClassicalRungeKuttaIntegrator
41 * @see MidpointIntegrator
42 * @see ThreeEighthesIntegrator
43 * @see LutherIntegrator
44 * @since 1.2
45 */
46
47 public class GillIntegrator extends RungeKuttaIntegrator {
48
49 /** Time steps Butcher array. */
50 private static final double[] STATIC_C = {
51 1.0 / 2.0, 1.0 / 2.0, 1.0
52 };
53
54 /** Internal weights Butcher array. */
55 private static final double[][] STATIC_A = {
56 { 1.0 / 2.0 },
57 { (JdkMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - JdkMath.sqrt(2.0)) / 2.0 },
58 { 0.0, -JdkMath.sqrt(2.0) / 2.0, (2.0 + JdkMath.sqrt(2.0)) / 2.0 }
59 };
60
61 /** Propagation weights Butcher array. */
62 private static final double[] STATIC_B = {
63 1.0 / 6.0, (2.0 - JdkMath.sqrt(2.0)) / 6.0, (2.0 + JdkMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
64 };
65
66 /** Simple constructor.
67 * Build a fourth-order Gill integrator with the given step.
68 * @param step integration step
69 */
70 public GillIntegrator(final double step) {
71 super("Gill", STATIC_C, STATIC_A, STATIC_B, new GillStepInterpolator(), step);
72 }
73 }