Example usage for org.apache.commons.math3.ode FirstOrderIntegrator addStepHandler

List of usage examples for org.apache.commons.math3.ode FirstOrderIntegrator addStepHandler

Introduction

In this page you can find the example usage for org.apache.commons.math3.ode FirstOrderIntegrator addStepHandler.

Prototype

void addStepHandler(StepHandler handler);

Source Link

Document

Add a step handler to this integrator.

Usage

From source file:reactor.semibatchreactor.Simulation.java

public static void main(String[] args) {
    double[] initialConditions = { 10, 0, 0, 0, 300 };
    double[] tempParameters = { 2500, 280, 2, 0.004, 75240, 300, -7.9076 * Math.pow(10, 7) };
    double[] odeParameters = { 0.2, 6.14, 0, 2.37989273, 8.94266 * Math.pow(10, 12), 803373.6 };
    SemiBatchReactor reactor = new SemiBatchReactor(initialConditions, tempParameters, odeParameters);
    FirstOrderIntegrator integrator = new DormandPrince853Integrator(0.1, 0.1, 0.001, 0.001);
    FirstOrderDifferentialEquations ode = reactor;

    integrator.addStepHandler(reactor.stepHandler);
    integrator.integrate(ode, 0.0, initialConditions, 10, initialConditions);
}

From source file:ummisco.gaml.extensions.maths.ode.utils.solver.Solver.java

Solver(final double step, final FirstOrderIntegrator integrator,
        final GamaMap<String, IList<Double>> integrated_val) {
    this.step = step;
    this.integrator = integrator;
    if (integrated_val != null) {
        integrator.addStepHandler(new StepHandler() {

            @Override//  w  ww  .ja  v  a2  s.c  om
            public void init(final double t0, final double[] y0, final double t) {
            }

            @Override
            public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
                final double time = interpolator.getCurrentTime();
                final double[] y = interpolator.getInterpolatedState();
                count++;
                storeValues(time, y, integrated_val);
            }
        });
    }
}