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