A simple runge-kutta 4 integrator
Project description
A simple implementation of Runge-Kutta for python.
Install from PyPi
pip install pyrk
Develop
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 Distribution
pyrk-0.5.2.tar.gz
(2.0 kB
view details)
File details
Details for the file pyrk-0.5.2.tar.gz
.
File metadata
- Download URL: pyrk-0.5.2.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 295eea131bbc0932fea439a93da79bf6f098f2559d6b1f5dd600fdeb508bba33 |
|
MD5 | d81641be6cbde1f4a1df0c8a02ef02f4 |
|
BLAKE2b-256 | 585141f2f0063b4a9e3240c30d72f68f3130d58c7e12ed2706268a53125037f5 |