Skip to content

Commit

Permalink
Merge pull request #219 from shashikant193/master
Browse files Browse the repository at this point in the history
  • Loading branch information
phanish-suryanarayana authored Sep 9, 2024
2 parents 2bd0805 + 8b94b87 commit ef868ee
Show file tree
Hide file tree
Showing 18 changed files with 233,771 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
-Name
-changes

--------------
September 09, 2024
Name: Shashikant Kumar
Changes: (utils/mdanalysis)
1. Python post processing for MD analysis
1. Included plotting
2. Simplified the inter-diffusion


--------------
September 05, 2024
Name: Shashikant Kumar
Expand Down
49 changes: 49 additions & 0 deletions utils/mdanalysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# `mdanalysis` – Post processing of MD

## Overview

`mdanalysis.py` is a Python script that provides a set of tools for processing MD trajectory files generated by [**SPARC**](https://github.com/SPARC-X/SPARC/) and calculating various quantities such as total internal energy, total pressure, self-diffusion coefficient, inter-diffusion coefficient, shear viscosity, and pair-correlation funcions.

## Requirements

To use `mdanalysis.py`, you need the following:

- Python 3.6 or later
- Numpy


## Usage
```shell
$ python mdanalysis.py carbon.mdanalysis.inpt
```
To use the `mdanalysis.py` one needs an input file `carbon.mdanalysis.inpt` which contains the following variables.
* `SYSTEM_NAME:` - Name of the system. This will determine the names of the file (e.g. C2.out, C2.aimd, C2.out_01 etc)
* `N_FOLDERS:` - Number of folders used to run the simulation (Each folder will be considered a MD trajectory with an indepedent starting point)
* `FOLDER_PATH_SIMULATIONS:` - Location of the folders
* `N_SIMULATIONS_FOLDER:` -Number of simulation run within each folder (If it has 3 simulations, C2.out, C2.out_01, C2.out_02 files are expected.)
* `N_EQUIL:` - Number of MD steps for equilibriation
* `PCF_FLAG:` - Flag to do a pair correlation function calculation
* `RANGE_PCF:` - Maximum radial distance to be considered
* `SIZE_HIST_PCF:` - Total number of spherical shells to be considered
* `SELF_DIFFUSION_FLAG:` - Flag to do self-diffusion coefficient calculation using integration of VACF
* `BLOCK_LENGTH_SELF_DIFFUSION:` - Block length for self diffuison calculation
* `INTER_DIFFUSION_FLAG:` - Flag to do inter-diffusion coefficient calculation using integration of VACF
* `BLOCK_LENGTH_INTER_DIFFUSION:` - Block length for inter diffuison calculation
* `VISCOSITY_FLAG:` - Flag to do shear viscosity calculation using integration of VACF
* `BLOCK_LENGTH_VISCOSITY:` - Block length for viscosity calculation
* `INTERNAL_ENERGY_FLAG:` - Flag to get the mean and error bar of total internal energy (ha/atom)
* `PRESSURE_FLAG:` - Flag to get the mean and error bar of total pressure (GPa)

An output file named `carbon.mdanalysis.out` will be written with all the values.
## Usage
* The inter-diffusion coefficient has only been implemented for binary systems.
* The error bar has been calculated using the re-blocking method (https://web.ornl.gov/~kentpr/thesis/pkthnode31.html). The data for the standard deviation, block-size is also written in a text file. Please check these files to ensure that the standard deviations have reached close to limiting values
* For diffusion coefficients and viscosity, velocity autocorrelation function (VACF) and stress autocorrelation function (SACF) has also been written in files `vacf.txt` and `sacf.txt`. Check these files to make sure that they have decayes to zero for the specified block length.
* The block length for diffusion coefficients and viscosity calculation needs to be tuned by the user such that the corresponding auto-correlation functions have decayed to zero.

## Example

Explore an example of how to use `mdanalysis` to calculate for a dummy carbon system in the `example/` directory.



Binary file added utils/mdanalysis/example/D_t_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions utils/mdanalysis/example/D_t_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
t[fs] D_t
0.0000E+00 2.7258E-04
4.0000E-02 5.4509E-04
8.0000E-02 8.1743E-04
1.2000E-01 1.0895E-03
1.6000E-01 1.3611E-03
2.0000E-01 1.6321E-03
2.4000E-01 1.9025E-03
2.8000E-01 2.1721E-03
3.2000E-01 2.4408E-03
3.6000E-01 2.7085E-03
4.0000E-01 2.9752E-03
4.4000E-01 3.2406E-03
4.8000E-01 3.5048E-03
5.2000E-01 3.7676E-03
5.6000E-01 4.0290E-03
6.0000E-01 4.2888E-03
6.4000E-01 4.5470E-03
6.8000E-01 4.8035E-03
7.2000E-01 5.0583E-03
7.6000E-01 5.3113E-03
8.0000E-01 5.5625E-03
8.4000E-01 5.8117E-03
8.8000E-01 6.0590E-03
9.2000E-01 6.3044E-03
9.6000E-01 6.5477E-03
1.0000E+00 6.7889E-03
1.0400E+00 7.0281E-03
1.0800E+00 7.2651E-03
1.1200E+00 7.5000E-03
1.1600E+00 7.7328E-03
1.2000E+00 7.9633E-03
1.2400E+00 8.1917E-03
1.2800E+00 8.4180E-03
1.3200E+00 8.6420E-03
1.3600E+00 8.8638E-03
1.4000E+00 9.0834E-03
1.4400E+00 9.3007E-03
1.4800E+00 9.5159E-03
1.5200E+00 9.7288E-03
1.5600E+00 9.9395E-03
1.6000E+00 1.0148E-02
1.6400E+00 1.0354E-02
1.6800E+00 1.0558E-02
1.7200E+00 1.0760E-02
1.7600E+00 1.0960E-02
1.8000E+00 1.1158E-02
1.8400E+00 1.1353E-02
1.8800E+00 1.1547E-02
1.9200E+00 1.1738E-02
1.9600E+00 1.1927E-02
2.0000E+00 1.2114E-02
2.0400E+00 1.2299E-02
2.0800E+00 1.2481E-02
2.1200E+00 1.2662E-02
2.1600E+00 1.2841E-02
2.2000E+00 1.3018E-02
2.2400E+00 1.3193E-02
2.2800E+00 1.3366E-02
2.3200E+00 1.3536E-02
2.3600E+00 1.3705E-02
2.4000E+00 1.3872E-02
2.4400E+00 1.4038E-02
2.4800E+00 1.4201E-02
2.5200E+00 1.4363E-02
2.5600E+00 1.4522E-02
2.6000E+00 1.4680E-02
2.6400E+00 1.4836E-02
2.6800E+00 1.4991E-02
2.7200E+00 1.5143E-02
2.7600E+00 1.5294E-02
2.8000E+00 1.5444E-02
2.8400E+00 1.5591E-02
2.8800E+00 1.5737E-02
2.9200E+00 1.5882E-02
2.9600E+00 1.6024E-02
3.0000E+00 1.6166E-02
3.0400E+00 1.6305E-02
3.0800E+00 1.6443E-02
3.1200E+00 1.6580E-02
3.1600E+00 1.6715E-02
3.2000E+00 1.6849E-02
3.2400E+00 1.6981E-02
3.2800E+00 1.7112E-02
3.3200E+00 1.7241E-02
3.3600E+00 1.7369E-02
3.4000E+00 1.7495E-02
3.4400E+00 1.7621E-02
3.4800E+00 1.7744E-02
3.5200E+00 1.7867E-02
3.5600E+00 1.7988E-02
3.6000E+00 1.8108E-02
3.6400E+00 1.8227E-02
3.6800E+00 1.8344E-02
3.7200E+00 1.8460E-02
3.7600E+00 1.8575E-02
3.8000E+00 1.8689E-02
3.8400E+00 1.8802E-02
3.8800E+00 1.8913E-02
3.9200E+00 1.9023E-02
3.9600E+00 1.9132E-02
5 changes: 5 additions & 0 deletions utils/mdanalysis/example/block_error_D.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1.000000E+00 1.868896E-02 9.844698E-05
2.000000E+00 1.868896E-02 1.375621E-04
4.000000E+00 1.868856E-02 1.910072E-04
8.000000E+00 1.868856E-02 2.291131E-04
1.600000E+01 1.866421E-02 2.360276E-04
9 changes: 9 additions & 0 deletions utils/mdanalysis/example/block_error_IEN.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
block-length mean std-dev
1.000E+00 -5.879E+01 2.572E-01
2.000E+00 -5.879E+01 2.536E-01
4.000E+00 -5.879E+01 2.730E-01
8.000E+00 -5.878E+01 3.229E-01
1.600E+01 -5.877E+01 3.948E-01
3.200E+01 -5.874E+01 4.953E-01
6.400E+01 -5.874E+01 6.371E-01
1.280E+02 -5.863E+01 6.983E-01
9 changes: 9 additions & 0 deletions utils/mdanalysis/example/block_error_pressure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
block-length mean std-dev
1.000E+00 3.293282E+04 1.714E+01
2.000E+00 3.293282E+04 2.413E+01
4.000E+00 3.293075E+04 3.382E+01
8.000E+00 3.292659E+04 4.689E+01
1.600E+01 3.291819E+04 6.301E+01
3.200E+01 3.290485E+04 7.374E+01
6.400E+01 3.290485E+04 8.589E+01
1.280E+02 3.293060E+04 1.058E+02
3 changes: 3 additions & 0 deletions utils/mdanalysis/example/block_error_viscosity.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1.000000E+00 1.383397E-02 2.736892E-03
2.000000E+00 1.383397E-02 3.620604E-03
4.000000E+00 1.274491E-02 3.574479E-03
56 changes: 56 additions & 0 deletions utils/mdanalysis/example/carbon.MDanalysis.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
***************************************************************************
* MD analysis (Version 05 Sept 2024) *
* Date: 09/09/2024, 07:07:25 *
***************************************************************************
Inputs:

SYSTEM_NAME: carbon # Name of the system. This will determine the names of the file (e.g. C2.out, C2.aimd, C2.out_01 etc)
N_FOLDERS: 1 # Number of folders used to run the simulation (Each folder will be considered a MD trajectory with an indepedent starting point)
FOLDER_PATH_SIMULATIONS: ./ # Location of the folders
N_SIMULATIONS_FOLDER: 1 # Number of simulation run within each folder (If it has 3 simulations, C2.out, C2.out_01, C2.out_02 files are expected.)


N_EQUIL: 10 # Number of MD steps for equilibriation


PCF_FLAG: 1 # Flag to do a pair correlation function calculation
RANGE_PCF: 10 # Maximum radial distance to be considered
SIZE_HIST_PCF: 100 # Total number of spherical shells to be considered

SELF_DIFFUSION_FLAG: 1 # Flag to do self-diffusion coefficient calculation using integration of VACF
BLOCK_LENGTH_SELF_DIFFUSION: 100 # Block length


INTER_DIFFUSION_FLAG: 0 # Flag to do inter-diffusion coefficient calculation using integration of VACF
BLOCK_LENGTH_INTER_DIFFUSION: 100 # Block length

VISCOSITY_FLAG: 1 # Flag to do shear viscosity calculation using integration of VACF
BLOCK_LENGTH_VISCOSITY: 100 # Block length

INTERNAL_ENERGY_FLAG: 1 # Flag to get the mean and error bar of total internal energy (ha/atom)
PRESSURE_FLAG: 1 # Flag to get the mean and error bar of total pressure (GPa)


***************************************************************************
Internal energy (UEN + KENIG):
Mean of internal energy [ha/atom]: -5.879440854E+01
Error bar of internal energy [ha/atom]: 2.536E-01
***************************************************************************
Pressure (PRES + PRESIG):
Mean of pressure [GPa]: 3.293282311E+04
Error bar of pressure [GPa]: 4.689E+01
***************************************************************************
Self diffusion coefficient:
Self diffusion coefficients [cm^2/s]:
1.8689E-02,
Self diffusion coefficients error bar[cm^2/s]:
1.3756E-04,
***************************************************************************
Shear viscosity:
Viscosity [Pa-s]:
1.3834E-02,
Viscosity error bar[Pa-s]:
3.6206E-03,
***************************************************************************
Pair correlation function:
Pair correlation function written!!
Loading

0 comments on commit ef868ee

Please sign in to comment.