Java tutorial
/* * Copyright (C) 2014 Mike C. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package reactor.semibatchreactor; import org.apache.commons.math3.ode.FirstOrderDifferentialEquations; import org.apache.commons.math3.ode.FirstOrderIntegrator; import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator; /** * * @author Michael C. 30/07/2014 */ public class Simulation { 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); } }