Solver:
Filter:
Classes (extension) | Math | Libraries > MathLib > Solvers

Solver : Object
ExtensionExtension

numerical solver of systems of Ordinary Differential Equations of any order
Source: Solver.sc
Subclasses: Euler, RK

Description

Solver is the base class to inherit from to implement numerical solving methods for ODEs.

Part of MathLib, a diverse library of mathematical functions.

WARNING: This class can be quite cpu intensive and with small dt values can completly freeze supercollider. ODE's of higher order are solved by converting them to systems of equations of the first order.

ODEs of the first order take the form:

y' = F(t,y)

where F:RxR -> R and y = y(t) and y' the derivative of f.

Systems of equations take the form:

dy1/dt = F1(t,y1) ... dyn/dt = Fn(t,yn)

or in vector form:

DY = F^(t,Y)

where F^ = { F1,...,Fn}, Y = { Y1,...,Yn}, and DY is the jacobian matrix of Y.

ODEs of order N take the form:

y = F(t,y,dy/dt,...,dNy/dtN)

and Systems of M equation of order N take the form;

dNy1/dtN = F1(t,y,dy1/dt,...,dN-1y1/dtN-1) ... dNyM/dtN = FM(t,y,dyM/dt,...,dN-1yM/dtN-1)

or in vector form

DY = F^(t,Y,DY,...,DNY)

Class Methods

Solver.new(f, dt, t: 0, y: 0)

Create a solver for a one dimensional equation or system of equations.

Arguments:

f

see -f below

dt

calculation time step in seconds

t

initial time

y

initial position: a number or array of numbers

Solver.newHO(f, dt, t, y)

Create a solver for a higher dimensional equation or system of equations.

Arguments:

f

see -f below

dt

calculation time step in seconds

t

initial time

y

initial position: a number or array of numbers

Inherited class methods

Instance Methods

.order

.order = value

Set or return the order of the ODE

.f

.f = value

f is the function F defining the equation DY = F^(t,Y,DY,...,DNY), and can take the following forms:

D ODE{ |t,y| ... }
System of 1D ODEs[{ |t,y| ... },...,{ |t,y| ... }]
N-order ODE{ |t,y,dy,..., dN-1y| ... }
System of M, N-order ODEs[{ |t,y,dy1,..., dN-1y1,...,dyM,..., dN-1yM| ... } ,...,{ |t,y,dy1,..., dN-1y1,...,dyM,..., dN-1yM| ... }]

.dt

.dt = value

Set or return calculation time step in seconds

.t

.t = value

Set or return time in seconds

.y

.y = value

It can take the following forms:

1D ODEy
System of 1D ODEs[y1,...,yn]
N-order ODE[y,dy,..., dN-1y]
System of M, N-order ODEs[[y1,dy1,..., dN-1y1],...,[yM,dy1,..., dN-1yM]]

The value can be reset and the calculation will continue from there.

.next

Get the next value from the solver.

In general this will be: [[y1,y'1,...,y1^(n-1)],...,[yM,y'M,...,yM^(n-1)]]

Inherited instance methods

Examples

NOTE: For the gui examples the ixiViews and wslib quarks are needed.

First order ODE

Second order ODE

System of second order ODE

Chaotic pendulum

Authors

Miguel Negro, 2009.