org.jcpsim.ode
Class DifferentialEquations

java.lang.Object
  extended by org.jcpsim.ode.DifferentialEquations
Direct Known Subclasses:
ArterialLine.ArterialLineModel, Function.TestModel, Pendulum.PendulumModel, SimpleRespirator.RCModel, VentilationOfRcLung.RCModel

public class DifferentialEquations
extends java.lang.Object

Superclass for all differential equations


Nested Class Summary
static class DifferentialEquations.Method
           
 
Field Summary
 DifferentialEquation[] de
           
 double dtused
           
 int n
           
 Tasks[] st
           
 int taskN
           
 
Constructor Summary
DifferentialEquations(double t, double dt, DifferentialEquations.Method method)
           
 
Method Summary
 DifferentialEquation add(DifferentialEquation eq)
           
 java.util.List<DifferentialEquation> add(java.util.List<DifferentialEquation> list)
           
 Tasks addTasks(Tasks st)
           
 void after()
           
 void before()
           
 double getDt()
          Gets proposed value for next time step.
 double getDtmax()
          Gets biggest allowed time step (default: initial dt).
 double getDtmin()
          Gets lowest allowed time step (default: initial dt * 0.000001).
 double getDttiny()
          Gets time distance before curve break (default: initial dt * 0.0001).
 double getDtused()
          Gets value used for last time step.
 double getEps()
          Gets error tolerance level (default: 0.000001).
 double getNextStepsize()
          Can be overridden.
 double getT()
          Gets the actual simulation time.
 boolean remove(DifferentialEquation eq)
           
 boolean removeTasks(Tasks st)
           
 void setDt(double x)
          Sets proposed value for next time step.
 void setDtmax(double x)
          Sets biggest allowed time step (default: initial dt).
 void setDtmin(double x)
          Sets lowest allowed time step (default: initial dt * 0.000001).
 void setDttiny(double x)
          Sets time distance before curve break (default: initial dt * 0.0001).
 void setEps(double x)
          Sets error tolerance level (default: 0.000001).
 void setInitialValues()
          Sets all state variables to their initial value at start time.
 void setMethod(DifferentialEquations.Method m)
          Sets the integration method.
 void setNextStepsize(double dt)
           
 void setT(double t)
           
 void setValues(double t)
          Is called just before (#link dxdt).
 void step_Euler()
          The simplest integration method (should only be used for testing purposes).
 void step_RungeKutta4()
          Implements the fourth-order Runge-Kutta algorithm.
 void step_RungeKutta45()
          performs one integration step with variable stepsize
computes:
dtused = value just used for last step
dt = proposed value for next step
 void step()
           
 void stepDelta(double delta)
           
 void stepUntil(double until)
          Should be called often enough to achieve smooth animations (ca. 10 Hz).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dtused

public double dtused

n

public int n

de

public DifferentialEquation[] de

taskN

public int taskN

st

public Tasks[] st
Constructor Detail

DifferentialEquations

public DifferentialEquations(double t,
                             double dt,
                             DifferentialEquations.Method method)
Parameters:
t - start time
dt - initial (and maximum) stepsize (delta t)
method - integration method
Method Detail

setMethod

public void setMethod(DifferentialEquations.Method m)
Sets the integration method.


getT

public double getT()
Gets the actual simulation time.


setT

public void setT(double t)

setDt

public void setDt(double x)
Sets proposed value for next time step.


getDt

public double getDt()
Gets proposed value for next time step.


getDtused

public double getDtused()
Gets value used for last time step.


setDtmax

public void setDtmax(double x)
Sets biggest allowed time step (default: initial dt).


getDtmax

public double getDtmax()
Gets biggest allowed time step (default: initial dt).


setDtmin

public void setDtmin(double x)
Sets lowest allowed time step (default: initial dt * 0.000001).


getDtmin

public double getDtmin()
Gets lowest allowed time step (default: initial dt * 0.000001).


setDttiny

public void setDttiny(double x)
Sets time distance before curve break (default: initial dt * 0.0001). Variable stepsize algorithms will try to step just a tiny distance before the next break in the curves (as set by DifferentialEquation.dxdt(double))


getDttiny

public double getDttiny()
Gets time distance before curve break (default: initial dt * 0.0001). Variable stepsize algorithms will try to step just a tiny distance before the next break in the curves (as set by DifferentialEquation.dxdt(double))


setEps

public void setEps(double x)
Sets error tolerance level (default: 0.000001).


getEps

public double getEps()
Gets error tolerance level (default: 0.000001).


before

public void before()

after

public void after()

add

public DifferentialEquation add(DifferentialEquation eq)

add

public java.util.List<DifferentialEquation> add(java.util.List<DifferentialEquation> list)

remove

public boolean remove(DifferentialEquation eq)

addTasks

public Tasks addTasks(Tasks st)

removeTasks

public boolean removeTasks(Tasks st)

setInitialValues

public void setInitialValues()
Sets all state variables to their initial value at start time.


setValues

public void setValues(double t)
Is called just before (#link dxdt). Useful is more than one Numerical model has to be solved. May be overridden.

Parameters:
t - the actual time

getNextStepsize

public double getNextStepsize()
Can be overridden.

Returns:
if this is greater than 0: time to next break

Integration algorithms with variable stepsize (like step_RungeKutta45()) will set their stepsize so that no step will jump over the break in the curves.


setNextStepsize

public void setNextStepsize(double dt)

step

public void step()

stepUntil

public void stepUntil(double until)
Should be called often enough to achieve smooth animations (ca. 10 Hz). TODO: Step exactly to 'until' time *and* consider 'nextStepSize' ! TODO: stepIntervall(double t)


stepDelta

public void stepDelta(double delta)

step_Euler

public void step_Euler()
The simplest integration method (should only be used for testing purposes). Performs one integration step of all differential equations with fixed stepsize dt


step_RungeKutta4

public void step_RungeKutta4()
Implements the fourth-order Runge-Kutta algorithm.


step_RungeKutta45

public void step_RungeKutta45()
performs one integration step with variable stepsize
computes:
dtused = value just used for last step
dt = proposed value for next step



jCpSim (Java CardioPulmonary SIMulations), v0.2.01
Dr. Frank Fischer, frank@jcpsim.org, http://www.jcpsim.org