dump2rotorang.py
- Overview
- Requirements
- Input files
- LAMMPS dump format
- Analysis details
- Output files
- Usage
- Example
- Notes
- Files managed in this repository
Overview
dump2rotorang.py analyzes LAMMPS trajectory files and calculates
orientation and z-position distributions of benzene molecules.
The script reads LAMMPS dump trajectory files *.lammpstrj, extracts the
coordinates of selected atoms in each molecule, and evaluates:
- the in-plane orientation angle of each benzene molecule
- the center z-position of each benzene molecule
The resulting histograms are saved as Python pickle files.
Requirements
This script requires Python 3 and the following Python packages:
- numpy
- pandas
Install them, for example, using pip:
pip install numpy pandas
Input files
The script searches for trajectory files with the following filename patterns:
D3d-o_*K.lammpstrj
D3d-p_*K.lammpstrj
For example:
D3d-o_300K.lammpstrj
D3d-o_400K.lammpstrj
D3d-p_300K.lammpstrj
D3d-p_400K.lammpstrj
The temperature is extracted from the filename using the pattern:
_(number)K.lammpstrj
For example, D3d-o_300K.lammpstrj is interpreted as 300 K.
LAMMPS dump format
The trajectory file is assumed to be a LAMMPS dump file containing unwrapped atomic coordinates:
xu yu zu
The script also assumes that the dump file contains a mol column, which
is used to identify molecules.
A typical header should include columns such as:
ITEM: ATOMS id mol type xu yu zu
Analysis details
The benzene atoms are selected by the following atom indices within each molecule:
benzene_id = [24, 25, 26, 27, 28, 29]
These indices are hard-coded in the script.
The orientation of each benzene molecule is calculated from the vector between:
- the center of the selected benzene atoms
- the midpoint of atoms 25 and 26 in the selected benzene atom list
The orientation angle is calculated using:
np.arctan2(vec[:, 1], vec[:, 0])
The z-position is calculated as the mean z-coordinate of the selected benzene atoms.
Output files
The script creates the following pickle files:
D3d-o.pkl
D3d-p.pkl
Each pickle file contains a dictionary indexed by temperature.
For example:
dset[300]["orientation"]
contains a pandas DataFrame with the following columns:
| Column | Description |
|---|---|
| angle | Bin center of orientation angle |
| angle_y | Histogram count of orientation angle |
| zpos | Bin center of z-position |
| zpos_y | Histogram count of z-position |
Usage
Place dump2rotorang.py in the directory containing the LAMMPS trajectory
files, then run:
python dump2rotorang.py hoge.lammpstrj
If trajectory files matching the expected patterns exist, the script will print the processed filenames and create pickle files.
Example:
D3d-o_300K.lammpstrj
D3d-o_400K.lammpstrj
D3d-o.pkl was created.
D3d-p_300K.lammpstrj
D3d-p_400K.lammpstrj
D3d-p.pkl was created.
Example
If example.lammpstrj is included as a sample trajectory file, rename or
copy it to match the expected naming rule before running the script:
cp example.lammpstrj D3d-o_300K.lammpstrj
python dump2rotorang.py
This will create:
D3d-o.pkl
Notes
- The atom indices used for benzene are currently hard-coded.
- The script assumes that all molecules have the same number of atoms.
- The orientation histogram is calculated in the range from
-pitopi. - The z-position histogram is calculated in the range from
24to25. - If the target system or molecule definition is changed, the values of
benzene_idand the histogram range for z-position may need to be modified.
Files managed in this repository
This repository is intended to manage only the following files:
dump2rotorang.py
example.lammpstrj
README.org
.gitignore