GillIntegrator.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. import org.apache.commons.math4.core.jdkmath.JdkMath;


  19. /**
  20.  * This class implements the Gill fourth order Runge-Kutta
  21.  * integrator for Ordinary Differential Equations .

  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/2 |   1/2       0       0      0
  27.  *   1/2 | (q-1)/2  (2-q)/2    0      0
  28.  *    1  |    0       -q/2  (2+q)/2   0
  29.  *       |-------------------------------
  30.  *       |   1/6    (2-q)/6 (2+q)/6  1/6
  31.  * </pre>
  32.  * where q = sqrt(2)
  33.  *
  34.  * @see EulerIntegrator
  35.  * @see ClassicalRungeKuttaIntegrator
  36.  * @see MidpointIntegrator
  37.  * @see ThreeEighthesIntegrator
  38.  * @see LutherIntegrator
  39.  * @since 1.2
  40.  */

  41. public class GillIntegrator extends RungeKuttaIntegrator {

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

  46.   /** Internal weights Butcher array. */
  47.   private static final double[][] STATIC_A = {
  48.     { 1.0 / 2.0 },
  49.     { (JdkMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - JdkMath.sqrt(2.0)) / 2.0 },
  50.     { 0.0, -JdkMath.sqrt(2.0) / 2.0, (2.0 + JdkMath.sqrt(2.0)) / 2.0 }
  51.   };

  52.   /** Propagation weights Butcher array. */
  53.   private static final double[] STATIC_B = {
  54.     1.0 / 6.0, (2.0 - JdkMath.sqrt(2.0)) / 6.0, (2.0 + JdkMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
  55.   };

  56.   /** Simple constructor.
  57.    * Build a fourth-order Gill integrator with the given step.
  58.    * @param step integration step
  59.    */
  60.   public GillIntegrator(final double step) {
  61.     super("Gill", STATIC_C, STATIC_A, STATIC_B, new GillStepInterpolator(), step);
  62.   }
  63. }