Skip to main content

PyTest code-style zincware

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.

Visualizer Example

Metadata

Release files for ZnVis 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ZnVis 0.1.0
File Size Uploaded
ZnVis-0.1.0.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ZnVis 0.1.0
File Interpreter ABI Platform
ZnVis-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / ZnVis-0.1.0.tar.gz

Download URL ZnVis-0.1.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
305b4d8acbe5def5784e239cb9f1987c2d1de9d058d6aab604795a481e40b179
BLAKE2b-256 checksum
How to use checksums
69479938feecf7d7e8c501ea2cfd36c953415a9c0d86919c47f8f8aeb1c16038
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / ZnVis-0.1.0-py3-none-any.whl

Download URL ZnVis-0.1.0-py3-none-any.whl
Size 20.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
041daf6cae4628133cdf512f2b701dca0c79272259f5b0ecb3dd3eed1465161d
BLAKE2b-256 checksum
How to use checksums
2fecaa3cb8311fed730f93d1d7fceed8887cde98057a1ab93bef464576328575
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page