Interactive visualization tool for VPIC (Vector Particle-In-Cell) simulation data.
- Interactive 2D/3D visualization of electromagnetic fields, particle hydro quantities, and diagnostics
- Diagnostic plots: j.E (energy dissipation), beta production (hybridVPIC), turbulence mixing
- Multiple plot types: Contours, 1D slices, averages
- Animation support for time series
- Tracer particle visualization with energy evolution
- Flexible configuration via YAML files or command-line arguments
- Auto-detection of data format, file structure, and particle species
- Multi-species support: Automatically detects ion species from hydro files (ideal for hybridVPIC)
In the VPIC run directory:
git clone https://github.com/xiaocanli/quick_check_vpic
cd quick_check_vpic
pip install .pip install numpy matplotlib h5py PySide6pip install pyyaml # For YAML configuration filesPerlmutter@NERSC: Use a conda environment and access via NERSC ThinLinc for better performance. ThinLinc provides a remote desktop environment that is much faster than X11 forwarding over SSH. See NERSC Python docs for setting up your Python environment.
For the GUI to work properly, you may need to set these environment variables:
export QT_API=PySide6
export QT_PLUGIN_PATH=~/.local/lib/python3.12/site-packages/PySide6/Qt/plugins/Caution
You might have a different version of Python. Adjust the path accordingly (e.g., python3.11, python3.9, etc.).
If you encounter the error qt.qpa.plugin: Could not find the Qt platform plugin "xcb", set these variables before running the program. You can add them to your ~/.bashrc or ~/.bash_profile for persistence:
echo 'export QT_API=PySide6' >> ~/.bashrc
echo 'export QT_PLUGIN_PATH=~/.local/lib/python3.12/site-packages/PySide6/Qt/plugins/' >> ~/.bashrc
source ~/.bashrcTo find your correct Qt plugin path:
python3 -c "from PySide6.QtCore import QLibraryInfo; print(QLibraryInfo.path(QLibraryInfo.LibraryPath.PluginsPath))"For HPC systems without internet access (e.g., air-gapped or restricted networks), you can prepare packages offline:
# Create a directory for wheels
mkdir wheelhouse
cd wheelhouse
# Download all required packages
pip download numpy matplotlib h5py PySide6 pyyaml# Copy the wheelhouse directory to your HPC system
# Then on the HPC system:
pip install --no-index --find-links=wheelhouse -r requirements.txtCreate a requirements.txt file:
numpy>=1.22
matplotlib>=3.6
h5py>=3
PySide6==6.4.3
pyyaml
Note: Make sure to download wheels for the correct Python version and platform that matches your HPC system. You can specify the platform when downloading:
pip download --platform manylinux2014_x86_64 --python-version 3.10 --only-binary=:all: numpy matplotlib h5py PySide6 pyyamlSimply run from your VPIC run directory:
cd /path/to/vpic/run/directory
python quick_check_vpic.pyThe tool will automatically:
- Detect HDF5 vs GDA data format
- Find smoothed data directories
- Identify turbulence mixing simulations
- Load the VPIC info file
Create a config.yaml file (copy from config_example.yaml):
# config.yaml
data:
hdf5_fields: true
smoothed_data: true
smooth_factor: 2
time:
tmin: 0
tmax: 100Then run:
python quick_check_vpic.py --config config.yamlOverride settings directly:
# Use HDF5 format, time range 10-50
python quick_check_vpic.py --hdf5 --tmin 10 --tmax 50
# Use GDA format without smoothing
python quick_check_vpic.py --gda --no-smoothSettings are applied in this order (later overrides earlier):
- Default values
- Auto-detected settings
config_example.yaml(if present)config.yaml(if present)- Specified config file (
--config) - Command-line arguments
Create config.yaml in your quick_check_vpic directory:
# Data format and location
data:
hdf5_fields: true # true for HDF5, false for GDA
smoothed_data: true # Use smoothed data
smooth_factor: 2 # Smoothing factor (if smoothed)
dir_smooth_data: "data_smooth" # Smoothed data directory
dir_fields_hdf5: "field_hdf5" # Field directory: "field_hdf5" (old VPIC) or "fields_hdf5" (new VPIC)
hdf5_data_order: "xyz" # HDF5 data organization: "xyz" (older VPIC) or "zyx" (newer VPIC)
momentum_field: true # Momentum data available
time_averaged_field: false # Time-averaged fields
turbulence_mixing: false # Turbulence mixing simulation
auto_detect_species: true # Auto-detect species from hydro files (recommended for hybridVPIC)
# species_list: ["electron", "H"] # Manually specify species (only if auto_detect_species is false)
# Time parameters
time:
tmin: 0 # Start frame
tmax: 52 # End frame
animation_tinterval: 100 # Animation interval (ms)
# Tracer particles
tracer:
filepath: "/path/to/tracer/data/"
filename: "electrons_ntraj1000_10emax.h5p"
# VPIC simulation info files
info_file: "../info" # Path to VPIC info file
log_file: "../vpic.out" # Path to VPIC log file (fallback if info file not found)The tool now automatically detects particle species from hydro files, making it compatible with both regular VPIC (with electrons) and hybridVPIC simulations (ion-only or multiple ion species).
Auto-detection (recommended):
data:
auto_detect_species: true # Automatically finds all species from hydro filesWhen enabled, the tool scans the hydro directory and discovers all available species (e.g., electron, H, ion, dion, hion). On startup, you'll see:
Auto-detected species: electron, H
Manual specification: For fine-grained control or when auto-detection doesn't work:
data:
auto_detect_species: false
species_list: ["ion", "dion", "hion"] # Specify exactly which species to loadUse cases:
- Regular VPIC: Auto-detects
electronand ion species (e.g.,H,He) - HybridVPIC: Auto-detects multiple ion species (e.g.,
ion,dion,hion) without electrons - Custom simulations: Manually specify any species combination
The main window provides:
- Variable selection: Choose electromagnetic fields, hydro quantities, or diagnostics
- Plot type: Contour, contour+slice, contour+average
- Time control: Slider and spinbox for frame selection
- Spatial range: X, Y, Z range selectors
- Animation: Play through time series with optional JPEG saving
- Contour: 2D color map of selected variable
- Contour + X/Y/Z Average: 2D map with averaged 1D profile
- Contour + X/Y/Z Slice: 2D map with 1D slice at specified position
- Time Frame: Navigate through simulation timesteps
- X/Y/Z Min/Max: Set spatial extent to visualize
- Plane: Select normal direction for 2D slicing (3D sims only)
- Auto-update: Automatically refresh plot when parameters change
- Integrate: Integrate along normal direction
- Fix colormap/colorbar: Lock color scheme and range
Select diagnostic plots from the Diagnostic plot dropdown. Available diagnostics:
-
jdotE: Energy dissipation (j·E). Shows where electromagnetic energy is converted to particle energy. Available for all simulations.
-
beta: Beta production diagnostics. Shows heating rate due to perpendicular and parallel pressure anisotropies in collisionless plasmas. Particularly useful for hybridVPIC simulations analyzing ion heating mechanisms. Requires
hydro-int-hdf5directory withhydro_beta_*.h5files. -
emix: Electron mixing fraction (for turbulence mixing simulations only). Shows
(ne_bot - ne_top) / (ne_bot + ne_top).
If beta files are not found, the tool will display a warning message and show a zero field.
Tracer trajectories are assumed to be in HDF5 format with each tracer in an individual group.
- Plot a field image first
- Select "trajectory" from the overplot dropdown
- Choose tracer index with spinbox
- Visualize particle trajectory colored by energy
- Inset plot shows energy vs time
Configure tracer paths in config.yaml or set tracer_filepath and tracer_filename in the code.
- Click "Start Animation" to play through time
- Optionally enable "Save JPEGs" to export frames to
./img/ - Use "Stop" and "Continue" to control playback
usage: quick_check_vpic.py [-h] [-c CONFIG] [--info-file INFO_FILE]
[--log-file LOG_FILE] [--hdf5] [--gda]
[--smooth] [--no-smooth] [--tmin TMIN]
[--tmax TMAX] [--no-auto-detect]
Options:
-h, --help Show help message
-c, --config CONFIG Path to YAML configuration file
--info-file INFO_FILE Path to VPIC info file (default: ../info)
--log-file LOG_FILE Path to VPIC log file (default: ../vpic.out)
--hdf5 Force HDF5 field format
--gda Force GDA field format
--smooth Force smoothed data mode
--no-smooth Force non-smoothed data mode
--tmin TMIN Minimum time frame
--tmax TMAX Maximum time frame
--no-auto-detect Disable auto-detection
Expected directory structure (from run directory):
run_directory/
├── info # VPIC simulation info (preferred)
├── vpic.out # VPIC log file (fallback if info missing)
├── field_hdf5/ # HDF5 fields (old VPIC) or
├── fields_hdf5/ # HDF5 fields (new VPIC) or
├── data/ # GDA fields
├── data_smooth/ # Smoothed data (optional)
├── hydro_hdf5/ # Hydro data
└── quick_check_vpic/ # This tool
├── quick_check_vpic.py
├── mainwindow.py
├── mainwindow.ui
├── config.yaml # Your config (optional)
└── config_example.yaml
This error occurs when Qt cannot find its platform plugins. This is common on HPC systems or when using X11 forwarding.
Solution 1: Set Qt plugin path
export QT_API=PySide6
export QT_PLUGIN_PATH=~/.local/lib/python3.12/site-packages/PySide6/Qt/plugins/
python3 quick_check_vpic.pySolution 2: Use ThinLinc or VNC (Recommended for HPC)
- At NERSC: Use ThinLinc instead of X11 forwarding
- Other HPC centers: Use VNC or remote desktop services
Solution 3: Reinstall PySide6
pip uninstall PySide6
pip install PySide6Solution 4: Check display settings
echo $DISPLAY # Should show something like :0 or localhost:10.0If DISPLAY is not set and you're on a remote system, you may need to enable X11 forwarding:
ssh -X user@hostname # Or use -Y for trusted X11 forwardingThe tool will automatically try to read from ../vpic.out log file if the info file is not found. This is useful for:
- Older simulations that don't have an
infofile - hybridVPIC runs that output parameters to the log file
If both files are missing, ensure one exists relative to where you run the script, or specify:
python quick_check_vpic.py --info-file /path/to/infoOverride with:
python quick_check_vpic.py --gda- Enable "Auto-update" checkbox
- Click "Plot" button after adjusting parameters
This can happen with:
-
Smoothed data: Verify
smooth_factormatches your data:python quick_check_vpic.py --smooth-factor 2
Or disable smoothing:
python quick_check_vpic.py --no-smooth
-
Wrong HDF5 data order: Newer VPIC versions organize data as (nz, ny, nx) instead of (nx, ny, nz). Update your
config.yaml:data: hdf5_data_order: "zyx" # For newer VPIC versions
Or use "xyz" for older versions (default)
Install PyYAML for config file support:
pip install pyyamlThe tool will still work with auto-detection or command-line args.
cd my_vpic_run
python quick_check_vpic/quick_check_vpic.py
# Select variable (e.g., "ex")
# Click "Start Animation"python quick_check_vpic.py --tmin 50 --tmax 100# Terminal 1: Smoothed
python quick_check_vpic.py --smooth
# Terminal 2: Raw
python quick_check_vpic.py --no-smoothCreate production_config.yaml:
data:
hdf5_fields: true
smoothed_data: true
smooth_factor: 4
time:
tmin: 0
tmax: 500Then:
python quick_check_vpic.py -c production_config.yamlThe layout mainwindow.ui is created using Qt Creator (free). To modify:
- Edit
mainwindow.uiin Qt Creator - Convert to Python:
pyside6-uic mainwindow.ui -o mainwindow.pyTo add new variables or diagnostics:
raw_plot_variables(): Add to variable listsread_data(): Add data reading logic if neededdiag_plot_variables(): For new diagnostics
Config: Configuration dataclass with YAML loading and auto-detectionload_config(): Configuration loading with fallback chainTracerData: Tracer particle data managementMplCanvas: Matplotlib Qt integrationMainWindow: Main GUI and visualization logic
- Configuration system: YAML files + command-line arguments
- Auto-detection: Automatically detect data format and structure
- Better error handling: Clearer error messages
- Type hints: Full type annotations for better IDE support
- Bug fixes: Fixed array dimension mismatches for smoothed data
- First time: Use auto-detection to see what the tool finds
- Save config: Once you find good settings, save to
config.yaml - Quick tests: Use command-line args for one-off changes
- Animation: Disable auto-update during animation for better performance
- Large datasets: Use spatial range selectors to focus on regions of interest
Please submit issues on GitHub or contact the maintainer:
- v2.2:
- Dynamic species detection: Automatically detects particle species from hydro files
- Beta production diagnostics: Added beta heating diagnostics for hybridVPIC simulations
- Reads field and hydro variables dynamically from HDF5 files instead of hardcoding
- Full support for hybridVPIC with multiple ion species (ion-only simulations)
- Added
auto_detect_speciesandspecies_listconfiguration options - Compatible with simulations having arbitrary species combinations
- v2.1:
- Added support for reading VPIC info from
vpic.outlog file (fallback wheninfofile is missing) - Added HPC offline package installation documentation
- Improved compatibility with hybridVPIC simulations
- Configurable log file path
- Added support for reading VPIC info from
- v2.0: Refactored with configuration system, auto-detection, type hints, and bug fixes
- v1.x: Original implementation
Note: This tool is designed for quick visualization and analysis. For publication-quality figures or detailed analysis, consider using dedicated analysis scripts.
