3D Vicsek Model Collective Motion Simulator with Numba Acceleration
Project description
manuk-kepudang: A Python Library for 3D Vicsek Model Simulation
A Python library for simulating collective motion using the 3D Vicsek model with Numba JIT acceleration and spatial entropy metrics.
Model
The Vicsek model (1995) describes self-propelled particles exhibiting collective motion through simple alignment rules. In 3D, each particle $i$ updates its velocity according to:
$$\mathbf{v}i(t + \Delta t) = v_0 \cdot \hat{\mathbf{u}}\left( \langle \hat{\mathbf{v}}j \rangle{|r{ij}| < r} + \eta \boldsymbol{\xi}_i \right)$$
where:
- $v_0$ is the constant speed of all particles
- $\langle \hat{\mathbf{v}}_j \rangle$ is the normalized average velocity of neighbors within radius $r$
- $\eta$ is the noise amplitude
- $\boldsymbol{\xi}_i$ is a random unit vector
- $\hat{\mathbf{u}}(\cdot)$ denotes normalization to unit vector
Position updates follow:
$$\mathbf{r}_i(t + \Delta t) = \mathbf{r}_i(t) + \mathbf{v}_i(t + \Delta t) \cdot \Delta t$$
with periodic boundary conditions in a cubic box of side $L$.
Key Parameters
| Parameter | Symbol | Description | Typical Range |
|---|---|---|---|
| N | $N$ | Number of particles | 50-5000 |
| L | $L$ | Box size | 5-50 |
| v0 | $v_0$ | Particle speed | 0.1-1.0 |
| r | $r$ | Interaction radius | 1.0-5.0 |
| eta | $\eta$ | Noise magnitude | 0.0-2.0 |
| dt | $\Delta t$ | Time step | 0.1-1.0 |
Order Parameter
The collective alignment is quantified by the order parameter:
$$\phi = \frac{1}{N v_0} \left| \sum_{i=1}^{N} \mathbf{v}_i \right|$$
where $\phi \approx 0$ indicates disordered motion and $\phi \approx 1$ indicates collective alignment.
Spatial Entropy Metrics
This library includes rigorous information-theoretic measures to quantify spatial order/disorder:
| Metric | Description | High Value | Low Value |
|---|---|---|---|
| Positional Entropy | Shannon entropy of spatial distribution | Uniform (disordered) | Clustered (ordered) |
| Orientational Entropy | Entropy of velocity directions on unit sphere | Isotropic (disordered) | Aligned (ordered) |
| Local Alignment Entropy | Heterogeneity of local order | Heterogeneous | Homogeneous |
| Pair Correlation Entropy | From radial distribution function g(r) | Ideal gas | Crystalline |
| Voronoi Cell Entropy | Geometric packing disorder | Irregular | Regular |
| Position-Velocity MI | Mutual information coupling | Spatial structure | Homogeneous |
| Spatial Complexity Index | Weighted composite measure | Disordered | Ordered |
*SCI = (H_positional + H_orientational + H_local_align + H_pair + H_voronoi + (1-MI)) / 6
Installation
From PyPI:
pip install manuk-kepudang
From source:
git clone https://github.com/sandyherho/manuk-kepudang.git
cd manuk-kepudang
pip install .
Development installation with Poetry:
git clone https://github.com/sandyherho/manuk-kepudang.git
cd manuk-kepudang
poetry install
Quick Start
CLI:
manuk-kepudang case1 # Run ordered phase scenario
manuk-kepudang case2 # Run disordered phase scenario
manuk-kepudang --all # Run all test cases
manuk-kepudang case1 --no-entropy # Skip entropy computation
Python API:
from manuk_kepudang import VicsekSystem, VicsekSolver
from manuk_kepudang import compute_metrics_timeseries
# Create system with 200 particles
system = VicsekSystem(
n_particles=200,
box_size=10.0,
speed=0.5,
interaction_radius=2.0,
noise=0.3
)
# Initialize solver with Numba acceleration
solver = VicsekSolver(dt=1.0, use_numba=True)
# Run simulation for 500 steps
result = solver.solve(system, n_steps=500)
# Compute entropy metrics
metrics = compute_metrics_timeseries(
result['positions'],
result['velocities'],
result['time'],
system.box_size,
system.speed,
system.interaction_radius
)
print(f"Final order parameter: {result['final_order_parameter']:.4f}")
print(f"Final SCI (disorder): {metrics['spatial_complexity_index_final']:.4f}")
Features
- High-performance: Numba JIT compilation for 10-100x speedup
- 3D simulation: Full three-dimensional particle dynamics
- Periodic boundaries: Correct handling of boundary conditions
- Order parameter tracking: Real-time collective alignment measurement
- Spatial entropy metrics: Rigorous information-theoretic disorder measures
- Multiple output formats: CSV, NetCDF (CF-compliant), PNG, GIF
- Configurable scenarios: Text-based configuration files
Output Files
The library generates:
- CSV files:
*_order_parameter.csv- Order parameter time series*_entropy_timeseries.csv- All entropy measures over time*_entropy_summary.csv- Statistics (mean, std, min, max, final)*_final_state.csv- Final particle positions and velocities
- NetCDF: Full trajectory data with all metrics and CF-compliant metadata
- Variables:
x,y,z,vx,vy,vz,order_parameter, all entropy metrics
- Variables:
- PNG: Static summary plots with entropy visualization
- GIF: Animated 3D visualization with camera rotation
Test Cases
| Case | Description | N | η |
|---|---|---|---|
| 1 | Ordered phase | 200 | 0.3 |
| 2 | Disordered phase | 200 | 2.0 |
| 3 | Large system | 500 | 0.5 |
| 4 | Phase transition | 300 | 1.0 |
Dependencies
- numpy >= 1.20.0
- scipy >= 1.7.0
- matplotlib >= 3.3.0
- pandas >= 1.3.0
- netCDF4 >= 1.5.0
- numba >= 0.53.0
- Pillow >= 8.0.0
- tqdm >= 4.60.0
License
MIT © Sandy H. S. Herho, Iwan P. Anwar, Nurjanna J. Trilaksono, Rusmawan Suwarman
Citation
@software{herho2025_manuk_kepudang,
title = {manuk-kepudang: A Python library for 3D Vicsek model simulation},
author = {Herho, Sandy H. S. and Anwar, Iwan P. and Trilaksono, Nurjanna J. and Suwarman, Rusmawan},
year = {2025},
url = {https://github.com/sandyherho/manuk-kepudang}
}
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manuk_kepudang-0.0.1.tar.gz.
File metadata
- Download URL: manuk_kepudang-0.0.1.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6045be1f3c3fc3a2c7dbd6245428a8ededea65f6dcb425e1a3b73a834b169c4e
|
|
| MD5 |
18c48780d600d7cb8a0a4167d8df556c
|
|
| BLAKE2b-256 |
eab1fb3d6fce29f66beaf932d4f8354f512dce43ffc97a17b257457aea829afa
|
File details
Details for the file manuk_kepudang-0.0.1-py3-none-any.whl.
File metadata
- Download URL: manuk_kepudang-0.0.1-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.11.9-100.fc39.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c8f8d36be621e0a7ab6b70dc91dadab4791343ac584b8b387caec0326a108a4
|
|
| MD5 |
22e5370f0b712e77adac81127bc22032
|
|
| BLAKE2b-256 |
83b2e2e98a13bd7d7ae70b35a1d77ef8ce5d08d47a49ada14f29adae5e1ec246
|