This library simulates the motion of N-body pendulums.
By using an interesting yet a very simple topic, the main objective is to create a project where
- the main simulator,
- the background information (the equations, the numerical methods), and
- the user interface (the visualiser)
are all included and properly combined.
Visit the website, where an on-line simulator is available (note that it consumes some amount of your CPU resource).
The simulator and the surrounding interfaces are implemented in Rust
, which are converted into WebAssembly
for real-time executions powered by wasm-bindgen.
Please check out the other project for more details.
All recent browsers should be supported in theory. The followings are checked at least:
- Chrome 120.0.6099.119
- Safari 17.1
- Microsoft Edge 121.0.2277.83
- Firefox 111.0.1
Things put at the root level (Cargo.toml
and src
) serve to construct a simple simulator written in Rust
.
One can try it locally and easily, without touching web-related things (WebAssembly
, Sphinx
documentation, TypeScript
) at all.
After cloning this project:
git clone https://github.com/NaokiHori/Pendulum
execute:
cargo run --release
A dumped file energy.dat
shows how the kinetic (2nd column), the potential (3rd column), and the total (4th column) energies change in time (1st column).
It is a simple txt
file basically; use whatever you like (e.g., Gnuplot
, Matplotlib
) to plot the results.
One of the physical-side topics which I am of interest in this project is the conservation of the total energy. Since I assume that the pendulums are frictionless, the total energy should be conserved throughout the run. Although it is trivial in theory, achieving this property is not easy at all; in particular one needs to design a special scheme to this end.
Visit the documentation to see how the numerical methods should be and how different the results are.
An article written in Japanese (mostly focusing on the physical side) is available as well.
Initially this project adopted C, which was removed from this repository and is now placed here (the code is still about 10% faster).