├── .gitignore ├── Examples ├── Acetonitrile │ ├── DEC │ │ ├── DEC.ipynb │ │ ├── PyLAT.sh │ │ ├── in.mol_nvt │ │ ├── mol.data │ │ └── output_Paper.json │ └── visc │ │ ├── PyLAT.sh │ │ ├── Visc.ipynb │ │ ├── inputgenerator.py │ │ ├── output_Paper.json │ │ └── test_1 │ │ ├── in.visc │ │ └── mol.data ├── Molten_NaCl │ ├── GKC │ │ ├── GKC.ipynb │ │ ├── PyLAT.sh │ │ ├── mol.data │ │ ├── nacl.in │ │ └── output_Paper.json │ └── nvt │ │ ├── NaCl_nvt.ipynb │ │ ├── PyLAT.sh │ │ ├── mol.data │ │ ├── nacl.in │ │ └── output_Paper.json └── README ├── LICENSE ├── PyLAT.py ├── README.md ├── compile.py ├── compile.sh ├── plots.py └── src ├── COMradial.py ├── MSD.py ├── __init__.py ├── calcCOM.f90 ├── calcCOM.py ├── calcCond.py ├── calcDielectricConstant.py ├── calcDiffusivity.py ├── calcNEconductivity.py ├── calcVisc.py ├── calcdistances.f90 ├── distSearch.py ├── fitVisc.py ├── getAtomCharges.py ├── getCoordinationNumber.py ├── getMolData.py ├── getTimeData.py ├── ionpair.py ├── ipcorr.f90 └── viscio.py /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/cb0c6ef7ac68f2300409ee85501d9ad432cb4c7e/Python.gitignore 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | docs/_build/ 75 | 76 | # PyBuilder 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | .python-version 88 | 89 | # pipenv 90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 93 | # install all needed dependencies. 94 | #Pipfile.lock 95 | 96 | # pyflow 97 | __pypackages__/ 98 | 99 | # Celery stuff 100 | celerybeat-schedule 101 | celerybeat.pid 102 | 103 | # SageMath parsed files 104 | *.sage.py 105 | 106 | # Environments 107 | .env 108 | .venv 109 | env/ 110 | venv/ 111 | ENV/ 112 | env.bak/ 113 | venv.bak/ 114 | 115 | # Spyder project settings 116 | .spyderproject 117 | .spyproject 118 | 119 | # Rope project settings 120 | .ropeproject 121 | 122 | # mkdocs documentation 123 | /site 124 | 125 | # mypy 126 | .mypy_cache/ 127 | .dmypy.json 128 | dmypy.json 129 | 130 | # Pyre type checker 131 | .pyre/ 132 | 133 | 134 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/DEC/DEC.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Analysis of Acetonitrile to calculate the dielectric constant\n", 8 | "\n", 9 | "Assumes the path to PyLAT/src has been added to PYTHONPATH" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Import Classes\n", 17 | "\n", 18 | "import and initialize required classes for calculations" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from calcDielectricConstant import calcDielectricConstant\n", 28 | "from getAtomCharges import getatomcharges\n", 29 | "from getCoordinationNumber import getcoordinationnumber\n", 30 | "\n", 31 | "dec=calcDielectricConstant()\n", 32 | "gc=getatomcharges()\n", 33 | "gcn=getcoordinationnumber()" 34 | ] 35 | }, 36 | { 37 | "cell_type": "markdown", 38 | "metadata": {}, 39 | "source": [ 40 | "# Define input \n", 41 | "input for dielectric constant calculations" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 2, 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "datfilename='mol.data'\n", 51 | "trjfilename=['mol.lammpstrj']\n", 52 | "temp=298\n", 53 | "verb=0\n", 54 | "DEC_start=0\n", 55 | "output={}" 56 | ] 57 | }, 58 | { 59 | "cell_type": "markdown", 60 | "metadata": {}, 61 | "source": [ 62 | "# Preliminary Calculations\n", 63 | "Preliminary calculations for DEC calculation" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 3, 69 | "metadata": {}, 70 | "outputs": [], 71 | "source": [ 72 | "n=gc.findnumatoms(datfilename)\n", 73 | "(molcharges,atomcharges,n)=gc.getmolcharges(datfilename,n)\n", 74 | "(V,Lx,Ly,Lz)=gcn.getvolume(trjfilename[0])" 75 | ] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": {}, 80 | "source": [ 81 | "# Property Calculations\n", 82 | "Calculation of dielectric constant" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 4, 88 | "metadata": {}, 89 | "outputs": [], 90 | "source": [ 91 | "output = dec.calcDEC(atomcharges,trjfilename,temp,output,V,verb,DEC_start)" 92 | ] 93 | }, 94 | { 95 | "cell_type": "markdown", 96 | "metadata": {}, 97 | "source": [ 98 | "# Plot dielectric constant" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 5, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "23.2845053628\n" 111 | ] 112 | }, 113 | { 114 | "data": { 115 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3XmcXGWd7/HPr6p635N0Op21IaxhC9BkWBSCQWVxBGYQxMGLozPRAb2A1+vEHZ2LF0VAZUQGFUEFN5BBRSFhERAJkEAICZCFkBCydWfr9L5UPfNHne5UN7V0d/pUNae+79erX33q1Kk6vz7VVd86z3POc8w5h4iI5K9QrgsQEZHcUhCIiOQ5BYGISJ5TEIiI5DkFgYhInlMQiIjkOQWBiEieUxCIiOQ534LAzGaY2eNm9oqZrTazq7z515rZFjNb4f2c61cNIiKSmfl1ZrGZ1QP1zrkXzKwCWA5cAFwMtDnnvjPc55o0aZJraGjwpU4RkaBavnz5TudcbablIn4V4JzbBmzzplvN7FVg2mieq6GhgWXLlo1leSIigWdmm4azXFb6CMysATgeeNab9WkzW2lmd5hZTTZqEBGR5HwPAjMrB+4DrnbO7QN+CMwG5hLfY7gxxeMWmtkyM1vW3Nzsd5kiInnL1yAwswLiIXC3c+53AM65Hc65qHMu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q23ATjVOXePH88vMtZ0+KjkBTO7Fmhzzn0nC+uaT3x00A/4vS6RsaCmIclLZtbm/Z5vZk+Y2QNmtsHMrjezf/LGtH/ZzGZ7y9Wa2X1m9rz3c5o3/4yEMe5fNLMK4Hrg3d68a7xB0G7wHrfSzD6ZsO4nzexBbyz528ws5C1/p5mt8mq4JlfbSfKDmoZE4DjgSOLDY28Afuycm2fxC8F8Bria+NgwNzvn/mpmM4GHvcd8DrjSOfe0NzhcF/HhKAb2CLyRaFuccyd5o14+bWaLvXXPIz7O/CbgIeAfiA9nMM05d7T3+Gr/N4HkMwWBCDzvvOGmzex1oP9D+mXgTG/6LGCO7b8YVaX3wf80cJOZ3Q38zjn3lr39glXvA441s4u821XAoUAP8bFtNnjr/iXxYSUeBQ42s1uABxPqEfGFgkAEuhOmYwm3Y+x/j4SAk51zXUMee72ZPUh8rJenEy8fmMCAzzjnHh40M96XMLSTzjnn9pjZccQvjvIp4GLi496I+EJ9BCLDs5h4MxEAtv+at7Odcy87574FPE98zPtW4peW7Pcw8G+tVdmIAAAArUlEQVTekNKY2WFmVubdN8/i164NAZcAfzWzSUDIOXcf8GXil/YU8Y32CESG538DPzCzlcTfN08S/7Z+tZmdSXzvYTXxYYljQNTMXiJ+rdzvER96+wXvkoPN7L8s4fPER7A8hPjY+fcDxwA/9cIB4hdVEfGNDh8VyREdZirjhZqGRETynPYIRETynPYIRETynIJARCTPKQhERPKcgkBEJM8pCERE8pyCQEQkz/0PwUbMd5PNlcsAAAAASUVORK5CYII=\n", 116 | "text/plain": [ 117 | "" 118 | ] 119 | }, 120 | "metadata": { 121 | "needs_background": "light" 122 | }, 123 | "output_type": "display_data" 124 | } 125 | ], 126 | "source": [ 127 | "%matplotlib inline\n", 128 | "from matplotlib import pyplot as plt\n", 129 | "\n", 130 | "DEC=output['Dielectric Constant']['list']\n", 131 | "count = range(0,len(DEC))\n", 132 | "\n", 133 | "plt.xlabel('Timesteps')\n", 134 | "plt.ylabel(r'$\\epsilon$')\n", 135 | "plt.plot(count,DEC)\n", 136 | "\n", 137 | "print(DEC[-1])" 138 | ] 139 | } 140 | ], 141 | "metadata": { 142 | "kernelspec": { 143 | "display_name": "Python 2", 144 | "language": "python", 145 | "name": "python2" 146 | }, 147 | "language_info": { 148 | "codemirror_mode": { 149 | "name": "ipython", 150 | "version": 2 151 | }, 152 | "file_extension": ".py", 153 | "mimetype": "text/x-python", 154 | "name": "python", 155 | "nbconvert_exporter": "python", 156 | "pygments_lexer": "ipython2", 157 | "version": "2.7.14" 158 | } 159 | }, 160 | "nbformat": 4, 161 | "nbformat_minor": 2 162 | } 163 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/DEC/PyLAT.sh: -------------------------------------------------------------------------------- 1 | python ../../../PyLAT.py -T 298 --nummol 1000 --mol ACN --DEC -v 2 mol.log mol.data mol.lammpstrj 2 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/DEC/in.mol_nvt: -------------------------------------------------------------------------------- 1 | # 2 | variable NAME index mol 3 | log ${NAME}.log 4 | variable infile index mol.data 5 | variable mytemp index 298 6 | 7 | # set up simulation 8 | # the following information is saved to restart files 9 | units real 10 | atom_style full 11 | boundary p p p 12 | pair_style lj/cut/coul/long 12 13 | kspace_style pppm 0.0001 14 | pair_modify tail yes 15 | pair_modify mix arithmetic 16 | special_bonds amber 17 | 18 | bond_style harmonic 19 | angle_style harmonic 20 | dihedral_style charmm 21 | improper_style cvff 22 | 23 | read_data ${infile} 24 | 25 | neighbor 2.0 bin 26 | neigh_modify delay 0 every 1 check yes page 1000000 one 20000 27 | timestep 1.0 28 | 29 | ## end information that is saved to restart files 30 | 31 | ## create velocity profile 32 | #velocity all create ${mytemp} 314159265 units box 33 | velocity all zero linear units box 34 | dump DUMP all custom 500 ${NAME}.lammpstrj id type x y z mol 35 | thermo_style custom step cpu cpuremain vol temp press ke pe etotal enthalpy lx ly lz xy xz yz density 36 | thermo 1000 37 | # 38 | ## thermostat and integrator 39 | #minimize 1e-4 1e-6 10000 10000 40 | 41 | #fix shake all shake 0.0001 20 0 b 1 a 1 42 | #fix NPT all npt temp ${mytemp} ${mytemp} 100.0 iso 1.0 1.0 100.0 43 | fix NVT all nvt temp ${mytemp} ${mytemp} 100.0 44 | 45 | restart 50000 restart.${NAME}.1 restart.${NAME}.2 46 | run 20000000 47 | 48 | 49 | write_restart restart.${NAME} 50 | write_data restart.data 51 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/visc/PyLAT.sh: -------------------------------------------------------------------------------- 1 | python ../../../PyLAT.py -T 298 --nummol 1000 --mol ACN --Visc --Visc_Dir test_ --Visc_Num 50 --Visc_Skip 100001 -v 2 visc.log mol.data mol.lammpstrj -f output.json 2 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/visc/Visc.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Analysis of Acetonitrile to calculate the viscosity\n", 8 | "\n", 9 | "Assumes the path to PyLAT/src has been added to PYTHONPATH" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Import Classes\n", 17 | "\n", 18 | "import and initialize required classes for calculations" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from calcVisc import calcVisc\n", 28 | "cv = calcVisc()" 29 | ] 30 | }, 31 | { 32 | "cell_type": "markdown", 33 | "metadata": {}, 34 | "source": [ 35 | "# Define input \n", 36 | "input for viscosity calculations" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 2, 42 | "metadata": {}, 43 | "outputs": [], 44 | "source": [ 45 | "visc_dir = 'test_'\n", 46 | "visc_num = 50\n", 47 | "visc_skip = 10001\n", 48 | "visc_log = 'visc.log'\n", 49 | "verb = 0\n", 50 | "output = {}\n", 51 | "visc_samples = 30\n", 52 | "visc_num_boots = 10\n", 53 | "visc_plot=False\n", 54 | "visc_guess = [1e-3,1.5e-1,1e2,1e3]" 55 | ] 56 | }, 57 | { 58 | "cell_type": "markdown", 59 | "metadata": {}, 60 | "source": [ 61 | "# Property Calculations\n", 62 | "Calculation of viscosity" 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 3, 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "output = cv.calcvisc(visc_num,visc_skip,visc_dir,visc_log,output,verb,visc_samples,visc_num_boots,visc_plot,visc_guess)" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "# Print Output" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": 4, 84 | "metadata": {}, 85 | "outputs": [ 86 | { 87 | "name": "stdout", 88 | "output_type": "stream", 89 | "text": [ 90 | "Viscosity: 0.554670202894 plus or minus 0.0460776871265 cP\n" 91 | ] 92 | } 93 | ], 94 | "source": [ 95 | "print('Viscosity: {} plus or minus {} cP'.format(output[\"Viscosity\"][\"Average Value\"],output[\"Viscosity\"][\"Standard Deviation\"]))\n" 96 | ] 97 | } 98 | ], 99 | "metadata": { 100 | "kernelspec": { 101 | "display_name": "Python 2", 102 | "language": "python", 103 | "name": "python2" 104 | }, 105 | "language_info": { 106 | "codemirror_mode": { 107 | "name": "ipython", 108 | "version": 2 109 | }, 110 | "file_extension": ".py", 111 | "mimetype": "text/x-python", 112 | "name": "python", 113 | "nbconvert_exporter": "python", 114 | "pygments_lexer": "ipython2", 115 | "version": "2.7.14" 116 | } 117 | }, 118 | "nbformat": 4, 119 | "nbformat_minor": 2 120 | } 121 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/visc/inputgenerator.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Jul 13 14:45:35 2015 4 | 5 | @author: mhumbert 6 | """ 7 | 8 | import os 9 | import random 10 | 11 | 12 | samplefile = open('test_1/in.visc','r').readlines() 13 | filelist= range(2,51) 14 | for num in filelist: 15 | os.system('mkdir test_{0}'.format(num)) 16 | output = open('test_{0}/in.visc'.format(num),'w') 17 | for line in range(0,len(samplefile)): 18 | if line == 31: 19 | output.write('velocity all create ${{mytemp}} {0} units box \n'.format(random.randint(1,999999999))) 20 | else: 21 | output.write(samplefile[line]) 22 | output.close() 23 | os.system('cp test_1/mol.data test_{0}/'.format(num)) 24 | -------------------------------------------------------------------------------- /Examples/Acetonitrile/visc/output_Paper.json: -------------------------------------------------------------------------------- 1 | { 2 | "Viscosity": { 3 | "Units": "cP", 4 | "Standard Deviation": 0.054894732053765036, 5 | "Average Value": 0.5579461373589749 6 | } 7 | } -------------------------------------------------------------------------------- /Examples/Acetonitrile/visc/test_1/in.visc: -------------------------------------------------------------------------------- 1 | # 2 | variable NAME index visc 3 | log ${NAME}.log 4 | variable infile index mol.data 5 | variable mytemp index 323 6 | 7 | # set up simulation 8 | # the following information is saved to restart files 9 | units real 10 | atom_style full 11 | boundary p p p 12 | pair_style lj/cut/coul/long 12 13 | kspace_style pppm 0.0001 14 | pair_modify tail yes 15 | pair_modify mix arithmetic 16 | special_bonds amber 17 | 18 | bond_style harmonic 19 | angle_style harmonic 20 | dihedral_style charmm 21 | improper_style cvff 22 | 23 | read_data ${infile} 24 | 25 | neighbor 2.0 bin 26 | neigh_modify delay 0 every 1 check yes page 1000000 one 20000 27 | timestep 1.0 28 | 29 | ## end information that is saved to restart files 30 | 31 | ## create velocity profile 32 | velocity all create ${mytemp} 884079717 units box 33 | velocity all zero linear units box 34 | #dump DUMP all custom 50 ${NAME}.lammpstrj id type x y z vx vy vz mol 35 | thermo_style custom step cpu cpuremain vol temp press density pxx pxy pxz pyy pyz pzz 36 | thermo 5 37 | # 38 | ## thermostat and integrator 39 | #minimize 1e-4 1e-6 10000 10000 40 | 41 | #fix shake all shake 0.0001 20 0 b 1 a 1 42 | #fix NPT all npt temp ${mytemp} ${mytemp} 100.0 iso 1.0 1.0 100.0 43 | fix NVT all nvt temp ${mytemp} ${mytemp} 100.0 44 | 45 | restart 50000 restart.${NAME}.1 restart.${NAME}.2 46 | run 10000000 47 | 48 | 49 | write_restart restart.${NAME} 50 | write_data restart.data 51 | -------------------------------------------------------------------------------- /Examples/Molten_NaCl/GKC/GKC.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Analysis to calculate the Green-Kubo conductivity of molten NaCl\n", 8 | "\n", 9 | "Assumes the path to PyLAT/src has been added to PYTHONPATH" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "# Import Classes\n", 17 | "\n", 18 | "import and initialize required classes for calculations" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "from getAtomCharges import getatomcharges\n", 28 | "from calcCond import calcCond \n", 29 | "\n", 30 | "\n", 31 | "gc = getatomcharges()\n", 32 | "cc = calcCond()" 33 | ] 34 | }, 35 | { 36 | "cell_type": "markdown", 37 | "metadata": {}, 38 | "source": [ 39 | "# Define input \n", 40 | "input for Green-Kubo conductivity calculations" 41 | ] 42 | }, 43 | { 44 | "cell_type": "code", 45 | "execution_count": 2, 46 | "metadata": {}, 47 | "outputs": [], 48 | "source": [ 49 | "output = {}\n", 50 | "datfilename = 'mol.data'\n", 51 | "trjfilename=['mol.lammpstrj']\n", 52 | "logfilename='log.lammps'\n", 53 | "temp=1300\n", 54 | "nummoltype=[864,864] #number of each molecule type\n", 55 | "moltypel=['Na','Cl'] #list of all molecule types\n", 56 | "moltype = []\n", 57 | "for i in range(0,len(moltypel)):\n", 58 | " for j in range(0,nummoltype[i]):\n", 59 | " moltype.append(int(i))\n", 60 | "verb=2\n", 61 | "GKC_skip=0\n", 62 | "GKC_Tolerance=0.001\n", 63 | "GKC_J_Output=False" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "metadata": {}, 69 | "source": [ 70 | "# Preliminary Calculations\n", 71 | "Preliminary calculations for GKC calculation" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 3, 77 | "metadata": {}, 78 | "outputs": [], 79 | "source": [ 80 | "output['Conductivity'] = {}\n", 81 | "output['Conductivity']['units'] = 'S/m'\n", 82 | "n = gc.findnumatoms(datfilename)\n", 83 | "(molcharges, atomcharges,n) = gc.getmolcharges(datfilename,n)" 84 | ] 85 | }, 86 | { 87 | "cell_type": "markdown", 88 | "metadata": {}, 89 | "source": [ 90 | "# Property Calculations\n", 91 | "Calculation of Green-Kubo conductivity" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": 4, 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "name": "stdout", 101 | "output_type": "stream", 102 | "text": [ 103 | "beginning COM velocity calculation\n", 104 | "COM velocity calculation 47.10% complete" 105 | ] 106 | } 107 | ], 108 | "source": [ 109 | "output = cc.calcConductivity(molcharges, trjfilename, logfilename, datfilename, temp, output, moltype, moltypel,verb,GKC_skip,GKC_Tolerance,GKC_J_Output)" 110 | ] 111 | }, 112 | { 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "# Plot Cumulative Integral" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 5, 122 | "metadata": {}, 123 | "outputs": [ 124 | { 125 | "data": { 126 | "text/plain": [ 127 | "[]" 128 | ] 129 | }, 130 | "execution_count": 5, 131 | "metadata": {}, 132 | "output_type": "execute_result" 133 | }, 134 | { 135 | "data": { 136 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZoAAAEOCAYAAACw8dE2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5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UGQIsDiJYkcZSohGJs/AKqh+HO/WrGwzwDjCxhpf/0cwWmdli4BNgYbj8BGBm7KMVaTwNBhBJMmY2CrjR3S+pZ/1M4F/AxPA6IyJJRWc0IknG3b8A3iu/YbMe+hEacaYkI0lJZzQiIhIondGIiEiglGhERCRQSjQiIhIoJRoREQmUEo2IiARKiUZERAL1/wFxGpHCafCcAwAAAABJRU5ErkJggg==\n", 137 | "text/plain": [ 138 | "" 139 | ] 140 | }, 141 | "metadata": { 142 | "needs_background": "light" 143 | }, 144 | "output_type": "display_data" 145 | } 146 | ], 147 | "source": [ 148 | "%matplotlib inline\n", 149 | "from matplotlib import pyplot as plt\n", 150 | "\n", 151 | "Cumulative_Int = output['Conductivity']['GK_Integral']\n", 152 | "time = output['Conductivity']['Time']\n", 153 | "\n", 154 | "plt.xscale('log')\n", 155 | "plt.xlabel('t (fs)')\n", 156 | "plt.ylabel(r'$\\int_{0}^{\\infty}\\langle J(t)\\cdot J(0)\\rangle dt$')\n", 157 | "plt.plot(time,Cumulative_Int)" 158 | ] 159 | }, 160 | { 161 | "cell_type": "markdown", 162 | "metadata": {}, 163 | "source": [ 164 | "# Final Values" 165 | ] 166 | }, 167 | { 168 | "cell_type": "code", 169 | "execution_count": 6, 170 | "metadata": {}, 171 | "outputs": [ 172 | { 173 | "name": "stdout", 174 | "output_type": "stream", 175 | "text": [ 176 | "Total Conductivity: 395.711812212 S/m\n", 177 | "Contrinution of Na: 240.048777457 S/m\n", 178 | "Contrinution of Cl: 155.663034755 S/m\n" 179 | ] 180 | } 181 | ], 182 | "source": [ 183 | "print('Total Conductivity: {} {}'.format(output['Conductivity']['Green_Kubo'],output['Conductivity']['units']))\n", 184 | "print('Contrinution of Na: {} {}'.format(output['Conductivity']['Green_Kubo_Na'],output['Conductivity']['units']))\n", 185 | "print('Contrinution of Cl: {} {}'.format(output['Conductivity']['Green_Kubo_Cl'],output['Conductivity']['units']))" 186 | ] 187 | } 188 | ], 189 | "metadata": { 190 | "kernelspec": { 191 | "display_name": "Python 2", 192 | "language": "python", 193 | "name": "python2" 194 | }, 195 | "language_info": { 196 | "codemirror_mode": { 197 | "name": "ipython", 198 | "version": 2 199 | }, 200 | "file_extension": ".py", 201 | "mimetype": "text/x-python", 202 | "name": "python", 203 | "nbconvert_exporter": "python", 204 | "pygments_lexer": "ipython2", 205 | "version": "2.7.14" 206 | } 207 | }, 208 | "nbformat": 4, 209 | "nbformat_minor": 2 210 | } 211 | -------------------------------------------------------------------------------- /Examples/Molten_NaCl/GKC/PyLAT.sh: -------------------------------------------------------------------------------- 1 | python ../../../PyLAT.py -T 1300 --nummol 864 --nummol 864 --mol Na --mol Cl --GKC -v 2 log.lammps mol.data mol.lammpstrj 2 | -------------------------------------------------------------------------------- /Examples/Molten_NaCl/GKC/nacl.in: -------------------------------------------------------------------------------- 1 | # Tosi Fumi NaCl 2 | variable thisTemp equal 1300 3 | variable anealSteps equal 3000000 4 | variable relaxSteps equal 5000000 5 | variable newAnealSteps equal 1000000 6 | variable newRelaxSteps equal 1000000 7 | variable runSteps equal 1000000 8 | variable thermoSteps equal 10000 9 | 10 | units real 11 | atom_style full 12 | dimension 3 13 | boundary p p p 14 | 15 | pair_style born/coul/long 15 16 | 17 | neighbor 3.0 bin 18 | neigh_modify every 2 delay 0 check yes one 3000 19 | kspace_style ewald 1.0e-4 20 | 21 | #Atom defination part 22 | #read_data NaCl.${thisTemp}.data 23 | read_data mol.data 24 | group na type 1 25 | group cl type 2 26 | group all union na cl 27 | region box block INF INF INF INF INF INF 28 | 29 | #minimize 1.0e-12 1.0e-8 100 1000 30 | #velocity all create 3000 131415926 dist gaussian 31 | #fix 1 all nvt temp 3000 ${thisTemp} 100 32 | thermo ${thermoSteps} 33 | thermo_style custom step cpu cpuremain temp pe density 34 | timestep 1 35 | #run ${anealSteps} 36 | 37 | #unfix 1 38 | fix 2 all nvt temp ${thisTemp} ${thisTemp} 100 39 | #run ${relaxSteps} 40 | 41 | #dump 1 na custom 100 naxyz.$i.txt id xu yu zu 42 | #dump 2 cl custom 100 clxyz.$i.txt id xu yu zu 43 | dump 1 all custom 5 mol.lammpstrj id mol type vx vy vz 44 | run ${runSteps} 45 | write_data restart.data 46 | -------------------------------------------------------------------------------- /Examples/Molten_NaCl/nvt/PyLAT.sh: -------------------------------------------------------------------------------- 1 | python ../../../PyLAT.py -T 1300 --nummol 864 --nummol 864 --mol Na --mol Cl -c --IPL --NEC -v 2 log.lammps mol.data mol.lammpstrj -f output.json 2 | -------------------------------------------------------------------------------- /Examples/Molten_NaCl/nvt/nacl.in: -------------------------------------------------------------------------------- 1 | # Tosi Fumi NaCl 2 | variable thisTemp equal 1300 3 | variable anealSteps equal 3000000 4 | variable relaxSteps equal 5000000 5 | variable newAnealSteps equal 1000000 6 | variable newRelaxSteps equal 1000000 7 | variable runSteps equal 5000000 8 | variable thermoSteps equal 10000 9 | 10 | units real 11 | atom_style full 12 | dimension 3 13 | boundary p p p 14 | 15 | pair_style born/coul/long 15 16 | 17 | neighbor 3.0 bin 18 | neigh_modify every 2 delay 0 check yes one 3000 19 | kspace_style ewald 1.0e-4 20 | 21 | #Atom defination part 22 | #read_data NaCl.${thisTemp}.data 23 | read_data mol.data 24 | group na type 1 25 | group cl type 2 26 | group all union na cl 27 | region box block INF INF INF INF INF INF 28 | 29 | #minimize 1.0e-12 1.0e-8 100 1000 30 | #velocity all create 3000 131415926 dist gaussian 31 | #fix 1 all nvt temp 3000 ${thisTemp} 100 32 | thermo ${thermoSteps} 33 | thermo_style custom step cpu cpuremain temp pe density 34 | timestep 1 35 | #run ${anealSteps} 36 | 37 | #unfix 1 38 | fix 2 all nvt temp ${thisTemp} ${thisTemp} 100 39 | #run ${relaxSteps} 40 | 41 | #dump 1 na custom 100 naxyz.$i.txt id xu yu zu 42 | #dump 2 cl custom 100 clxyz.$i.txt id xu yu zu 43 | dump 1 all custom 100 mol.lammpstrj id mol type x y z vx vy vz 44 | run ${runSteps} 45 | write_data restart.data 46 | -------------------------------------------------------------------------------- /Examples/README: -------------------------------------------------------------------------------- 1 | Example systems used for PyLAT publication. For most properties, the output can be generated by running the lammps simulation and then the PyLAT.sh shell script. For the viscosity calculation, the other input files need to be generated. This is done by running the inputgenerator.py script. Then, all of the simulations need to be run. Finally, the PyLAT.sh script can be run to do the analysis. 2 | 3 | For the Jupyter notebook examples, it is still reccommended to run in an HPC environment. Jupyter notebooks can be executed using the command "jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=-1 {$Notebook}" with the Jupyter package installed. This command will execute all code cells in the notebook. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /PyLAT.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Created on Wed May 20 13:37:57 2015 5 | 6 | @author: mhumbert 7 | 8 | 9 | PyLAT: Python LAMMPS Analysis Tools 10 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 11 | 12 | This program is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU General Public License as published by 14 | the Free Software Foundation, either version 3 of the License, or 15 | (at your option) any later version. 16 | 17 | This program is distributed in the hope that it will be useful, 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | GNU General Public License for more details. 21 | 22 | You should have received a copy of the GNU General Public License 23 | along with this program. If not, see . 24 | 25 | This is the driver file for the PyLAT program. This file parsers the user 26 | input, and then calls the proper class files 27 | """ 28 | if __name__ == '__main__': 29 | 30 | import argparse as args 31 | import sys 32 | import json 33 | 34 | try: 35 | import src.calccomf 36 | except ImportError: 37 | print("Please use either 'sh compile.sh' or 'python compile.py' to compile the fortran modules") 38 | sys.exit(1) 39 | 40 | #sys.path.append('~/Projects/Parser/publish/src') 41 | 42 | from src.MSD import MSD 43 | from src.calcDiffusivity import calcdiffusivity 44 | from src.calcCOM import calcCOM 45 | from src.getTimeData import gettimedata 46 | from src.getMolData import getmoldata 47 | from src.COMradial import COMradialdistribution 48 | from src.getAtomCharges import getatomcharges 49 | from src.calcNEconductivity import calcNEconductivity 50 | from src.calcCond import calcCond 51 | from src.getCoordinationNumber import getcoordinationnumber 52 | from src.ionpair import ionpair 53 | from src.calcDielectricConstant import calcDielectricConstant 54 | from src.distSearch import distSearch 55 | from src.calcVisc import calcVisc 56 | from src.fitVisc import fitVisc 57 | 58 | parser = args.ArgumentParser(formatter_class=args.RawTextHelpFormatter, description=''' 59 | Analyze output from LAMMPS simulation 60 | 61 | Required files are the log file, the data file and at least one trajectory 62 | file in that order 63 | 64 | Also required is the name and number of each molecule type in the system. 65 | To do this, use the --mol and --nummol flags. Use the same order as they 66 | were entered into the data file. 67 | 68 | If you want to calculate an ionic conductivity or dielectric constant, a 69 | temperature must be included using a --temp flag. 70 | 71 | The output of this program is a json file with all of the requested 72 | information. Default file name is output.json. To use data in this file, 73 | use the following python code: 74 | import json 75 | openfile = open("filename") 76 | dict = json.load(openfile) 77 | 78 | This yields a dictionary with all of the information that you can query. 79 | 80 | plot.py is an interactive program written to parse and display the 81 | information in the json output files. Proper usage is 82 | plots.py {output file} 83 | ''', epilog = ''' 84 | 85 | Example: For diffusivity and RDF of a system with 500 water and 500 86 | methanol in the directory methanol/inwater 87 | 88 | python PyLAT.py -d -g --mol H2O --mol CH3OH --nummol 500 89 | --nummol 500 -p methanol/inwater/ -f methanolwater.json -v 2 mol.log 90 | restart.dat mol1.lammpstrj mol2.lammpstrj 91 | ''') 92 | File_Options = parser.add_argument_group("File arguments") 93 | File_Options.add_argument('LOG', nargs=1, help = 'LAMMPS log file.') 94 | File_Options.add_argument('DAT', nargs=1, help = 'LAMMPS data dile.') 95 | File_Options.add_argument('TRJ', action='append', nargs='+', 96 | help = 'LAMMPS trajectory file. Can include multiple trajectory files.') 97 | File_Options.add_argument('-p', '--path', 98 | help = 'Path to directory containing files. Will also save output in same directory. Default is current directory. Example: path/to/directory/', 99 | default = './') 100 | File_Options.add_argument('-i', '--input', help = 'json file if properties have already been calculated for this system') 101 | File_Options.add_argument('-f', '--output', 102 | help = 'File name for output file. Defult file name is output.json', default = 'output.json') 103 | properties = parser.add_argument_group("Possible Properties") 104 | properties.add_argument('-g', '--RDF', help = 'Radial Distribution Function.', action = 'store_true') 105 | properties.add_argument('-c', '--coord', help = 'Coordination Number. Will determine the first three minima of the RDF and calculates the coordination numbers integrating to those points.', action = 'store_true') 106 | properties.add_argument('-m', '--MSD', help = 'Mean Square Displacement.', action = 'store_true') 107 | properties.add_argument('-d', '--D', 108 | help = 'Diffusivity using MSD. Automatically includes MSD calculations.', 109 | action = 'store_true') 110 | properties.add_argument('--NEC', 111 | help = 'Nernst Einstein ionic conductivity. Automatically includes MSD and diffusivity calculations.', 112 | action = 'store_true') 113 | properties.add_argument('--GKC', help = 'Green-Kubo ionic conductivity.', action = 'store_true') 114 | properties.add_argument('--IPL', help = 'Ion Pair Lifetime.', action = 'store_true') 115 | properties.add_argument('--DEC', help = 'Dielectric Constant', action = 'store_true') 116 | properties.add_argument('--DS', help = 'Search for molecules of given types at a given distance', action = 'store_true') 117 | properties.add_argument('--Visc',help='Calculate the viscosity of the system. Requires multiple log files in different directories. The name of the log files will be taken from the LOG option', action='store_true') 118 | 119 | system = parser.add_argument_group("System Properties") 120 | system.add_argument('--mol', help = 'Add molecule name to list of molecules. Required', action = 'append', required=True) 121 | system.add_argument('--nummol', help = 'Add number of molecule type to list. Must have same number as --mol. Required', 122 | action = 'append', required=True, type=int) 123 | system.add_argument('-T', '--temp', help = 'Temperature of system. Required for conductivity calculations', type=float) 124 | parser.add_argument('-v', '--verbose', help = '''Verbosity of program: \n0: No print statements \n1: Print after each major step \n2: Print after each major step and progress of the major step at each minor step. Not recommended for cluster calculations''', type=int) 125 | 126 | MSDoptions = parser.add_argument_group('MSD Options') 127 | MSDoptions.add_argument('--MSD_skip', help = 'Number of timesteps to skip at the beginning of the trajectory file before calculating MSD. Default is 0', default = 0, type=int) 128 | MSDoptions.add_argument('--MSD_num_init', help = 'Number of initial timesteps to consider in MSD calculation. Default is half of frames being used in MSD calculation', default = None) 129 | 130 | Difoptions = parser.add_argument_group('Diffusivity Options') 131 | Difoptions.add_argument('--D_Tolerance', help = 'Tolerance for determining linear region in Log-Log plot. Default is 0.075', type=float, default=0.075) 132 | 133 | RDFoptions = parser.add_argument_group('RDF Options') 134 | RDFoptions.add_argument('--RDF_Timesteps', help = 'Number of timesteps to use in the RDF calculation. \nWill use the last n timesteps. \nDefault is to use all timesteps', type = int) 135 | RDFoptions.add_argument('--RDF_maxr', help = 'Maximum r for RDF calculation. Default is half the shortest box length.', default = None) 136 | RDFoptions.add_argument('--RDF_binsize', help = 'Bin size for RDF calculation. Default is 0.1', default = 0.1, type = float) 137 | 138 | 139 | GKCoptions = parser.add_argument_group('GK Conductivity options') 140 | GKCoptions.add_argument('--GKC_skip', help = 'Number of timesteps to skip at the beginning of the trajectory file before calculating GK Conductivity. Default is 0', default = 0, type=int) 141 | GKCoptions.add_argument('--GKC_Tolerance', help= 'Tolerance for finding the converged region for GK conductivity calculation. Default is 0.001', default = 0.001, type=float) 142 | GKCoptions.add_argument('--GKC_J_Output', help='Option to output the charge flux correlation function. If included, a file J.dat will be created with the values of the correlation function.', action='store_true') 143 | 144 | IPLoptions = parser.add_argument_group('Ion Pair Lifetime options') 145 | IPLoptions.add_argument('--IPL_skip', help = 'Number of timesteps to skip at the beginning of the trajectory file before calculating Ion Pair Lifetime. Default is 0', default = 0, type=int) 146 | 147 | DECoptions = parser.add_argument_group('Dielectric Constant options') 148 | DECoptions.add_argument('--DEC_start', help = 'Starting frame for dielectric constant calculations. Default is 1', default = 1, type = int) 149 | 150 | DSoptions = parser.add_argument_group('Distance Search Options') 151 | DSoptions.add_argument('--DS_MOL1', help = 'Molecule name for the first molecule type. Required for Distance Search') 152 | DSoptions.add_argument('--DS_MOL2', help = 'Molecule name for the second molecule type. Required for Distance Search') 153 | DSoptions.add_argument('--DS_Dist', help = 'Distance between molecules. Required for Distance Search', type = float) 154 | DSoptions.add_argument('--DS_Dist_Tol', help = 'Tolerance for distance. Required for Distance Search', type = float) 155 | DSoptions.add_argument('--DS_First_Frame', help = 'First frame for distance search calculation. Default is 1', default = 1, type = int) 156 | DSoptions.add_argument('--DS_Num_Samples', help = 'Number of samples to find. Default is 1', default = 1, type = int) 157 | 158 | Viscoptions = parser.add_argument_group('Viscosity options') 159 | Viscoptions.add_argument('--Visc_Dir', help = 'Basename for the viscosity directories. For example, if basename is "visc" the directories should be visc1, visc2, ... \n If no base name is given, directories should be 1, 2, 3, ...', 160 | default = None) 161 | Viscoptions.add_argument('--Visc_Num', help = 'Number of Trajectories to use in the viscosity calculation. Each trajectory should have a seperate trajectory',type=int) 162 | Viscoptions.add_argument('--Visc_Skip', help = 'Number of timesteps to skip in the viscosity calculation. Default of 0 should only be used if the simulations were equilibrated before the start of the production run', default=0, type=int) 163 | Viscoptions.add_argument('--Visc_Num_Boots', help = 'Number of times to sample trajectories for bootstrapping. Default is 10', default = 10, type = int) 164 | Viscoptions.add_argument('--Visc_Samples', help = 'Number of samples for each bootstrapping iteration. Default is 30', default = 30, type = int) 165 | Viscoptions.add_argument('--Visc_Plot', help = 'Include plotting for viscosity fitting. Matplotlib required for fitting. Will output to x11', action = 'store_true') 166 | Viscoptions.add_argument('--Visc_Guess', help = 'Initial guess for viscosity fitting parameters. Must add all four parameters with one call. Order of parameters is A, alpha, tau1, tau2. Default is the equivalent of calling "--Visc_Guess 1e-3 1.5e-1 1e2 1e3".', type = float, nargs = 4) 167 | 168 | arg = parser.parse_args() 169 | 170 | c = calcCOM() 171 | m = MSD() 172 | cd = calcdiffusivity() 173 | gt = gettimedata() 174 | gm = getmoldata() 175 | crd = COMradialdistribution() 176 | gc = getatomcharges() 177 | ne = calcNEconductivity() 178 | cc = calcCond() 179 | gcn = getcoordinationnumber() 180 | ip = ionpair() 181 | dec = calcDielectricConstant() 182 | ds = distSearch() 183 | cv = calcVisc() 184 | fv = fitVisc() 185 | 186 | if arg.path[-1] != '/': 187 | arg.path = arg.path + '/' 188 | 189 | for i in range(0,len(arg.TRJ[0])): 190 | arg.TRJ[0][i] = arg.path + arg.TRJ[0][i] 191 | 192 | trjfilename = arg.TRJ[0] 193 | datfilename = arg.path + arg.DAT[0] 194 | logfilename = arg.path + arg.LOG[0] 195 | 196 | if arg.verbose == 2: 197 | ver = True 198 | else: 199 | ver = False 200 | 201 | 202 | if arg.input == None: 203 | output = {} 204 | 205 | else: 206 | inputfile = arg.path + arg.input 207 | openfile = open(inputfile, 'r') 208 | output = json.load(openfile) 209 | openfile.close() 210 | 211 | nummoltype = arg.nummol 212 | moltypel = arg.mol 213 | moltype = [] 214 | for i in range(0,len(moltypel)): 215 | for j in range(0,nummoltype[i]): 216 | moltype.append(int(i)) 217 | 218 | if arg.NEC or arg.GKC: 219 | if arg.temp == None: 220 | sys.exit('Need temperature for conductivity calculations') 221 | if 'Conductivity' not in output.keys(): 222 | output['Conductivity'] = {} 223 | output['Conductivity']['units'] = 'S/m' 224 | 225 | if arg.DEC: 226 | if arg.temp == None: 227 | sys.exit('Need temperature for dielectric constant calculations') 228 | 229 | 230 | if len(arg.mol) != len(arg.nummol): 231 | sys.exit('Must enter same number of arguments for nummol and mol') 232 | 233 | if arg.NEC and 'Diffusivity' not in output.keys(): 234 | arg.D = True 235 | 236 | if arg.D and 'MSD' not in output.keys(): 237 | arg.MSD = True 238 | 239 | if arg.coord and 'RDF' not in output.keys(): 240 | arg.RDF = True 241 | 242 | if arg.MSD or arg.D or arg.IPL: 243 | tsjump = gt.getjump(trjfilename[0]) 244 | dt = gt.getdt(logfilename) 245 | if arg.NEC or arg.GKC or arg.GKC or arg.DEC: 246 | n = gc.findnumatoms(datfilename) 247 | (molcharges, atomcharges,n) = gc.getmolcharges(datfilename,n) 248 | molcharge = gc.molchargedict(molcharges, moltypel, moltype) 249 | if arg.RDF or arg.MSD or arg.IPL or arg.coord or arg.DEC: 250 | (V, Lx, Ly, Lz) = gcn.getvolume(trjfilename[0]) 251 | 252 | if arg.RDF or arg.MSD or arg.IPL: 253 | if arg.verbose >= 1: 254 | print('beginning COM calculation') 255 | (comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2) = c.calcCOM(trjfilename,datfilename, ver) 256 | if arg.verbose == 1: 257 | print('COM calculation complete') 258 | 259 | if arg.RDF: 260 | if arg.RDF_Timesteps == None: 261 | arg.RDF_Timesteps = len(comx) 262 | if arg.RDF_Timesteps > len(comx): 263 | print('Number of RDF timesteps requested longer than simulation. Using all timesteps.') 264 | arg.RDF_Timesteps = len(comx) 265 | if arg.verbose >= 1: 266 | print('beginning RDF calculation') 267 | output['RDF'] = {} 268 | output['RDF']['units'] = 'unitless, angstroms' 269 | output = crd.runradial(datfilename, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, output, nummoltype, moltypel, moltype, arg.RDF_Timesteps, ver,arg.RDF_maxr,arg.RDF_binsize) 270 | if arg.verbose >= 1: 271 | print('RDF calculation complete') 272 | 273 | if arg.coord: 274 | if arg.verbose >= 1: 275 | print('beginning coordination number calculation') 276 | output = gcn.calccoordinationnumber(output, nummoltype, moltypel, V) 277 | if arg.verbose >= 1: 278 | print('coordination number calculation complete') 279 | 280 | if arg.DEC: 281 | output = dec.calcDEC(atomcharges, trjfilename, arg.temp, output, V, arg.verbose, arg.DEC_start) 282 | 283 | if arg.GKC: 284 | if arg.verbose >= 1: 285 | print('beginning GK conductivity calculation') 286 | output = cc.calcConductivity(molcharges, trjfilename, logfilename, datfilename, arg.temp, output, moltype, moltypel,arg.verbose,arg.GKC_skip,arg.GKC_Tolerance,arg.GKC_J_Output) 287 | if arg.verbose >= 1: 288 | print('GK conductivity calculation complete') 289 | 290 | if arg.IPL: 291 | if arg.verbose >= 1: 292 | print('beginning Ion Pair Lifetime calculation') 293 | ip.runionpair(comx,comy,comz,Lx,Ly,Lz,moltypel,moltype,tsjump,dt,output,ver,arg.IPL_skip) 294 | if arg.verbose >= 1: 295 | print('Ion Pair Lifetime calculation complete') 296 | 297 | 298 | if arg.DS: 299 | if arg.verbose >= 1: 300 | print('beginning Distance Search') 301 | output = ds.distSearch(arg.DS_MOL1, arg.DS_MOL2, arg.DS_Dist, arg.DS_Dist_Tol, arg.DS_First_Frame, arg.DS_Num_Samples, trjfilename, datfilename, moltype, moltypel, output) 302 | 303 | 304 | if arg.MSD: 305 | if arg.verbose >= 1: 306 | print('beginning MSD calculation') 307 | output = m.runMSD(comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, moltype, moltypel, dt, tsjump, output, ver, arg.MSD_skip, arg.MSD_num_init) 308 | if arg.verbose == 1: 309 | print('MSD calculation complete') 310 | 311 | if arg.D: 312 | if arg.verbose >= 1: 313 | print('beginning diffusivity calculation') 314 | cd.calcdiffusivity(output, moltypel, dt,arg.D_Tolerance) 315 | if arg.verbose: 316 | print('diffusivity calculation complete') 317 | 318 | if arg.NEC: 319 | if arg.verbose >= 1: 320 | print('beginning NE conductivity calculation') 321 | output = ne.calcNEconductivity(output, molcharge, Lx, Ly, Lz, nummoltype, moltypel, arg.temp) 322 | if arg.verbose >= 1: 323 | print('NE conductivity calculation complete') 324 | 325 | if arg.Visc: 326 | if arg.verbose >= 1: 327 | print('beginning viscosity calculation') 328 | if arg.Visc_Guess == None: 329 | arg.Visc_Guess = [1e-3,1.5e-1,1e2,1e3] 330 | if len(arg.Visc_Guess) != 4: 331 | print('need four inputs for viscosity initial parameters.') 332 | output = cv.calcvisc(arg.Visc_Num,arg.Visc_Skip,arg.Visc_Dir,arg.LOG[0],output, arg.verbose, arg.Visc_Samples, arg.Visc_Num_Boots, arg.Visc_Plot, arg.Visc_Guess) 333 | #output = fv.fitvisc(output) 334 | if arg.verbose >= 1: 335 | print('viscosity calculation complete') 336 | 337 | if output == {}: 338 | sys.exit('Please select at least one property to calculate') 339 | 340 | if arg.verbose >= 1: 341 | print('beginning file generation') 342 | outputfile = open(arg.path + arg.output, 'w') 343 | json.dump(output, outputfile, indent=4, sort_keys=True) 344 | outputfile.close() 345 | if arg.verbose >= 1: 346 | print('file generated') 347 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PyLAT 2 | 3 | This is the github repository for the Python LAMMPS Analysis Tools. 4 | 5 | Some of the properties utilize Fortran for speedup. Before using this code, run either the shell script compile.sh or the python script compile.py 6 | 7 | ## Requirements 8 | numpy>=1.14.1 9 | 10 | scipy>=1.0.0 11 | 12 | The following information can be accessed by running the command "python PyLAT.py -h" 13 | 14 | usage: 15 | 16 | PyLAT.py [-h] [-p PATH] [-i INPUT] [-f OUTPUT] [-g] [-c] [-m] [-d] 17 | [--NEC] [--GKC] [--IPL] [--DEC] [--DS] [--Visc] --mol MOL 18 | --nummol NUMMOL [-T TEMP] [-v VERBOSE] [--MSD_skip MSD_SKIP] 19 | [--MSD_num_init MSD_NUM_INIT] [--D_Tolerance D_TOLERANCE] 20 | [--RDF_Timesteps RDF_TIMESTEPS] [--RDF_maxr RDF_MAXR] 21 | [--RDF_binsize RDF_BINSIZE] [--GKC_skip GKC_SKIP] 22 | [--GKC_Tolerance GKC_TOLERANCE] [--GKC_J_Output] 23 | [--IPL_skip IPL_SKIP] [--DEC_start DEC_START] 24 | [--DS_MOL1 DS_MOL1] [--DS_MOL2 DS_MOL2] [--DS_Dist DS_DIST] 25 | [--DS_Dist_Tol DS_DIST_TOL] [--DS_First_Frame DS_FIRST_FRAME] 26 | [--DS_Num_Samples DS_NUM_SAMPLES] [--Visc_Dir VISC_DIR] 27 | [--Visc_Num VISC_NUM] [--Visc_Skip VISC_SKIP] 28 | [--Visc_Num_Boots VISC_NUM_BOOTS] 29 | [--Visc_Samples VISC_SAMPLES] [--Visc_Plot] 30 | [--Visc_Guess VISC_GUESS VISC_GUESS VISC_GUESS VISC_GUESS] 31 | LOG DAT TRJ [TRJ ...] 32 | 33 | Analyze output from LAMMPS simulation 34 | 35 | Required files are the log file, the data file and at least one trajectory 36 | file in that order 37 | 38 | Also required is the name and number of each molecule type in the system. 39 | To do this, use the --mol and --nummol flags. Use the same order as they 40 | were entered into the data file. 41 | 42 | If you want to calculate an ionic conductivity or dielectric constant, a 43 | temperature must be included using a --temp flag. 44 | 45 | The output of this program is a json file with all of the requested 46 | information. Default file name is output.json. To use data in this file, 47 | use the following python code: 48 | import json 49 | openfile = open("filename") 50 | dict = json.load(openfile) 51 | 52 | This yields a dictionary with all of the information that you can query. 53 | 54 | plot.py is an interactive program written to parse and display the 55 | information in the json output files. Proper usage is 56 | plots.py {output file} 57 | 58 | 59 | optional arguments: 60 | 61 | -h, --help show this help message and exit 62 | -v VERBOSE, --verbose VERBOSE 63 | Verbosity of program: 64 | 0: No print statements 65 | 1: Print after each major step 66 | 2: Print after each major step and progress of the major step at each minor step. 67 | Not recommended for cluster calculations 68 | 69 | File arguments: 70 | 71 | LOG LAMMPS log file. 72 | DAT LAMMPS data dile. 73 | TRJ LAMMPS trajectory file. Can include multiple trajectory files. 74 | -p PATH, --path PATH Path to directory containing files. Will also save output in same directory. 75 | Default is current directory. Example: path/to/directory/ 76 | -i INPUT, --input INPUT 77 | json file if properties have already been calculated for this system 78 | -f OUTPUT, --output OUTPUT 79 | File name for output file. Defult file name is output.json 80 | 81 | Possible Properties: 82 | 83 | -g, --RDF Radial Distribution Function. 84 | -c, --coord Coordination Number. Will determine the first three minima of the RDF 85 | and calculates the coordination numbers integrating to those points. 86 | -m, --MSD Mean Square Displacement. 87 | -d, --D Diffusivity using MSD. Automatically includes MSD calculations. 88 | --NEC Nernst Einstein ionic conductivity. 89 | Automatically includes MSD and diffusivity calculations. 90 | --GKC Green-Kubo ionic conductivity. 91 | --IPL Ion Pair Lifetime. 92 | --DEC Dielectric Constant 93 | --DS Search for molecules of given types at a given distance 94 | --Visc Calculate the viscosity of the system. 95 | Requires multiple log files in different directories. 96 | The name of the log files will be taken from the LOG option 97 | 98 | System Properties: 99 | 100 | --mol MOL Add molecule name to list of molecules. Required 101 | --nummol NUMMOL Add number of molecule type to list. Must have same number as --mol. Required 102 | -T TEMP, --temp TEMP Temperature of system. Required for conductivity calculations 103 | 104 | MSD Options: 105 | 106 | --MSD_skip MSD_SKIP Number of timesteps to skip at the beginning of the 107 | trajectory file before calculating MSD. 108 | Default is 0 109 | --MSD_num_init MSD_NUM_INIT 110 | Number of initial timesteps to consider in MSD calculation. 111 | Default is half of frames being used in MSD calculation 112 | 113 | Diffusivity Options: 114 | 115 | --D_Tolerance D_TOLERANCE 116 | Tolerance for determining linear region in Log-Log plot. Default is 0.075 117 | 118 | RDF Options: 119 | 120 | --RDF_Timesteps RDF_TIMESTEPS 121 | Number of timesteps to use in the RDF calculation. 122 | Will use the last n timesteps. 123 | Default is to use all timesteps 124 | --RDF_maxr RDF_MAXR Maximum r for RDF calculation. Default is half the shortest box length. 125 | --RDF_binsize RDF_BINSIZE 126 | Bin size for RDF calculation. Default is 0.1 127 | 128 | GK Conductivity options: 129 | 130 | --GKC_skip GKC_SKIP Number of timesteps to skip at the beginning of the trajectory file 131 | before calculating GK Conductivity. Default is 0 132 | --GKC_Tolerance GKC_TOLERANCE 133 | Tolerance for finding the converged region for GK conductivity calculation. 134 | Default is 0.001 135 | --GKC_J_Output Option to output the charge flux correlation function. 136 | If included, a file J.dat will be created with the values 137 | of the correlation function. 138 | 139 | Ion Pair Lifetime options: 140 | 141 | --IPL_skip IPL_SKIP Number of timesteps to skip at the beginning of the trajectory file 142 | before calculating Ion Pair Lifetime. Default is 0 143 | 144 | Dielectric Constant options: 145 | 146 | --DEC_start DEC_START 147 | Starting frame for dielectric constant calculations. Default is 1 148 | 149 | Distance Search Options: 150 | 151 | --DS_MOL1 DS_MOL1 Molecule name for the first molecule type. Required for Distance Search 152 | --DS_MOL2 DS_MOL2 Molecule name for the second molecule type. Required for Distance Search 153 | --DS_Dist DS_DIST Distance between molecules. Required for Distance Search 154 | --DS_Dist_Tol DS_DIST_TOL 155 | Tolerance for distance. Required for Distance Search 156 | --DS_First_Frame DS_FIRST_FRAME 157 | First frame for distance search calculation. Default is 1 158 | --DS_Num_Samples DS_NUM_SAMPLES 159 | Number of samples to find. Default is 1 160 | 161 | Viscosity options: 162 | 163 | --Visc_Dir VISC_DIR Basename for the viscosity directories. 164 | For example, if basename is "visc" the directories should be visc1, visc2, ... 165 | If no base name is given, directories should be 1, 2, 3, ... 166 | --Visc_Num VISC_NUM Number of Trajectories to use in the viscosity calculation. 167 | Each trajectory should have a seperate trajectory 168 | --Visc_Skip VISC_SKIP 169 | Number of timesteps to skip in the viscosity calculation. 170 | Default of 0 should only be used if the simulations were equilibrated 171 | before the start of the production run 172 | --Visc_Num_Boots VISC_NUM_BOOTS 173 | Number of times to sample trajectories for bootstrapping. Default is 10 174 | --Visc_Samples VISC_SAMPLES 175 | Number of samples for each bootstrapping iteration. Default is 30 176 | --Visc_Plot Include plotting for viscosity fitting. 177 | Matplotlib required for fitting. Will output to x11 178 | --Visc_Guess VISC_GUESS VISC_GUESS VISC_GUESS VISC_GUESS 179 | Initial guess for viscosity fitting parameters. 180 | Must add all four parameters with one call. 181 | Order of parameters is A, alpha, tau1, tau2. 182 | Default is the equivalent of calling "--Visc_Guess 1e-3 1.5e-1 1e2 1e3". 183 | 184 | 185 | Example: For diffusivity and RDF of a system with 500 water and 500 186 | methanol in the directory methanol/inwater 187 | 188 | python PyLAT.py -d -g --mol H2O --mol CH3OH --nummol 500 189 | --nummol 500 -p methanol/inwater/ -f methanolwater.json -v 2 mol.log 190 | restart.dat mol1.lammpstrj mol2.lammpstrj 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /compile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: utf-8 -*- 3 | """ 4 | Created on Wed Mar 6 10:32:17 2019 5 | Modified by Rohit Goswami (HaoZeke) 6 | 7 | @author: mhumbert 8 | """ 9 | 10 | from numpy import f2py 11 | import os, glob 12 | 13 | os.chdir('src') 14 | 15 | f = open('calcdistances.f90','r').read() 16 | f2py.compile(f,modulename='calcdistances',source_fn='calcdistances.f90',verbose=False) 17 | f = open('calcCOM.f90','r').read() 18 | f2py.compile(f,modulename='calccomf',source_fn='calcCOM.f90',verbose=False) 19 | f = open('ipcorr.f90','r').read() 20 | f2py.compile(f,modulename='ipcorr',source_fn='ipcorr.f90',verbose=False) 21 | 22 | os.symlink(glob.glob('ipcorr.*.so')[0],'ipcorr.so') 23 | os.symlink(glob.glob('calcdistances.*.so')[0],'calcdistances.so') 24 | os.symlink(glob.glob('calccomf.*.so')[0],'calccomf.so') 25 | 26 | os.chdir('..') 27 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | cd src 2 | python -m numpy.f2py -c -m calccomf calcCOM.f90 3 | python -m numpy.f2py -c -m calcdistances calcdistances.f90 4 | python -m numpy.f2py -c -m ipcorr ipcorr.f90 5 | #f2py -c -m src/elradial src/elradial.f90 6 | #f2py -c -m src/siteradial src/siteradial.f90 7 | 8 | ln -s ipcorr.*.so ipcorr.so 9 | ln -s calcdistances.*.so calcdistances.so 10 | ln -s calccomf.*.so calccomf.so 11 | 12 | cd .. 13 | -------------------------------------------------------------------------------- /plots.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Aug 16 16:06:40 2017 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | 24 | """ 25 | This script is used to parse/visualize the output of the PyLAT codes 26 | 27 | To use, call python plots.py {json file} and follow prompts 28 | """ 29 | 30 | from matplotlib import pyplot as plt 31 | import sys 32 | import json 33 | import numpy as np 34 | 35 | def aver(x,y): 36 | xstart = float(raw_input("Select Starting x value (-1 for last point): ")) 37 | if xstart==-1: 38 | print y[-1] 39 | else: 40 | xend = float(raw_input("Select ending x value: ")) 41 | xstartind = None 42 | xendind = None 43 | for i in range(0,len(x)): 44 | if x[i] > xstart and xstartind==None: 45 | xstartind=i 46 | if x[i] > xend and xendind==None: 47 | xendind=i 48 | print np.average(y[xstartind:xendind]) 49 | 50 | 51 | def writefile(x,y,filename): 52 | out=open(filename,'w') 53 | for i in range(0,len(x)): 54 | out.write('{}\t{}\n'.format(x[i],y[i])) 55 | out.close() 56 | 57 | def dic(data): 58 | keylist = data.keys() 59 | for i in range(0,len(keylist)): 60 | print('{}\t{}'.format(i,keylist[i])) 61 | select = int(raw_input("Select number of next level or y variable: ")) 62 | if type(data[keylist[select]])==list: 63 | select2 = int(raw_input("select x variable or if no x variable select -1 for plot vs count: ")) 64 | if select2==-1: 65 | plt.plot(range(0,len(data[keylist[select]])),data[keylist[select]]) 66 | x = range(0,len(data[keylist[select]])) 67 | y = data[keylist[select]] 68 | else: 69 | plt.plot(data[keylist[select2]],data[keylist[select]]) 70 | x = data[keylist[select2]] 71 | y = data[keylist[select]] 72 | plt.show() 73 | select3 = raw_input("Would you like to calculate an average or get last point? ") 74 | if select3.lower()=="yes" or select3.lower()=="y": 75 | aver(x,y) 76 | select4 = raw_input("Would you like to save a data file? ") 77 | if select4.lower()=="yes" or select4.lower()=="y": 78 | filename = raw_input("Please give file name: ") 79 | writefile(x, y, filename) 80 | elif type(data[keylist[select]])==int: 81 | print("You have selected an int. the value is {}".format(data[keylist[select]])) 82 | elif type(data[keylist[select]])==float: 83 | print("You have selected a float. the value is {}".format(data[keylist[select]])) 84 | elif type(data[keylist[select]])==dict: 85 | dic(data[keylist[select]]) 86 | elif keylist[select]=="units": 87 | print("The units are {}.".format(data[keylist[select]])) 88 | elif type(data[keylist[select]])==str: 89 | print(data[keylist[select]]) 90 | elif type(data[keylist[select]])==unicode: 91 | print(data[keylist[select]]) 92 | else: 93 | print type(data[keylist[select]]) 94 | print("Type unknown. The value is {}".format(data[keylist[select]])) 95 | 96 | 97 | 98 | if __name__=="__main__": 99 | data = json.load(open(sys.argv[1])) 100 | dic(data) 101 | -------------------------------------------------------------------------------- /src/COMradial.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | PyLAT: Python LAMMPS Analysis Tools 5 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | """ 20 | 21 | from __future__ import division, print_function, unicode_literals, \ 22 | absolute_import 23 | 24 | import copy 25 | 26 | import numpy as np 27 | from six.moves import range 28 | 29 | __author__ = "mhumbert" 30 | 31 | 32 | class COMradialdistribution: 33 | def runradial(self, datfilename, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, 34 | Lz2, output, nummoltype, moltypel, moltype, timesteps, ver, 35 | maxr, binsize): 36 | 37 | """ 38 | 39 | This function calculates the radial distribution function between the 40 | center of mass for all species in the system 41 | 42 | """ 43 | (maxr, numbins, count, g,firststep) = self.setgparam(Lx2, Ly2, Lz2, timesteps, 44 | moltypel, maxr, 45 | binsize,len(comx)) 46 | (count) = self.radialdistribution(g, len(comx[1]), moltype, comx, 47 | comy, comz, Lx, Ly, Lz, binsize, 48 | numbins, maxr, count) 49 | (radiuslist) = self.radialnormalization(numbins, binsize, Lx, Ly, Lz, 50 | nummoltype, count, g, 51 | firststep) 52 | self.append_dict(radiuslist, g, output, moltypel) 53 | return output 54 | 55 | def setgparam(self, Lx2, Ly2, Lz2, timesteps, moltypel, maxr, binsize,numsteps): 56 | # uses side lengths to set the maximum radius for box and number of bins 57 | # also sets the first line using data on firststep and number of atoms 58 | firststep = numsteps-timesteps 59 | if maxr == None: 60 | maxr = min(Lx2, Ly2, Lz2) 61 | else: 62 | maxr = float(maxr) 63 | numbins = int(np.ceil(maxr / binsize)) 64 | count = firststep 65 | g = np.zeros((len(moltypel), len(moltypel), numbins)) 66 | return maxr, numbins, count, g, firststep 67 | 68 | def radialdistribution(self, g, nummol, moltype, comx, comy, comz, Lx, Ly, 69 | Lz, binsize, numbins, maxr, count): 70 | # calculates the number of molecules within each shell 71 | comxt = np.array(comx[count:]).transpose() 72 | comyt = np.array(comy[count:]).transpose() 73 | comzt = np.array(comz[count:]).transpose() 74 | indexlist = [] 75 | 76 | # change indeces order to com*[molecule][timestep] 77 | 78 | for i in range(0,len(g)): 79 | indexlist.append(np.array(moltype) == i) 80 | #creates two dimensional array 81 | #first dimension is molecule type 82 | #second dimension is over molecules 83 | #contains boolean for if that molecule is of the molecule type 84 | 85 | for molecule in range(0, nummol - 1): 86 | dx = comxt[molecule+1:] - np.tile(comxt[molecule], 87 | (len(comxt)-molecule-1,1)) 88 | dy = comyt[molecule+1:] - np.tile(comyt[molecule], 89 | (len(comyt)-molecule-1,1)) 90 | dz = comzt[molecule+1:] - np.tile(comzt[molecule], 91 | (len(comzt)-molecule-1,1)) 92 | 93 | dx -= Lx * np.around(dx / Lx) 94 | dy -= Ly * np.around(dy / Ly) 95 | dz -= Lz * np.around(dz / Lz) 96 | #minimum image convention 97 | 98 | r2 = dx ** 2 + dy ** 2 + dz ** 2 99 | r = np.sqrt(r2) 100 | for i in range(0,len(indexlist)): 101 | gt,dist = np.histogram(r[indexlist[i][molecule+1:]].ravel(), 102 | bins=numbins, 103 | range=(0.5*binsize,binsize*(numbins+0.5))) 104 | g[moltype[molecule]][i]+= gt 105 | g[i][moltype[molecule]]+= gt 106 | 107 | count = len(comx) 108 | return count 109 | 110 | def radialnormalization(self, numbins, binsize, Lx, Ly, Lz, nummol, count, 111 | g, firststep): 112 | # normalizes g to box density 113 | radiuslist = (np.arange(numbins) + 1) * binsize 114 | radiuslist = np.around(radiuslist,decimals = 1) 115 | for i in range(0, len(g)): 116 | for j in range(0, len(g)): 117 | g[i][j] *= Lx * Ly * Lz / nummol[i] / nummol[j] / 4 / np.pi / ( 118 | radiuslist) ** 2 / binsize / ( 119 | count - firststep) 120 | return radiuslist 121 | 122 | def append_dict(self, radiuslist, g, output, moltypel): 123 | for i in range(0, len(moltypel)): 124 | for j in range(i, len(moltypel)): 125 | if not all([v == 0 for v in g[i][j]]): 126 | output['RDF']['{0}-{1}'.format(moltypel[i], 127 | moltypel[ 128 | j])] = copy.deepcopy( 129 | g[i][j].tolist()) 130 | if 'distance' not in list(output['RDF'].keys()): 131 | output['RDF']['distance'] = copy.deepcopy(radiuslist.tolist()) 132 | -------------------------------------------------------------------------------- /src/MSD.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Mar 12 14:08:27 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | 25 | import numpy as np 26 | #import matplotlib.pyplot as plt 27 | import os 28 | import time 29 | import copy 30 | import warnings 31 | import sys 32 | 33 | class MSD: 34 | 35 | def runMSD(self, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2, moltype, moltypel, dt, tsjump, output, ver, skip, num_init): 36 | 37 | """ 38 | This function calculates the mean square displacement for all molecule 39 | types in the system from center of mass positions 40 | """ 41 | 42 | (comx, comy, comz) = self.unwrap(comx,comy,comz,Lx,Ly,Lz,Lx2,Ly2,Lz2) 43 | if ver > 0: 44 | print('unwrap complete') 45 | num_timesteps = len(comx) 46 | (num_init, len_MSD, MSD, diffusivity) = self.gettimesteps(num_timesteps, moltypel,skip, num_init) 47 | (molcheck,nummol) = self.setmolarray(moltype,moltypel) 48 | for i in range(skip,num_init+skip): 49 | for j in range(i,i+len_MSD): 50 | r2 = self.calcr2(comx, comy, comz, i, j) 51 | MSD = self.MSDadd(r2, MSD, molcheck, i, j) 52 | if ver: 53 | sys.stdout.write('\rMSD calculation {:.2f}% complete'.format((i+1-skip)*100.0/num_init)) 54 | if ver: 55 | sys.stdout.write('\n') 56 | MSD = self.MSDnorm(MSD, num_init, nummol) 57 | Time = self.createtime(dt, tsjump, len_MSD) 58 | self.append_dict(MSD, moltypel, output, Time) 59 | return output 60 | 61 | def unwrap(self, comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2): 62 | #unwraps the coordintes of the molecules 63 | #assumes if a molecule is more than half a box length away from its 64 | #previous coordinte that it passed through a periodic boundary 65 | for i in range(1,len(comx)): 66 | for j in range(0,len(comx[i])): 67 | if (comx[i][j]-comx[i-1][j])>Lx2: 68 | while (comx[i][j]-comx[i-1][j])>Lx2: 69 | comx[i][j] -= Lx 70 | elif (comx[i][j]-comx[i-1][j]) < (-Lx2): 71 | while (comx[i][j]-comx[i-1][j]) < (-Lx2): 72 | comx[i][j] += Lx 73 | 74 | if (comy[i][j]-comy[i-1][j])>Ly2: 75 | while (comy[i][j]-comy[i-1][j])>Ly2: 76 | comy[i][j] -= Ly 77 | elif (comy[i][j]-comy[i-1][j]) < (-Ly2): 78 | while (comy[i][j]-comy[i-1][j]) < (-Ly2): 79 | comy[i][j] += Ly 80 | 81 | if (comz[i][j]-comz[i-1][j])>Lz2: 82 | while (comz[i][j]-comz[i-1][j])>Lz2: 83 | comz[i][j] -= Lz 84 | elif (comz[i][j]-comz[i-1][j])< (-Lz2): 85 | while (comz[i][j]-comz[i-1][j])< (-Lz2): 86 | comz[i][j] += Lz 87 | return (comx, comy, comz) 88 | 89 | def gettimesteps(self, num_timesteps,moltypel,skip,num_init): 90 | #Calculates the length of the trajectory 91 | #Uses length to determine length of MSD and number of initial timesteps 92 | if num_init==None: 93 | num_init = int(np.floor((num_timesteps-skip)/2)) 94 | else: 95 | num_init=int(num_init) 96 | len_MSD = num_timesteps-skip-num_init 97 | MSD = np.zeros((len(moltypel), len_MSD)) 98 | diffusivity = [] 99 | return (num_init, len_MSD, MSD, diffusivity) 100 | 101 | def setmolarray(self, moltype, moltypel): 102 | #Generates arrays for dot product calculation 103 | #Array is MxN where M is number of molecule types and N is number of molecules 104 | #value is 1 if molecule N is of type M else is 0 105 | molcheck = np.zeros((len(moltypel), len(moltype))) 106 | for i in range(0,len(moltype)): 107 | molcheck[moltype[i]][i]=1 108 | nummol = np.zeros(len(moltypel)) 109 | for i in range(0,len(nummol)): 110 | nummol[i] = np.sum(molcheck[i]) 111 | return (molcheck,nummol) 112 | 113 | def calcr2(self, comx, comy, comz, i, j): 114 | #Calculates distance molecule has traveled between steps i and j 115 | r2 = (comx[j]-comx[i])**2 + (comy[j]-comy[i])**2 + (comz[j]-comz[i])**2 116 | 117 | return r2 118 | 119 | def MSDadd(self, r2, MSD, molcheck, i, j): 120 | #Uses dot product to calculate average MSD for a molecule type 121 | for k in range(0,len(molcheck)): 122 | sr2 = np.dot(r2, molcheck[k]) 123 | MSD[k][j-i] += sr2 124 | return MSD 125 | 126 | def MSDnorm(self, MSD,MSDt,nummol): 127 | #Normalize the MSD by number of molecules and number of initial timesteps 128 | for i in range(0,len(nummol)): 129 | MSD[i] /= MSDt*nummol[i] 130 | 131 | return MSD 132 | 133 | def createtime(self, dt, tsjump, MSDt): 134 | #Creates an array of time values 135 | Time = np.arange(0,MSDt,dtype=float) 136 | Time *= dt*tsjump 137 | return Time 138 | 139 | 140 | def append_dict(self, MSD, moltypel, output, Time): 141 | #Write MSD to output dictionary 142 | output['MSD'] = {} 143 | output['MSD']['units']='Angstroms^2, fs' 144 | for i in range(0,len(moltypel)): 145 | output['MSD'][moltypel[i]] = copy.deepcopy(MSD[i].tolist()) 146 | 147 | output['MSD']['time'] = copy.deepcopy(Time.tolist()) 148 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaginnGroup/PyLAT/0a5b7d7e2d5133c004cf2937dcd4f725a2067eb6/src/__init__.py -------------------------------------------------------------------------------- /src/calcCOM.f90: -------------------------------------------------------------------------------- 1 | subroutine calccom(n, nummol, x, y, z, mol, amass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2, comxt, comyt, comzt) 2 | 3 | integer, intent(in) :: n, nummol 4 | real, dimension(:), intent(in) :: x,y,z 5 | integer, dimension(:), intent(in) :: mol 6 | real, dimension(:), intent(in) :: amass 7 | real, dimension(:), intent(in) :: molmass 8 | real, intent(in) :: Lx, Ly, Lz, Lx2, Ly2, Lz2 9 | real, dimension(nummol), intent(out) :: comxt, comyt, comzt 10 | real, dimension(nummol) :: xt, yt, zt 11 | real, dimension(n) :: ux, uy, uz 12 | xt(:)=0. 13 | comxt(:)=0. 14 | comyt(:)=0. 15 | comzt(:)=0. 16 | do i=1,n 17 | if (xt(mol(i)) == 0.) then 18 | xt(mol(i)) = x(i) 19 | yt(mol(i)) = y(i) 20 | zt(mol(i)) = z(i) 21 | ux(i) = x(i) 22 | uy(i) = y(i) 23 | uz(i) = z(i) 24 | else 25 | if (x(i)-xt(mol(i)) > Lx2) then 26 | ux(i) = x(i)-Lx 27 | elseif (xt(mol(i))- x(i) > Lx2) then 28 | ux(i) = x(i)+lx 29 | else 30 | ux(i) = x(i) 31 | endif 32 | 33 | if (y(i)-yt(mol(i)) > Ly2) then 34 | uy(i) = y(i)-Ly 35 | elseif (yt(mol(i))- y(i) > Ly2) then 36 | uy(i) = y(i)+ly 37 | else 38 | uy(i) = y(i) 39 | endif 40 | 41 | if (z(i)-zt(mol(i)) > Lz2) then 42 | uz(i) = z(i)-Lz 43 | elseif (zt(mol(i))- z(i) > Lz2) then 44 | uz(i) = z(i)+lz 45 | else 46 | uz(i) = z(i) 47 | endif 48 | endif 49 | 50 | comxt(mol(i)) = comxt(mol(i)) + ux(i)*amass(i) 51 | comyt(mol(i)) = comyt(mol(i)) + uy(i)*amass(i) 52 | comzt(mol(i)) = comzt(mol(i)) + uz(i)*amass(i) 53 | enddo 54 | do i=1,nummol 55 | comxt(i) = comxt(i)/molmass(i) 56 | comyt(i) = comyt(i)/molmass(i) 57 | comzt(i) = comzt(i)/molmass(i) 58 | enddo 59 | return 60 | end subroutine calccom 61 | -------------------------------------------------------------------------------- /src/calcCOM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Tue Mar 10 10:07:34 2015 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | 24 | import numpy as np 25 | import os 26 | import src.calccomf as calccomf 27 | import sys 28 | 29 | 30 | class calcCOM: 31 | 32 | def calcCOM(self, trjfilename, datfilename, ver): 33 | """ 34 | This function will read in the x,y,z positions of all atoms for a 35 | timestep and then calculate the center of mass for all molecules in the 36 | system. Returns the x, y and z coordinates of all molecules for all 37 | timesteps. 38 | 39 | Center of mass coordinates are often used in place of atomic positions 40 | to minimize the amount of memory required for calculations 41 | """ 42 | 43 | 44 | (num_lines, n, num_timesteps, count, line)=self.getnum(trjfilename) 45 | (Lx, Lx2, Ly, Ly2, Lz, Lz2) = self.getdimensions(trjfilename[0]) 46 | (x,y,z,mol,atype) = self.createarrays(n) 47 | (xcol, ycol, zcol, molcol, typecol) = self.getcolumns(trjfilename[0]) 48 | atommass = self.getmass(datfilename) 49 | for i in range(0,len(trjfilename)): 50 | trjfile = open(trjfilename[i]) 51 | while line[i] < num_lines[i]: 52 | (x,y,z,mol,atype,line) = self.readdata(trjfile, n, line, x, y, z, mol, atype, xcol, ycol, zcol, molcol, typecol,i) 53 | if count == 0: 54 | (nummol, comx, comy, comz, molmass) = self.comprep(mol, n, atype, atommass, num_timesteps) 55 | (comx, comy, comz, count) = self.calccom(comx, comy, comz, x, y, z, mol, atype, atommass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2, n, count, nummol) 56 | if ver: 57 | sys.stdout.write('\rCOM calculation {:.2f}% complete'.format(count*100.0/num_timesteps)) 58 | trjfile.close() 59 | if ver: 60 | sys.stdout.write('\n') 61 | return (comx, comy, comz, Lx, Ly, Lz, Lx2, Ly2, Lz2) 62 | 63 | def getnum(self,trjfilename): 64 | # uses the trjectory file and returns the number of lines and the number of atoms 65 | trjfile = open(trjfilename[0]) 66 | for i in range(0,3): 67 | trjfile.readline() 68 | n = int(trjfile.readline()) 69 | trjfile.close() 70 | num_timesteps=1 71 | num_lines=[] 72 | for i in range(0,len(trjfilename)): 73 | num_lines.append(int(sum(1 for line in open(trjfilename[i])))) 74 | num_timesteps += int(num_lines[i] / (n+9))-1 75 | line = [10 for x in trjfilename] 76 | for j in range(1,len(trjfilename)): 77 | line[j] += n+9 78 | count = 0 79 | return (num_lines, n, num_timesteps, count, line) 80 | 81 | def getdimensions(self,trjfilename): 82 | # uses trjectory file to get the length of box sides 83 | trjfile = open(trjfilename) 84 | for i in range(0,5): 85 | trjfile.readline() 86 | xbounds = trjfile.readline() 87 | xbounds = xbounds.split() 88 | ybounds = trjfile.readline() 89 | ybounds = ybounds.split() 90 | zbounds = trjfile.readline() 91 | zbounds = zbounds.split() 92 | Lx = float(xbounds[1])-float(xbounds[0]) 93 | Lx2 = Lx/2 94 | Ly = float(ybounds[1])-float(ybounds[0]) 95 | Ly2 = Ly/2 96 | Lz = float(zbounds[1])-float(zbounds[0]) 97 | Lz2 = Lz/2 98 | trjfile.close() 99 | return (Lx, Lx2, Ly, Ly2, Lz, Lz2) 100 | 101 | def createarrays(self,n): 102 | #creates numpy arrays for data reading 103 | x = np.zeros(n) 104 | y = np.zeros(n) 105 | z = np.zeros(n) 106 | mol = np.zeros(n) 107 | atype = np.zeros(n) 108 | return (x,y,z,mol,atype) 109 | 110 | def getcolumns(self,trjfilename): 111 | # defines the columns each data type is in in the trjectory file 112 | trjfile = open(trjfilename) 113 | for j in range(0,8): 114 | trjfile.readline() 115 | inline = trjfile.readline() 116 | inline = inline.split() 117 | inline.remove('ITEM:') 118 | inline.remove('ATOMS') 119 | xcol = inline.index('x') 120 | ycol = inline.index('y') 121 | zcol = inline.index('z') 122 | molcol = inline.index('mol') 123 | typecol = inline.index('type') 124 | trjfile.close() 125 | return (xcol, ycol, zcol, molcol, typecol) 126 | 127 | def getmass(self, datfilename): 128 | # returns a dictionary of the mass of each atom type 129 | atommass = {} 130 | foundmass= False 131 | readingmasses = True 132 | atomnum = 1 133 | datfile = open(datfilename) 134 | for i in range(0,4): 135 | datfile.readline() 136 | 137 | while foundmass == False: 138 | line = datfile.readline() 139 | line = line.split() 140 | 141 | if len(line) > 0: 142 | if line[0] == 'Masses': 143 | foundmass = True 144 | datfile.readline() 145 | 146 | while readingmasses == True: 147 | line = datfile.readline() 148 | line = line.split() 149 | if len(line) > 0: 150 | if int(line[0]) == atomnum: 151 | atommass[int(line[0])] = float(line[1]) 152 | atomnum += 1 153 | 154 | else: 155 | readingmasses = False 156 | 157 | else: 158 | readingmasses = False 159 | datfile.close() 160 | return atommass 161 | 162 | def readdata(self, trjfile, n, line, x, y, z, mol, atype, xcol, ycol, zcol, molcol, typecol, i): 163 | # reads data from trjectory file into precreated arrays 164 | for j in range(0,9): 165 | trjfile.readline() 166 | for a in range(0,n): 167 | inline = trjfile.readline() 168 | inline = inline.split() 169 | x[a]= inline[xcol] 170 | y[a]= inline[ycol] 171 | z[a]= inline[zcol] 172 | mol[a]= inline[molcol] 173 | atype[a]= inline[typecol] 174 | 175 | line[i] += n+9 176 | return (x,y,z,mol,atype,line) 177 | 178 | def comprep(self, mol, n, atype, atommass, num_timesteps): 179 | #creates arrays to prepare for center of mass calculations 180 | nummol = int(max(mol)) 181 | comx = [[0 for x in range(nummol)]for x in range(num_timesteps)] 182 | comy = [[0 for x in range(nummol)]for x in range(num_timesteps)] 183 | comz = [[0 for x in range(nummol)]for x in range(num_timesteps)] 184 | 185 | molmass = np.zeros(nummol) 186 | for atom in range(0,n): 187 | molmass[int(mol[atom]-1)] += atommass[atype[atom]] 188 | 189 | return (nummol, comx, comy, comz, molmass) 190 | 191 | def calccom(self, comx, comy, comz, x, y, z, mol, atype, atommass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2, n, count, nummol): 192 | #calculates the center of mass for each molecule 193 | amass = np.zeros(n) 194 | for i in range(0,n): 195 | amass[i] = atommass[atype[i]] 196 | 197 | 198 | #Calls a fortran code to increase the efficiency of the calculations 199 | (comxt, comyt, comzt)= calccomf.calccom(n, nummol, x, y, z, mol, amass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2) 200 | comx[count] += comxt 201 | comy[count] += comyt 202 | comz[count] += comzt 203 | count += 1 204 | 205 | return (comx, comy, comz, count) 206 | -------------------------------------------------------------------------------- /src/calcCond.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri May 8 10:17:55 2015 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | import numpy as np 24 | from scipy.optimize import curve_fit 25 | from scipy.integrate import cumtrapz 26 | from src.getTimeData import gettimedata 27 | import src.calccomf as calccomf 28 | import copy 29 | import sys 30 | 31 | class calcCond: 32 | g = gettimedata() 33 | def calcConductivity(self, molcharges, trjfilename,logfilename, datfilename, T, output, moltype, moltypel,ver,firstpoint,tol,Jout): 34 | 35 | """ 36 | This function calculates the ionic conductivity of the system using the 37 | Green-Kubo formalism 38 | 39 | returns both the total conductivity as well as the contribution of each 40 | species 41 | 42 | """ 43 | 44 | dt = self.g.getdt(logfilename) 45 | tsjump = self.g.getjump(trjfilename[0]) 46 | (num_lines, n, num_timesteps, count, line) = self.getnum(trjfilename) 47 | atommass = self.getmass(datfilename) 48 | V = self.getdimensions(trjfilename[0]) 49 | (vx, vy, vz, mol, atype) = self.createarrays(n, num_timesteps, moltype) 50 | (vxcol, vycol, vzcol, idcol, molcol, typecol) = self.getcolumns(trjfilename[0]) 51 | dotlist = self.getchargearrays(molcharges,moltype) 52 | if ver >= 1: 53 | print('beginning COM velocity calculation') 54 | for i in range(0,len(trjfilename)): 55 | trjfile = open(trjfilename[i]) 56 | while count < num_timesteps: 57 | (vx,vy,vz,line,mol, atype) = self.readdata(trjfile, n, line, vx, vy, vz, vxcol, vycol, vzcol, idcol, i, mol, molcol, atype, typecol) 58 | if count == 0: 59 | (comvx, comvy, comvz, nummol, molmass, jx, jy, jz) = self.COMprep(mol, atype, atommass, n, num_timesteps, moltypel) 60 | (comvx, comvy, comvz) = self.calcCOMv(comvx, comvy, comvz, vx, vy, vz, mol, atype, atommass, molmass, n, nummol) 61 | (jx, jy, jz, count) = self.calcj(dotlist, comvx, comvy, comvz, jx, jy, jz, count) 62 | if ver == 2: 63 | sys.stdout.write('\rCOM velocity calculation {:.2f}% complete'.format(count*100.0/num_timesteps)) 64 | if ver == 2: 65 | sys.stdout.write('\n') 66 | if ver >= 2: 67 | print('begining GK conductivity correlation') 68 | J = self.clacJ(jx, jy, jz, dt, tsjump, firstpoint,ver) 69 | if Jout: 70 | self.writeJ(J,tsjump,dt) 71 | integral = self.integrateJ(J, tsjump*dt) 72 | (begcon, endcon) = self.findconvergance(J[0],tol) 73 | time = [] 74 | for i in range(0,len(integral[0])): 75 | time.append(i*tsjump*dt) 76 | print(time[begcon]) 77 | print(time[endcon]) 78 | cond = np.zeros(len(J)) 79 | for i in range(0,len(J)): 80 | ave = self.fitcurve(time, integral[i], begcon, endcon) 81 | cond[i] = self.greenkubo(ave, T, V) 82 | GKintegral = self.greenkubo(integral,T,V) 83 | fit = [] 84 | for i in range(0,len(time)): 85 | fit.append(ave) 86 | output['Conductivity']['Green_Kubo'] = cond[0] 87 | a = GKintegral[0] 88 | a = a.tolist() 89 | output['Conductivity']['GK_Integral'] = a 90 | output['Conductivity']['Time'] = time 91 | for i in range(1,len(cond)): 92 | output['Conductivity']['Green_Kubo_{0}'.format(moltypel[i-1])] = cond[i] 93 | a = GKintegral[i] 94 | a = a.tolist() 95 | output['Conductivity']['GK_Integral_{0}'.format(moltypel[i-1])] = a 96 | return output 97 | 98 | def getdimensions(self,trjfilename): 99 | # uses trjectory file to get the length of box sides 100 | trjfile = open(trjfilename) 101 | for i in range(0,5): 102 | trjfile.readline() 103 | xbounds = trjfile.readline() 104 | xbounds = xbounds.split() 105 | ybounds = trjfile.readline() 106 | ybounds = ybounds.split() 107 | zbounds = trjfile.readline() 108 | zbounds = zbounds.split() 109 | Lx = float(xbounds[1])-float(xbounds[0]) 110 | Ly = float(ybounds[1])-float(ybounds[0]) 111 | Lz = float(zbounds[1])-float(zbounds[0]) 112 | V = Lx * Ly * Lz /10**30 113 | trjfile.close() 114 | return V 115 | 116 | def getnum(self,trjfilename): 117 | # uses the trjectory file and returns the number of lines and the number of atoms 118 | trjfile = open(trjfilename[0]) 119 | for j in range(0,3): 120 | trjfile.readline() 121 | n = int(trjfile.readline()) 122 | trjfile.close() 123 | num_timesteps=1 124 | num_lines=[] 125 | for i in range(0,len(trjfilename)): 126 | num_lines.append(int(sum(1 for line in open(trjfilename[i])))) 127 | num_timesteps += int(num_lines[i] / (n+9))-1 128 | line = [10 for x in trjfilename] 129 | for j in range(1,len(trjfilename)): 130 | line[j] += n+9 131 | count = 0 132 | return (num_lines, n, num_timesteps, count, line) 133 | 134 | def createarrays(self,n, num_timesteps, moltype): 135 | #creates numpy arrays for data reading 136 | vx = np.zeros(n) 137 | vy = np.zeros(n) 138 | vz = np.zeros(n) 139 | mol = np.zeros(n, dtype=int) 140 | atype = np.zeros(n) 141 | return (vx, vy, vz, mol, atype) 142 | 143 | def getcolumns(self,trjfilename): 144 | # defines the columns each data type is in in the trjectory file 145 | trjfile = open(trjfilename) 146 | for j in range(0,8): 147 | trjfile.readline() 148 | inline = trjfile.readline() 149 | inline = inline.split() 150 | inline.remove('ITEM:') 151 | inline.remove('ATOMS') 152 | vxcol = inline.index('vx') 153 | vycol = inline.index('vy') 154 | vzcol = inline.index('vz') 155 | idcol = inline.index('id') 156 | molcol = inline.index('mol') 157 | typecol = inline.index('type') 158 | trjfile.close() 159 | return (vxcol, vycol, vzcol, idcol, molcol, typecol) 160 | 161 | def readdata(self, trjfile, n, line, vx, vy, vz, vxcol, vycol, vzcol, idcol, i, mol, molcol, atype, typecol): 162 | # reads data from trjectory file into precreated arrays 163 | for j in range(0,9): 164 | trjfile.readline() 165 | for a in range(0,n): 166 | inline = trjfile.readline() 167 | inline = inline.split() 168 | vx[int(inline[idcol])-1]= float(inline[vxcol]) 169 | vy[int(inline[idcol])-1]= float(inline[vycol]) 170 | vz[int(inline[idcol])-1]= float(inline[vzcol]) 171 | mol[int(inline[idcol])-1] = int(inline[molcol]) 172 | atype[int(inline[idcol])-1] = int(inline[typecol]) 173 | 174 | line[i] += n+9 175 | return (vx,vy,vz,line, mol, atype) 176 | 177 | def calcj(self, dotlist, comvx, comvy, comvz, jx, jy, jz, count): 178 | #calculates the charge flux for a timestep 179 | #seperated into the contributions by different molecule types 180 | for i in range(0,len(dotlist)): 181 | jx[i][count] = np.dot(dotlist[i], comvx) 182 | jy[i][count] = np.dot(dotlist[i], comvy) 183 | jz[i][count] = np.dot(dotlist[i], comvz) 184 | count += 1 185 | return (jx, jy, jz, count) 186 | 187 | def clacJ(self, jx, jy, jz, dt, tsjump, firstpoint,ver): 188 | #Calculates the charge flux correlation function for all timesteps 189 | #J[0] is the total charge correlation function 190 | #J[m] is the charge correlation function for the mth species 191 | counter = 0 192 | J = np.zeros((len(jx)+1,len(jx[0]))) 193 | for l in range(0,len(jx)): 194 | for m in range(0, len(jx)): 195 | Jtest = self.correlate(jx[l],jx[m]) 196 | J[0] += Jtest 197 | J[m+1] += Jtest 198 | Jtest = self.correlate(jy[l],jy[m]) 199 | J[0] += Jtest 200 | J[m+1] += Jtest 201 | Jtest = self.correlate(jz[l],jz[m]) 202 | J[0] += Jtest 203 | J[m+1] += Jtest 204 | counter += 1 205 | if ver == 2: 206 | sys.stdout.write('\rGK conductivity correlation {0}% complete'.format(100.*float(counter)/len(jx)**2)) 207 | if ver == 2: 208 | sys.stdout.write('\n') 209 | return J 210 | 211 | def integrateJ(self, J, dt): 212 | #Integrates the charge flux correlation function to calculate conductivity 213 | integral = np.zeros((len(J),len(J[0]))) 214 | for i in range(0,len(J)): 215 | integral[i][1:] = cumtrapz(J[i], dx=dt) 216 | return integral 217 | 218 | def fitcurve(self, time, integral, begin, end): 219 | #calculates average value of the integral over the range begin:end 220 | ave = (np.average(integral[begin:end])) 221 | return ave 222 | 223 | def greenkubo(self, ave, T, V): 224 | #normalizes the average value of the integral to obtain the conductivity 225 | k = 1.38e-23 226 | el = 1.60217e-19 227 | cond = ave/3/k/T/V*el**2/10**5 228 | return cond 229 | 230 | 231 | def COMprep(self, mol, atype, atommass, n, num_timesteps, moltypel): 232 | #creates arrays to prepare for center of mass velocity calculations 233 | nummol = int(max(mol)) 234 | comvx = np.zeros(nummol) 235 | comvy = np.zeros(nummol) 236 | comvz = np.zeros(nummol) 237 | 238 | molmass = np.zeros(nummol) 239 | for atom in range(0,n): 240 | molmass[mol[atom]-1] += atommass[atype[atom]] 241 | jx = np.zeros((len(moltypel),num_timesteps)) 242 | jy = np.zeros((len(moltypel),num_timesteps)) 243 | jz = np.zeros((len(moltypel),num_timesteps)) 244 | return (comvx, comvy, comvz, nummol, molmass, jx, jy, jz) 245 | 246 | def getmass(self, datfilename): 247 | # returns a dictionary of the mass of each atom type 248 | atommass = {} 249 | foundmass= False 250 | readingmasses = True 251 | atomnum = 1 252 | datfile = open(datfilename) 253 | for i in range(0,4): 254 | datfile.readline() 255 | 256 | while foundmass == False: 257 | line = datfile.readline() 258 | line = line.split() 259 | 260 | if len(line) > 0: 261 | if line[0] == 'Masses': 262 | foundmass = True 263 | datfile.readline() 264 | 265 | while readingmasses == True: 266 | line = datfile.readline() 267 | line = line.split() 268 | if len(line) > 0: 269 | if int(line[0]) == atomnum: 270 | atommass[int(line[0])] = float(line[1]) 271 | atomnum += 1 272 | 273 | else: 274 | readingmasses = False 275 | 276 | else: 277 | readingmasses = False 278 | datfile.close() 279 | return atommass 280 | 281 | def calcCOMv(self, comvx, comvy, comvz, vx, vy, vz, mol, atype, atommass, molmass, n, nummol): 282 | #calculates the center of mass velocity of all molecules for the timestep 283 | amass = np.zeros(n) 284 | for i in range(0,n): 285 | amass[i] = atommass[atype[i]] 286 | (comvxt, comvyt, comvzt)= calccomf.calccom(n, nummol, vx, vy, vz, mol, amass, molmass, 0, 0, 0, 100000, 100000, 100000) 287 | comvx = copy.deepcopy(comvxt) 288 | comvy = copy.deepcopy(comvyt) 289 | comvz = copy.deepcopy(comvzt) 290 | 291 | return (comvx, comvy, comvz) 292 | 293 | def findconvergance(self, J,tol): 294 | #Determines range of indeces for fitting the integral 295 | #The range is for when the sum of the square of five consecutive values is less than the tolerance 296 | converged = False 297 | i = 3 298 | while not converged: 299 | if i >= len(J): 300 | print('J did not converge') 301 | begcon = i-1 302 | converged = True 303 | else: 304 | test = J[i-3]**2 + J[i-2]**2 + J[i-1]**2 + J[i]**2 305 | if test < tol * J[0]**2: 306 | begcon = i 307 | i += 1 308 | converged = True 309 | else: 310 | i += 1 311 | 312 | while converged: 313 | if i >= len(J): 314 | endcon = i-1 315 | converged = False 316 | else: 317 | test = J[i-3]**2 + J[i-2]**2 + J[i-1]**2 + J[i]**2 318 | if test > tol * J[0]**2: 319 | endcon = i 320 | converged = False 321 | else: 322 | i += 1 323 | return (begcon, endcon) 324 | 325 | def getchargearrays(self, molcharges, moltype): 326 | #generates an array with the charge on each molecule 327 | dotlist = np.zeros((int(max(moltype)+1),int(len(molcharges)))) 328 | for i in range(0,len(dotlist)): 329 | for k in range(0,len(moltype)): 330 | if moltype[k] == i: 331 | dotlist[i][k] = molcharges[k] 332 | 333 | return dotlist 334 | 335 | def writeJ(self,J, tsjump, dt): 336 | #writes the values of the charge flux correlation function to J.dat 337 | #First column is time, second is the total correlation function 338 | #Remaining columns are the contribution of different molecule types 339 | outfile = open('J.dat','w') 340 | for i in range(0,len(J[0])): 341 | outfile.write('{}\t{}'.format(tsjump*dt*i,J[0][i])) 342 | for k in range(1,len(J)): 343 | outfile.write('\t{}'.format(J[k][i])) 344 | outfile.write('\n') 345 | 346 | def correlate(self,a,b): 347 | #Use fast Fourier transforms to calculate the correlation function between a and b 348 | #Zeros are added to the end of the arrays to avoid wrapping the calculation 349 | al = np.concatenate((a,np.zeros(len(a))),axis=0) 350 | bl = np.concatenate((b,np.zeros(len(b))),axis=0) 351 | c= np.fft.ifft(np.fft.fft(al)*np.conjugate(np.fft.fft(bl))).real 352 | d = c[:int(len(c)/2)] 353 | d/=(np.arange(len(d))+1)[::-1] 354 | return d 355 | -------------------------------------------------------------------------------- /src/calcDielectricConstant.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu Jun 2 14:49:27 2016 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | 24 | import numpy as np 25 | import sys 26 | 27 | class calcDielectricConstant: 28 | def calcDEC(self, atomcharges, trjfilename, T, output, V, ver,start): 29 | 30 | """ 31 | This function calculates the dielectric constant of the system using 32 | the fluctuations in the dipole moment 33 | """ 34 | 35 | (num_lines, n, num_timesteps, count, line) = self.getnum(trjfilename) 36 | (Lx, Lx2, Ly, Ly2, Lz, Lz2) = self.getdimensions(trjfilename) 37 | (x,y,z,mol,Mx,My,Mz) = self.createarrays(n,num_timesteps) 38 | (xcol, ycol, zcol, molcol, idcol) = self.getcolumns(trjfilename) 39 | if ver >= 1: 40 | print('beginning dipole moment calculation') 41 | for i in range(0,len(trjfilename)): 42 | trjfile = open(trjfilename[i]) 43 | while line[i] < num_lines[i]: 44 | (x,y,z,mol,line) = self.readdata(trjfile, n, line, x, y, z, mol, xcol, ycol, zcol, molcol, idcol, i) 45 | self.unwrap(x, y, z, mol, Lx, Lx2, Ly, Ly2, Lz, Lz2) 46 | (Mx[count],My[count],Mz[count]) = self.calcdipolemoment(x, y, z, atomcharges) 47 | count += 1 48 | if ver > 1: 49 | sys.stdout.write('\rdipole moment calculation {:.2f}% complete'.format(count*100.0/num_timesteps)) 50 | if ver > 1: 51 | sys.stdout.write('\n') 52 | if ver >= 1: 53 | print('calculating dielectric constant') 54 | (AveM2, AveM) = self.calcaverage(Mx, My, Mz,start) 55 | dielectric = self.calcdielectric(AveM2, AveM, V, T) 56 | output['Dielectric Constant'] = {} 57 | output['Dielectric Constant']['units'] = 'unitless' 58 | output['Dielectric Constant']['explanation'] = 'returns a list of the cumulative dielectric constant for the number of timesteps used in the averages to show convergence.' 59 | output['Dielectric Constant']['list'] = dielectric 60 | return output 61 | 62 | def getnum(self,trjfilename): 63 | # uses the trjectory file and returns the number of lines and the number of atoms 64 | trjfile = open(trjfilename[0]) 65 | for i in range(0,3): 66 | trjfile.readline() 67 | n = int(trjfile.readline()) 68 | trjfile.close() 69 | num_timesteps=1 70 | num_lines=[] 71 | for i in range(0,len(trjfilename)): 72 | num_lines.append(int(sum(1 for line in open(trjfilename[i])))) 73 | num_timesteps += int(num_lines[i] / (n+9))-1 74 | line = [10 for x in trjfilename] 75 | for j in range(1,len(trjfilename)): 76 | line[j] += n+9 77 | count = 0 78 | return (num_lines, n, num_timesteps, count, line) 79 | 80 | def getdimensions(self,trjfilename): 81 | # uses trjectory file to get the length of box sides 82 | trjfile = open(trjfilename[0]) 83 | for i in range(0,5): 84 | trjfile.readline() 85 | xbounds = trjfile.readline() 86 | xbounds = xbounds.split() 87 | ybounds = trjfile.readline() 88 | ybounds = ybounds.split() 89 | zbounds = trjfile.readline() 90 | zbounds = zbounds.split() 91 | Lx = float(xbounds[1])-float(xbounds[0]) 92 | Lx2 = Lx/2 93 | Ly = float(ybounds[1])-float(ybounds[0]) 94 | Ly2 = Ly/2 95 | Lz = float(zbounds[1])-float(zbounds[0]) 96 | Lz2 = Lz/2 97 | trjfile.close() 98 | return (Lx, Lx2, Ly, Ly2, Lz, Lz2) 99 | 100 | def createarrays(self,n, num_timesteps): 101 | #creates numpy arrays for data reading 102 | x = np.zeros(n) 103 | y = np.zeros(n) 104 | z = np.zeros(n) 105 | mol = np.zeros(n) 106 | Mx = np.zeros(num_timesteps) 107 | My = np.zeros(num_timesteps) 108 | Mz = np.zeros(num_timesteps) 109 | return (x,y,z,mol,Mx,My,Mz) 110 | 111 | def getcolumns(self,trjfilename): 112 | # defines the columns each data type is in in the trjectory file 113 | trjfile = open(trjfilename[0]) 114 | for j in range(0,8): 115 | trjfile.readline() 116 | inline = trjfile.readline() 117 | inline = inline.split() 118 | inline.remove('ITEM:') 119 | inline.remove('ATOMS') 120 | try: 121 | xcol = inline.index('x') 122 | except: 123 | xcol = inline.index('xu') 124 | try: 125 | ycol = inline.index('y') 126 | except: 127 | ycol = inline.index('yu') 128 | try: 129 | zcol = inline.index('z') 130 | except: 131 | zcol = inline.index('zu') 132 | molcol = inline.index('mol') 133 | idcol = inline.index('id') 134 | trjfile.close() 135 | return (xcol, ycol, zcol, molcol, idcol) 136 | 137 | def readdata(self, trjfile, n, line, x, y, z, mol, xcol, ycol, zcol, molcol, idcol, i): 138 | # reads data from trjectory file into precreated arrays 139 | for j in range(0,9): 140 | trjfile.readline() 141 | for a in range(0,n): 142 | inline = trjfile.readline() 143 | inline = inline.split() 144 | aid = inline[idcol] 145 | x[int(aid)-1]= inline[xcol] 146 | y[int(aid)-1]= inline[ycol] 147 | z[int(aid)-1]= inline[zcol] 148 | mol[int(aid)-1]= inline[molcol] 149 | 150 | line[i] += n+9 151 | return (x,y,z,mol,line) 152 | 153 | def unwrap(self, x, y, z, mol, Lx, Lx2, Ly, Ly2, Lz, Lz2): 154 | #Ensures all atoms in a molecule are in the same image 155 | for atom in range(1,len(x)): 156 | if mol[atom] == mol[atom-1]: 157 | if x[atom] - x[atom-1] > Lx2: 158 | x[atom] -= Lx 159 | elif x[atom] - x[atom-1] < -1*Lx2: 160 | x[atom] += Lx 161 | if y[atom] - y[atom-1] > Ly2: 162 | y[atom] -= Ly 163 | elif y[atom] - y[atom-1] < -1*Ly2: 164 | y[atom] += Ly 165 | if z[atom] - z[atom-1] > Lz2: 166 | z[atom] -= Lz 167 | elif z[atom] - z[atom-1] < -1*Lz2: 168 | z[atom] += Lz 169 | 170 | def calcdipolemoment(self, x, y, z, atomcharges): 171 | #calculates the dipole moment for a given timestep 172 | mx = np.dot(x,atomcharges) 173 | my = np.dot(y,atomcharges) 174 | mz = np.dot(z,atomcharges) 175 | return (mx,my,mz) 176 | 177 | def calcaverage(self,Mx,My,Mz,start): 178 | #Calculates the cumulative average dipole moment and dipole moment squared for fluctuation calculations 179 | normarray = np.arange(1,len(Mx)-start+1) 180 | AveM2 = np.cumsum(Mx[start:]**2+My[start:]**2+Mz[start:]**2)/normarray 181 | AveM = (np.cumsum(Mx[start:])**2+np.cumsum(My[start:])**2+np.cumsum(Mz[start:])**2)/normarray**2 182 | return (AveM2, AveM) 183 | 184 | def calcdielectric(self, AveM2, AveM, V, T): 185 | #Calculates the running average of the dielectric constant 186 | kb = 1.38065e-23 187 | epsilon0 = 8.85418e-12 188 | AveM2 *= 1e-20*1.6022e-19**2 #correct units 189 | AveM *= 1e-20*1.6022e-19**2 190 | V *= 1e-30 191 | dielectric = (1+1/3./epsilon0/V/kb/T*(AveM2-AveM)).tolist() 192 | return dielectric 193 | 194 | def getvolume(self, trjfilename): 195 | #Calculates volume of the system 196 | trjfile = open(trjfilename) 197 | for i in range(0,5): 198 | trjfile.readline() 199 | xbounds = trjfile.readline() 200 | xbounds = xbounds.split() 201 | ybounds = trjfile.readline() 202 | ybounds = ybounds.split() 203 | zbounds = trjfile.readline() 204 | zbounds = zbounds.split() 205 | Lx = float(xbounds[1])-float(xbounds[0]) 206 | Ly = float(ybounds[1])-float(ybounds[0]) 207 | Lz = float(zbounds[1])-float(zbounds[0]) 208 | trjfile.close() 209 | V = Lx*Ly*Lz 210 | return (V, Lx, Ly, Lz) 211 | 212 | -------------------------------------------------------------------------------- /src/calcDiffusivity.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed May 27 16:05:33 2015 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | import numpy as np 24 | from scipy import stats 25 | import warnings 26 | 27 | class calcdiffusivity: 28 | 29 | 30 | def calcdiffusivity(self, output, moltypel, dt, tol): 31 | 32 | """ 33 | This function fits the mean square displacement to calculate the 34 | diffusivity for all molecule types in the system 35 | """ 36 | 37 | output['Diffusivity'] = {} 38 | output['Diffusivity']['units'] = 'm^2/s' 39 | for i in range(0,len(moltypel)): 40 | MSD = output['MSD'][moltypel[i]] 41 | lnMSD = np.log(MSD[1:]) 42 | time = output['MSD']['time'] 43 | lntime = np.log(time[1:]) 44 | firststep = self.findlinearregion(lnMSD, lntime, dt, tol) 45 | #self.writeLogLog(lnMSD,lntime,moltypel[i]) 46 | diffusivity = self.getdiffusivity(time, MSD, firststep) 47 | output['Diffusivity'][moltypel[i]] = diffusivity 48 | 49 | 50 | 51 | def findlinearregion(self, lnMSD, lntime, dt, tol): 52 | #Uses the slope of the log-log plot to find linear regoin of MSD 53 | timestepskip=np.ceil(500/dt) 54 | linearregion=True 55 | maxtime = len(lnMSD) 56 | numskip=1 57 | while linearregion == True: 58 | if numskip*timestepskip+1 > maxtime: 59 | firststep = maxtime-1-(numskip-1)*timestepskip 60 | return firststep 61 | linearregion= False 62 | else: 63 | t1=int(maxtime-1-(numskip-1)*timestepskip) 64 | t2=int(maxtime-1-numskip*timestepskip) 65 | slope = (lnMSD[t1]-lnMSD[t2])/(lntime[t1]-lntime[t2]) 66 | if abs(slope-1.) < tol: 67 | numskip += 1 68 | else: 69 | firststep=t1 70 | return firststep 71 | linearregion = False 72 | 73 | 74 | def getdiffusivity(self, Time, MSD, firststep): 75 | #Fits the linear region of the MSD to obtain the diffusivity 76 | calctime = [] 77 | calcMSD = [] 78 | for i in range(int(firststep), len(Time)): 79 | calctime.append(Time[i]) 80 | calcMSD.append(MSD[i]) 81 | if len(calctime)==1: 82 | diffusivity = 'runtime not long enough' 83 | else: 84 | with warnings.catch_warnings(): 85 | warnings.simplefilter("ignore") 86 | line = stats.linregress(calctime,calcMSD) 87 | slope = line[0] 88 | diffusivity=slope/600000 89 | return diffusivity 90 | 91 | def writeLogLog(self,lnMSD,lntime,moltype): 92 | outfile = open('LogLog{}.dat'.format(moltype),'w') 93 | for i in range(0,len(lnMSD)): 94 | outfile.write('{}\t{}\n'.format(lntime[i],lnMSD[i])) 95 | outfile.close() 96 | 97 | -------------------------------------------------------------------------------- /src/calcNEconductivity.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu May 7 15:06:47 2015 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | 24 | class calcNEconductivity: 25 | 26 | def calcNEconductivity(self, output, molcharge, Lx, Ly, Lz, nummoltype, moltypel, T): 27 | ''' 28 | This function uses the Nernst-Einstien equation to estimate the ionic 29 | conductivity of the system from the diffusivities 30 | 31 | ''' 32 | V = Lx*Ly*Lz*10**-30 33 | e = 1.60217657e-19 34 | k = 1.3806488e-23 35 | NEcond = 0 36 | for i in range(0,len(moltypel)): 37 | q = float(molcharge[moltypel[i]]) 38 | if q != 0: 39 | try: 40 | D = float(output['Diffusivity'][moltypel[i]]) 41 | except ValueError: 42 | output['Nernst Einstien Conductivity in S/m'] = 'runtime not long enough' 43 | return output 44 | N = int(nummoltype[i]) 45 | NEcond += N*q**2*D 46 | output['Conductivity']['Nernst_Einstein_{0}'.format(moltypel[i])]=N*q**2*D*e**2/k/T/V 47 | NEcond *= e**2/k/T/V 48 | 49 | output['Conductivity']['Nernst_Einstein'] = NEcond 50 | 51 | 52 | return output 53 | -------------------------------------------------------------------------------- /src/calcVisc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Dec 11 09:16:20 2015 4 | 5 | @author: mhumbert 6 | PyLAT: Python LAMMPS Analysis Tools 7 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | """ 23 | 24 | import numpy as np 25 | import sys 26 | from random import randint 27 | 28 | from .fitVisc import fitVisc 29 | from .viscio import LammpsLog 30 | 31 | class calcVisc: 32 | 33 | def calcvisc(self,numtrj,numskip,dirbase,logname,output,ver,numsamples,numboot,plot, popt2): 34 | ''' 35 | 36 | Calculates average and standard deviation of the integral of the 37 | pressure tensor autocorrelation function over numtrj lammps trajectories 38 | 39 | ''' 40 | output['Viscosity']={} 41 | output['Viscosity']['Units']='cP' 42 | if dirbase==None: 43 | dirbase='./' 44 | filename=dirbase+'1/'+logname 45 | Log = LammpsLog.from_file(filename) 46 | (Time,visco)=Log.viscosity(numskip) 47 | trjlen = len(Time) 48 | viscosity = np.zeros((numtrj,trjlen)) 49 | for i in range(0,len(visco)): 50 | viscosity[0][i] += visco[i] 51 | if ver>=1: 52 | sys.stdout.write('Viscosity Trajectory 1 of {} complete'.format(numtrj)) 53 | 54 | 55 | for i in range(2,numtrj+1): 56 | filename=dirbase+str(i)+'/'+logname 57 | Log = LammpsLog.from_file(filename) 58 | (Time,visco)=Log.viscosity(numskip) 59 | if len(visco) < trjlen: 60 | trjlen = len(visco) 61 | for j in range(0,trjlen): 62 | viscosity[i-1][j] += visco[j] 63 | if ver>=1: 64 | sys.stdout.write('\rViscosity Trajectory {} of {} complete'.format(i,numtrj)) 65 | if ver>=1: 66 | sys.stdout.write('\n') 67 | 68 | #Begin Bootstrapping for error estimate 69 | Values = [] 70 | fv = fitVisc() 71 | for i in range(0,numboot): 72 | Values.append(self.Bootstrap(numsamples,trjlen,numtrj,viscosity,Time,fv,plot, popt2)) 73 | if ver > 1: 74 | sys.stdout.write('\rViscosity Bootstrap {} of {} complete'.format(i+1,numboot)) 75 | if ver > 1: 76 | sys.stdout.write('\n') 77 | 78 | (ave,stddev,Values) = self.getAverage(Values,numsamples,trjlen,numtrj,viscosity,Time,fv) 79 | 80 | output['Viscosity']['Average Value'] = ave 81 | output['Viscosity']['Standard Deviation'] = stddev 82 | #output['Viscosity']['Average Integral']=average.tolist() 83 | #output['Viscosity']['Standard Deviation']=stddev.tolist() 84 | #output['Viscosity']['Time']=Time[:trjlen].tolist() 85 | 86 | return(output) 87 | 88 | def getAverage(self, Values,numsamples,trjlen,numtrj,viscosity,Time,fv): 89 | #calculate average and standard deviation of Values array 90 | #Was originally implemented to perform a z-test on the values to determine outliers 91 | ave = np.average(Values) 92 | stddev = np.std(Values) 93 | #maxval = np.max(Values) 94 | #minval = np.min(Values) 95 | #if ((maxval-ave)>(3*stddev)): 96 | #Values.remove(maxval) 97 | #print('{} removed from values'.format(maxval)) 98 | #Values.append(self.Bootstrap(numsamples,trjlen,numtrj,viscosity,Time,fv)) 99 | #(ave, stddev,Values) = self.getAverage(Values,numsamples,trjlen,numtrj,viscosity,Time,fv) 100 | #elif ((ave-minval)>(5*stddev)): 101 | #Values.remove(minval) 102 | #print('{} removed from values'.format(minval)) 103 | #Values.append(self.Bootstrap(numsamples,trjlen,numtrj,viscosity,Time,fv)) 104 | #(ave, stddev,Values) = self.getAverage(Values,numsamples,trjlen,numtrj,viscosity,Time,fv) 105 | return (ave,stddev,Values) 106 | 107 | def Bootstrap(self,numsamples,trjlen,numtrj,viscosity,Time,fv,plot,popt2): 108 | #Perform calculate the viscosity of one bootstrapping sample 109 | Bootlist = np.zeros((numsamples,trjlen)) 110 | for j in range(0,numsamples): 111 | rint=randint(0,numtrj-1) 112 | for k in range(0,trjlen): 113 | Bootlist[j][k] = viscosity[rint][k] 114 | average = np.zeros(trjlen) 115 | stddev = np.zeros(trjlen) 116 | for j in range(0,trjlen): 117 | average[j] = np.average(Bootlist.transpose()[j]) 118 | stddev[j] = np.std(Bootlist.transpose()[j]) 119 | Value = fv.fitvisc(Time,average,stddev,plot,popt2) 120 | return Value 121 | -------------------------------------------------------------------------------- /src/calcdistances.f90: -------------------------------------------------------------------------------- 1 | subroutine calcdistances(nummol,comx, comy, comz, Lx, Ly, Lz,r) 2 | 3 | integer, intent(in) :: nummol 4 | real, dimension(:), intent(in) :: comx 5 | real, dimension(:), intent(in) :: comy 6 | real, dimension(:), intent(in) :: comz 7 | real, intent(in) :: Lx 8 | real, intent(in) :: Ly 9 | real, intent(in) :: Lz 10 | real :: dx,dy,dz 11 | real, dimension(0:nummol-1,0:nummol-1),intent(out) :: r 12 | do i=1,nummol-1 13 | do j=i+1, nummol 14 | dx=comx(i)-comx(j) 15 | dy=comy(i)-comy(j) 16 | dz=comz(i)-comz(j) 17 | dx=dx-Lx*float(nint(dx/Lx)) 18 | dy=dy-Ly*float(nint(dy/Ly)) 19 | dz=dz-Lz*float(nint(dz/Lz)) 20 | r(i-1,j-1)=sqrt(dx**2+dy**2+dz**2) 21 | r(j-1,i-1)=sqrt(dx**2+dy**2+dz**2) 22 | end do 23 | end do 24 | return 25 | end subroutine calcdistances 26 | -------------------------------------------------------------------------------- /src/distSearch.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Nov 17 14:09:31 2017 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | 24 | """ 25 | 26 | import numpy as np 27 | import __future__ 28 | import src.calccomf as calccomf 29 | 30 | class distSearch: 31 | def distSearch(self, mol1, mol2, dist, deltaDist, firstFrame, numSamples, trjfilename, datfilename, moltype, moltypel,output): 32 | 33 | 34 | """ 35 | This function will search through a trajectory to find examples where two 36 | molecules of given types are at a certain distance apart. Useful for 37 | generation of images 38 | """ 39 | 40 | output['Distance_Search'] = {} 41 | (num_lines, n, num_timesteps, count, line, numFound, frame)=self.getnum(trjfilename) 42 | (Lx, Lx2, Ly, Ly2, Lz, Lz2) = self.getdimensions(trjfilename[0]) 43 | (x,y,z,mol,atype,aid) = self.createarrays(n) 44 | (xcol, ycol, zcol, molcol, typecol, idcol) = self.getcolumns(trjfilename[0]) 45 | atommass = self.getmass(datfilename) 46 | for i in range(0,len(trjfilename)): 47 | trjfile = open(trjfilename[i]) 48 | for j in range(0,firstFrame-1): 49 | for k in range(0,n+9): 50 | trjfile.readline() 51 | line[i] += n+9 52 | #print 'frame {}'.format(frame) 53 | frame+=1 54 | while line[i] < num_lines[i] and numFound < numSamples: 55 | #print 'frame {}'.format(frame) 56 | (x,y,z,mol,atype,line,aid) = self.readdata(trjfile, n, line, x, y, z, mol, atype, aid, xcol, ycol, zcol, molcol, typecol,i,idcol) 57 | if count == 0: 58 | (nummol, comx, comy, comz, molmass) = self.comprep(mol, n, atype, atommass, num_timesteps) 59 | molid = self.molID(mol,aid,moltype) 60 | (comx, comy, comz, count) = self.calccom(comx, comy, comz, x, y, z, mol, atype, atommass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2, n, count, nummol) 61 | (numFound,output) = self.distCalc(comx, comy, comz, mol1, mol2, dist, deltaDist, moltype, molid, numFound, numSamples, Lx, Ly, Lz,frame, moltypel, output) 62 | frame += 1 63 | return output 64 | 65 | def getnum(self,trjfilename): 66 | # uses the trjectory file and returns the number of lines and the number of atoms 67 | trjfile = open(trjfilename[0]) 68 | for i in range(0,3): 69 | trjfile.readline() 70 | n = int(trjfile.readline()) 71 | trjfile.close() 72 | num_timesteps=1 73 | num_lines=[] 74 | for i in range(0,len(trjfilename)): 75 | num_lines.append(int(sum(1 for line in open(trjfilename[i])))) 76 | num_timesteps += int(num_lines[i] / (n+9))-1 77 | line = [10 for x in trjfilename] 78 | for j in range(1,len(trjfilename)): 79 | line[j] += n+9 80 | count = 0 81 | numFound = 0 82 | frame = 1 83 | return (num_lines, n, num_timesteps, count, line, numFound, frame) 84 | 85 | def getdimensions(self,trjfilename): 86 | # uses trjectory file to get the length of box sides 87 | trjfile = open(trjfilename) 88 | for i in range(0,5): 89 | trjfile.readline() 90 | xbounds = trjfile.readline() 91 | xbounds = xbounds.split() 92 | ybounds = trjfile.readline() 93 | ybounds = ybounds.split() 94 | zbounds = trjfile.readline() 95 | zbounds = zbounds.split() 96 | Lx = float(xbounds[1])-float(xbounds[0]) 97 | Lx2 = Lx/2 98 | Ly = float(ybounds[1])-float(ybounds[0]) 99 | Ly2 = Ly/2 100 | Lz = float(zbounds[1])-float(zbounds[0]) 101 | Lz2 = Lz/2 102 | trjfile.close() 103 | return (Lx, Lx2, Ly, Ly2, Lz, Lz2) 104 | 105 | def createarrays(self,n): 106 | #creates numpy arrays for data reading 107 | x = np.zeros(n) 108 | y = np.zeros(n) 109 | z = np.zeros(n) 110 | mol = np.zeros(n) 111 | atype = np.zeros(n) 112 | aid = np.zeros(n) 113 | return (x,y,z,mol,atype,aid) 114 | 115 | def getcolumns(self,trjfilename): 116 | # defines the columns each data type is in in the trjectory file 117 | trjfile = open(trjfilename) 118 | for j in range(0,8): 119 | trjfile.readline() 120 | inline = trjfile.readline() 121 | inline = inline.split() 122 | inline.remove('ITEM:') 123 | inline.remove('ATOMS') 124 | xcol = inline.index('x') 125 | ycol = inline.index('y') 126 | zcol = inline.index('z') 127 | molcol = inline.index('mol') 128 | typecol = inline.index('type') 129 | idcol = inline.index('id') 130 | trjfile.close() 131 | return (xcol, ycol, zcol, molcol, typecol, idcol) 132 | 133 | def getmass(self, datfilename): 134 | # returns a dictionary of the mass of each atom type 135 | atommass = {} 136 | foundmass= False 137 | readingmasses = True 138 | atomnum = 1 139 | datfile = open(datfilename) 140 | for i in range(0,4): 141 | datfile.readline() 142 | 143 | while foundmass == False: 144 | line = datfile.readline() 145 | line = line.split() 146 | 147 | if len(line) > 0: 148 | if line[0] == 'Masses': 149 | foundmass = True 150 | datfile.readline() 151 | 152 | while readingmasses == True: 153 | line = datfile.readline() 154 | line = line.split() 155 | if len(line) > 0: 156 | if int(line[0]) == atomnum: 157 | atommass[int(line[0])] = float(line[1]) 158 | atomnum += 1 159 | 160 | else: 161 | readingmasses = False 162 | 163 | else: 164 | readingmasses = False 165 | datfile.close() 166 | return atommass 167 | 168 | def readdata(self, trjfile, n, line, x, y, z, mol, atype, aid, xcol, ycol, zcol, molcol, typecol, i, idcol): 169 | # reads data from trjectory file into precreated arrays 170 | for j in range(0,9): 171 | trjfile.readline() 172 | for a in range(0,n): 173 | inline = trjfile.readline() 174 | inline = inline.split() 175 | x[a]= inline[xcol] 176 | y[a]= inline[ycol] 177 | z[a]= inline[zcol] 178 | mol[a]= inline[molcol] 179 | atype[a]= inline[typecol] 180 | aid[a] = inline[idcol] 181 | 182 | line[i] += n+9 183 | return (x,y,z,mol,atype,line,aid) 184 | 185 | def comprep(self, mol, n, atype, atommass, num_timesteps): 186 | #creates arrays to prepare for center of mass calculations 187 | nummol = int(max(mol)) 188 | comx = [0 for x in range(nummol)] 189 | comy = [0 for x in range(nummol)] 190 | comz = [0 for x in range(nummol)] 191 | 192 | molmass = np.zeros(nummol) 193 | for atom in range(0,n): 194 | molmass[int(mol[atom]-1)] += atommass[atype[atom]] 195 | 196 | return (nummol, comx, comy, comz, molmass) 197 | 198 | def molID(self, mol, aid, moltype): 199 | #generates arrays for ids of example molecules 200 | molid = [[] for i in range(0,len(moltype))] 201 | for i in range(0,len(mol)): 202 | molid[int(mol[i])-1].append(int(aid[i])) 203 | return molid 204 | 205 | def calccom(self, comx, comy, comz, x, y, z, mol, atype, atommass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2, n, count, nummol): 206 | #calculates the center of mass for each molecule 207 | amass = np.zeros(n) 208 | for i in range(0,n): 209 | amass[i] = atommass[atype[i]] 210 | 211 | (comxt, comyt, comzt)= calccomf.calccom(n, nummol, x, y, z, mol, amass, molmass, Lx, Ly, Lz, Lx2, Ly2, Lz2) 212 | comx = np.array(comxt) 213 | comy = np.array(comyt) 214 | comz = np.array(comzt) 215 | 216 | count += 1 217 | 218 | return (comx, comy, comz, count) 219 | def distCalc(self, comx, comy, comz, mol1, mol2, dist, deltaDist, moltype, molid, numFound, numSamples, Lx, Ly, Lz, frame, moltypel, output): 220 | #Finds molecules at the given distance apart 221 | ind = [] 222 | for i in range(0,len(moltype)): 223 | ind.append(moltype[i]==moltypel.index(mol2)) 224 | indid = [l for l, x in enumerate(ind) if x] 225 | for i in range(0,len(moltype)): 226 | if moltype[i]==moltypel.index(mol1): 227 | dx = comx[ind]-np.array([comx[i] for j in range(0,len(indid))]) 228 | dy = comy[ind]-np.array([comy[i] for j in range(0,len(indid))]) 229 | dz = comz[ind]-np.array([comz[i] for j in range(0,len(indid))]) 230 | 231 | dx -= Lx * np.around(dx / Lx) 232 | dy -= Ly * np.around(dy / Ly) 233 | dz -= Lz * np.around(dz / Lz) 234 | 235 | r2 = dx ** 2 + dy ** 2 + dz ** 2 236 | r = np.sqrt(r2) 237 | 238 | for j in range(0,len(r)): 239 | if (np.abs(r[j]-dist) < deltaDist) and (numFound < numSamples): 240 | if ((mol1 == mol2) and (i < indid[j])) or (not mol1==mol2): 241 | numFound += 1 242 | molid[i].sort() 243 | molid[indid[j]].sort() 244 | print('Sample {} Found'.format(numFound)) 245 | output['Distance_Search']['Sample_{}'.format(numFound)] = {} 246 | output['Distance_Search']['Sample_{}'.format(numFound)]['Distance'] = float(r[j]) 247 | output['Distance_Search']['Sample_{}'.format(numFound)]['Frame'] = int(frame) 248 | output['Distance_Search']['Sample_{}'.format(numFound)]['Molecule_1_IDs'] = molid[i] 249 | output['Distance_Search']['Sample_{}'.format(numFound)]['molecule_2_IDs'] = molid[indid[j]] 250 | 251 | return (numFound,output) 252 | 253 | 254 | 255 | -------------------------------------------------------------------------------- /src/fitVisc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed May 18 16:05:34 2016 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | 25 | import numpy as np 26 | from scipy import optimize 27 | 28 | 29 | class fitVisc: 30 | 31 | def doubexp(self,x,A,alpha,tau1, tau2): 32 | return A*alpha*tau1*(1-np.exp(-x/tau1))+A*(1-alpha)*tau2*(1-np.exp(-x/tau2)) 33 | 34 | def doubexp1(self,x,A,alpha,tau1, tau2): 35 | return A*alpha*tau1*(1-np.exp(-x/tau1)) 36 | 37 | def doubexp2(self,x,A,alpha,tau1, tau2): 38 | return A*(1-alpha)*tau2*(1-np.exp(-x/tau2)) 39 | 40 | def singleexp(self, x, A, tau): 41 | return A*(1-np.exp(-x/tau)) 42 | 43 | def fitvisc(self,time,visc,stddev,plot, popt2): 44 | #popt2=[1e-3,1.5e-1,1e2,1e3] 45 | #popt2=[2e-3,5e-2,2e3,2e2] 46 | #popt2=[1e-4,1e2] 47 | foundcutoff = False 48 | foundstart = False 49 | start = 1 50 | while not foundstart and start 2000: 52 | foundstart = True 53 | else: 54 | start+=1 55 | cut = 1 56 | while not foundcutoff and cut 0.4*visc[cut]: 58 | foundcutoff = True 59 | else: 60 | cut += 1 61 | #cut = len(visc) 62 | #popt2,pcov2 = optimize.curve_fit(self.doubexp, time[start:cut], visc[start:cut],maxfev=1000000,p0=popt2, sigma=stddev[start:cut]) 63 | popt2,pcov2 = optimize.curve_fit(self.doubexp, time[start:cut], visc[start:cut],maxfev=1000000,p0=popt2, sigma=stddev[start:cut],bounds=(0,[np.inf,1,np.inf,np.inf])) 64 | 65 | fit = [] 66 | fit1 = [] 67 | fit2 = [] 68 | for t in time: 69 | fit.append(self.doubexp(t,*popt2)) 70 | fit1.append(self.doubexp1(t,*popt2)) 71 | fit2.append(self.doubexp2(t,*popt2)) 72 | Value = popt2[0]*popt2[1]*popt2[2]+popt2[0]*(1-popt2[1])*popt2[3] 73 | #Value = popt2[0] 74 | 75 | if plot: 76 | timep = time/1000000 77 | from matplotlib import pyplot as plt 78 | from matplotlib import rcParams 79 | rcParams.update({'font.size':14}) 80 | print('Viscosity estimate is {}'.format(Value)) 81 | print('A={}, alpha={}, tau1={}, tau2={}'.format(popt2[0],popt2[1],popt2[2],popt2[3])) 82 | print('Time cutoff is {}'.format(time[cut])) 83 | plt.ticklabel_format(axis='x', style='sci', scilimits=(0,0)) 84 | plt.plot(timep[:len(visc)],visc,label='Viscosity') 85 | plt.plot(timep[:len(fit)],fit,label='Double Exponential fit') 86 | plt.plot(timep[:len(fit1)],fit1,label=r'Contribution of $\tau_1$') 87 | plt.plot(timep[:len(fit2)],fit2,label=r'Contribution of $\tau_2$') 88 | plt.axvline(timep[cut]) 89 | plt.ylabel('Viscosity (mPa*s)') 90 | plt.xlabel('Time (ns)') 91 | plt.legend() 92 | plt.show() 93 | 94 | return(Value) 95 | -------------------------------------------------------------------------------- /src/getAtomCharges.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Thu May 7 14:10:12 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | import numpy as np 25 | class getatomcharges: 26 | 27 | def findnumatoms(self, datfilename): 28 | #returns number of atoms in the simulation 29 | datfile = open(datfilename) 30 | foundnumatoms=False 31 | datfile.readline() 32 | while foundnumatoms==False: 33 | line = datfile.readline() 34 | line = line.split() 35 | if len(line) >= 2: 36 | if line[1] == 'atoms': 37 | n=int(line[0]) 38 | foundnumatoms = True 39 | datfile.close() 40 | return n 41 | 42 | def getmolcharges(self, datfilename, n): 43 | #Returns arrays with the charge of all atoms and molecules in the system 44 | datfile = open(datfilename) 45 | for j in range(0,4): 46 | datfile.readline() 47 | atomcharges = np.zeros(n) 48 | mol = np.zeros(n) 49 | foundatoms= False 50 | readingcharges = True 51 | 52 | while foundatoms == False: 53 | line = datfile.readline() 54 | line = line.split() 55 | 56 | if len(line) > 0: 57 | if line[0] == 'Atoms': 58 | foundatoms = True 59 | datfile.readline() 60 | 61 | while readingcharges == True: 62 | line = datfile.readline() 63 | line = line.split() 64 | if len(line) == 10 or len(line) == 7: 65 | atomcharges[int(line[0])-1] = float(line[3]) 66 | mol[int(line[0])-1] = int(line[1]) 67 | 68 | else: 69 | readingcharges = False 70 | 71 | nummol = int(max(mol)) 72 | molcharges = np.zeros(nummol) 73 | for atom in range(0,n): 74 | molcharges[int(mol[int(atom)])-1] += atomcharges[int(atom)] 75 | 76 | datfile.close() 77 | return (molcharges,atomcharges,n) 78 | 79 | def molchargedict(self, molcharges, moltypel, moltype): 80 | #creates a dictionary assigning charge to a molecule type 81 | molcharge = {} 82 | for molecules in range(0,len(moltypel)): 83 | molcharge[moltypel[molecules]] = molcharges[moltype.index(molecules)] 84 | return molcharge 85 | -------------------------------------------------------------------------------- /src/getCoordinationNumber.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed May 27 12:38:04 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | import numpy 25 | from scipy.integrate import cumtrapz 26 | import copy 27 | 28 | class getcoordinationnumber: 29 | def calccoordinationnumber(self, output, nummoltype, moltypel, V): 30 | 31 | """ 32 | This function integrates the radial distribution function to obtain the 33 | coordination number for all molecule types 34 | 35 | This code determines the first three minima in the radial distribution 36 | function and returns the coordination number for these three points. 37 | The cumulative integral is also returned 38 | """ 39 | 40 | output['Coordination_Number'] = {} 41 | output['Coordination_Number']['units'] = 'Minima in angstroms, Coordination numbers in Angstroms' 42 | output['Coordination_Number']['explanation'] = 'This program finds the first three local minima and finds the coordination number integrating until there. Na-H20 represents the coordination number for water around sodium.' 43 | pairlist = list(output['RDF'].keys()) 44 | pairlist.remove('units') 45 | pairlist.remove('distance') 46 | r = output['RDF']['distance'] 47 | for i in range(0,len(pairlist)): 48 | g = output['RDF'][pairlist[i]] 49 | split = pairlist[i].split('-') 50 | mol1 = split[0] 51 | mol2 = split[1] 52 | (minima,index) = self.findfirst3minima(g,r) 53 | output['Coordination_Number']['{0} around {1}'.format(mol1, mol2)] = {} 54 | integral = self.integrate(g,r,nummoltype, moltypel, V, mol1) 55 | output['Coordination_Number']['{0} around {1}'.format(mol1, mol2)]['Cumulative_Integral'] = copy.deepcopy(integral) 56 | output['Coordination_Number']['{0} around {1}'.format(mol1, mol2)]['Minima'] = minima 57 | coord = [] 58 | for j in range(0,len(minima)): 59 | coord.append(integral[index[j]]) 60 | output['Coordination_Number']['{0} around {1}'.format(mol1, mol2)]['Coordination_Numbers'] = coord 61 | if mol2 != mol1: 62 | output['Coordination_Number']['{0} around {1}'.format(mol2, mol1)] = {} 63 | integral = self.integrate(g,r,nummoltype, moltypel, V, mol2) 64 | output['Coordination_Number']['{0} around {1}'.format(mol2, mol1)]['Cumulative_Integral'] = copy.deepcopy(integral) 65 | output['Coordination_Number']['{0} around {1}'.format(mol2, mol1)]['Minima'] = minima 66 | coord = [] 67 | for j in range(0,len(minima)): 68 | coord.append(integral[index[j]]) 69 | output['Coordination_Number']['{0} around {1}'.format(mol2, mol1)]['Coordination_Numbers'] = coord 70 | return output 71 | 72 | def findfirst3minima(self, g, r): 73 | #determines the first three minima in the radial distribution function 74 | foundpositive = False 75 | minima = [] 76 | index = [] 77 | i=0 78 | while not foundpositive: 79 | if g[i] > 1: 80 | foundpositive = True 81 | i += 1 82 | else: 83 | i +=1 84 | 85 | while len(minima) < 3 and i < len(g)-2: 86 | if g[i-1] > g[i] and g[i+1] > g[i]: 87 | minima.append(r[i]) 88 | index.append(i) 89 | i += 1 90 | 91 | return (minima,index) 92 | 93 | 94 | def integrate(self, g,r, nummoltype, moltypel, V, mol): 95 | #integrates the radial distribution functions 96 | integrallist = [] 97 | for i in range(0,len(g)): 98 | integrallist.append(g[i]*nummoltype[moltypel.index(mol)]/V*4*numpy.pi*r[i]**2) 99 | integral = cumtrapz(integrallist, x = r) 100 | integral= integral.tolist() 101 | return integral 102 | 103 | def getvolume(self, trjfilename): 104 | #calculates the volume of the system (assumes NVT or NVE ensemble) 105 | trjfile = open(trjfilename) 106 | for i in range(0,5): 107 | trjfile.readline() 108 | xbounds = trjfile.readline() 109 | xbounds = xbounds.split() 110 | ybounds = trjfile.readline() 111 | ybounds = ybounds.split() 112 | zbounds = trjfile.readline() 113 | zbounds = zbounds.split() 114 | Lx = float(xbounds[1])-float(xbounds[0]) 115 | Ly = float(ybounds[1])-float(ybounds[0]) 116 | Lz = float(zbounds[1])-float(zbounds[0]) 117 | trjfile.close() 118 | V = Lx*Ly*Lz 119 | return (V, Lx, Ly, Lz) 120 | -------------------------------------------------------------------------------- /src/getMolData.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Mar 13 10:36:25 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | 25 | 26 | class getmoldata: 27 | 28 | def getmoltype(self, datfilename): 29 | # determines molecule types and number of each molecule type 30 | #also creates a list of molecule type of each molecule 31 | datfile = open(datfilename) 32 | datfile.readline() 33 | datfile.readline() 34 | nummoltype = [] 35 | moltypel = [] 36 | moltype = [] 37 | readingmolecules = True 38 | while readingmolecules == True: 39 | line = datfile.readline() 40 | line = line.split() 41 | if len(line) == 4: 42 | nummoltype.append(int(line[1])) 43 | moltypel.append(line[2]) 44 | 45 | else: 46 | readingmolecules = False 47 | 48 | for i in range(0,len(moltypel)): 49 | for j in range(0,nummoltype[i]): 50 | moltype.append(int(i)) 51 | 52 | datfile.close() 53 | return (nummoltype, moltypel, moltype) 54 | 55 | -------------------------------------------------------------------------------- /src/getTimeData.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Mar 13 10:41:46 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | import sys 25 | 26 | class gettimedata: 27 | 28 | def getdt(self, logfilename): 29 | #determines the timestep of the simulation 30 | numlines=int(sum(1 for line in open(logfilename))) 31 | logfile = open(logfilename) 32 | foundtimestep=False 33 | count=0 34 | while foundtimestep==False: 35 | if count > numlines: 36 | sys.exit('could not find timestep size in log file') 37 | inline = logfile.readline() 38 | inline = inline.split() 39 | if len(inline) > 0: 40 | if inline[0] == 'timestep': 41 | dt = float(inline[1]) 42 | foundtimestep=True 43 | count+=1 44 | logfile.close() 45 | 46 | return dt 47 | 48 | def getjump(self, trjfilename): 49 | #determines the frequency of output for the trajectory file 50 | trjfile = open(trjfilename) 51 | trjfile.readline() 52 | t1 = trjfile.readline() 53 | t1 = int(t1) 54 | trjfile.readline() 55 | n = int(trjfile.readline()) 56 | for i in range(0,n+6): 57 | trjfile.readline() 58 | t2 = int(trjfile.readline()) 59 | tsjump = t2-t1 60 | return tsjump 61 | -------------------------------------------------------------------------------- /src/ionpair.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Aug 3 10:49:36 2015 4 | 5 | @author: mhumbert 6 | 7 | PyLAT: Python LAMMPS Analysis Tools 8 | Copyright (C) 2018 Michael Humbert, Yong Zhang and Ed Maginn 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | """ 24 | import src.calcdistances as calcdistances 25 | import numpy as np 26 | from scipy.integrate import cumtrapz 27 | import src.ipcorr as ipcorr 28 | from scipy.optimize import curve_fit 29 | import copy 30 | import sys 31 | import warnings 32 | 33 | class ionpair: 34 | 35 | 36 | def runionpair(self,comx,comy,comz,Lx,Ly,Lz,moltypel,moltype,tsjump,dt,output,ver,skipframes): 37 | 38 | """ 39 | Calculates the ion pair lifetime for all combinations of molecule types 40 | in the system. An ion pair for types A and B is defined as the closest 41 | molecule of type B around a molecule of type A 42 | 43 | The integral is fit using multiexponentials from one to five 44 | exponentials to obtain a good fit without overfitting 45 | """ 46 | 47 | output['Ion_Pair_Lifetime'] = {} 48 | output['Ion_Pair_Lifetime']['Units'] = 'picoseconds' 49 | output['Ion_Pair_Lifetime']['Explanation'] = 'The Ion Pair Lifetime correlation function is fit to a single exponential, a double exponential up to 5 exponentials. The results shown are the result of these successive fittings' 50 | (closest,begin,end,C)=self.init(len(comx[0]),moltypel,len(comx),moltype) 51 | for step in range(0,len(comx)): 52 | r = self.calcdistance(comx[step],comy[step],comz[step],Lx,Ly,Lz) 53 | self.findclosest(r,closest,begin,end,step) 54 | if ver: 55 | sys.stdout.write('\rIPL distance calculation {:.2f}% complete'.format((step+1)*100.0/len(comx))) 56 | 57 | if ver: 58 | sys.stdout.write('\n') 59 | 60 | correlation = self.correlation(closest,moltype,moltypel,ver,skipframes) 61 | if ver: 62 | print('correlation complete') 63 | time = [] 64 | for i in range(0,len(correlation)): 65 | time.append(float(i*tsjump*dt/1000)) 66 | begin = int(1000/dt/tsjump) 67 | end = len(time) 68 | for i in range(0,len(moltypel)): 69 | for j in range(0,len(moltypel)): 70 | if i != j: 71 | y = [] 72 | end = 0 73 | for k in range(0,len(correlation)): 74 | y.append(float(correlation[k][i][j])) 75 | if correlation[k][i][j] <= 0.04 and end ==0: 76 | end = k 77 | if end==0: 78 | end = len(y) 79 | (IPL,r2) = self.curvefit(y,time,begin,end) 80 | output['Ion_Pair_Lifetime']['{0} around {1}'.format(moltypel[j],moltypel[i])]=IPL 81 | output['Ion_Pair_Lifetime']['{0} around {1} r2'.format(moltypel[j],moltypel[i])]=r2 82 | output['Ion_Pair_Lifetime']['{0} around {1} correlation'.format(moltypel[j],moltypel[i])]=copy.deepcopy(y) 83 | output['Ion_Pair_Lifetime']['Correlation_Time']=copy.deepcopy(time) 84 | 85 | def init(self,nummol, moltypel, numtimesteps,moltype): 86 | #initializes arrays for the calculations 87 | closest = np.zeros((numtimesteps,nummol,len(moltypel))) 88 | C = np.zeros((len(moltypel),len(moltypel))) 89 | begin = [0] 90 | end = [] 91 | for i in range(1,len(moltype)): 92 | if moltype[i]!= moltype[i-1]: 93 | end.append(i) 94 | begin.append(i) 95 | 96 | end.append(len(moltype)) 97 | return (closest,begin,end,C) 98 | 99 | def calcdistance(self,comx,comy,comz,Lx,Ly,Lz): 100 | #Runs a fortran script calculating the distance between all molecules 101 | r = calcdistances.calcdistances(len(comx),comx,comy,comz,Lx,Ly,Lz) 102 | return r 103 | 104 | def findclosest(self,r,closest,begin,end,timestep): 105 | #Search molecules to find the closest molecules at each timestep 106 | for i in range(0,len(r)): 107 | for j in range(0,len(begin)): 108 | distance = 10000 109 | for k in range(begin[j],end[j]): 110 | if r[i][k]. 19 | 20 | """ 21 | 22 | import re 23 | import numpy as np 24 | from multiprocessing import Pool 25 | from scipy.integrate import cumtrapz 26 | 27 | def _list2float(seq): 28 | for x in seq: 29 | try: 30 | yield float(x) 31 | except ValueError: 32 | yield x 33 | 34 | def autocorrelate (a): 35 | b=np.concatenate((a,np.zeros(len(a))),axis=0) 36 | c= np.fft.ifft(np.fft.fft(b)*np.conjugate(np.fft.fft(b))).real 37 | d=c[:int(len(c)/2)] 38 | d=d/(np.array(range(len(a)))+1)[::-1] 39 | return d 40 | 41 | 42 | class LammpsLog(): 43 | """ 44 | Parser for LAMMPS log file (parse function). 45 | Saves the output properties (log file) in the form of a dictionary (LOG) with the key being 46 | the LAMMPS output property (see 'thermo_style custom' command in the LAMMPS documentation). 47 | For example, LOG['temp'] will return the temperature data array in the log file. 48 | """ 49 | 50 | def __init__(self, llog, avgs=None): 51 | """ 52 | Args: 53 | llog: 54 | Dictionary of lamps log 55 | avgs: 56 | Dictionary of averages, will be generated automatically if unspecified 57 | """ 58 | 59 | self.llog = llog # Dictionary LOG has all the output property data as numpy 1D arrays with the property name as the key 60 | 61 | if avgs: 62 | self.avgs = avgs # Dictionary of averages for storage / query 63 | else: 64 | self.avgs = {} 65 | # calculate the average 66 | for key in self.llog.keys(): 67 | self.avgs[str(key)] = np.mean(self.llog[key]) 68 | 69 | @classmethod 70 | def from_file(cls, filename): 71 | """ 72 | Parses the log file. 73 | """ 74 | md = 0 # To avoid reading the minimization data steps 75 | header = 0 76 | footer_blank_line = 0 77 | llog = {} 78 | 79 | with open(filename, 'r') as logfile: 80 | total_lines = len(logfile.readlines()) 81 | logfile.seek(0) 82 | 83 | for line in logfile: 84 | 85 | # timestep 86 | time = re.search('timestep\s+([0-9]+)', line) 87 | if time: 88 | timestep = float(time.group(1)) 89 | llog['timestep']=timestep 90 | 91 | # total steps of MD 92 | steps = re.search('run\s+([0-9]+)', line) 93 | if steps: 94 | md_step = float(steps.group(1)) 95 | md = 1 96 | 97 | # save freq to log 98 | thermo = re.search('thermo\s+([0-9]+)', line) 99 | if thermo: 100 | log_save_freq = float(thermo.group(1)) 101 | 102 | # log format 103 | format = re.search('thermo_style.+', line) 104 | if format: 105 | data_format = format.group().split()[2:] 106 | 107 | if all(isinstance(x, float) for x in list(_list2float(line.split()))) and md == 1 and len(line)>=3: break 108 | 109 | header += 1 110 | #time.sleep(5) 111 | 112 | #note: we are starting from the "break" above 113 | raw_data = [] 114 | for line in logfile: 115 | if all(isinstance(x, float) for x in list(_list2float(line.split()))) and len(line)>=3: 116 | raw_data.append(line.split()) 117 | else: 118 | break 119 | #if line == '\n': 120 | #footer_blank_line += 1 121 | #print int(md_step/log_save_freq) 122 | 123 | #if total_lines >= header + md_step/log_save_freq: 124 | #rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=int(total_lines-header-md_step/log_save_freq-1 )-footer_blank_line) 125 | 126 | #else: 127 | #rawdata = np.genfromtxt(fname=filename,dtype=float,skip_header=header,skip_footer=1) 128 | rawdata = np.array(raw_data,np.float) 129 | for column, property in enumerate(data_format): 130 | llog[property] = rawdata[:, column] 131 | 132 | return LammpsLog(llog) 133 | 134 | def list_properties(self): 135 | """ 136 | print the list of properties 137 | """ 138 | print(log.llog.keys()) 139 | 140 | 141 | # viscosity 142 | def viscosity(self,cutoff): 143 | 144 | """ 145 | cutoff: initial lines ignored during the calculation 146 | output: returns arrays for the time and the integration which is 147 | the viscosity in cP 148 | """ 149 | 150 | NCORES=1 151 | p=Pool(NCORES) 152 | 153 | numtimesteps = len(self.llog['pxy']) 154 | calcsteps = np.floor((numtimesteps-cutoff)/10000)*10000 155 | cutoff = int(numtimesteps - calcsteps) 156 | a1=self.llog['pxy'][cutoff:] 157 | a2=self.llog['pxz'][cutoff:] 158 | a3=self.llog['pyz'][cutoff:] 159 | a4=self.llog['pxx'][cutoff:]-self.llog['pyy'][cutoff:] 160 | a5=self.llog['pyy'][cutoff:]-self.llog['pzz'][cutoff:] 161 | a6=self.llog['pxx'][cutoff:]-self.llog['pzz'][cutoff:] 162 | array_array=[a1,a2,a3,a4,a5,a6] 163 | pv=p.map(autocorrelate,array_array) 164 | pcorr = (pv[0]+pv[1]+pv[2])/6+(pv[3]+pv[4]+pv[5])/24 165 | 166 | temp=np.mean(self.llog['temp'][cutoff:]) 167 | 168 | visco = (cumtrapz(pcorr,self.llog['step'][:len(pcorr)]))*self.llog['timestep']*10**-15*1000*101325.**2*self.llog['vol'][-1]*10**-30/(1.38*10**-23*temp) 169 | Time = np.array(self.llog['step'][:len(pcorr)-1])*self.llog['timestep'] 170 | p.close() 171 | return (Time,visco) 172 | 173 | @property 174 | def as_dict(self): 175 | return {"@module": self.__class__.__module__, 176 | "@class": self.__class__.__name__, 177 | "llog": self.llog, 178 | "avgs": self.avgs} 179 | 180 | @classmethod 181 | def from_dict(cls, d): 182 | return LammpsLog(d['llog'], d['avgs']) 183 | 184 | 185 | if __name__ == '__main__': 186 | filename = 'visc.log' 187 | log = LammpsLog.from_file(filename) 188 | log.viscosity(100001) 189 | --------------------------------------------------------------------------------