Skip to content

Integrate a system of ordinary differential equations using the explicit Euler method.

License

Notifications You must be signed in to change notification settings

Planeshifter/ode-euler

 
 

Repository files navigation

ode-euler

NPM version Build Status Coverage Status Dependencies

Integrate a system of ordinary differential equations using the explicit Euler method.

Installation

$ npm install compute-ode-euler

For use in the browser, use browserify.

Usage

var euler = require( 'compute-ode-euler' );

euler( y0, deriv, t0, dt )

What does this function do?

Examples

var euler = require( 'compute-ode-euler' );

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 = euler( y0, deriv, t0, dt );

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

// Integrate all the way around a circle:
// => integrator.y = [ 1.0199349143076457, -0.00008432969374211775 ]

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

License

MIT license.

Copyright

Copyright © 2015. The Compute.io Authors.

About

Integrate a system of ordinary differential equations using the explicit Euler method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 83.1%
  • Makefile 16.9%