npm.nicfv.com
    Preparing search index...

    Class DifferentialSystem

    Represents a system of differential equations.

    Index
    • Initialize a new system of differential equations.

      Parameters

      • dimensions: number

        The number of equations in this system

      Returns DifferentialSystem

      const system = new DifferentialSystem(3); // x, y, z
      
    • Set a differential equation for a specific dimension. All differential equations must be set before solving.

      Parameters

      • dimension: number

        The 0-indexed dimension number to set the equation for

      • de: Equation

        The differential equation for this dimension must accept a global state vector ordered by dimension and derivative order

        x, dx/dt, ..., d(i-1)x/dt(i-1),
        y, dy/dt, ..., d(j-1)y/dt(j-1),
        z, dz/dt, ..., d(k-1)z/dt(k-1),
        ... (higher dimensions)

        Where i is the highest order of x (dimension 0), j is the highest order of y (dimension 1) and k is the highest order of z (dimension 2)

      • ...ic: number[]

        Initial conditions for this dimension, ordered x, dx/dt, ..., d(n-1)x/dt(n-1)

      Returns void

      const sigma = 1;
      const rho = 1;
      const beta = 8 / 3;
      const dx = (t, x, y, z) => sigma * (y - x);
      const dy = (t, x, y, z) => x * (rho - z) - y;
      const dz = (t, x, y, z) => x * y - beta * z;
      system.setEquationFor(0, dx, 10); // x0 = 10
      system.setEquationFor(1, dy, 10); // y0 = 10
      system.setEquationFor(2, dz, 10); // z0 = 10
    • Solve this system of differential equations from t=0 to t=tf with timestep dt.

      Parameters

      • dt: number

        The timestep

      • tf: number

        The final time

      Returns Step[][]

      Square array with the first index being the 0-indexed dimension and second index being the time index, each entry contains the timestamp and all orders of derivatives

      const data = system.solve(1e-3, 4);