Visualization of particle trajectories.
Project description
ZnVis
ZnVis is a visualisation engine for particle simulation data. Simply define the particles in the simulation with details including their positions, colour, direction, and shape, and the visualization engine will display the system using the Open3D engine. ZnVis works both from a Python script and in Jupyter!
ZnVis can currently perform the following tasks:
- Visualize simulations and trajectories
- Create spherical and cylindrical mesh's for visualization
- Handle custom mesh objects
- Export png stills from the visualizer
- Export scences as
.obj
files.
Installation
ZnVis is a purely Python package hosted on PyPi. It can therefore be installed using pip with:
pip install znvis
If you prefer to access the source code, run the following from a terminal:
git clone https://github.com/zincware/ZnVis.git
cd ZnVis
pip install .
Once complete, you will be able to start using the visualizer by importing it as:
import znvis
How does it work?
ZnVis is essentially a convenience wrapper of the Open3D project with a focus on mesh visualization. The idea came out of wanting a simple way of visualizing particle trajectories from numpy arrays directly from a simulation script.
Below we show an example script from a reinforcement learning experiment built using Shameless plug alert SwarmRL
import numpy as np
import h5py as hf
import znvis as vis
# Load data from the database
with hf.File("training/trajectory.hdf5", 'r') as db:
positions = db["colloids"]["Unwrapped_Positions"][:]
# Split data for convenience
colloid_positions = positions[:, 0:10, :]
rod_positions = positions[:, 10:, :]
# Create free colloid mesh
colloid_mesh = vis.Sphere(radius=2.14, colour=np.array([30, 144, 255]) / 255, resolution=10)
colloid_particle = vis.Particle(name="Colloid", mesh=mesh, position=colloid_positions)
# Create rod colloid mesh
rod_mesh = vis.Sphere(radius=2.14, colour=np.array([255, 140, 0]) / 255, resolution=10)
rod_particle = vis.Particle(name="Rod", mesh=mesh, position=rod_positions)
# Run the visualizer
visualizer = vis.Visualizer(particles=[colloid_particle, rod_particle], frame_rate=80)
visualizer.run_visualization()
Just like that, a visualization window (shown below) will pop up from which you can play the trajectory and watch your RL agents rotate a rod.
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
File details
Details for the file ZnVis-0.1.0.tar.gz
.
File metadata
- Download URL: ZnVis-0.1.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 305b4d8acbe5def5784e239cb9f1987c2d1de9d058d6aab604795a481e40b179 |
|
MD5 | 8c310da0250131f43354f4ba1552bc3b |
|
BLAKE2b-256 | 69479938feecf7d7e8c501ea2cfd36c953415a9c0d86919c47f8f8aeb1c16038 |
File details
Details for the file ZnVis-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: ZnVis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 041daf6cae4628133cdf512f2b701dca0c79272259f5b0ecb3dd3eed1465161d |
|
MD5 | 8ef456071764d65c74ad0437936d631b |
|
BLAKE2b-256 | 2fecaa3cb8311fed730f93d1d7fceed8887cde98057a1ab93bef464576328575 |