A Go tool for analyzing LAMMPS molecular dynamics simulation output files. This utility parses LAMMPS trajectory data to calculate atomic distances and track atom trajectories over time with parallel processing for improved performance.
This tool provides an interactive command-line interface for processing LAMMPS output files. It allows scientists and researchers to extract specific information about atomic movements and interactions from simulation data.
- Distance Calculation: Calculate distances between selected atoms across simulation timesteps
- Trajectory Tracking: Follow the movement of specific atoms throughout the simulation
- Parallel Processing: Utilizes Go's concurrency features for efficient data handling
- Interactive Selection: User-friendly interface to select atoms of interest
- Flexible Output: Results can be written to files or displayed in the console
- Go 1.13 or higher
- Git
- (Optional) UPX for executable compression
git clone https://github.com/ErikPitko/lammps-parser.git
cd lammps-parsermake buildmake build-winbuild: Creates binary for Linux/Unix systems inbin/directorybuild-win: Cross-compiles Windows executable with optimized CGO flags- Note: Remove
#before upx commands in Makefile to enable executable compression
Run the binary with a LAMMPS trajectory file as the input:
./bin/lammps-parser path/to/your/lammps_output.lammpstrjThe program will guide you through several prompts:
- Whether you want to compute distances between atoms (Y/n)
- If yes, the output file name (leave empty for console output)
- Selection of atoms to track (multiple selections possible)
- Whether you want to compute atom trajectories
- If yes, which atom to trace and the trajectory output file name
The project is organized into several packages:
- distance: Handles calculations of distances between atoms
- trajectory: Tracks atom positions over time
- utilities: Contains helper functions for parsing and data conversion
The parser implements a highly concurrent processing model:
- Uses goroutines to process timesteps in parallel
- Implements channels for communication between processors
- Uses semaphores to limit memory consumption during trajectory processing
- Synchronizes file access with mutexes
The program processes LAMMPS trajectory files in a streaming fashion:
- First pass identifies all atom types
- Second pass processes the data for selected atoms
- Data is buffered in memory efficiently to handle large files
- promptui: Interactive command-line prompts
- golang.org/x/sync/semaphore: Semaphore implementation for Go
- GoStats
- The program uses buffered channels with a capacity based on the estimated number of steps
- A semaphore limits the number of trajectory calculations in flight to prevent memory exhaustion
- Parallel workers process distance calculations, improving throughput on multi-core systems
Contributions to improve the parser are welcome. Please feel free to submit issues or pull requests to the repository.