ThreeEighthesIntegrator.java

  1. /*
  2.  * Licensed to the Hipparchus project 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 Hipparchus project 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.  *      https://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.hipparchus.ode.nonstiff;

  18. import org.hipparchus.ode.EquationsMapper;
  19. import org.hipparchus.ode.ODEStateAndDerivative;
  20. import org.hipparchus.ode.nonstiff.interpolators.ThreeEighthesStateInterpolator;

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

  42. public class ThreeEighthesIntegrator extends FixedStepRungeKuttaIntegrator {

  43.     /** Name of integration scheme. */
  44.     public static final String METHOD_NAME = "3/8";

  45.     /** Simple constructor.
  46.      * Build a 3/8 integrator with the given step.
  47.      * @param step integration step
  48.      */
  49.     public ThreeEighthesIntegrator(final double step) {
  50.         super(METHOD_NAME, step);
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public double[] getC() {
  55.         return new double[] {
  56.             1.0 / 3.0, 2.0 / 3.0, 1.0
  57.         };
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public double[][] getA() {
  62.         return new double[][] {
  63.             {  1.0 / 3.0 },
  64.             { -1.0 / 3.0, 1.0 },
  65.             {  1.0, -1.0, 1.0 }
  66.         };
  67.     }

  68.     /** {@inheritDoc} */
  69.     @Override
  70.     public double[] getB() {
  71.         return new double[] {
  72.             1.0 / 8.0, 3.0 / 8.0, 3.0 / 8.0, 1.0 / 8.0
  73.         };
  74.     }

  75.     /** {@inheritDoc} */
  76.     @Override
  77.     protected ThreeEighthesStateInterpolator createInterpolator(final boolean forward, final double[][] yDotK,
  78.                                                                 final ODEStateAndDerivative globalPreviousState,
  79.                                                                 final ODEStateAndDerivative globalCurrentState,
  80.                                                                 final EquationsMapper mapper) {
  81.         return new ThreeEighthesStateInterpolator(forward, yDotK, globalPreviousState, globalCurrentState,
  82.                                                  globalPreviousState, globalCurrentState, mapper);
  83.     }

  84. }