More functions

Here we demonstrate the reading of MD data in LAMMPS format. Unlike the VASP standard, we need to specify the MD settings separately, with a tuple containing the initial temperature, final temperature and MD time-step. This is the same for all other data formats (but please note that the form of this tuple may change with data types as different information is recorded by the trajectory files, details can be found in Docs).

The octahedral tilting and distortion calculation can be accelerated with the multi_thread option, where the frames will be allocated to multiple threads with the help from joblib.

Also, multiple times of dynamics function can be called on the same initialized Trajectory object if you want to change the analysis options.

from pdyna.core import Trajectory

# please make sure the file "lammps_example_mapbbr3.out.gz" is unzipped in the same directory as this script in prior

MDtup = (200, 200, 1)  # tuple containing the MD simulation parameters: (initial T, final T, time step in fs)
traj = Trajectory("lammps", ('lammps_example_mapbbr3.out', MDtup))

traj.dynamics(
    read_mode=1,            # key parameter, 1: equilibration mode, 2: transient mode
    uniname='LAMMPS_test',  # A unique user-defined name for this trajectory, will be used in printing and figure saving
    allow_equil=0.5,        # take the first x fraction of the trajectory as equilibration, this part will not be computed
    read_every=0,           # read only every n steps, default is 0 which the code will decide an appropriate value according to the system size
    saveFigures=True,       # whether to save produced figures

    # function toggles
    toggle_lat = True,           # switch of lattice parameter calculation
    toggle_tavg = True,          # Switch of time averaged structure. 
    toggle_tilt_distort = True,  # switch of octahedral tilting and distortion calculation
    toggle_MO = True,            # switch of molecular orientation (MO) calculation (for organic A-site)

    # Lattice parameter calculation
    lat_method=2,    # lattice parameter analysis methods, 1: direct lattice cell dimension, 2: pseudo-cubic lattice parameter
    zdir=1,          # specified z-direction in case of lat_method 2, 0: a-axis, 1: b-axis, 2: c-axis

    # time averaged structure
    start_ratio=0.8,       # time-averaging structure ratio, e.g. 0.9 means only averaging the last 10% of trajectory
    tavg_save_dir='.\\',   # directory for saving the time-averaging structures

    # octahedral tilting and distortion
    structure_type=1,         # 1: 3C polytype, 2: other non-perovskite with orthogonal reference enabled, 3: other non-perovskite with initial config as reference
    multi_thread=8,           # enable multi-threading in this calculation
    tilt_corr_NN1=True,       # Enable first NN correlation of tilting, reflecting the Glazer notation. Default is True.
    tilt_corr_spatial=True,   # Enable computing of spatial correlation beyond NN1. Default is False.   
)
------------------------------------------------------------
Loading Trajectory files...
Current sample: LAMMPS_test
Time Span: 19.9 ps
Frame count: 199
Reading from frame no.100
Reading every 1 frame(s)
Number of atoms: 20736
Temperature: 100K
 
A-sites are -> MA: 1728
_images/0afe4e9c478b1ec06527696406bf6b36e165f278d7cf5a25cc0da49fe1e80d47.png
Pseudo-cubic lattice parameter:  [5.953  6.0569 5.9543]

Computing octahedral tilting and distortion...
Progress: 100%|██████████| 99/99 [01:56<00:00,  1.18s/it]
_images/ea5fd0e01a2c68167541399ca4ec5d2aa1ce8ddc3f367bc36607b9da048857a5.png _images/57f1e9e43b529afab06e3a03cc11e362278b9a0dc40c644338967a0a0e183532.png _images/b5ab9ba39d1235c37d203943202ea49226176396fe27712dbc49b7f9f420b9ef.png
c:\Users\Xia\anaconda3\lib\site-packages\pdyna\analysis.py:4462: RuntimeWarning: overflow encountered in exp
  return np.exp(-k*x)
Tilting spatial correlation length: 
 [[  0.42  159.218   1.224]
 [  1.167 144.872   1.083]
 [  1.182 159.694   0.413]]
dynamic X-site distortion: [0.0327 0.0999 0.0905 0.1196]
dynamic B-site distortion: [0.0613 0.0598 0.0708]
dynamic tilting: [0.  9.4 0. ]
tilting correlation: [ 0.037 -1.     0.038]
 
_images/d606c8c4492b5ba1c463ba20deb554dd3c9b343a4dbf637cd2b8a8fb6499cbee.png _images/dee8e018d6c1e242f27768d1d9b7d822d51fee34ebeef19b140cac1854e0efee.png _images/5881021e237d6d7d45ee4ccac5e41079f0e0be9c0cf8aca57eb165c4eff05cdd.png _images/5830e3f73e6c21ed0e5d7be32914f57192ef3a61162c2bdd01fdb227c0c9e154.png _images/c535b364c61c7c5b11828ccb174f2ec5bfdd2771d3d7a659771b7f1224ff801b.png _images/3cdad11e20f7f27c32c9f967608d42c37ddfa26c4787999f0609edb2f364c1bb.png
 
--Elapsed Time
Data Reading:          00:00:12
Structure Resolving:   00:00:02
Lattice Parameter:     00:00:13
Tilting & Distortion:  00:02:11
Molecular Orientation: 00:01:05
Total:                 00:03:44
------------------------------------------------------------