Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Solver

Brief

Solver is a tool class to represent ordinary differential equation between vector-valued functions

Main features

  • First, second and third order non-linear solving
  • Bufferization of result for best performance

Getting started

A solver is an object that models an ode between any object of type Vector. The equation has the following form

ODE

Where u is an unknown vector valued function and f a smooth time dependant vector field.

Initialize a solver

Solver objects are initialized with the value of the initial condition u0, the function f and the time step dt Therefore to initialize a solver, simply choose values of theses parameters that models your problem.

Example

let f = u => u; // equation du/dt = u first order linear equation
let dt = 0.1; // time step
let u0 = new Vector3(1, 0, 0); // initial condition
let solver = new Solver(f, dt, u0),
console.log(solver.dt) // prints 0.1

Solve equations

Once you've initialized the solver, you can start compute solutions of your equation. There is two ways to do that :

  • Compute values step-by-step
  • Compute value after a maximum duration
let u = solver.step();
let v = solver.solve(tmax);

You can change initial condition and time step each time you call step and solve methods.

let u0 = Vector3(2, 3, 7);
let dt = 0.1;
let u = solver.step(u0, dt);

Note currently only Euler's explicit method is provided.

Time dependant equations

Time dependant equations uses the member t to count time from the last initialisation/reset of the solver. Each time an equation is solved, t is set to it's final value after solving. If you want to reset the value of t, call the reset method.

Hierarchy

  • Solver

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Solver(f: VectorField, dt: number, u0: Vector): Solver

Properties

dt

dt: number

current time step

f

f: VectorField

time dependant vector field f

t

t: number

time elapsed, incremented each time step or solve methods are called

tmp

tmp: Vector

buffer value, stores the value of the last f(u, t) computed

u0

u0: Vector

last initial condition used

u1

u1: Vector

last solution computed

Methods

reset

  • reset(u0?: Vector, dt?: number): this
  • brief

    reset the solver with initial condition and time step

    details

    the timer member this.t is set to 0.

    Parameters

    • Default value u0: Vector = this.u0

      initial condition

    • Default value dt: number = this.dt

      time step

    Returns this

solve

  • brief

    computes value of solution according to current u0 at t = tmax

    details

    this.u1 is set to u(tmax)

    Parameters

    • tmax: number

      instant where to compute the solution

    • Optional u0: Vector

      initial condition

    • Default value dt: number = this.dt

      time step

    Returns Vector

    reference to this.u1 after computation

step

  • brief

    compute next value of solution according to current u0

    Parameters

    • Optional u0: Vector

      initial condition

    • Default value dt: number = this.dt

      time step

    Returns Vector

    reference to this.u1 after computation

Generated using TypeDoc