|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjabble.Evolver
jabble.SingleLoopEvolver
jabble.RungeKutta
public abstract class RungeKutta
Solves a 1D Ordinary Differential Equation using Runge-Kutta.
Runge-Kutta is a method of numerically integrate an ordinary differential equation by using a step at the midpoint of an interval to cancel out lower-order error terms. We use the fourth order formula, sometimes refered as RK4. Given an ODE dy/dx = f(x, y), the algorithm is as follow:
k1 = h f(xn , yn)
k2 = h f(xn + h/2, yn + k1/2)
k3 = h f(xn + h/2, yn + k2/2)
k4 = h f(xn + h, yn+ k3)
yn+1 = yn + k1/6 + k2/3 + k3/3 + k4/6 + O(h5)
where:
In the Jabble framework, to use RungeKutta you must be working on a 1D grid.
You need to create a class that extends RungeKutta, and declare the f() method,
which corresponds to the f function. Instead of using the standard
Field.at(Point) to calculate the value at a point, you should use the
valueOf(Field): this way you can construct an f() method that
calculates the function at the midpoint without doing so explicitely.
TODO: add example
| Field Summary |
|---|
| Fields inherited from class jabble.Evolver |
|---|
constantsMap, dDirs, fieldArrayMap, fieldMap, grid, stopTrigger |
| Constructor Summary | |
|---|---|
RungeKutta(java.lang.String fieldName)
Creates a new instance of RungeKutta |
|
| Method Summary | |
|---|---|
protected void |
calculateNewFields(Point point)
Calculates the value of the fields at the given Point. |
protected abstract double |
f()
Computes f(x, y), the function that defines the ODE to be solved. |
protected double |
f1()
Computes k1. |
protected double |
f2()
Computes k2. |
protected double |
f3()
Computes k3. |
protected double |
f4()
Computes k4. |
void |
solve(Field field)
Solves the ODE over the given Field. |
void |
solveAtPoint(Field field,
Point point)
Solves the ODE over the given Field at the given Point. |
protected double |
valueOf(Field field)
Returns the value of the Field at the current Point, or mid-Point. |
| Methods inherited from class jabble.SingleLoopEvolver |
|---|
calculateNewFields |
| Methods inherited from class jabble.Evolver |
|---|
evolve, evolve, evolve, getNPreviousSlicesNeeded, initializeFieldArray, initializeFieldArray, skipBoundaryPoint |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RungeKutta(java.lang.String fieldName)
| Method Detail |
|---|
protected final double valueOf(Field field)
f() instead of Field.at(Point): for
example, instead of double phiValue = phi.at(point); one would use
double phiValue = valueOf(phi);.
field - a Field used during the computation
protected abstract double f()
valueOf(Field).
protected double f1()
protected double f2()
protected double f3()
protected double f4()
protected void calculateNewFields(Point point)
SingleLoopEvolver
calculateNewFields in class SingleLoopEvolverpoint - the point where to compute the new value of the fields
public void solveAtPoint(Field field,
Point point)
field - Field to store the solution of the equationpoint - Point at which to calculate the valuepublic void solve(Field field)
field - Field to store the solution of the equation
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||