189 lines
4.1 KiB
Org Mode
189 lines
4.1 KiB
Org Mode
#+TITLE: dump2rotorang.py
|
|
#+AUTHOR:
|
|
#+DATE:
|
|
|
|
* 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:
|
|
|
|
#+begin_src sh
|
|
pip install numpy pandas
|
|
#+end_src
|
|
|
|
* Input files
|
|
|
|
The script searches for trajectory files with the following filename
|
|
patterns:
|
|
|
|
#+begin_src text
|
|
D3d-o_*K.lammpstrj
|
|
D3d-p_*K.lammpstrj
|
|
#+end_src
|
|
|
|
For example:
|
|
|
|
#+begin_src text
|
|
D3d-o_300K.lammpstrj
|
|
D3d-o_400K.lammpstrj
|
|
D3d-p_300K.lammpstrj
|
|
D3d-p_400K.lammpstrj
|
|
#+end_src
|
|
|
|
The temperature is extracted from the filename using the pattern:
|
|
|
|
#+begin_src text
|
|
_(number)K.lammpstrj
|
|
#+end_src
|
|
|
|
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:
|
|
|
|
#+begin_src text
|
|
xu yu zu
|
|
#+end_src
|
|
|
|
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:
|
|
|
|
#+begin_src text
|
|
ITEM: ATOMS id mol type xu yu zu
|
|
#+end_src
|
|
|
|
* Analysis details
|
|
|
|
The benzene atoms are selected by the following atom indices within each
|
|
molecule:
|
|
|
|
#+begin_src python
|
|
benzene_id = [24, 25, 26, 27, 28, 29]
|
|
#+end_src
|
|
|
|
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:
|
|
|
|
#+begin_src python
|
|
np.arctan2(vec[:, 1], vec[:, 0])
|
|
#+end_src
|
|
|
|
The z-position is calculated as the mean z-coordinate of the selected
|
|
benzene atoms.
|
|
|
|
* Output files
|
|
|
|
The script creates the following pickle files:
|
|
|
|
#+begin_src text
|
|
D3d-o.pkl
|
|
D3d-p.pkl
|
|
#+end_src
|
|
|
|
Each pickle file contains a dictionary indexed by temperature.
|
|
|
|
For example:
|
|
|
|
#+begin_src python
|
|
dset[300]["orientation"]
|
|
#+end_src
|
|
|
|
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:
|
|
|
|
#+begin_src sh
|
|
python dump2rotorang.py hoge.lammpstrj
|
|
#+end_src
|
|
|
|
If trajectory files matching the expected patterns exist, the script will
|
|
print the processed filenames and create pickle files.
|
|
|
|
Example:
|
|
|
|
#+begin_src text
|
|
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.
|
|
#+end_src
|
|
|
|
* 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:
|
|
|
|
#+begin_src sh
|
|
cp example.lammpstrj D3d-o_300K.lammpstrj
|
|
python dump2rotorang.py
|
|
#+end_src
|
|
|
|
This will create:
|
|
|
|
#+begin_src text
|
|
D3d-o.pkl
|
|
#+end_src
|
|
|
|
* 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 =-pi= to =pi=.
|
|
- The z-position histogram is calculated in the range from =24= to =25=.
|
|
- If the target system or molecule definition is changed, the values of
|
|
=benzene_id= and 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:
|
|
|
|
#+begin_src text
|
|
dump2rotorang.py
|
|
example.lammpstrj
|
|
README.org
|
|
.gitignore
|
|
#+end_src
|
|
|
|
|