ThreeEighthesIntegrator.java

  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. package org.apache.commons.math4.legacy.ode.nonstiff;


  18. /**
  19.  * This class implements the 3/8 fourth order Runge-Kutta
  20.  * integrator for Ordinary Differential Equations.
  21.  *
  22.  * <p>This method is an explicit Runge-Kutta method, its Butcher-array
  23.  * is the following one :
  24.  * <pre>
  25.  *    0  |  0    0    0    0
  26.  *   1/3 | 1/3   0    0    0
  27.  *   2/3 |-1/3   1    0    0
  28.  *    1  |  1   -1    1    0
  29.  *       |--------------------
  30.  *       | 1/8  3/8  3/8  1/8
  31.  * </pre>
  32.  *
  33.  * @see EulerIntegrator
  34.  * @see ClassicalRungeKuttaIntegrator
  35.  * @see GillIntegrator
  36.  * @see MidpointIntegrator
  37.  * @see LutherIntegrator
  38.  * @since 1.2
  39.  */

  40. public class ThreeEighthesIntegrator extends RungeKuttaIntegrator {

  41.   /** Time steps Butcher array. */
  42.   private static final double[] STATIC_C = {
  43.     1.0 / 3.0, 2.0 / 3.0, 1.0
  44.   };

  45.   /** Internal weights Butcher array. */
  46.   private static final double[][] STATIC_A = {
  47.     {  1.0 / 3.0 },
  48.     { -1.0 / 3.0, 1.0 },
  49.     {  1.0, -1.0, 1.0 }
  50.   };

  51.   /** Propagation weights Butcher array. */
  52.   private static final double[] STATIC_B = {
  53.     1.0 / 8.0, 3.0 / 8.0, 3.0 / 8.0, 1.0 / 8.0
  54.   };

  55.   /** Simple constructor.
  56.    * Build a 3/8 integrator with the given step.
  57.    * @param step integration step
  58.    */
  59.   public ThreeEighthesIntegrator(final double step) {
  60.     super("3/8", STATIC_C, STATIC_A, STATIC_B, new ThreeEighthesStepInterpolator(), step);
  61.   }
  62. }