26package umontreal.ssj.simevents;
29import java.util.Collections;
30import java.util.ArrayList;
60 private double stepSize;
63 private double[] A =
new double[4];
64 private double[] B =
new double[4];
65 private double[] C =
new double[4];
68 private StepEvent stepEv =
null;
71 private class StepEvent
extends Event {
88 throw new IllegalArgumentException(
"Integration step with undefined method");
94 public String toString() {
95 return "Integration step for continuous variable ";
99 private List<Continuous> list;
100 private Simulator sim;
109 this.list =
new ArrayList<Continuous>();
123 return Collections.unmodifiableList(list);
134 stepEv =
new StepEvent(sim);
137 if (list.isEmpty()) {
138 stepEv.schedule(stepSize);
217 private void oneStepEuler() {
219 double t = sim.time() - stepSize;
221 current = list.size();
222 while (current > 0) {
223 v = list.get(--current);
226 current = list.size();
227 while (current > 0) {
228 v = list.get(--current);
236 private void oneStepRK() {
238 double t = sim.time() - stepSize;
239 int current = list.size();
240 while (current > 0) {
241 v = list.get(--current);
246 for (
int i = 1; i <= order - 1; i++) {
247 current = list.size();
248 while (current > 0) {
249 v = list.get(--current);
250 v.pi = v.derivative(t + stepSize * C[i - 1]);
251 v.sum = v.sum + v.pi * B[i - 1];
252 v.phi = v.buffer + stepSize * v.pi * A[i - 1];
254 current = list.size();
255 while (current > 0) {
256 v = list.get(--current);
260 current = list.size();
261 while (current > 0) {
262 v = list.get(--current);
263 v.pi = v.derivative(t + stepSize * C[order - 1]);
264 v.value = v.buffer + stepSize * (v.sum + v.pi * B[order - 1]);
IntegMethod integMethod()
Return an integer that represent the integration method in use.
List< Continuous > getContinuousVariables()
Returns the list of continuous-time variables currently integrated by the simulator.
void stopInteg(Continuous c)
Stops the integration process for Continuous variable.
void selectRungeKutta4(double h)
Selects a Runge-Kutta method of order 4 as the integration method to be used, with step size h.
void selectRungeKutta2(double h)
Selects a Runge-Kutta method of order 2 as the integration method to be used, with step size h.
void startInteg(Continuous c)
Starts the integration process that will change the state of.
void selectEuler(double h)
Selects the Euler method as the integration method, with the integration step size h,...
ContinuousState(Simulator sim)
Creates a new ContinuousState object linked to the given simulator.
Represents a variable in a continuous-time simulation.
void afterEachStep()
This method is executed after each integration step for this Continuous variable.
abstract double derivative(double t)
This method should return the derivative of this variable with respect to time, at time .
This abstract class provides event scheduling tools.
void scheduleNext()
Schedules this event as the first event in the event list, to be executed at the current time (as the...
abstract void actions()
This is the method that is executed when this event occurs.
void schedule(double delay)
Schedules this event to happen in delay time units, i.e., at time sim.time() + delay,...
Represents the executive of a discrete-event simulator.