/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.math3.ode.nonstiff;

import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.MaxCountExceededException;
import org.apache.commons.math3.exception.NoBracketingException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.ode.ExpandableStatefulODE;
import org.apache.commons.math3.ode.MultistepIntegrator;


Base class for Adams-Bashforth and Adams-Moulton integrators.
Since:2.0
/** Base class for {@link AdamsBashforthIntegrator Adams-Bashforth} and * {@link AdamsMoultonIntegrator Adams-Moulton} integrators. * @since 2.0 */
public abstract class AdamsIntegrator extends MultistepIntegrator {
Transformer.
/** Transformer. */
private final AdamsNordsieckTransformer transformer;
Build an Adams integrator with the given order and step control parameters.
Params:
  • name – name of the method
  • nSteps – number of steps of the method excluding the one being computed
  • order – order of the method
  • minStep – minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
  • maxStep – maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
  • scalAbsoluteTolerance – allowed absolute error
  • scalRelativeTolerance – allowed relative error
Throws:
/** * Build an Adams integrator with the given order and step control parameters. * @param name name of the method * @param nSteps number of steps of the method excluding the one being computed * @param order order of the method * @param minStep minimal step (sign is irrelevant, regardless of * integration direction, forward or backward), the last step can * be smaller than this * @param maxStep maximal step (sign is irrelevant, regardless of * integration direction, forward or backward), the last step can * be smaller than this * @param scalAbsoluteTolerance allowed absolute error * @param scalRelativeTolerance allowed relative error * @exception NumberIsTooSmallException if order is 1 or less */
public AdamsIntegrator(final String name, final int nSteps, final int order, final double minStep, final double maxStep, final double scalAbsoluteTolerance, final double scalRelativeTolerance) throws NumberIsTooSmallException { super(name, nSteps, order, minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance); transformer = AdamsNordsieckTransformer.getInstance(nSteps); }
Build an Adams integrator with the given order and step control parameters.
Params:
  • name – name of the method
  • nSteps – number of steps of the method excluding the one being computed
  • order – order of the method
  • minStep – minimal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
  • maxStep – maximal step (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this
  • vecAbsoluteTolerance – allowed absolute error
  • vecRelativeTolerance – allowed relative error
Throws:
/** * Build an Adams integrator with the given order and step control parameters. * @param name name of the method * @param nSteps number of steps of the method excluding the one being computed * @param order order of the method * @param minStep minimal step (sign is irrelevant, regardless of * integration direction, forward or backward), the last step can * be smaller than this * @param maxStep maximal step (sign is irrelevant, regardless of * integration direction, forward or backward), the last step can * be smaller than this * @param vecAbsoluteTolerance allowed absolute error * @param vecRelativeTolerance allowed relative error * @exception IllegalArgumentException if order is 1 or less */
public AdamsIntegrator(final String name, final int nSteps, final int order, final double minStep, final double maxStep, final double[] vecAbsoluteTolerance, final double[] vecRelativeTolerance) throws IllegalArgumentException { super(name, nSteps, order, minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance); transformer = AdamsNordsieckTransformer.getInstance(nSteps); }
{@inheritDoc}
/** {@inheritDoc} */
@Override public abstract void integrate(final ExpandableStatefulODE equations, final double t) throws NumberIsTooSmallException, DimensionMismatchException, MaxCountExceededException, NoBracketingException;
{@inheritDoc}
/** {@inheritDoc} */
@Override protected Array2DRowRealMatrix initializeHighOrderDerivatives(final double h, final double[] t, final double[][] y, final double[][] yDot) { return transformer.initializeHighOrderDerivatives(h, t, y, yDot); }
Update the high order scaled derivatives for Adams integrators (phase 1).

The complete update of high order derivatives has a form similar to:

rn+1 = (s1(n) - s1(n+1)) P-1 u + P-1 A P rn
this method computes the P-1 A P rn part.

Params:
  • highOrder – high order scaled derivatives (h2/2 y'', ... hk/k! y(k))
See Also:
Returns:updated high order derivatives
/** Update the high order scaled derivatives for Adams integrators (phase 1). * <p>The complete update of high order derivatives has a form similar to: * <pre> * r<sub>n+1</sub> = (s<sub>1</sub>(n) - s<sub>1</sub>(n+1)) P<sup>-1</sup> u + P<sup>-1</sup> A P r<sub>n</sub> * </pre> * this method computes the P<sup>-1</sup> A P r<sub>n</sub> part.</p> * @param highOrder high order scaled derivatives * (h<sup>2</sup>/2 y'', ... h<sup>k</sup>/k! y(k)) * @return updated high order derivatives * @see #updateHighOrderDerivativesPhase2(double[], double[], Array2DRowRealMatrix) */
public Array2DRowRealMatrix updateHighOrderDerivativesPhase1(final Array2DRowRealMatrix highOrder) { return transformer.updateHighOrderDerivativesPhase1(highOrder); }
Update the high order scaled derivatives Adams integrators (phase 2).

The complete update of high order derivatives has a form similar to:

rn+1 = (s1(n) - s1(n+1)) P-1 u + P-1 A P rn
this method computes the (s1(n) - s1(n+1)) P-1 u part.

Phase 1 of the update must already have been performed.

Params:
  • start – first order scaled derivatives at step start
  • end – first order scaled derivatives at step end
  • highOrder – high order scaled derivatives, will be modified (h2/2 y'', ... hk/k! y(k))
See Also:
/** Update the high order scaled derivatives Adams integrators (phase 2). * <p>The complete update of high order derivatives has a form similar to: * <pre> * r<sub>n+1</sub> = (s<sub>1</sub>(n) - s<sub>1</sub>(n+1)) P<sup>-1</sup> u + P<sup>-1</sup> A P r<sub>n</sub> * </pre> * this method computes the (s<sub>1</sub>(n) - s<sub>1</sub>(n+1)) P<sup>-1</sup> u part.</p> * <p>Phase 1 of the update must already have been performed.</p> * @param start first order scaled derivatives at step start * @param end first order scaled derivatives at step end * @param highOrder high order scaled derivatives, will be modified * (h<sup>2</sup>/2 y'', ... h<sup>k</sup>/k! y(k)) * @see #updateHighOrderDerivativesPhase1(Array2DRowRealMatrix) */
public void updateHighOrderDerivativesPhase2(final double[] start, final double[] end, final Array2DRowRealMatrix highOrder) { transformer.updateHighOrderDerivativesPhase2(start, end, highOrder); } }