A simple runge-kutta 4 integrator
Project description
A simple implementation of Runge-Kutta for python.
Setup
Install
pip install pyrk
Develop
git clone https://github.com/walchko/pyrk cd pyrk pip install -e .
Usage
See the examples in the docs folder or a simple one:
from __future__ import division, print_function
from pyrk import RK4
import numpy as np
import matplotlib.pyplot as plt
def vanderpol(t, xi, u):
dx, x = xi
mu = 4.0 # damping
ddx = mu*(1-x**2)*dx-x
dx = dx
return np.array([ddx, dx])
rk = RK4(vanderpol)
t, y = rk.solve(np.array([0, 1]), .01, 200)
y1 = []
y2 = []
for v in y:
y1.append(v[0])
y2.append(v[1])
plt.plot(y1, y2)
plt.ylabel('velocity')
plt.xlabel('position')
plt.grid(True)
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
pyrk-0.6.0-py2-none-any.whl
(4.3 kB
view details)
File details
Details for the file pyrk-0.6.0-py2-none-any.whl
.
File metadata
- Download URL: pyrk-0.6.0-py2-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c0c6720e50a338d1b5529c76911b6a02dcf40d01e7ae5f5aad140bb07693840 |
|
MD5 | b7af173d9bab86327a18754a03c2e94d |
|
BLAKE2b-256 | ba196baed74287b39c6f9c3d7a0d40554ce204465503f41d1832f1b33253d58d |