npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ode-rk4

v1.1.3

Published

Integrate a system of ODEs using the Fourth Order Runge-Kutta (RK-4) method

Downloads

55

Readme

ode-rk4 Build Status npm version Dependency Status

Integrate a system of ODEs using the Fourth Order Runge-Kutta (RK-4) method

Introduction

This module integrates a system of ordinary differential equations of the form

where is a vector of length . Given time step , the Runge-Kutta 4 method integrates the ODE with update

For a similar adaptive method using the fifth order Cash-Karp Runge-Kutta method with fourth order embedded error estimator, see [https://github.com/scijs/ode45-cash-karp](ode45-cash-karp].

Install

$ npm install ode-rk4

Example

var rk4 = require('ode-rk4')

var deriv = function(dydt, y, t) {
  dydt[0] = -y[1]
  dydt[1] =  y[0]
}

var y0 = [1,0]
var n = 1000
var t0 = 0
var dt = 2.0 * Math.PI / n

var integrator = rk4( y0, deriv, t0, dt )

// Integrate 1000 steps:
integrator.steps(n)

// Integrate all the way around a circle:
// => integrator.y = [ 0.9999999999995743, -8.160481752145232e-11 ]

API

require('ode-rk4')( y0, deriv, t0, dt )

Arguments:

  • y0: an array or typed array containing initial conditions. This vector is updated in-place with each integrator step.
  • deriv: a function that calculates the derivative. Format is function( dydt, y, t ). Inputs are current state y and current time t, output is the calculated derivative dydt.
  • t0: initial time .
  • dt: time step .

Returns: Initialized integrator object.

Properties:

  • n: dimension of y0.
  • y: current state. Initialized as a shallow copy of input y0.
  • deriv: function that calculates the derivative. Initialized from input. May be changed.
  • t: current time, incremented by dt with each time step.
  • dt: time step . Initialized from input dt. May be changed.

Methods:

  • .step(): takes a single step of the RK-4 integrator and stores the result in-place in the y property.
  • .steps( n ): takes n steps of the RK-4 integrator, storing the result in-place in the y property.

Credits

(c) 2015 Ricky Reusser. MIT License