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