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
020import org.apache.commons.math3.util.FastMath;
021
022
023/**
024 * This class implements the Gill fourth order Runge-Kutta
025 * integrator for Ordinary Differential Equations .
026
027 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
028 * is the following one :
029 * <pre>
030 *    0  |    0        0       0      0
031 *   1/2 |   1/2       0       0      0
032 *   1/2 | (q-1)/2  (2-q)/2    0      0
033 *    1  |    0       -q/2  (2+q)/2   0
034 *       |-------------------------------
035 *       |   1/6    (2-q)/6 (2+q)/6  1/6
036 * </pre>
037 * where q = sqrt(2)</p>
038 *
039 * @see EulerIntegrator
040 * @see ClassicalRungeKuttaIntegrator
041 * @see MidpointIntegrator
042 * @see ThreeEighthesIntegrator
043 * @see LutherIntegrator
044 * @version $Id: GillIntegrator.java 1588755 2014-04-20 13:30:16Z luc $
045 * @since 1.2
046 */
047
048public class GillIntegrator extends RungeKuttaIntegrator {
049
050  /** Time steps Butcher array. */
051  private static final double[] STATIC_C = {
052    1.0 / 2.0, 1.0 / 2.0, 1.0
053  };
054
055  /** Internal weights Butcher array. */
056  private static final double[][] STATIC_A = {
057    { 1.0 / 2.0 },
058    { (FastMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - FastMath.sqrt(2.0)) / 2.0 },
059    { 0.0, -FastMath.sqrt(2.0) / 2.0, (2.0 + FastMath.sqrt(2.0)) / 2.0 }
060  };
061
062  /** Propagation weights Butcher array. */
063  private static final double[] STATIC_B = {
064    1.0 / 6.0, (2.0 - FastMath.sqrt(2.0)) / 6.0, (2.0 + FastMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
065  };
066
067  /** Simple constructor.
068   * Build a fourth-order Gill integrator with the given step.
069   * @param step integration step
070   */
071  public GillIntegrator(final double step) {
072    super("Gill", STATIC_C, STATIC_A, STATIC_B, new GillStepInterpolator(), step);
073  }
074
075}