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