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.math.ode;
19
20 /**
21 * This class implements the Gill fourth order Runge-Kutta
22 * integrator for Ordinary Differential Equations .
23
24 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
25 * is the following one :
26 * <pre>
27 * 0 | 0 0 0 0
28 * 1/2 | 1/2 0 0 0
29 * 1/2 | (q-1)/2 (2-q)/2 0 0
30 * 1 | 0 -q/2 (2+q)/2 0
31 * |-------------------------------
32 * | 1/6 (2-q)/6 (2+q)/6 1/6
33 * </pre>
34 * where q = sqrt(2)</p>
35 *
36 * @see EulerIntegrator
37 * @see ClassicalRungeKuttaIntegrator
38 * @see MidpointIntegrator
39 * @see ThreeEighthesIntegrator
40 * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
41 * @since 1.2
42 */
43
44 public class GillIntegrator
45 extends RungeKuttaIntegrator {
46
47 /** Integrator method name. */
48 private static final String methodName = "Gill";
49
50 /** Time steps Butcher array. */
51 private static final double[] c = {
52 1.0 / 2.0, 1.0 / 2.0, 1.0
53 };
54
55 /** Internal weights Butcher array. */
56 private static final double[][] a = {
57 { 1.0 / 2.0 },
58 { (Math.sqrt(2.0) - 1.0) / 2.0, (2.0 - Math.sqrt(2.0)) / 2.0 },
59 { 0.0, -Math.sqrt(2.0) / 2.0, (2.0 + Math.sqrt(2.0)) / 2.0 }
60 };
61
62 /** Propagation weights Butcher array. */
63 private static final double[] b = {
64 1.0 / 6.0, (2.0 - Math.sqrt(2.0)) / 6.0, (2.0 + Math.sqrt(2.0)) / 6.0, 1.0 / 6.0
65 };
66
67 /** Simple constructor.
68 * Build a fourth-order Gill integrator with the given step.
69 * @param step integration step
70 */
71 public GillIntegrator(double step) {
72 super(c, a, b, new GillStepInterpolator(), step);
73 }
74
75 /** Get the name of the method.
76 * @return name of the method
77 */
78 public String getName() {
79 return methodName;
80 }
81
82 }