001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math3.ode.nonstiff;
019
020
021/**
022 * This class implements the classical fourth order Runge-Kutta
023 * integrator for Ordinary Differential Equations (it is the most
024 * often used Runge-Kutta method).
025 *
026 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
027 * is the following one :
028 * <pre>
029 *    0  |  0    0    0    0
030 *   1/2 | 1/2   0    0    0
031 *   1/2 |  0   1/2   0    0
032 *    1  |  0    0    1    0
033 *       |--------------------
034 *       | 1/6  1/3  1/3  1/6
035 * </pre>
036 * </p>
037 *
038 * @see EulerIntegrator
039 * @see GillIntegrator
040 * @see MidpointIntegrator
041 * @see ThreeEighthesIntegrator
042 * @see LutherIntegrator
043 * @version $Id: ClassicalRungeKuttaIntegrator.java 1588755 2014-04-20 13:30:16Z luc $
044 * @since 1.2
045 */
046
047public class ClassicalRungeKuttaIntegrator extends RungeKuttaIntegrator {
048
049  /** Time steps Butcher array. */
050  private static final double[] STATIC_C = {
051    1.0 / 2.0, 1.0 / 2.0, 1.0
052  };
053
054  /** Internal weights Butcher array. */
055  private static final double[][] STATIC_A = {
056    { 1.0 / 2.0 },
057    { 0.0, 1.0 / 2.0 },
058    { 0.0, 0.0, 1.0 }
059  };
060
061  /** Propagation weights Butcher array. */
062  private static final double[] STATIC_B = {
063    1.0 / 6.0, 1.0 / 3.0, 1.0 / 3.0, 1.0 / 6.0
064  };
065
066  /** Simple constructor.
067   * Build a fourth-order Runge-Kutta integrator with the given
068   * step.
069   * @param step integration step
070   */
071  public ClassicalRungeKuttaIntegrator(final double step) {
072    super("classical Runge-Kutta", STATIC_C, STATIC_A, STATIC_B,
073          new ClassicalRungeKuttaStepInterpolator(), step);
074  }
075
076}