| Crates.io | parsys |
| lib.rs | parsys |
| version | 0.2.0 |
| created_at | 2020-10-25 10:43:27.836252+00 |
| updated_at | 2020-11-01 09:31:34.781985+00 |
| description | A 2D particle system simulator library |
| homepage | |
| repository | https://gitlab.com/hankruiger/parsys |
| max_upload_size | |
| id | 305258 |
| size | 26,453 |
parsysThis is an experimental particle system simulator.
The API is very likely to change so using it in your project is currently not recommended.
Two integration methods are implemented: Explicit Euler (EE) and Runge-Kutta 4 (RK4). EE is faster but less accurate.
For a simulation step from $t$ to $t + h$, we need as input:
\vec{x}^t$: Positions of all particles at time $t$.\vec{v}^t$: Velocities of all particles at time $t$.\vec{a}(\vec{x}, \vec{v})$: A function that, given all positions and velocities, computes the accelerations.As output, we will compute approximations of $\vec{x}^{t + h}$ and $\vec{v}^{t + h}$.
Explicit Euler integration works as follows:
\vec{a}^t = \vec{a}(\vec{x}^t, \vec{v}^t)$O(h^2)$):
\vec{x}^{t + h} \approx \vec{x}^t + h \vec{v}^t$\vec{v}^{t + h} \approx \vec{v}^t + h \vec{a}^t$For a simulation step from $t$ to $t + h$, we need as input:
\vec{x}^t$: Positions of all particles at time $t$.\vec{v}^t$: Velocities of all particles at time $t$.\vec{a}(\vec{x}, \vec{v})$: A function that, given all positions and velocities, computes the accelerations.As output, we will compute approximations of $\vec{x}^{t + h}$ and $\vec{v}^{t + h}$.
RK4 integration works as follows:
\vec{a}^t = \vec{a}(\vec{x}^t, \vec{v}^t)$\vec{x}^{mid_1} = \vec{x}^t + \frac{h}{2}\vec{v}^t$ and $\vec{v}^{mid_1} = \vec{v}^t + \frac{h}{2}\vec{a}^t$\vec{a}^{mid_1} = \vec{a}(\vec{x}^{mid_1}, \vec{v}^{mid_1})$\vec{x}^{mid_2} = \vec{x}^t + \frac{h}{2}\vec{v}^{mid_1}$ and $\vec{v}^{mid_2} = \vec{v}^t + \frac{h}{2}\vec{a}^{mid_1}$\vec{a}^{mid_2} = \vec{a}(\vec{x}^{mid_2}, \vec{v}^{mid_2})$\vec{x}^{end} = \vec{x}^t + h\vec{v}^{mid_2}$ and $\vec{v}^{end} = \vec{v}^t + h\vec{a}^{mid_2}$\vec{a}^{end} = \vec{a}(\vec{x}^{end}, \vec{v}^{end})$O(h^5)$):
\vec{x}^{t + h} \approx \vec{x}^t + h \frac{\vec{v}^t + 2 \vec{v}^{mid_1} + 2 \vec{v}^{mid_2} + \vec{v}^{end}}{6}$\vec{v}^{t + h} \approx \vec{v}^t + h \frac{\vec{a}^t + 2 \vec{a}^{mid_1} + 2 \vec{a}^{mid_2} + \vec{a}^{end}}{6}$