├── .github
└── workflows
│ └── python-publish.yml
├── .zenodo.json
├── LICENSE
├── README.md
├── docs
├── Makefile
├── README
├── advanced.rst
├── api.rst
├── conf.py
├── index.rst
├── installation.rst
├── introduction.rst
├── requirements.rst
├── requirements.txt
├── starting.rst
└── troubleshooting.rst
├── examples
├── GaN
│ ├── FORCE_CONSTANTS
│ ├── GaN.tersoff
│ ├── POSCAR_unitcell
│ ├── README
│ ├── data.gan
│ ├── gan_api.py
│ ├── gan_api_dyn.py
│ ├── in.lammps
│ ├── in.lammps_data
│ └── phonopy_api.py
├── Graphene
│ ├── CH.airebo
│ ├── SiC.tersoff
│ ├── api.py
│ ├── data.dat
│ └── in.lammps
├── Pd
│ ├── FORCE_CONSTANTS
│ ├── FORCE_CONSTANTS_800K
│ ├── POSCAR_unitcell
│ ├── README
│ ├── data.pd
│ ├── in.lammps
│ └── pd_api.py
├── Si
│ ├── FORCE_CONSTANTS
│ ├── POSCAR_unitcell
│ ├── README
│ ├── SiCGe.tersoff
│ ├── data.si
│ ├── in.lammps
│ └── si_api.py
├── gromacs
│ ├── POSCAR
│ ├── naphthalene.py
│ ├── params.itp
│ └── unitcell_whole.g96
└── tinker
│ ├── POSCAR
│ ├── api_tinker.py
│ ├── structure.key
│ └── structure.txyz
├── phonolammps
├── __init__.py
├── arrange.py
├── capture.py
├── iofile.py
├── phonopy_link.py
└── swissparam.py
├── requirements.txt
├── scripts
└── phonolammps
└── setup.py
/.github/workflows/python-publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow will upload a Python Package using Twine when a release is created
2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3 |
4 | # This workflow uses actions that are not certified by GitHub.
5 | # They are provided by a third-party and are governed by
6 | # separate terms of service, privacy policy, and support
7 | # documentation.
8 |
9 | name: Upload Python Package
10 |
11 | on: [push, pull_request]
12 |
13 | permissions:
14 | contents: read
15 |
16 | jobs:
17 | deploy:
18 |
19 | runs-on: ubuntu-latest
20 | if: github.ref == 'refs/heads/master'
21 | steps:
22 | - uses: actions/checkout@v4
23 | - name: Set up Python
24 | uses: actions/setup-python@v3
25 | with:
26 | python-version: '3.x'
27 | - name: Install dependencies
28 | run: |
29 | python -m pip install --upgrade pip
30 | pip install build
31 | - name: Build package
32 | run: python -m build
33 | - name: Publish package
34 | uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
35 | with:
36 | user: __token__
37 | password: ${{ secrets.PYPI_API_TOKEN }}
38 | skip_existing: true
39 |
--------------------------------------------------------------------------------
/.zenodo.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "
In recent years Phonopy[1] has become a very well known software in the materials science field for calculating phonon properties of crystals. While Phonopy provides interfaces for many popular first principles calculations software such as VASP[2], WIEN2K[3], SIESTA[4], etc., the implementation of interfaces for empirical potentials software is usually more challenging. This fact is due to the large variability of input structure definitions that these kind of software require in comparison to first principles.
\n\nphonoLAMMPS is an open source python software designed to compute the phonon harmonic force constants interfacing LAMMPS[5] and phonopy. Additionaly, phonoLAMMPS also interfaces with dynaphopy[6] to compute the renormalized force constants at finite temperature from LAMMPS molecular dynamics simulations.
\n\nThis software can be used either as a python module with a similar Phonopy-like
\ninterface or as a simple commandline script.
\n\nMain features
\n- Command line interface (phonopy like style)
\n- Python API fully compatible with phonopy
\n- Use of official LAMMPS python interface
\n- Simple and easy to use
\n- Finite temperature force constants using DynaPhoPy
\n\n[1] A. Togo and I. Tanaka, Scr. Mater., 108, 1-5 (2015)
\n[2] G. Kresse and J. Hafner, Phys. Rev. B 47, 558 (1993); ibid. 49, 14 251 (1994).
\n[3] P. Blaha, K.Schwarz, F. Tran, R. Laskowski, G.K.H. Madsen and L.D. Marks, J. Chem. Phys. 152, 074101 (2020)
\n[4] J.M. Soler, E. Artacho, J.D. Gale, A. Garcia, J. Junquera, P. Ordejón and D. Sánchez-Portal, J. Phys. Condens. Matter 14 2745 (2002)
\n[5] S. Plimpton, J Comp Phys, 117, 1-19 (1995)
\n[6] A. Carreras, A. Togo, I. Tanaka, Comput. Phys. Commun. 221:221–34 (2017)
",
3 | "license": {
4 | "id": "MIT"
5 | },
6 | "title": "phonoLAMMPS: A python interface for LAMMPS phonon calculations using phonopy",
7 | "keywords": [
8 | "LAMMPS, phonon, phonopy, python"
9 | ],
10 | "creators": [
11 | {
12 | "orcid": "0000-0001-5529-2440",
13 | "affiliation": "Multiverse Computing",
14 | "name": "Abel Carreras"
15 | }
16 | ],
17 | "access_right": "open"
18 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 Abel Carreras Conill
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://badge.fury.io/py/phonoLAMMPS)
2 | [](http://pepy.tech/project/phonolammps)
3 | [](https://doi.org/10.5281/zenodo.3940625)
4 |
5 |
6 | phonoLAMMPS
7 | ===========
8 | Calculate the harmonic interatomic force constants using phonopy and LAMMPS.
9 | Online manual: https://phonolammps.readthedocs.io
10 |
11 | Main features
12 | -------------
13 | - Command line interface (phonopy like style)
14 | - Python API fully compatible with phonopy
15 | - Use of official LAMMPS python interface
16 | - Simple and easy to use
17 | - Finite temperature force constants using DynaPhoPy
18 |
19 | Requirements
20 | ------------
21 | - python 2.7.x/3.x
22 | - numpy
23 | - phonopy (https://atztogo.github.io/phonopy/)
24 | - LAMMPS python interface (https://lammps.sandia.gov/doc/Python_library.html)
25 |
26 | Optional requirements for phonon band structure preview
27 | -------------------------------------------------------
28 | - matplotlib
29 | - seekpath (https://github.com/giovannipizzi/seekpath)
30 |
31 | Optional requirements for finite temperature FC calculations
32 | ------------------------------------------------------------
33 | - DynaPhoPy (https://github.com/abelcarreras/DynaPhoPy)
34 |
35 | Optional requirements for tinker
36 | ------------------------------------------------------------
37 | - Tinker testgrad (https://dasher.wustl.edu/tinker/)
38 |
39 |
40 | Installation instructions
41 | --------------------------
42 |
43 | 1) From source code
44 | ```
45 | # python setup.py install --user --prefix=
46 | ```
47 |
48 | 2) From PyPI repository
49 |
50 | ```
51 | # pip install phonoLAMMPS --user
52 | ```
53 |
54 | For convenience, you may want to copy (or link) the files inside scripts
55 | folder to a location included in $PATH environment variable
56 |
57 | Command line interface
58 | ----------------------
59 | phonoLAMMPS has a similar interface to phonopy to allow to easily
60 | calculate the 2nd order force constants and generate the crystal unitcell
61 | from a LAMMPS input file in VASP/POSCAR format. All outputs
62 | are fully compatible and ready to use in phonopy calculations.
63 | Also features a quick preview of the phonon
64 | band structure (requires seekpath).
65 |
66 | ```
67 | # phonolammps in.lammps --dim 2 2 2 -c POSCAR_unitcell -p
68 | ```
69 | Additionally phonoLAMMPS allows to easily calculate finite temperature force constants
70 | from molecular dynamics by quasiparticle theory (requires dynaphopy).
71 | ```
72 | # phonolammps in.lammps --dim 2 2 2 -c POSCAR_unitcell -p -t 300 (at 300 K)
73 | ```
74 | The obtained *FORCE_CONSTANTS* and *POSCAR_unitcell* can be used in phonopy using
75 | **--readfc** option for more advanced calculations.
76 | ```
77 | # phonopy --dim="2 2 2" --readfc -c POSCAR_unitcell band.conf
78 | ```
79 |
80 | Python API
81 | ----------
82 | Simple python API fully compatible with phonopy.
83 |
84 | ```
85 | from phonolammps import Phonolammps
86 | from phonopy import Phonopy
87 |
88 | phlammps = Phonolammps('in.lammps',
89 | supercell_matrix=[[3, 0, 0],
90 | [0, 3, 0],
91 | [0, 0, 3]])
92 |
93 | unitcell = phlammps.get_unitcell()
94 | force_constants = phlammps.get_force_constants()
95 | supercell_matrix = phlammps.get_supercell_matrix()
96 |
97 | phonon = Phonopy(unitcell,
98 | supercell_matrix)
99 |
100 | phonon.set_force_constants(force_constants)
101 | phonon.set_mesh([20, 20, 20])
102 |
103 | phonon.set_total_DOS()
104 | phonon.plot_total_DOS().show()
105 |
106 | phonon.set_thermal_properties()
107 | phonon.plot_thermal_properties().show()
108 | ```
109 |
110 | Contact info
111 | ---------------------------------------------------------
112 | Abel Carreras
113 |
abelcarreras83@gmail.com
114 |
115 | Donostia International Physics Center (DIPC)
116 |
Donostia-San Sebastian (Spain)
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SOURCEDIR = .
8 | BUILDDIR = _build
9 |
10 | # Put it first so that "make" without argument is like "make help".
11 | help:
12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13 |
14 | .PHONY: help Makefile
15 |
16 | # Catch-all target: route all unknown targets to Sphinx using the new
17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18 | %: Makefile
19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
--------------------------------------------------------------------------------
/docs/README:
--------------------------------------------------------------------------------
1 | This is phonoLAMMPS documentation written using sphinx
2 |
3 | To compile this documentation sphinx should be installed in your system.
4 | You can use pip to install it:
5 |
6 | pip install sphinx --user
7 |
8 |
9 | Use the provided Makefile to compile the documentation. Example:
10 |
11 | HTML compilation:
12 |
13 | make html
14 |
15 | Latex document compilation (requires latex to be installed in your system):
16 |
17 | make latexpdf
18 |
19 |
--------------------------------------------------------------------------------
/docs/advanced.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Advanced topics
4 | ===============
5 |
6 | Use non-analytical corrections (NAC) in phonon band structure
7 | -------------------------------------------------------------
8 |
9 | Non-analytical corrections (NAC) can be used in phonoLAMMPS during the plot of the
10 | phononn band structure preview. To use them a file named **BORN** containing the Born charges
11 | anf the dielectric tensor should exist in the working directory. This file is formated in phonopy
12 | format (check phonopy documentation for further information). To activate this options **--use_NAC** flag is used ::
13 |
14 | $ phonolammps in.lammps --dim 2 2 2 --use_NAC -p
15 |
16 | Notice that this option does not modify the calculated force constants written in **FORCE_CONSTANTS** file.
17 | It is only used in the phonon band structure plot, therefore it makes no effect without **-p** flag.
18 |
19 | Atomic position optimization
20 | ----------------------------
21 |
22 | The atomic positions of the unit cell can be optimized using **--optimization** flag.
23 | This uses LAMMPS minimize to perform a minimization of atomic forces at constant volume.
24 | The forces tolerance for the convergence criterion is defined by **--force_tol** flag. ::
25 |
26 | $ phonolammps in.lammps --dim 2 2 2 --optimization --force_tol 1e-10 -p
27 |
28 | This option performs a simple minimization. If a more sophisticated optimization is required
29 | then use LAMMPS directly. This option is best used to refine the atomic positions of an already
30 | optimized unit cell.
31 |
32 | Finite temperature force constants
33 | ----------------------------------
34 |
35 | Finite temperature force constants can be calculated from molecular dynamics using
36 | dynaphopy software (http://abelcarreras.github.io/DynaPhoPy). This software implements
37 | the normal mode projection technique to obtain the renormalized force constants at finite
38 | temperature based on quasiparticle theory. Phonolammps provide a minimum functionality to
39 | make this process automatic using both LAMMPS and dynaphopy python API.
40 | To use this feature dynaphopy must be installed (for further details check dynaphopy documentation).
41 |
42 | In command line script temperature is defined by **-t** flag. By default this value is 0 and usual
43 | 2n order force constants are calculated. If the temperature is higher than 0 then a molecular
44 | dynamics (MD) simulation is calculated with LAMMPS using a supercell defined by **--dim** flag.
45 | By default the length of the MD if 20 ps with time step of 0.001 ps and a relaxation time of 5 ps,
46 | but these parameters can be tweaked using **--total_time**, **--relaxation_time** and **--relaxation_time** flags.
47 |
48 | example for silicon::
49 |
50 | $ phonolammps in.lammps --dim 2 2 2 -pa 0.0 0.5 0.5 0.5 0.0 0.5 0.5 0.5 0.0 -t 300 -p
51 |
52 |
53 | to have more control over the simulation and the renormalization precedure you will have to use
54 | the two software separately.
55 |
56 |
--------------------------------------------------------------------------------
/docs/api.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | API
4 | ===
5 | This is the Python API for phonoLAMMPS
6 |
7 | .. automodule:: phonolammps
8 | :members:
9 |
10 |
11 | end
12 |
13 |
--------------------------------------------------------------------------------
/docs/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # symeess documentation build configuration file, created by
4 | # sphinx-quickstart on Tue Oct 24 16:17:35 2017.
5 | #
6 | # This file is execfile()d with the current directory set to its
7 | # containing dir.
8 | #
9 | # Note that not all possible configuration values are present in this
10 | # autogenerated file.
11 | #
12 | # All configuration values have a default; values that are commented out
13 | # serve to show the default.
14 |
15 | # If extensions (or modules to document with autodoc) are in another directory,
16 | # add these directories to sys.path here. If the directory is relative to the
17 | # documentation root, use os.path.abspath to make it absolute, like shown here.
18 | #
19 | import os
20 | import sys
21 | sys.path.insert(0, os.path.abspath('../'))
22 |
23 |
24 | # -- General configuration ------------------------------------------------
25 |
26 | # If your documentation needs a minimal Sphinx version, state it here.
27 | #
28 | # needs_sphinx = '1.0'
29 |
30 | # Add any Sphinx extension module names here, as strings. They can be
31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32 | # ones.
33 | extensions = ['sphinx.ext.autodoc',
34 | # 'sphinx.ext.coverage',
35 | # 'sphinx.ext.napoleon',
36 | 'sphinx.ext.intersphinx',
37 | 'sphinx.ext.mathjax',
38 | 'sphinx.ext.viewcode',
39 | 'sphinx.ext.githubpages']
40 |
41 |
42 | # Add any paths that contain templates here, relative to this directory.
43 | #templates_path = ['_templates']
44 |
45 | # The suffix(es) of source filenames.
46 | # You can specify multiple suffix as a list of string:
47 | #
48 | # source_suffix = ['.rst', '.md']
49 | source_suffix = '.rst'
50 |
51 | # The master toctree document.
52 | master_doc = 'index'
53 |
54 | # General information about the project.
55 | project = u'phonoLAMMPS'
56 | copyright = u'2019, Abel Carreras'
57 | author = u'Abel Carreras'
58 |
59 | # The version info for the project you're documenting, acts as replacement for
60 | # |version| and |release|, also used in various other places throughout the
61 | # built documents.
62 | #
63 | # The short X.Y version.
64 | version = u''
65 | # The full version, including alpha/beta/rc tags.
66 | release = u''
67 |
68 | # The language for content autogenerated by Sphinx. Refer to documentation
69 | # for a list of supported languages.
70 | #
71 | # This is also used if you do content translation via gettext catalogs.
72 | # Usually you set "language" from the command line for these cases.
73 | language = None
74 |
75 | # List of patterns, relative to source directory, that match files and
76 | # directories to ignore when looking for source files.
77 | # This patterns also effect to html_static_path and html_extra_path
78 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
79 |
80 | # The name of the Pygments (syntax highlighting) style to use.
81 | # pygments_style = 'sphinx'
82 |
83 | # If true, `todo` and `todoList` produce output, else they produce nothing.
84 | todo_include_todos = False
85 |
86 | autodoc_mock_imports = ['lammps', 'lammps', 'phonopy']
87 |
88 |
89 | # -- Options for HTML output ----------------------------------------------
90 |
91 | # The theme to use for HTML and HTML Help pages. See the documentation for
92 | # a list of builtin themes.
93 | #
94 | html_theme = 'sphinx_rtd_theme'
95 | RTD_NEW_THEME = True
96 |
97 | # Theme options are theme-specific and customize the look and feel of a theme
98 | # further. For a list of options available for each theme, see the
99 | # documentation.
100 | #
101 | # html_theme_options = {}
102 |
103 | # Add any paths that contain custom static files (such as style sheets) here,
104 | # relative to this directory. They are copied after the builtin static files,
105 | # so a file named "default.css" will overwrite the builtin "default.css".
106 | # html_static_path = ['_static']
107 | # html_context = {
108 | # 'css_files': [
109 | # '_static/theme_overrides.css', # override wide tables in RTD theme
110 | # ],
111 | # }
112 |
113 | # Custom sidebar templates, must be a dictionary that maps document names
114 | # to template names.
115 | #
116 | # This is required for the alabaster theme
117 | # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
118 | # html_sidebars = {
119 | # '**': [
120 | # 'relations.html', # needs 'show_related': True theme option to display
121 | # 'searchbox.html',
122 | # ]
123 | # }
124 |
125 |
126 | # -- Options for HTMLHelp output ------------------------------------------
127 |
128 | # Output file base name for HTML help builder.
129 | htmlhelp_basename = 'phonolammpsdoc'
130 |
131 |
132 | # -- Options for LaTeX output ---------------------------------------------
133 |
134 | latex_elements = {
135 | # The paper size ('letterpaper' or 'a4paper').
136 | #
137 | # 'papersize': 'letterpaper',
138 |
139 | # The font size ('10pt', '11pt' or '12pt').
140 | #
141 | # 'pointsize': '10pt',
142 |
143 | # Additional stuff for the LaTeX preamble.
144 | #
145 | # 'preamble': '',
146 |
147 | # Latex figure (float) alignment
148 | #
149 | # 'figure_align': 'htbp',
150 | }
151 |
152 | # Grouping the document tree into LaTeX files. List of tuples
153 | # (source start file, target name, title,
154 | # author, documentclass [howto, manual, or own class]).
155 | latex_documents = [
156 | (master_doc, 'phonolammps.tex', u'phonoLAMMPS Documentation',
157 | u'Abel Carreras', 'manual'),
158 | ]
159 |
160 |
161 | # -- Options for manual page output ---------------------------------------
162 |
163 | # One entry per manual page. List of tuples
164 | # (source start file, name, description, authors, manual section).
165 | man_pages = [
166 | (master_doc, 'phonoLAMMPS', u'phonoLAMMPS Documentation',
167 | [author], 1)
168 | ]
169 |
170 |
171 | # -- Options for Texinfo output -------------------------------------------
172 |
173 | # Grouping the document tree into Texinfo files. List of tuples
174 | # (source start file, target name, title, author,
175 | # dir menu entry, description, category)
176 | texinfo_documents = [
177 | (master_doc, 'phonoLAMMPS', u'phonoLAMMPS Documentation',
178 | author, 'phonoLAMMPS', 'One line description of project.',
179 | 'Miscellaneous'),
180 | ]
181 |
182 |
183 |
184 |
185 | # Example configuration for intersphinx: refer to the Python standard library.
186 | intersphinx_mapping = {'https://docs.python.org/': None}
187 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | phonoLAMMPS
4 | ===========
5 |
6 | A simple LAMMPS interface with phonopy.
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 | :caption: Table of contents
11 | :numbered:
12 |
13 | introduction
14 | requirements
15 | installation
16 | starting
17 | advanced
18 | api
19 | troubleshooting
20 |
21 |
--------------------------------------------------------------------------------
/docs/installation.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Installation
4 | ============
5 | phonoLAMMPS can be installed directly from the source code (python package) or via PyPI repository.
6 |
7 | 1) From source code ::
8 |
9 | python setup.py install --user --prefix=
10 |
11 |
12 | 2) From PyPI repository ::
13 |
14 | pip install phonoLAMMPS --user
15 |
16 | For convenience, you may want to copy (or link) the files inside scripts
17 | folder to a location included in **$PATH** environment variable.
18 |
19 | .. Note::
20 | Depending on your configuration or OS this may be done automatically.
21 |
22 |
--------------------------------------------------------------------------------
/docs/introduction.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Introduction
4 | ============
5 |
6 | PhonoLAMMPS is a python software designed to interface between *LAMMPS* and *phonopy*. With this software allows
7 | to calculate the 2nd order interatomic force constants with phonopy using the forces obtained by LAMMPS.
8 | For this purpose phonoLAMMPS uses the official LAMMPS python API to link both LAMMPS & phonopy.
9 | This is done in a clean way without generating temporal intermediate files on the disk.
10 |
11 | PhonoLAMMPS can be used either as a python module with a very similar interface to phonopy or
12 | via a command line interface using a provided general python script written using argparse.
13 |
14 | PhonoLAMMPS has been tested with the following LAMMPS versions:
15 | - 16 March 2018
16 | - 15 May 2019
17 | - 29 Oct 2020.
18 |
19 | Main features
20 | -------------
21 | - Command line interface (phonopy like style)
22 | - Python API fully compatible with phonopy
23 | - Use of official LAMMPS python interface
24 | - Simple and easy to use
25 | - New! Finite temperature force constants using DynaPhoPy
26 |
27 |
--------------------------------------------------------------------------------
/docs/requirements.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Requirements
4 | ============
5 |
6 | phonoLAMMPS requires a few python modules to be installed in your computer in order to work properly.
7 | Additionally seekpath and matplotlib are necessary to show the preview of the phonon band structure.
8 | All this packages can be downloaded easily using PyPI or conda repositories.
9 |
10 | Mandatory requirements
11 | ----------------------
12 | - python 2.7.x/3.x
13 | - numpy
14 | - phonopy (https://atztogo.github.io/phonopy/)
15 | - LAMMPS python interface (https://lammps.sandia.gov/doc/Python_library.html)
16 |
17 | *Note: LAMMPS python interface may need to be installed manually from LAMMPS source.
18 | Check LAMMPS manual for further information*
19 |
20 | Optional requirements for phonon band structure preview
21 | -------------------------------------------------------
22 | - matplotlib
23 | - seekpath (https://github.com/giovannipizzi/seekpath)
24 |
25 | Optional requirements for finite temperature FC calculations
26 | ------------------------------------------------------------
27 | - DynaPhoPy (https://github.com/abelcarreras/DynaPhoPy)
28 |
29 |
--------------------------------------------------------------------------------
/docs/requirements.txt:
--------------------------------------------------------------------------------
1 | ###################################################
2 | # Required packages for phonolammps documentation #
3 | ###################################################
4 |
5 | numpy>=1.8.2
6 |
--------------------------------------------------------------------------------
/docs/starting.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Get started
4 | ===========
5 |
6 | Python API
7 | ----------
8 | phonoLAMMPS has been designed to have a very similar python interface to phonopy.
9 | For this reason the python objects generated by phonoLAMMPS can be used with phonopy functions.
10 | The procedure to obtain the force constants from LAMMPS forces is the following:
11 |
12 | 1) Loading phonoLAMMPS module ::
13 |
14 | from phonolammps import Phonolammps
15 |
16 | Creating an instance of the main phonoLAMMPS class. In this call you have to introduce a lammps
17 | input that contains the definition of the crystal unit cell the *unitcell* and *empirical potential/s*.
18 | For this you have two options:
19 |
20 | 2a. Use a LAMMPS input file (in.lammps)
21 |
22 | .. code-block:: python
23 |
24 | phlammps = Phonolammps('in.lammps',
25 | supercell_matrix=[[2, 0, 0],
26 | [0, 2, 0],
27 | [0, 0, 2]],
28 | primitive_matrix=[[0.0, 0.5 ,0.5],
29 | [0.5, 0.0, 0.5],
30 | [0.5, 0.5, 0.0])
31 |
32 | Where *supercell_matrix* defines the supercell expansion used to calculate the force constants
33 | using the finite displacements method, and *primitive_matrix* (optional) defines the primitive cell axis matrix.
34 | If *primitive_matrix* is not defined, identity matrix is used (primitive cell = unit cell).
35 |
36 | 2b. Use a python list containing LAMMPS input commands (one command per line)
37 |
38 | .. code-block:: python
39 |
40 | list_of_commands = open('in.lammps').read().split('\n')
41 | phlammps = Phonolammps(list_of_commands,
42 | supercell_matrix=[[2, 0, 0],
43 | [0, 2, 0],
44 | [0, 0, 2]])
45 | primitive_matrix=[[0.0, 0.5 ,0.5],
46 | [0.5, 0.0, 0.5],
47 | [0.5, 0.5, 0.0])
48 |
49 | This second option may be handy if you want to generate/modify LAMMPS commands in a python script.
50 |
51 | 3) Get the data needed for phonopy
52 |
53 | .. code-block:: python
54 |
55 | unitcell = phlammps.get_unitcell()
56 | force_constants = phlammps.get_force_constants()
57 | supercell_matrix = phlammps.get_supercell_matrix()
58 |
59 |
60 | 4) From this you have all the information you need for phonopy calculations
61 |
62 | .. code-block:: python
63 |
64 | from phonopy import Phonopy
65 | phonon = Phonopy(unitcell,
66 | supercell_matrix)
67 |
68 | phonon.set_force_constants(force_constants)
69 | phonon.set_mesh([20, 20, 20])
70 |
71 | phonon.set_total_DOS()
72 | phonon.plot_total_DOS().show()
73 |
74 | phonon.set_thermal_properties()
75 | phonon.plot_thermal_properties().show()
76 |
77 |
78 | Command line interface
79 | ----------------------
80 | To use phonoLAMMPS from command line interface you need a LAMMPS input file containing the
81 | definition of the unit cell and potentials.
82 |
83 | example: ::
84 |
85 | units metal
86 |
87 | boundary p p p
88 |
89 | box tilt large
90 |
91 | atom_style atomic
92 |
93 | read_data data.si
94 |
95 | pair_style tersoff
96 | pair_coeff * * SiCGe.tersoff Si(C)
97 |
98 | neighbor 0.3 bin
99 |
100 | Notice that run command, as well as other MD related commands (thermostat, velocities, etc..) should not
101 | be included in the input file.
102 |
103 | .. note::
104 | In this example **read data** command is used to define the atoms
105 | coordinates in a different file (refer to LAMMPS manual for further information).
106 |
107 | *Phonolammps* script uses *argparse* to provide a clean command line interface using flags
108 | All options available are displayed by using **-h** ::
109 |
110 | $ phonolammps -h
111 | usage: phonolammps [-h] [-o file] [--dim N N N] [-p] [-c file]
112 | [-pa F F F F F F F F F] [-t F] [--optimize] [--force_tol F]
113 | [--amplitude F] [--total_time F] [--relaxation_time F]
114 | [--timestep F] [--logshow] [--no_symmetrize] [--use_NAC]
115 | [--write_force_sets]
116 | lammps_file
117 |
118 | phonoLAMMPS options
119 |
120 | positional arguments:
121 | lammps_file lammps input file
122 |
123 | optional arguments:
124 | -h, --help show this help message and exit
125 | -o file force constants output file [default: FORCE_CONSTANTS]
126 | --dim N N N dimensions of the supercell
127 | -p plot phonon band structure
128 | -c file, --cell file generates a POSCAR type file containing the unit cell
129 | -pa F F F F F F F F F, --primitive_axis F F F F F F F F F
130 | primitive axis
131 | -t F temperature in K
132 | --optimize optimize atoms position of unitcell
133 | --force_tol F forces tolerance for optimization
134 | --amplitude F displacement distance [default: 0.01 angstrom]
135 | --total_time F total MD time in picoseconds [default: 20 ps]
136 | --relaxation_time F MD relaxation time in picoseconds [default: 5 ps]
137 | --timestep F MD time step in picoseconds [default: 0.001 ps]
138 | --logshow show LAMMPS & dynaphopy log on screen
139 | --no_symmetrize deactivate force constant symmetrization
140 | --use_NAC include non analytical corrections (Requires BORN file
141 | in work directory)
142 | --write_force_sets write FORCE_SETS file
143 | --version print version
144 |
145 | A simple example for crystalline silicon using a 2x2x2 supercell would be ::
146 |
147 | phonolammps in.lammps --dim 2 2 2 -pa 0.0 0.5 0.5 0.5 0.0 0.5 0.5 0.5 0.0 -c POSCAR_unitcell -p
148 |
149 | where **in.lammps** is a LAMMPS input containing the unit cell, *--dim* defines the supercell, *--pa* are the
150 | primitive axis in matrix format written in one line (phonopy style), *-c FILENAME* (optional) requests to write the unitcell
151 | (the same written in LAMMPS input) in VASP format on the disk to be used in phonopy calculations, and *-p* requests to show
152 | a preview of the phonon band structure in a matplotlib plot.
153 | The output of this script is a file named **FORCE_CONSTANTS** that contains the interatomic 2nd order force constants in phonopy format.
154 |
155 | To use the obtained **FORCE_CONSTANTS** in more advanced calculations, or to have more control on the displayed data
156 | it is recommended to use PHONOPY by reading the **FORCE_CONSTANTS** file using **--readfc** option ::
157 |
158 | phonopy --dim="2 2 2" --pa="0.0 0.5 0.5 0.5 0.0 0.5 0.5 0.5 0.0" --readfc -c POSCAR_unitcell band.conf
159 |
160 |
--------------------------------------------------------------------------------
/docs/troubleshooting.rst:
--------------------------------------------------------------------------------
1 | .. highlight:: rst
2 |
3 | Troubleshooting
4 | ===============
5 |
6 | Check LAMMPS python API
7 | -----------------------
8 | If there is some problem with LAMMPS installation this is a simple script that
9 | can help you to find it out. Run this script inside one of the example folders
10 | (where in.lammps file is placed)
11 |
12 | .. code-block:: python
13 |
14 | from lammps import lammps
15 |
16 | lmp1 = lammps()
17 | lmp1.file("in.lammps")
18 | lmp1.close()
19 |
20 | if everything works as expected you should get an output like this ::
21 |
22 | LAMMPS (15 May 2019)
23 | OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:88)
24 | using 1 OpenMP thread(s) per MPI task
25 | Lattice spacing in x,y,z = 4.785 2.76262 5.189
26 | Created triclinic box = (0 0 0) to (3.19 2.76262 5.189) with tilt (-1.595 0 0)
27 | WARNING: Triclinic box skew is large (src/domain.cpp:194)
28 | 1 by 1 by 1 MPI processor grid
29 | Created 4 atoms
30 | create_atoms CPU = 0.00049852 secs
31 | Reading potential file GaN.tersoff with DATE: 2007-10-22
32 | Total wall time: 0:00:00
33 |
34 |
35 | otherwise there may be some trouble with LAMMPS python interface. Check LAMMPS
36 | manual for further information.
37 |
38 |
39 | Check LAMMPS calculations log
40 | -----------------------------
41 |
42 | By default LAMMPS logs are deactivated and not shown during the calculation. If issues appear it may be
43 | useful to check LAMMPS force calculations logs. This is done by using **-logshow** flag. Ex: ::
44 |
45 | $ phonolammps in.lammps --dim 2 2 2 --logshow
46 |
47 |
--------------------------------------------------------------------------------
/examples/GaN/GaN.tersoff:
--------------------------------------------------------------------------------
1 | # DATE: 2007-10-22 CONTRIBUTOR: Xiaowang Zhou, xzhou @ sandia.gov CITATION: Nord, Albe, Erhart and Nordlund, J. Phys Condens Matter, 15, 5649 (2003)
2 | # Tersoff parameters for various elements and mixtures
3 | # multiple entries can be added to this file, LAMMPS reads the ones it needs
4 | # these entries are in LAMMPS "metal" units:
5 | # A,B = eV; lambda1,lambda2,lambda3 = 1/Angstroms; R,D = Angstroms
6 | # other quantities are unitless
7 |
8 | # format of a single entry (one or more lines):
9 | # element 1, element 2, element 3,
10 | # m, gamma, lambda3, c, d, costheta0, n, beta, lambda2, B, R, D, lambda1, A
11 |
12 | # The following GaN potential is from J. Nord, K. Albe, P. Erhart
13 | # and K. Nordlund, J. Phys.: Condens. Matter, 15, 5649(2003).
14 | # This file is from Xiaowang Zhou, xzhou @ sandia.gov
15 |
16 | Ga Ga Ga 1.0 0.007874 1.846 1.918000 0.75000 -0.301300 1.0 1.0
17 | 1.44970 410.132 2.87 0.15 1.60916 535.199
18 | N N N 1.0 0.766120 0.000 0.178493 0.20172 -0.045238 1.0 1.0
19 | 2.38426 423.769 2.20 0.20 3.55779 1044.77
20 | Ga Ga N 1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 0.0
21 | 0.00000 0.00000 2.90 0.20 0.00000 0.00000
22 | Ga N N 1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 1.0
23 | 2.63906 3864.27 2.90 0.20 2.93516 6136.44
24 | N Ga Ga 1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 1.0
25 | 2.63906 3864.27 2.90 0.20 2.93516 6136.44
26 | N Ga N 1.0 0.766120 0.000 0.178493 0.20172 -0.045238 1.0 0.0
27 | 0.00000 0.00000 2.20 0.20 0.00000 0.00000
28 | N N Ga 1.0 0.001632 0.000 65.20700 2.82100 -0.518000 1.0 0.0
29 | 0.00000 0.00000 2.90 0.20 0.00000 0.00000
30 | Ga N Ga 1.0 0.007874 1.846 1.918000 0.75000 -0.301300 1.0 0.0
31 | 0.00000 0.00000 2.87 0.15 0.00000 0.00000
32 |
--------------------------------------------------------------------------------
/examples/GaN/POSCAR_unitcell:
--------------------------------------------------------------------------------
1 | Generated using phonoLAMMPS
2 | 1.0
3 | 3.1899997378 0.0000000000 0.0000000000
4 | -1.5950000124 2.7626210760 0.0000000000
5 | 0.0000000000 0.0000000000 5.1890001297
6 | Ga N
7 | 2 2
8 | Direct
9 | 0.666666755125401 0.333333340000000 0.000000000000000
10 | 0.333333340125393 0.666666630000000 0.500000000000000
11 | 0.666666755125401 0.333333340000000 0.375000000000000
12 | 0.333333340125393 0.666666630000000 0.875000000000000
13 |
--------------------------------------------------------------------------------
/examples/GaN/README:
--------------------------------------------------------------------------------
1 | ---------------------------------------------
2 | Example of usage using command line interface
3 | ---------------------------------------------
4 |
5 | Run this to generate a FORCE_CONSTANTS file and show a preview of the phonon band structure.
6 | Use --dim to change the size of the supercells used to calculate the force constants.
7 | use -c to generate a POSCAR type file containing the crystal unit cell to use in phonopy.
8 | -p activates the phonon band structure preview,
9 | --pa can be used to define the primitive axis in a same manner as phonopy (this option only
10 | affects the phonon band structure preview):
11 |
12 | # phonolammps in.lammps -c POSCAR_unitcell --dim 3 3 3 -p
13 |
14 | or
15 |
16 | # phonolammps in.lammps_data -c POSCAR_unitcell --dim 3 3 3 -p
17 |
--------------------------------------------------------------------------------
/examples/GaN/data.gan:
--------------------------------------------------------------------------------
1 | Generated using dynaphopy
2 |
3 | 4 atoms
4 |
5 | 2 atom types
6 |
7 |
8 | 0.0000000000 3.1900000572 xlo xhi
9 | 0.0000000000 2.7626210760 ylo yhi
10 | 0.0000000000 5.1890001297 zlo zhi
11 | -1.5950000286 0.0000000000 0.0000000000 xy xz yz
12 |
13 | Masses
14 |
15 | 1 69.7230000000
16 | 2 14.0067000000
17 |
18 | Atoms
19 |
20 | 1 1 1.5950000924 0.9208737104 0.0000000000
21 | 2 1 -0.0000000160 1.8417472827 2.5945000649
22 | 3 2 1.5950000924 0.9208737104 1.9458750486
23 | 4 2 -0.0000000160 1.8417472827 4.5403751135
24 |
--------------------------------------------------------------------------------
/examples/GaN/gan_api.py:
--------------------------------------------------------------------------------
1 | # Simple API example to calculate the harmonic force constants
2 |
3 | from phonolammps import Phonolammps
4 | import numpy as np
5 |
6 | lammps_inp = open('in.lammps').read().split('\n')
7 | print(np.array(lammps_inp))
8 | phlammps = Phonolammps(lammps_inp,
9 | supercell_matrix=np.diag([3, 3, 3]),
10 | primitive_matrix=np.identity(3))
11 |
12 | phlammps.optimize_unitcell(energy_tol=0, force_tol=1e-10)
13 | phlammps.plot_phonon_dispersion_bands()
14 |
15 | force_constants = phlammps.get_force_constants()
16 |
17 | print(force_constants)
--------------------------------------------------------------------------------
/examples/GaN/gan_api_dyn.py:
--------------------------------------------------------------------------------
1 | # API example to calculate finite temperature (300K) force constants
2 | # using dynaphopy (quasiparticle theory)
3 |
4 | from phonolammps import Phonolammps
5 | from dynaphopy.interface.lammps_link import generate_lammps_trajectory
6 | from dynaphopy.interface.phonopy_link import ForceConstants
7 | from dynaphopy import Quasiparticle
8 | from dynaphopy.atoms import Structure
9 |
10 | import numpy as np
11 |
12 | # calculate harmonic force constants with phonoLAMMPS
13 | lammps_inp = open('in.lammps').read().split('\n')
14 | print(np.array(lammps_inp))
15 | phlammps = Phonolammps(lammps_inp,
16 | supercell_matrix=np.diag([3, 3, 3]),
17 | primitive_matrix=np.identity(3))
18 |
19 | phlammps.optimize_unitcell(energy_tol=0, force_tol=1e-10)
20 | phlammps.plot_phonon_dispersion_bands()
21 |
22 | # set force constants for dynaphopy
23 | force_constants = ForceConstants(phlammps.get_force_constants(),
24 | supercell=phlammps.get_supercell_matrix())
25 |
26 | # Print harmonic force constants
27 | print('harmonic force constants')
28 | print(force_constants.get_array())
29 |
30 | structure = phlammps.get_unitcell()
31 |
32 |
33 | # define structure for dynaphopy
34 | dp_structure = Structure(cell=structure.get_cell(), # cell_matrix, lattice vectors in rows
35 | scaled_positions=structure.get_scaled_positions(),
36 | atomic_elements=structure.get_chemical_symbols(),
37 | primitive_matrix=phlammps.get_primitve_matrix(),
38 | force_constants=force_constants)
39 |
40 | # calculate trajectory for dynaphopy with lammps
41 | trajectory = generate_lammps_trajectory(dp_structure, 'in.lammps',
42 | total_time=10, # ps
43 | time_step=0.001, # ps
44 | relaxation_time=5, # ps
45 | silent=False,
46 | supercell=[3, 3, 3],
47 | memmap=False,
48 | velocity_only=True,
49 | temperature=300)
50 |
51 | # set dynaphopy calculation
52 | calculation = Quasiparticle(trajectory)
53 | calculation.select_power_spectra_algorithm(2) # select FFT algorithm
54 |
55 | calculation.get_renormalized_phonon_dispersion_bands()
56 | renormalized_force_constants = calculation.get_renormalized_force_constants()
57 |
58 | # Print phonon band structure
59 | calculation.plot_renormalized_phonon_dispersion_bands()
60 |
61 | # Plot linewidths vs frequencies (interpolated to a mesh 20x20x20)
62 | # calculation.parameters.mesh_phonopy = [20, 20, 20]
63 | # calculation.plot_frequencies_vs_linewidths()
64 | # calculation.write_mesh_data()
65 |
66 | # Print renormalized force constants
67 | print('renormalized force constants at 300K')
68 | print(renormalized_force_constants.get_array())
--------------------------------------------------------------------------------
/examples/GaN/in.lammps:
--------------------------------------------------------------------------------
1 | units metal
2 |
3 | boundary p p p
4 |
5 | box tilt large
6 |
7 | atom_style atomic
8 |
9 | lattice custom 1.0 &
10 | a1 3.1900000572 0.000000000 0.0000000000 &
11 | a2 -1.5950000280 2.762621076 0.0000000000 &
12 | a3 0.0000000000 0.000000000 5.1890001297 &
13 | basis 0.66666669 0.33333334 0.000000000 &
14 | basis 0.33333331 0.66666663 0.500000000 &
15 | basis 0.66666669 0.33333334 0.375000000 &
16 | basis 0.33333331 0.66666663 0.875000000
17 |
18 | region box1 prism 0 0.6666666 0 1 0 1 -0.33333333 0 0 units lattice
19 |
20 | create_box 2 box1
21 |
22 | create_atoms 1 box basis 1 1 &
23 | basis 2 1 &
24 | basis 3 2 &
25 | basis 4 2
26 |
27 | mass 1 69.7230
28 | mass 2 14.0067
29 |
30 | pair_style tersoff
31 | pair_coeff * * GaN.tersoff Ga N
32 |
33 | neighbor 0.3 bin
34 |
35 |
--------------------------------------------------------------------------------
/examples/GaN/in.lammps_data:
--------------------------------------------------------------------------------
1 | # GaN molecular dynamics using Tersoff potential
2 |
3 | units metal
4 |
5 | boundary p p p
6 |
7 | box tilt large
8 |
9 | atom_style atomic
10 |
11 | read_data data.gan
12 |
13 | pair_style tersoff
14 | pair_coeff * * GaN.tersoff Ga N
15 |
16 | neighbor 0.3 bin
17 |
--------------------------------------------------------------------------------
/examples/GaN/phonopy_api.py:
--------------------------------------------------------------------------------
1 | # Integration with phonopy
2 |
3 | from phonolammps import Phonolammps
4 | from phonopy import Phonopy
5 |
6 | phlammps = Phonolammps('in.lammps',
7 | supercell_matrix=[[3, 0, 0],
8 | [0, 3, 0],
9 | [0, 0, 3]])
10 |
11 | unitcell = phlammps.get_unitcell()
12 | force_constants = phlammps.get_force_constants()
13 | supercell_matrix = phlammps.get_supercell_matrix()
14 |
15 | phonon = Phonopy(unitcell,
16 | supercell_matrix)
17 |
18 | phonon.set_force_constants(force_constants)
19 | phonon.run_mesh([20, 20, 20])
20 |
21 | phonon.run_total_dos()
22 | phonon.plot_total_dos()
23 |
24 | phonon.run_thermal_properties()
25 | phonon.plot_thermal_properties().show()
--------------------------------------------------------------------------------
/examples/Graphene/SiC.tersoff:
--------------------------------------------------------------------------------
1 | # Si and C mixture, parameterized for Tersoff potential
2 | # this file is from Rutuparna.Narulkar @ okstate.edu
3 | # values are from Phys Rev B, 39, 5566-5568 (1989)
4 | # and errata (PRB 41, 3248)
5 |
6 | # Tersoff parameters for various elements and mixtures
7 | # multiple entries can be added to this file, LAMMPS reads the ones it needs
8 | # these entries are in LAMMPS "metal" units:
9 | # A,B = eV; lambda1,lambda2,lambda3 = 1/Angstroms; R,D = Angstroms
10 | # other quantities are unitless
11 |
12 | # format of a single entry (one or more lines):
13 | # element 1, element 2, element 3,
14 | # m, gamma, lambda3, c, d, costheta0, n,
15 | # beta, lambda2, B, R, D, lambda1, A
16 |
17 | C C C 3.0 1.0 0.0 38049 4.3484 -.57058 .72751
18 | 0.00000015724 2.2119 346.7 1.95 0.15 3.4879 1393.6
19 |
20 | Si Si Si 3.0 1.0 0.0 100390 16.217 -.59825 .78734
21 | 0.0000011 1.73222 471.18 2.85 0.15 2.4799 1830.8
22 |
23 | Si Si C 3.0 1.0 0.0 100390 16.217 -.59825 0.0
24 | 0.0 0.0 0.0 2.36 0.15 0.0 0.0
25 |
26 | Si C C 3.0 1.0 0.0 100390 16.217 -.59825 .787340
27 | 0.0000011 1.97205 395.126 2.36 0.15 2.9839 1597.3111
28 |
29 | C Si Si 3.0 1.0 0.0 38049 4.3484 -.57058 .72751
30 | 0.00000015724 1.97205 395.126 2.36 0.15 2.9839 1597.3111
31 |
32 | C Si C 3.0 1.0 0.0 38049 4.3484 -.57058 0.0
33 | 0.0 0.0 0.0 1.95 0.15 0.0 0.0
34 |
35 | C C Si 3.0 1.0 0.0 38049 4.3484 -.57058 0.0
36 | 0.0 0.0 0.0 2.36 0.15 0.0 0.0
37 |
38 | Si C Si 3.0 1.0 0.0 100390 16.217 -.59825 0.0
39 | 0.0 0.0 0.0 2.85 0.15 0.0 0.0
40 |
--------------------------------------------------------------------------------
/examples/Graphene/api.py:
--------------------------------------------------------------------------------
1 | # API example to calculate finite temperature (300K) force constants
2 | # using dynaphopy (quasiparticle theory)
3 |
4 | from phonolammps import Phonolammps
5 | import numpy as np
6 |
7 |
8 | sm = np.diag([10, 10, 1])
9 | pm = np.identity(3)
10 |
11 | # calculate harmonic force constants with phonoLAMMPS
12 | phlammps = Phonolammps('in.lammps',
13 | supercell_matrix=sm,
14 | primitive_matrix=pm)
15 |
16 |
17 | bl = {
18 | "ranges": [[[0.0, 0.0, 0.0], [0.5, 0.0, 0.0]],
19 | [[0.5, 0.0, 0.0], [0.3333333333, 0.3333333333333, 0.0]],
20 | [[0.3333333333, 0.3333333333333, 0.0], [0.0, 0.0, 0.0]]],
21 | "labels": [("GAMMA", "M"), ("M", "K"), ("K", "GAMMA")]
22 | }
23 | phlammps.plot_phonon_dispersion_bands(bands_and_labels=bl)
24 |
--------------------------------------------------------------------------------
/examples/Graphene/data.dat:
--------------------------------------------------------------------------------
1 | # Graphene cell with dimension 10 x 10 x 1 and a = 2.522
2 | 2 atoms
3 | 1 atom types
4 |
5 | 0 2.46 xlo xhi
6 | 0 2.13 ylo yhi
7 | -1 1 zlo zhi
8 | -1.23 0 0 xy xz yz
9 |
10 | Atoms
11 |
12 | 1 1 0.00000000000000 0.00000000000000 0.2
13 | 2 1 1.23 0.71 0.2
14 |
--------------------------------------------------------------------------------
/examples/Graphene/in.lammps:
--------------------------------------------------------------------------------
1 | # 3D copper block simulation
2 | units metal
3 | boundary p p p
4 | atom_style atomic
5 |
6 | # geometry
7 | read_data data.dat
8 |
9 | mass * 12.0107
10 |
11 | # EAM potential
12 | # pair_style tersoff
13 | # pair_coeff * * SiC.tersoff C
14 |
15 | pair_style airebo 10 0 0
16 | pair_coeff * * CH.airebo C
17 |
18 | neighbor 2. nsq
19 | neigh_modify every 1 delay 0 check yes
20 |
21 | # #Langevin random seed
22 | # variable dt equal 2e-3
23 | # variable r equal 57085
24 | # variable T equal 300
25 | # variable dT equal "v_dt * 100"
26 |
27 | # timestep ${dt}
28 |
29 | # # initialize
30 | # velocity all create $T 28459 rot yes dist gaussian mom yes
31 | # reset_timestep 0
32 |
33 | # # fixes
34 | # fix 1 all langevin $T $T ${dT} 73504 zero yes
35 | # fix 2 all nve
36 | # fix 3 all phonon 10 50000 1000000 map.in Graphene nasr 50
37 |
38 | # # output
39 | # # 1 2 3 4 5 6 7
40 | # thermo_style custom step temp pe ke press pxx pyy
41 | # thermo 100
42 |
43 | # restart 1000000 restart.one restart.two
44 |
45 | # dump 1 all xyz 50000 dump.graphene.xyz
46 |
47 | # # execution
48 | # run 6000000
49 | # write_restart Restart.final
50 |
--------------------------------------------------------------------------------
/examples/Pd/FORCE_CONSTANTS_800K:
--------------------------------------------------------------------------------
1 | 8 8
2 | 1 1
3 | 4.931298309735486 0.000000000000000 -0.000000000000000
4 | -0.000000000000000 4.931298309735487 -0.000000000000000
5 | -0.000000000000000 -0.000000000000000 4.931298309735485
6 | 1 2
7 | -2.725034703931399 0.000000000028844 0.000000000020396
8 | 0.000000000028844 0.066612438639189 0.048772359757294
9 | 0.000000000020396 0.048772359757294 0.032125172321922
10 | 1 3
11 | -0.631299347026995 -1.208818671949217 0.042238102547930
12 | -1.208818671949217 -2.027122918263550 -0.024386179885091
13 | 0.042238102547930 -0.024386179885090 0.032125172320257
14 | 1 4
15 | -0.631299346978864 1.208818671920373 -0.042238102538852
16 | 1.208818671920373 -2.027122918312898 -0.024386179901677
17 | -0.042238102538852 -0.024386179901677 0.032125172321476
18 | 1 5
19 | -0.631299347026994 -0.363117092318293 -1.153764541068161
20 | -0.363117092318294 -0.212007844982255 -0.666126268331177
21 | -1.153764541068161 -0.666126268331177 -1.782989900961038
22 | 1 6
23 | -0.631299346978865 0.363117092317237 1.153764541037941
24 | 0.363117092317238 -0.212007844997080 -0.666126268359969
25 | 1.153764541037941 -0.666126268359969 -1.782989900994344
26 | 1 7
27 | -0.002362093997458 0.000000000001056 0.000000000000747
28 | 0.000000000001056 -0.840945098023982 1.332252536720621
29 | 0.000000000000747 1.332252536720621 -1.782989900948846
30 | 1 8
31 | 0.321295876205087 0.000000000000000 -0.000000000000000
32 | 0.000000000000000 0.321295876205088 -0.000000000000000
33 | 0.000000000000000 -0.000000000000000 0.321295876205088
34 | 2 1
35 | -2.725034703931399 0.000000000028844 0.000000000020396
36 | 0.000000000028844 0.066612438639189 0.048772359757294
37 | 0.000000000020396 0.048772359757294 0.032125172321922
38 | 2 2
39 | 4.931298309735486 -0.000000000000000 -0.000000000000000
40 | -0.000000000000000 4.931298309735487 -0.000000000000000
41 | -0.000000000000000 -0.000000000000000 4.931298309735485
42 | 2 3
43 | -0.631299346978864 1.208818671920373 -0.042238102538852
44 | 1.208818671920373 -2.027122918312898 -0.024386179901677
45 | -0.042238102538852 -0.024386179901677 0.032125172321476
46 | 2 4
47 | -0.631299347026995 -1.208818671949217 0.042238102547930
48 | -1.208818671949217 -2.027122918263550 -0.024386179885091
49 | 0.042238102547930 -0.024386179885090 0.032125172320257
50 | 2 5
51 | -0.631299346978865 0.363117092317237 1.153764541037941
52 | 0.363117092317238 -0.212007844997080 -0.666126268359969
53 | 1.153764541037941 -0.666126268359969 -1.782989900994344
54 | 2 6
55 | -0.631299347026994 -0.363117092318293 -1.153764541068161
56 | -0.363117092318294 -0.212007844982255 -0.666126268331177
57 | -1.153764541068161 -0.666126268331177 -1.782989900961038
58 | 2 7
59 | 0.321295876205087 0.000000000000000 -0.000000000000000
60 | 0.000000000000000 0.321295876205088 -0.000000000000000
61 | 0.000000000000000 -0.000000000000000 0.321295876205088
62 | 2 8
63 | -0.002362093997458 0.000000000001056 0.000000000000747
64 | 0.000000000001056 -0.840945098023982 1.332252536720621
65 | 0.000000000000747 1.332252536720621 -1.782989900948846
66 | 3 1
67 | -0.631299347026995 -1.208818671949217 0.042238102547930
68 | -1.208818671949217 -2.027122918263550 -0.024386179885091
69 | 0.042238102547930 -0.024386179885090 0.032125172320257
70 | 3 2
71 | -0.631299346978864 1.208818671920373 -0.042238102538852
72 | 1.208818671920373 -2.027122918312898 -0.024386179901677
73 | -0.042238102538852 -0.024386179901677 0.032125172321476
74 | 3 3
75 | 4.931298309735486 -0.000000000000000 -0.000000000000000
76 | -0.000000000000000 4.931298309735487 -0.000000000000000
77 | -0.000000000000000 -0.000000000000000 4.931298309735485
78 | 3 4
79 | -2.725034703931399 0.000000000028844 0.000000000020396
80 | 0.000000000028844 0.066612438639189 0.048772359757294
81 | 0.000000000020396 0.048772359757294 0.032125172321922
82 | 3 5
83 | -0.002362093997458 0.000000000001056 0.000000000000747
84 | 0.000000000001056 -0.840945098023982 1.332252536720621
85 | 0.000000000000747 1.332252536720621 -1.782989900948846
86 | 3 6
87 | 0.321295876205087 0.000000000000000 -0.000000000000000
88 | 0.000000000000000 0.321295876205088 -0.000000000000000
89 | 0.000000000000000 -0.000000000000000 0.321295876205088
90 | 3 7
91 | -0.631299347026994 -0.363117092318293 -1.153764541068161
92 | -0.363117092318294 -0.212007844982255 -0.666126268331177
93 | -1.153764541068161 -0.666126268331177 -1.782989900961038
94 | 3 8
95 | -0.631299346978865 0.363117092317237 1.153764541037941
96 | 0.363117092317238 -0.212007844997080 -0.666126268359969
97 | 1.153764541037941 -0.666126268359969 -1.782989900994344
98 | 4 1
99 | -0.631299346978864 1.208818671920373 -0.042238102538852
100 | 1.208818671920373 -2.027122918312898 -0.024386179901677
101 | -0.042238102538852 -0.024386179901677 0.032125172321476
102 | 4 2
103 | -0.631299347026995 -1.208818671949217 0.042238102547930
104 | -1.208818671949217 -2.027122918263550 -0.024386179885091
105 | 0.042238102547930 -0.024386179885090 0.032125172320257
106 | 4 3
107 | -2.725034703931399 0.000000000028844 0.000000000020396
108 | 0.000000000028844 0.066612438639189 0.048772359757294
109 | 0.000000000020396 0.048772359757294 0.032125172321922
110 | 4 4
111 | 4.931298309735486 -0.000000000000000 -0.000000000000000
112 | -0.000000000000000 4.931298309735487 -0.000000000000000
113 | -0.000000000000000 -0.000000000000000 4.931298309735485
114 | 4 5
115 | 0.321295876205087 0.000000000000000 -0.000000000000000
116 | 0.000000000000000 0.321295876205088 -0.000000000000000
117 | 0.000000000000000 -0.000000000000000 0.321295876205088
118 | 4 6
119 | -0.002362093997458 0.000000000001056 0.000000000000747
120 | 0.000000000001056 -0.840945098023982 1.332252536720621
121 | 0.000000000000747 1.332252536720621 -1.782989900948846
122 | 4 7
123 | -0.631299346978865 0.363117092317237 1.153764541037941
124 | 0.363117092317238 -0.212007844997080 -0.666126268359969
125 | 1.153764541037941 -0.666126268359969 -1.782989900994344
126 | 4 8
127 | -0.631299347026994 -0.363117092318293 -1.153764541068161
128 | -0.363117092318294 -0.212007844982255 -0.666126268331177
129 | -1.153764541068161 -0.666126268331177 -1.782989900961038
130 | 5 1
131 | -0.631299347026994 -0.363117092318293 -1.153764541068161
132 | -0.363117092318294 -0.212007844982255 -0.666126268331177
133 | -1.153764541068161 -0.666126268331177 -1.782989900961038
134 | 5 2
135 | -0.631299346978865 0.363117092317237 1.153764541037941
136 | 0.363117092317238 -0.212007844997080 -0.666126268359969
137 | 1.153764541037941 -0.666126268359969 -1.782989900994344
138 | 5 3
139 | -0.002362093997458 0.000000000001056 0.000000000000747
140 | 0.000000000001056 -0.840945098023982 1.332252536720621
141 | 0.000000000000747 1.332252536720621 -1.782989900948846
142 | 5 4
143 | 0.321295876205087 0.000000000000000 -0.000000000000000
144 | 0.000000000000000 0.321295876205088 -0.000000000000000
145 | 0.000000000000000 -0.000000000000000 0.321295876205088
146 | 5 5
147 | 4.931298309735486 -0.000000000000000 -0.000000000000000
148 | -0.000000000000000 4.931298309735487 -0.000000000000000
149 | -0.000000000000000 -0.000000000000000 4.931298309735485
150 | 5 6
151 | -2.725034703931399 0.000000000028844 0.000000000020396
152 | 0.000000000028844 0.066612438639189 0.048772359757294
153 | 0.000000000020396 0.048772359757294 0.032125172321922
154 | 5 7
155 | -0.631299347026995 -1.208818671949217 0.042238102547930
156 | -1.208818671949217 -2.027122918263550 -0.024386179885091
157 | 0.042238102547930 -0.024386179885090 0.032125172320257
158 | 5 8
159 | -0.631299346978864 1.208818671920373 -0.042238102538852
160 | 1.208818671920373 -2.027122918312898 -0.024386179901677
161 | -0.042238102538852 -0.024386179901677 0.032125172321476
162 | 6 1
163 | -0.631299346978865 0.363117092317237 1.153764541037941
164 | 0.363117092317238 -0.212007844997080 -0.666126268359969
165 | 1.153764541037941 -0.666126268359969 -1.782989900994344
166 | 6 2
167 | -0.631299347026994 -0.363117092318293 -1.153764541068161
168 | -0.363117092318294 -0.212007844982255 -0.666126268331177
169 | -1.153764541068161 -0.666126268331177 -1.782989900961038
170 | 6 3
171 | 0.321295876205087 0.000000000000000 -0.000000000000000
172 | 0.000000000000000 0.321295876205088 -0.000000000000000
173 | 0.000000000000000 -0.000000000000000 0.321295876205088
174 | 6 4
175 | -0.002362093997458 0.000000000001056 0.000000000000747
176 | 0.000000000001056 -0.840945098023982 1.332252536720621
177 | 0.000000000000747 1.332252536720621 -1.782989900948846
178 | 6 5
179 | -2.725034703931399 0.000000000028844 0.000000000020396
180 | 0.000000000028844 0.066612438639189 0.048772359757294
181 | 0.000000000020396 0.048772359757294 0.032125172321922
182 | 6 6
183 | 4.931298309735486 -0.000000000000000 -0.000000000000000
184 | -0.000000000000000 4.931298309735487 -0.000000000000000
185 | -0.000000000000000 -0.000000000000000 4.931298309735485
186 | 6 7
187 | -0.631299346978864 1.208818671920373 -0.042238102538852
188 | 1.208818671920373 -2.027122918312898 -0.024386179901677
189 | -0.042238102538852 -0.024386179901677 0.032125172321476
190 | 6 8
191 | -0.631299347026995 -1.208818671949217 0.042238102547930
192 | -1.208818671949217 -2.027122918263550 -0.024386179885091
193 | 0.042238102547930 -0.024386179885090 0.032125172320257
194 | 7 1
195 | -0.002362093997458 0.000000000001056 0.000000000000747
196 | 0.000000000001056 -0.840945098023982 1.332252536720621
197 | 0.000000000000747 1.332252536720621 -1.782989900948846
198 | 7 2
199 | 0.321295876205087 0.000000000000000 -0.000000000000000
200 | 0.000000000000000 0.321295876205088 -0.000000000000000
201 | 0.000000000000000 -0.000000000000000 0.321295876205088
202 | 7 3
203 | -0.631299347026994 -0.363117092318293 -1.153764541068161
204 | -0.363117092318294 -0.212007844982255 -0.666126268331177
205 | -1.153764541068161 -0.666126268331177 -1.782989900961038
206 | 7 4
207 | -0.631299346978865 0.363117092317237 1.153764541037941
208 | 0.363117092317238 -0.212007844997080 -0.666126268359969
209 | 1.153764541037941 -0.666126268359969 -1.782989900994344
210 | 7 5
211 | -0.631299347026995 -1.208818671949217 0.042238102547930
212 | -1.208818671949217 -2.027122918263550 -0.024386179885091
213 | 0.042238102547930 -0.024386179885090 0.032125172320257
214 | 7 6
215 | -0.631299346978864 1.208818671920373 -0.042238102538852
216 | 1.208818671920373 -2.027122918312898 -0.024386179901677
217 | -0.042238102538852 -0.024386179901677 0.032125172321476
218 | 7 7
219 | 4.931298309735486 -0.000000000000000 -0.000000000000000
220 | -0.000000000000000 4.931298309735487 -0.000000000000000
221 | -0.000000000000000 -0.000000000000000 4.931298309735485
222 | 7 8
223 | -2.725034703931399 0.000000000028844 0.000000000020396
224 | 0.000000000028844 0.066612438639189 0.048772359757294
225 | 0.000000000020396 0.048772359757294 0.032125172321922
226 | 8 1
227 | 0.321295876205087 0.000000000000000 -0.000000000000000
228 | 0.000000000000000 0.321295876205088 -0.000000000000000
229 | 0.000000000000000 -0.000000000000000 0.321295876205088
230 | 8 2
231 | -0.002362093997458 0.000000000001056 0.000000000000747
232 | 0.000000000001056 -0.840945098023982 1.332252536720621
233 | 0.000000000000747 1.332252536720621 -1.782989900948846
234 | 8 3
235 | -0.631299346978865 0.363117092317237 1.153764541037941
236 | 0.363117092317238 -0.212007844997080 -0.666126268359969
237 | 1.153764541037941 -0.666126268359969 -1.782989900994344
238 | 8 4
239 | -0.631299347026994 -0.363117092318293 -1.153764541068161
240 | -0.363117092318294 -0.212007844982255 -0.666126268331177
241 | -1.153764541068161 -0.666126268331177 -1.782989900961038
242 | 8 5
243 | -0.631299346978864 1.208818671920373 -0.042238102538852
244 | 1.208818671920373 -2.027122918312898 -0.024386179901677
245 | -0.042238102538852 -0.024386179901677 0.032125172321476
246 | 8 6
247 | -0.631299347026995 -1.208818671949217 0.042238102547930
248 | -1.208818671949217 -2.027122918263550 -0.024386179885091
249 | 0.042238102547930 -0.024386179885090 0.032125172320257
250 | 8 7
251 | -2.725034703931399 0.000000000028844 0.000000000020396
252 | 0.000000000028844 0.066612438639189 0.048772359757294
253 | 0.000000000020396 0.048772359757294 0.032125172321922
254 | 8 8
255 | 4.931298309735486 -0.000000000000000 -0.000000000000000
256 | -0.000000000000000 4.931298309735487 -0.000000000000000
257 | -0.000000000000000 -0.000000000000000 4.931298309735485
258 |
--------------------------------------------------------------------------------
/examples/Pd/POSCAR_unitcell:
--------------------------------------------------------------------------------
1 | Generated using phonoLAMMPS
2 | 1.0
3 | 2.8284271247 0.0000000000 0.0000000000
4 | 1.4142135624 2.4494897428 0.0000000000
5 | 1.4142135624 0.8164965809 2.3094010768
6 | Pd
7 | 1
8 | Direct
9 | 0.000000000000000 0.000000000000000 0.000000000000000
10 |
--------------------------------------------------------------------------------
/examples/Pd/README:
--------------------------------------------------------------------------------
1 | ---------------------------------------------
2 | Pb EAM potential example using primitive cell
3 | ---------------------------------------------
4 |
5 | This example requires the EAM potential developed by J.B. Adams, which can be obtained from:
6 | https://www.ctcms.nist.gov/potentials/1989--Adams-J-B--Pd.html (file should be renamed to Pd.eam)
7 |
8 | Run this example as follows to generate the force constants and show band structure:
9 |
10 | # phonolammps in.lammps --dim 4 4 4 -c POSCAR_unitcell -p
11 |
--------------------------------------------------------------------------------
/examples/Pd/data.pd:
--------------------------------------------------------------------------------
1 | Generated using dynaphopy
2 |
3 | 1 atoms
4 |
5 | 1 atom types
6 |
7 |
8 | 0.0000000000 2.8284271247 xlo xhi
9 | 0.0000000000 2.4494897428 ylo yhi
10 | 0.0000000000 2.3094010768 zlo zhi
11 | 1.4142135624 1.4142135624 0.8164965809 xy xz yz
12 |
13 | Masses
14 |
15 | 1 106.4200000000
16 |
17 | Atoms
18 |
19 | 1 1 0.0000000000 0.0000000000 0.0000000000
20 |
--------------------------------------------------------------------------------
/examples/Pd/in.lammps:
--------------------------------------------------------------------------------
1 |
2 | units metal
3 |
4 | boundary p p p
5 |
6 | box tilt large
7 |
8 | atom_style atomic
9 |
10 | read_data data.pd
11 |
12 | pair_style eam
13 | pair_coeff * * Pd.eam
14 |
15 | neighbor 0.3 bin
16 |
--------------------------------------------------------------------------------
/examples/Pd/pd_api.py:
--------------------------------------------------------------------------------
1 | #########################################################################
2 | # Example to calculate renormalized force constants at finite temperature
3 | # by using molecular dynamics & phonon quasiparticle approach
4 | # Requires: lammps, phonopy & dynaphopy
5 | #########################################################################
6 |
7 | from phonolammps import Phonolammps
8 | from dynaphopy import Quasiparticle
9 | from dynaphopy.atoms import Structure
10 | from dynaphopy.interface.lammps_link import generate_lammps_trajectory
11 | from dynaphopy.interface.phonopy_link import ForceConstants
12 | from contextlib import contextmanager
13 | from phonopy.file_IO import write_FORCE_CONSTANTS, write_force_constants_to_hdf5
14 |
15 | import numpy as np
16 | import os
17 | import sys
18 |
19 |
20 | @contextmanager
21 | def silence_stdout():
22 |
23 | new_target = open(os.devnull, "w")
24 | old_target, sys.stdout = sys.stdout, new_target
25 | try:
26 | yield new_target
27 | finally:
28 | sys.stdout = old_target
29 |
30 | # input parameters
31 | supercell = [2, 2, 2]
32 | primitive_mat = [[1, 0, 0],
33 | [0, 1, 0],
34 | [0, 0, 1]]
35 | temperature = 800
36 |
37 | # calculate harmonic force constants with phonolammps
38 | phlammps = Phonolammps('in.lammps',
39 | supercell_matrix=np.diag(supercell),
40 | primitive_matrix=primitive_mat)
41 |
42 | force_constants = phlammps.get_force_constants()
43 | unitcell = phlammps.get_unitcell()
44 |
45 | structure = Structure(cell=unitcell.get_cell(), # cell_matrix, lattice vectors in rows
46 | scaled_positions=unitcell.get_scaled_positions(),
47 | atomic_elements=unitcell.get_chemical_symbols(),
48 | primitive_matrix=primitive_mat)
49 |
50 | structure.set_force_constants(ForceConstants(force_constants,
51 | supercell=np.diag(supercell)))
52 |
53 | # generate LAMMPS MD trajectory (requires dynaphopy development)
54 | trajectory = generate_lammps_trajectory(structure, 'in.lammps',
55 | total_time=20,
56 | time_step=0.001,
57 | relaxation_time=5,
58 | silent=False,
59 | supercell=supercell,
60 | memmap=False,
61 | velocity_only=False,
62 | temperature=temperature)
63 |
64 | # Calculate renormalized force constants with dynaphopy
65 | calculation = Quasiparticle(trajectory)
66 | with silence_stdout():
67 | calculation.select_power_spectra_algorithm(2) # 1: Max. Entrop. 2:FFT
68 | calculation.plot_renormalized_phonon_dispersion_bands()
69 | renormalized_force_constants = calculation.get_renormalized_force_constants()
70 |
71 | # Save renormalized force constants and unitcell to disk
72 | write_FORCE_CONSTANTS(renormalized_force_constants.get_array(),
73 | filename='FORCE_CONSTANTS_{}K'.format(temperature))
74 | phlammps.write_unitcell_POSCAR(filename='POSCAR_unitcell')
75 |
--------------------------------------------------------------------------------
/examples/Si/POSCAR_unitcell:
--------------------------------------------------------------------------------
1 | Generated using phonoLAMMPS
2 | 1.0
3 | 5.4500000000 0.0000000000 0.0000000000
4 | 0.0000000000 5.4500000000 0.0000000000
5 | 0.0000000000 0.0000000000 5.4500000000
6 | Si
7 | 8
8 | Direct
9 | 0.875000000000000 0.875000000000000 0.875000000000000
10 | 0.875000000000000 0.375000000000000 0.375000000000000
11 | 0.375000000000000 0.875000000000000 0.375000000000000
12 | 0.375000000000000 0.375000000000000 0.875000000000000
13 | 0.125000000000000 0.125000000000000 0.125000000000000
14 | 0.125000000000000 0.625000000000000 0.625000000000000
15 | 0.625000000000000 0.125000000000000 0.625000000000000
16 | 0.625000000000000 0.625000000000000 0.125000000000000
17 |
--------------------------------------------------------------------------------
/examples/Si/README:
--------------------------------------------------------------------------------
1 | ----------------------------
2 | Si Tersoff potential example
3 | ----------------------------
4 |
5 | Run this example as follows to generate the force constants and show band structure:
6 |
7 | # phonolammps in.lammps --dim 2 2 2 -pa 0.0 0.5 0.5 0.5 0.0 0.5 0.5 0.5 0.0 -c POSCAR_unitcell -p
8 |
9 | To perform a preliminary optimization of the atoms position in the unit cell (constant volume):
10 |
11 | # phonolammps in.lammps --dim 2 2 2 -pa 0.0 0.5 0.5 0.5 0.0 0.5 0.5 0.5 0.0 --optimize -c POSCAR_unitcell -p
12 |
--------------------------------------------------------------------------------
/examples/Si/SiCGe.tersoff:
--------------------------------------------------------------------------------
1 | # DATE: 2009-03-18 CONTRIBUTOR: Aidan Thompson, athomps@sandia.gov CITATION: Tersoff, Phys Rev B, 39, 5566 (1989)
2 |
3 | # Tersoff parameters for various elements and mixtures
4 | # multiple entries can be added to this file, LAMMPS reads the ones it needs
5 | # these entries are in LAMMPS "metal" units:
6 | # A,B = eV; lambda1,lambda2,lambda3 = 1/Angstroms; R,D = Angstroms
7 | # other quantities are unitless
8 |
9 | # Aidan Thompson (athomps at sandia.gov) takes full blame for this
10 | # file. It specifies various potentials published by J. Tersoff for
11 | # silicon, carbon and germanium. Since Tersoff published several
12 | # different silicon potentials, I refer to them using atom types
13 | # Si(B), Si(C) and Si(D). The last two are almost almost identical but
14 | # refer to two different publications. These names should be used in
15 | # the LAMMPS command when the file is invoked. For example:
16 | # pair_coeff * * SiCGe.tersoff Si(B). The Si(D), C and Ge potentials
17 | # can be used pure silicon, pure carbon, pure germanium, binary SiC,
18 | # and binary SiGe, but not binary GeC or ternary SiGeC. LAMMPS will
19 | # generate an error if this file is used with any combination
20 | # involving C and Ge, since there are no entries for the GeC
21 | # interactions (Tersoff did not publish parameters for this
22 | # cross-interaction.)
23 |
24 | # format of a single entry (one or more lines):
25 | # element 1, element 2, element 3,
26 | # m, gamma, lambda3, c, d, costheta0, n, beta, lambda2, B, R, D, lambda1, A
27 |
28 | # The original Tersoff potential for Silicon, Si(B)
29 | # J. Tersoff, PRB, 37, 6991 (1988)
30 |
31 | Si(B) Si(B) Si(B) 3.0 1.0 1.3258 4.8381 2.0417 0.0000 22.956
32 | 0.33675 1.3258 95.373 3.0 0.2 3.2394 3264.7
33 |
34 | # The later Tersoff potential for Silicon, Si(C)
35 | # J. Tersoff, PRB, 38, 9902 (1988)
36 |
37 | Si(C) Si(C) Si(C) 3.0 1.0 1.7322 1.0039e5 16.218 -0.59826 0.78734
38 | 1.0999e-6 1.7322 471.18 2.85 0.15 2.4799 1830.8
39 |
40 | # The later Tersoff potential for Carbon, Silicon, and Germanium
41 | # J. Tersoff, PRB, 39, 5566 (1989) + errata (PRB 41, 3248)
42 | # The Si and C parameters are very close to those in SiC.tersoff
43 |
44 | C C C 3.0 1.0 0.0 3.8049e4 4.3484 -0.57058 0.72751 1.5724e-7 2.2119 346.74 1.95 0.15 3.4879 1393.6
45 | Si(D) Si(D) Si(D) 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 1.1000e-6 1.7322 471.18 2.85 0.15 2.4799 1830.8
46 | Ge Ge Ge 3.0 1.0 0.0 1.0643e5 15.652 -0.43884 0.75627 9.0166e-7 1.7047 419.23 2.95 0.15 2.4451 1769.0
47 |
48 | C Si(D) Si(D) 3.0 1.0 0.0 3.8049e4 4.3484 -0.57058 0.72751 1.5724e-7 1.97205 395.1451 2.3573 0.1527 2.9839 1597.3111
49 | C Si(D) C 3.0 1.0 0.0 3.8049e4 4.3484 -0.57058 0.72751 0.0 0.0 0.0 1.95 0.15 0.0 0.0
50 | C C Si(D) 3.0 1.0 0.0 3.8049e4 4.3484 -0.57058 0.72751 0.0 0.0 0.0 2.3573 0.1527 0.0 0.0
51 |
52 | Si(D) C C 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 1.1000e-6 1.97205 395.1451 2.3573 0.1527 2.9839 1597.3111
53 | Si(D) Si(D) C 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 0.0 0.0 0.0 2.3573 0.1527 0.0 0.0
54 | Si(D) C Si(D) 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 0.0 0.0 0.0 2.85 0.15 0.0 0.0
55 |
56 | Si(D) Ge Ge 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 1.1000e-6 1.71845 444.7177 2.8996 0.1500 2.4625 1799.6347
57 | Si(D) Si(D) Ge 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 0.0 0.0 0.0 2.8996 0.1500 0.0 0.0
58 | Si(D) Ge Si(D) 3.0 1.0 0.0 1.0039e5 16.217 -0.59825 0.78734 0.0 0.0 0.0 2.85 0.15 0.0 0.0
59 |
60 | Ge Si(D) Si(D) 3.0 1.0 0.0 1.0643e5 15.652 -0.43884 0.75627 9.0166e-7 1.71845 444.7177 2.8996 0.1500 2.4625 1799.6347
61 | Ge Si(D) Ge 3.0 1.0 0.0 1.0643e5 15.652 -0.43884 0.75627 0.0 0.0 0.0 2.95 0.15 0.0 0.0
62 | Ge Ge Si(D) 3.0 1.0 0.0 1.0643e5 15.652 -0.43884 0.75627 0.0 0.0 0.0 2.8996 0.1500 0.0 0.0
63 |
64 |
--------------------------------------------------------------------------------
/examples/Si/data.si:
--------------------------------------------------------------------------------
1 | Generated using dynaphopy
2 |
3 | 8 atoms
4 |
5 | 1 atom types
6 |
7 |
8 | 0.0000000000 5.4500000000 xlo xhi
9 | 0.0000000000 5.4500000000 ylo yhi
10 | 0.0000000000 5.4500000000 zlo zhi
11 | 0.0000000000 0.0000000000 0.0000000000 xy xz yz
12 |
13 | Masses
14 |
15 | 1 28.0855000000
16 |
17 | Atoms
18 |
19 | 1 1 4.7687500000 4.7687500000 4.7687500000
20 | 2 1 4.7687500000 2.0437500000 2.0437500000
21 | 3 1 2.0437500000 4.7687500000 2.0437500000
22 | 4 1 2.0437500000 2.0437500000 4.7687500000
23 | 5 1 0.6812500000 0.6812500000 0.6812500000
24 | 6 1 0.6812500000 3.4062500000 3.4062500000
25 | 7 1 3.4062500000 0.6812500000 3.4062500000
26 | 8 1 3.4062500000 3.4062500000 0.6812500000
27 |
--------------------------------------------------------------------------------
/examples/Si/in.lammps:
--------------------------------------------------------------------------------
1 |
2 | units metal
3 |
4 | boundary p p p
5 |
6 | box tilt large
7 |
8 | atom_style atomic
9 |
10 | read_data data.si
11 |
12 | pair_style tersoff
13 | pair_coeff * * SiCGe.tersoff Si(C)
14 |
15 | neighbor 0.3 bin
16 |
--------------------------------------------------------------------------------
/examples/Si/si_api.py:
--------------------------------------------------------------------------------
1 | # API example to calculate finite temperature (300K) force constants
2 | # using dynaphopy (quasiparticle theory)
3 |
4 | from phonolammps import Phonolammps
5 | from dynaphopy.interface.lammps_link import generate_lammps_trajectory
6 | from dynaphopy.interface.phonopy_link import ForceConstants
7 | from dynaphopy import Quasiparticle
8 | from dynaphopy.atoms import Structure
9 |
10 | import numpy as np
11 |
12 | # calculate harmonic force constants with phonoLAMMPS
13 | phlammps = Phonolammps('in.lammps',
14 | supercell_matrix=np.diag([2, 2, 2]),
15 | primitive_matrix=[[0.0, 0.5, 0.5],
16 | [0.5, 0.0, 0.5],
17 | [0.5, 0.5, 0.0]],
18 | )
19 |
20 | phlammps.plot_phonon_dispersion_bands()
21 |
22 | # set force constants for dynaphopy
23 | force_constants = ForceConstants(phlammps.get_force_constants(),
24 | supercell=phlammps.get_supercell_matrix())
25 |
26 | # Print harmonic force constants
27 | print('harmonic force constants')
28 | print(force_constants.get_array())
29 |
30 | structure = phlammps.get_unitcell()
31 |
32 |
33 | # define structure for dynaphopy
34 | dp_structure = Structure(cell=structure.get_cell(), # cell_matrix, lattice vectors in rows
35 | scaled_positions=structure.get_scaled_positions(),
36 | atomic_elements=structure.get_chemical_symbols(),
37 | primitive_matrix=phlammps.get_primitve_matrix(),
38 | force_constants=force_constants)
39 |
40 | # calculate trajectory for dynaphopy with lammps
41 | trajectory = generate_lammps_trajectory(dp_structure, 'in.lammps',
42 | total_time=20, # ps
43 | time_step=0.001, # ps
44 | relaxation_time=5, # ps
45 | silent=False,
46 | supercell=[2, 2, 2],
47 | memmap=False,
48 | velocity_only=True,
49 | temperature=300)
50 |
51 | # set dynaphopy calculation
52 | calculation = Quasiparticle(trajectory)
53 | calculation.select_power_spectra_algorithm(2) # select FFT algorithm
54 |
55 | calculation.get_renormalized_phonon_dispersion_bands()
56 | renormalized_force_constants = calculation.get_renormalized_force_constants()
57 |
58 | # Print phonon band structure
59 | calculation.plot_renormalized_phonon_dispersion_bands()
60 |
61 | # Plot linewidths vs frequencies (interpolated to a mesh 20x20x20)
62 | # calculation.parameters.mesh_phonopy = [20, 20, 20]
63 | # calculation.plot_frequencies_vs_linewidths()
64 | # calculation.write_mesh_data()
65 |
66 | # Print renormalized force constants
67 | print('renormalized force constants at 300K')
68 | print(renormalized_force_constants.get_array())
--------------------------------------------------------------------------------
/examples/gromacs/POSCAR:
--------------------------------------------------------------------------------
1 | Generated using phonoLAMMPS
2 | 1.0
3 | 8.1940000000 0.0000000000 0.0000000000
4 | 0.0000000000 5.9680000000 0.0000000000
5 | 3.4004000000 0.0000000000 7.2231000000
6 | C H
7 | 20 16
8 | Direct
9 | 0.506171502609953 0.267243811997319 0.827824519942961
10 | 0.644273283928643 0.411341610254692 0.720268877628719
11 | 0.761417411620277 0.353863602546917 0.537038459941023
12 | 0.901338019966498 0.499146353887399 0.424851577577494
13 | 1.016618752495042 0.438283150134048 0.244730679348202
14 | 0.993548529341883 0.233600919906166 0.172540442469300
15 | 0.856270132667239 0.088292201742627 0.279804532679874
16 | 0.738317757739001 0.145745103887399 0.463336476028298
17 | 0.598278779745232 0.001616869973190 0.574932684027633
18 | 0.483686752706000 0.062270018431635 0.755365979980894
19 | 0.493595785579969 0.766883716487936 0.172653194611732
20 | 0.355729829842274 0.911842002345844 0.279730574130221
21 | 0.238570190673174 0.854320625000000 0.463477254918248
22 | 0.098555635222422 0.998731752680965 0.574978853954673
23 | -0.016697417843564 0.937642984249330 0.755144580581744
24 | 0.006344468071492 0.733018830428954 0.827855298971356
25 | 0.143601176171109 0.587634182305630 0.720158714402403
26 | 0.261524303293865 0.645362050938338 0.537092262325040
27 | 0.401685760857788 0.501014840817694 0.424844728717587
28 | 0.516107029412932 0.561864661528150 0.244592583516773
29 | 0.417568365679891 0.315021008713137 0.967956705569631
30 | 0.662298745459046 0.571222131367292 0.775342956625272
31 | 0.920311156548860 0.658401965482574 0.480315684401434
32 | 1.124631776652796 0.549898290884719 0.161759355401420
33 | 1.083162475659978 0.186073532171582 0.031947978014980
34 | 0.837511509601056 -0.070417774798928 0.224140254184491
35 | 0.579431639571141 -0.157419381702413 0.519262773601362
36 | 0.374968594792170 -0.050162582104558 0.838872392739959
37 | 0.582396464929439 0.814266611930295 0.031893102684443
38 | 0.337810633021280 1.070839090147453 0.224129609170578
39 | 0.079802019128555 1.157759301273458 0.519255883208041
40 | -0.124934692954094 1.049133532171582 0.839032232697872
41 | -0.083195808695100 0.685332917225201 0.967894073181875
42 | 0.162617934543425 0.428886429289544 0.775429271365480
43 | 0.420702962117458 0.341906843163539 0.480296952831887
44 | 0.624856365149070 0.450546796246649 0.161832612036383
45 |
--------------------------------------------------------------------------------
/examples/gromacs/naphthalene.py:
--------------------------------------------------------------------------------
1 | from phonolammps import PhonoGromacs
2 | import numpy as np
3 |
4 |
5 | gmx_params = {'rvdw': 0.28, # nm
6 | 'rlist': 0.28, # nm
7 | 'rcoulomb': 0.28} # nm
8 |
9 | phg = PhonoGromacs('unitcell_whole.g96',
10 | supercell_matrix=np.identity(3) * 4,
11 | displacement_distance=0.15, # angs
12 | gmx_params=gmx_params,
13 | itp_file='params.itp',
14 | omp_num_threads=6,
15 | show_progress=True)
16 |
17 | phg.write_unitcell_POSCAR()
18 | phg.plot_phonon_dispersion_bands()
19 | phg.write_force_constants()
20 | phonon = phg.get_phonopy_phonon()
21 | phonon.run_mesh([40, 40, 40])
22 | phonon.run_total_dos()
23 | phonon.plot_total_dos().show()
24 |
--------------------------------------------------------------------------------
/examples/gromacs/params.itp:
--------------------------------------------------------------------------------
1 | ; ----
2 | ; Built itp for test.mol2
3 | ; by user vzoete Sun Jul 18 22:30:43 UTC 2021
4 | ; ----
5 | ;
6 |
7 | [ atomtypes ]
8 | ; name at.num mass charge ptype sigma epsilon
9 | CB 6 12.0110 0.0 A 0.355005 0.292880
10 | HCMM 1 1.0079 0.0 A 0.235197 0.092048
11 |
12 |
13 | [ pairtypes ]
14 | ; i j func sigma1-4 epsilon1-4 ; THESE ARE 1-4 INTERACTIONS
15 |
16 | [ moleculetype ]
17 | ; Name nrexcl
18 | test 3
19 |
20 | [ atoms ]
21 | ; nr type resnr resid atom cgnr charge mass
22 | 1 CB 1 LIG C 1 -0.1500 12.0110
23 | 2 CB 1 LIG C1 2 -0.1500 12.0110
24 | 3 CB 1 LIG C2 3 0.0000 12.0110
25 | 4 CB 1 LIG C3 4 -0.1500 12.0110
26 | 5 CB 1 LIG C4 5 -0.1500 12.0110
27 | 6 CB 1 LIG C5 6 -0.1500 12.0110
28 | 7 CB 1 LIG C6 7 -0.1500 12.0110
29 | 8 CB 1 LIG C7 8 0.0000 12.0110
30 | 9 CB 1 LIG C8 9 -0.1500 12.0110
31 | 10 CB 1 LIG C9 10 -0.1500 12.0110
32 | 11 CB 1 LIG C10 11 -0.1500 12.0110
33 | 12 CB 1 LIG C11 12 -0.1500 12.0110
34 | 13 CB 1 LIG C12 13 0.0000 12.0110
35 | 14 CB 1 LIG C13 14 -0.1500 12.0110
36 | 15 CB 1 LIG C14 15 -0.1500 12.0110
37 | 16 CB 1 LIG C15 16 -0.1500 12.0110
38 | 17 CB 1 LIG C16 17 -0.1500 12.0110
39 | 18 CB 1 LIG C17 18 0.0000 12.0110
40 | 19 CB 1 LIG C18 19 -0.1500 12.0110
41 | 20 CB 1 LIG C19 20 -0.1500 12.0110
42 | 21 HCMM 1 LIG H 21 0.1500 1.0079
43 | 22 HCMM 1 LIG H1 22 0.1500 1.0079
44 | 23 HCMM 1 LIG H2 23 0.1500 1.0079
45 | 24 HCMM 1 LIG H3 24 0.1500 1.0079
46 | 25 HCMM 1 LIG H4 25 0.1500 1.0079
47 | 26 HCMM 1 LIG H5 26 0.1500 1.0079
48 | 27 HCMM 1 LIG H6 27 0.1500 1.0079
49 | 28 HCMM 1 LIG H7 28 0.1500 1.0079
50 | 29 HCMM 1 LIG H8 29 0.1500 1.0079
51 | 30 HCMM 1 LIG H9 30 0.1500 1.0079
52 | 31 HCMM 1 LIG H10 31 0.1500 1.0079
53 | 32 HCMM 1 LIG H11 32 0.1500 1.0079
54 | 33 HCMM 1 LIG H12 33 0.1500 1.0079
55 | 34 HCMM 1 LIG H13 34 0.1500 1.0079
56 | 35 HCMM 1 LIG H14 35 0.1500 1.0079
57 | 36 HCMM 1 LIG H15 36 0.1500 1.0079
58 |
59 | [ bonds ]
60 | ; ai aj fu b0 kb, b0 kb
61 | 29 11 1 0.10840 319534.6 0.10840 319534.6
62 | 25 6 1 0.10840 319534.6 0.10840 319534.6
63 | 36 20 1 0.10840 319534.6 0.10840 319534.6
64 | 24 5 1 0.10840 319534.6 0.10840 319534.6
65 | 6 5 1 0.13740 335613.7 0.13740 335613.7
66 | 6 7 1 0.13740 335613.7 0.13740 335613.7
67 | 11 20 1 0.13740 335613.7 0.13740 335613.7
68 | 11 12 1 0.13740 335613.7 0.13740 335613.7
69 | 26 7 1 0.10840 319534.6 0.10840 319534.6
70 | 30 12 1 0.10840 319534.6 0.10840 319534.6
71 | 5 4 1 0.13740 335613.7 0.13740 335613.7
72 | 20 19 1 0.13740 335613.7 0.13740 335613.7
73 | 7 8 1 0.13740 335613.7 0.13740 335613.7
74 | 12 13 1 0.13740 335613.7 0.13740 335613.7
75 | 19 35 1 0.10840 319534.6 0.10840 319534.6
76 | 19 18 1 0.13740 335613.7 0.13740 335613.7
77 | 4 23 1 0.10840 319534.6 0.10840 319534.6
78 | 4 3 1 0.13740 335613.7 0.13740 335613.7
79 | 8 3 1 0.13740 335613.7 0.13740 335613.7
80 | 8 9 1 0.13740 335613.7 0.13740 335613.7
81 | 13 18 1 0.13740 335613.7 0.13740 335613.7
82 | 13 14 1 0.13740 335613.7 0.13740 335613.7
83 | 31 14 1 0.10840 319534.6 0.10840 319534.6
84 | 27 9 1 0.10840 319534.6 0.10840 319534.6
85 | 3 2 1 0.13740 335613.7 0.13740 335613.7
86 | 18 17 1 0.13740 335613.7 0.13740 335613.7
87 | 14 15 1 0.13740 335613.7 0.13740 335613.7
88 | 9 10 1 0.13740 335613.7 0.13740 335613.7
89 | 2 22 1 0.10840 319534.6 0.10840 319534.6
90 | 2 1 1 0.13740 335613.7 0.13740 335613.7
91 | 17 34 1 0.10840 319534.6 0.10840 319534.6
92 | 17 16 1 0.13740 335613.7 0.13740 335613.7
93 | 15 16 1 0.13740 335613.7 0.13740 335613.7
94 | 15 32 1 0.10840 319534.6 0.10840 319534.6
95 | 10 1 1 0.13740 335613.7 0.13740 335613.7
96 | 10 28 1 0.10840 319534.6 0.10840 319534.6
97 | 1 21 1 0.10840 319534.6 0.10840 319534.6
98 | 16 33 1 0.10840 319534.6 0.10840 319534.6
99 |
100 | [ pairs ]
101 | ; ai aj fu
102 | 1 4 1
103 | 1 8 1
104 | 1 27 1
105 | 2 9 1
106 | 2 28 1
107 | 2 5 1
108 | 2 23 1
109 | 2 7 1
110 | 3 10 1
111 | 3 21 1
112 | 3 6 1
113 | 3 24 1
114 | 3 26 1
115 | 3 27 1
116 | 4 22 1
117 | 4 7 1
118 | 4 9 1
119 | 4 25 1
120 | 5 8 1
121 | 5 26 1
122 | 6 23 1
123 | 6 9 1
124 | 7 24 1
125 | 7 10 1
126 | 7 27 1
127 | 8 22 1
128 | 8 23 1
129 | 8 25 1
130 | 8 28 1
131 | 9 26 1
132 | 9 21 1
133 | 10 22 1
134 | 11 14 1
135 | 11 18 1
136 | 11 35 1
137 | 12 19 1
138 | 12 36 1
139 | 12 15 1
140 | 12 31 1
141 | 12 17 1
142 | 13 20 1
143 | 13 29 1
144 | 13 16 1
145 | 13 32 1
146 | 13 34 1
147 | 13 35 1
148 | 14 30 1
149 | 14 17 1
150 | 14 19 1
151 | 14 33 1
152 | 15 18 1
153 | 15 34 1
154 | 16 31 1
155 | 16 19 1
156 | 17 32 1
157 | 17 20 1
158 | 17 35 1
159 | 18 30 1
160 | 18 31 1
161 | 18 33 1
162 | 18 36 1
163 | 19 34 1
164 | 19 29 1
165 | 20 30 1
166 | 21 22 1
167 | 21 28 1
168 | 23 24 1
169 | 24 25 1
170 | 25 26 1
171 | 27 28 1
172 | 29 30 1
173 | 29 36 1
174 | 31 32 1
175 | 32 33 1
176 | 33 34 1
177 | 35 36 1
178 |
179 | [ angles ]
180 | ; ai aj ak fu th0 kth ub0 kub th0 kth ub0 kub
181 | 2 1 10 1 119.9770 402.88 119.9770 402.88
182 | 2 1 21 1 120.5710 339.05 120.5710 339.05
183 | 10 1 21 1 120.5710 339.05 120.5710 339.05
184 | 1 2 3 1 119.9770 402.88 119.9770 402.88
185 | 1 2 22 1 120.5710 339.05 120.5710 339.05
186 | 3 2 22 1 120.5710 339.05 120.5710 339.05
187 | 2 3 4 1 119.9770 402.88 119.9770 402.88
188 | 2 3 8 1 119.9770 402.88 119.9770 402.88
189 | 4 3 8 1 119.9770 402.88 119.9770 402.88
190 | 3 4 5 1 119.9770 402.88 119.9770 402.88
191 | 3 4 23 1 120.5710 339.05 120.5710 339.05
192 | 5 4 23 1 120.5710 339.05 120.5710 339.05
193 | 4 5 6 1 119.9770 402.88 119.9770 402.88
194 | 4 5 24 1 120.5710 339.05 120.5710 339.05
195 | 6 5 24 1 120.5710 339.05 120.5710 339.05
196 | 5 6 7 1 119.9770 402.88 119.9770 402.88
197 | 5 6 25 1 120.5710 339.05 120.5710 339.05
198 | 7 6 25 1 120.5710 339.05 120.5710 339.05
199 | 6 7 8 1 119.9770 402.88 119.9770 402.88
200 | 6 7 26 1 120.5710 339.05 120.5710 339.05
201 | 8 7 26 1 120.5710 339.05 120.5710 339.05
202 | 3 8 7 1 119.9770 402.88 119.9770 402.88
203 | 3 8 9 1 119.9770 402.88 119.9770 402.88
204 | 7 8 9 1 119.9770 402.88 119.9770 402.88
205 | 8 9 10 1 119.9770 402.88 119.9770 402.88
206 | 8 9 27 1 120.5710 339.05 120.5710 339.05
207 | 10 9 27 1 120.5710 339.05 120.5710 339.05
208 | 1 10 9 1 119.9770 402.88 119.9770 402.88
209 | 1 10 28 1 120.5710 339.05 120.5710 339.05
210 | 9 10 28 1 120.5710 339.05 120.5710 339.05
211 | 12 11 20 1 119.9770 402.88 119.9770 402.88
212 | 12 11 29 1 120.5710 339.05 120.5710 339.05
213 | 20 11 29 1 120.5710 339.05 120.5710 339.05
214 | 11 12 13 1 119.9770 402.88 119.9770 402.88
215 | 11 12 30 1 120.5710 339.05 120.5710 339.05
216 | 13 12 30 1 120.5710 339.05 120.5710 339.05
217 | 12 13 14 1 119.9770 402.88 119.9770 402.88
218 | 12 13 18 1 119.9770 402.88 119.9770 402.88
219 | 14 13 18 1 119.9770 402.88 119.9770 402.88
220 | 13 14 15 1 119.9770 402.88 119.9770 402.88
221 | 13 14 31 1 120.5710 339.05 120.5710 339.05
222 | 15 14 31 1 120.5710 339.05 120.5710 339.05
223 | 14 15 16 1 119.9770 402.88 119.9770 402.88
224 | 14 15 32 1 120.5710 339.05 120.5710 339.05
225 | 16 15 32 1 120.5710 339.05 120.5710 339.05
226 | 15 16 17 1 119.9770 402.88 119.9770 402.88
227 | 15 16 33 1 120.5710 339.05 120.5710 339.05
228 | 17 16 33 1 120.5710 339.05 120.5710 339.05
229 | 16 17 18 1 119.9770 402.88 119.9770 402.88
230 | 16 17 34 1 120.5710 339.05 120.5710 339.05
231 | 18 17 34 1 120.5710 339.05 120.5710 339.05
232 | 13 18 17 1 119.9770 402.88 119.9770 402.88
233 | 13 18 19 1 119.9770 402.88 119.9770 402.88
234 | 17 18 19 1 119.9770 402.88 119.9770 402.88
235 | 18 19 20 1 119.9770 402.88 119.9770 402.88
236 | 18 19 35 1 120.5710 339.05 120.5710 339.05
237 | 20 19 35 1 120.5710 339.05 120.5710 339.05
238 | 11 20 19 1 119.9770 402.88 119.9770 402.88
239 | 11 20 36 1 120.5710 339.05 120.5710 339.05
240 | 19 20 36 1 120.5710 339.05 120.5710 339.05
241 |
242 | [ dihedrals ]
243 | ; ai aj ak al fu phi0 kphi mult phi0 kphi mult
244 | 1 2 3 4 9 180.00 14.6440 2 180.00 14.6440 2
245 | 1 2 3 8 9 180.00 14.6440 2 180.00 14.6440 2
246 | 1 10 9 8 9 180.00 14.6440 2 180.00 14.6440 2
247 | 1 10 9 27 9 180.00 14.6440 2 180.00 14.6440 2
248 | 2 1 10 9 9 180.00 14.6440 2 180.00 14.6440 2
249 | 2 1 10 28 9 180.00 14.6440 2 180.00 14.6440 2
250 | 2 3 4 5 9 180.00 14.6440 2 180.00 14.6440 2
251 | 2 3 4 23 9 180.00 14.6440 2 180.00 14.6440 2
252 | 2 3 8 7 9 180.00 14.6440 2 180.00 14.6440 2
253 | 2 3 8 9 9 180.00 14.6440 2 180.00 14.6440 2
254 | 3 2 1 10 9 180.00 14.6440 2 180.00 14.6440 2
255 | 3 2 1 21 9 180.00 14.6440 2 180.00 14.6440 2
256 | 3 4 5 6 9 180.00 14.6440 2 180.00 14.6440 2
257 | 3 4 5 24 9 180.00 14.6440 2 180.00 14.6440 2
258 | 3 8 7 6 9 180.00 14.6440 2 180.00 14.6440 2
259 | 3 8 7 26 9 180.00 14.6440 2 180.00 14.6440 2
260 | 3 8 9 10 9 180.00 14.6440 2 180.00 14.6440 2
261 | 3 8 9 27 9 180.00 14.6440 2 180.00 14.6440 2
262 | 4 3 2 22 9 180.00 14.6440 2 180.00 14.6440 2
263 | 4 3 8 7 9 180.00 14.6440 2 180.00 14.6440 2
264 | 4 3 8 9 9 180.00 14.6440 2 180.00 14.6440 2
265 | 4 5 6 7 9 180.00 14.6440 2 180.00 14.6440 2
266 | 4 5 6 25 9 180.00 14.6440 2 180.00 14.6440 2
267 | 5 4 3 8 9 180.00 14.6440 2 180.00 14.6440 2
268 | 5 6 7 8 9 180.00 14.6440 2 180.00 14.6440 2
269 | 5 6 7 26 9 180.00 14.6440 2 180.00 14.6440 2
270 | 6 5 4 23 9 180.00 14.6440 2 180.00 14.6440 2
271 | 6 7 8 9 9 180.00 14.6440 2 180.00 14.6440 2
272 | 7 6 5 24 9 180.00 14.6440 2 180.00 14.6440 2
273 | 7 8 9 10 9 180.00 14.6440 2 180.00 14.6440 2
274 | 7 8 9 27 9 180.00 14.6440 2 180.00 14.6440 2
275 | 8 3 2 22 9 180.00 14.6440 2 180.00 14.6440 2
276 | 8 3 4 23 9 180.00 14.6440 2 180.00 14.6440 2
277 | 8 7 6 25 9 180.00 14.6440 2 180.00 14.6440 2
278 | 8 9 10 28 9 180.00 14.6440 2 180.00 14.6440 2
279 | 9 8 7 26 9 180.00 14.6440 2 180.00 14.6440 2
280 | 9 10 1 21 9 180.00 14.6440 2 180.00 14.6440 2
281 | 10 1 2 22 9 180.00 14.6440 2 180.00 14.6440 2
282 | 11 12 13 14 9 180.00 14.6440 2 180.00 14.6440 2
283 | 11 12 13 18 9 180.00 14.6440 2 180.00 14.6440 2
284 | 11 20 19 18 9 180.00 14.6440 2 180.00 14.6440 2
285 | 11 20 19 35 9 180.00 14.6440 2 180.00 14.6440 2
286 | 12 11 20 19 9 180.00 14.6440 2 180.00 14.6440 2
287 | 12 11 20 36 9 180.00 14.6440 2 180.00 14.6440 2
288 | 12 13 14 15 9 180.00 14.6440 2 180.00 14.6440 2
289 | 12 13 14 31 9 180.00 14.6440 2 180.00 14.6440 2
290 | 12 13 18 17 9 180.00 14.6440 2 180.00 14.6440 2
291 | 12 13 18 19 9 180.00 14.6440 2 180.00 14.6440 2
292 | 13 12 11 20 9 180.00 14.6440 2 180.00 14.6440 2
293 | 13 12 11 29 9 180.00 14.6440 2 180.00 14.6440 2
294 | 13 14 15 16 9 180.00 14.6440 2 180.00 14.6440 2
295 | 13 14 15 32 9 180.00 14.6440 2 180.00 14.6440 2
296 | 13 18 17 16 9 180.00 14.6440 2 180.00 14.6440 2
297 | 13 18 17 34 9 180.00 14.6440 2 180.00 14.6440 2
298 | 13 18 19 20 9 180.00 14.6440 2 180.00 14.6440 2
299 | 13 18 19 35 9 180.00 14.6440 2 180.00 14.6440 2
300 | 14 13 12 30 9 180.00 14.6440 2 180.00 14.6440 2
301 | 14 13 18 17 9 180.00 14.6440 2 180.00 14.6440 2
302 | 14 13 18 19 9 180.00 14.6440 2 180.00 14.6440 2
303 | 14 15 16 17 9 180.00 14.6440 2 180.00 14.6440 2
304 | 14 15 16 33 9 180.00 14.6440 2 180.00 14.6440 2
305 | 15 14 13 18 9 180.00 14.6440 2 180.00 14.6440 2
306 | 15 16 17 18 9 180.00 14.6440 2 180.00 14.6440 2
307 | 15 16 17 34 9 180.00 14.6440 2 180.00 14.6440 2
308 | 16 15 14 31 9 180.00 14.6440 2 180.00 14.6440 2
309 | 16 17 18 19 9 180.00 14.6440 2 180.00 14.6440 2
310 | 17 16 15 32 9 180.00 14.6440 2 180.00 14.6440 2
311 | 17 18 19 20 9 180.00 14.6440 2 180.00 14.6440 2
312 | 17 18 19 35 9 180.00 14.6440 2 180.00 14.6440 2
313 | 18 13 12 30 9 180.00 14.6440 2 180.00 14.6440 2
314 | 18 13 14 31 9 180.00 14.6440 2 180.00 14.6440 2
315 | 18 17 16 33 9 180.00 14.6440 2 180.00 14.6440 2
316 | 18 19 20 36 9 180.00 14.6440 2 180.00 14.6440 2
317 | 19 18 17 34 9 180.00 14.6440 2 180.00 14.6440 2
318 | 19 20 11 29 9 180.00 14.6440 2 180.00 14.6440 2
319 | 20 11 12 30 9 180.00 14.6440 2 180.00 14.6440 2
320 | 21 1 2 22 9 180.00 14.6440 2 180.00 14.6440 2
321 | 21 1 10 28 9 180.00 14.6440 2 180.00 14.6440 2
322 | 23 4 5 24 9 180.00 14.6440 2 180.00 14.6440 2
323 | 24 5 6 25 9 180.00 14.6440 2 180.00 14.6440 2
324 | 25 6 7 26 9 180.00 14.6440 2 180.00 14.6440 2
325 | 27 9 10 28 9 180.00 14.6440 2 180.00 14.6440 2
326 | 29 11 12 30 9 180.00 14.6440 2 180.00 14.6440 2
327 | 29 11 20 36 9 180.00 14.6440 2 180.00 14.6440 2
328 | 31 14 15 32 9 180.00 14.6440 2 180.00 14.6440 2
329 | 32 15 16 33 9 180.00 14.6440 2 180.00 14.6440 2
330 | 33 16 17 34 9 180.00 14.6440 2 180.00 14.6440 2
331 | 35 19 20 36 9 180.00 14.6440 2 180.00 14.6440 2
332 |
333 | [ dihedrals ]
334 | ; ai aj ak al fu xi0 kxi xi0 kxi
335 | 1 2 10 21 2 0.00 9.0291 0.00 9.0291
336 | 2 3 1 22 2 0.00 9.0291 0.00 9.0291
337 | 3 8 2 4 2 0.00 21.0790 0.00 21.0790
338 | 4 5 3 23 2 0.00 9.0291 0.00 9.0291
339 | 5 6 4 24 2 0.00 9.0291 0.00 9.0291
340 | 6 7 5 25 2 0.00 9.0291 0.00 9.0291
341 | 8 7 3 9 2 0.00 21.0790 0.00 21.0790
342 | 7 8 6 26 2 0.00 9.0291 0.00 9.0291
343 | 9 10 8 27 2 0.00 9.0291 0.00 9.0291
344 | 10 9 1 28 2 0.00 9.0291 0.00 9.0291
345 | 11 20 12 29 2 0.00 9.0291 0.00 9.0291
346 | 12 13 11 30 2 0.00 9.0291 0.00 9.0291
347 | 13 14 12 18 2 0.00 21.0790 0.00 21.0790
348 | 14 15 13 31 2 0.00 9.0291 0.00 9.0291
349 | 15 16 14 32 2 0.00 9.0291 0.00 9.0291
350 | 18 19 13 17 2 0.00 21.0790 0.00 21.0790
351 | 16 17 15 33 2 0.00 9.0291 0.00 9.0291
352 | 17 16 18 34 2 0.00 9.0291 0.00 9.0291
353 | 19 20 18 35 2 0.00 9.0291 0.00 9.0291
354 | 20 19 11 36 2 0.00 9.0291 0.00 9.0291
355 |
356 |
357 | #ifdef POSRES_LIGAND
358 | [ position_restraints ]
359 | ; atom type fx fy fz
360 | 1 1 1000 1000 1000
361 | 2 1 1000 1000 1000
362 | 3 1 1000 1000 1000
363 | 4 1 1000 1000 1000
364 | 5 1 1000 1000 1000
365 | 6 1 1000 1000 1000
366 | 7 1 1000 1000 1000
367 | 8 1 1000 1000 1000
368 | 9 1 1000 1000 1000
369 | 10 1 1000 1000 1000
370 | 11 1 1000 1000 1000
371 | 12 1 1000 1000 1000
372 | 13 1 1000 1000 1000
373 | 14 1 1000 1000 1000
374 | 15 1 1000 1000 1000
375 | 16 1 1000 1000 1000
376 | 17 1 1000 1000 1000
377 | 18 1 1000 1000 1000
378 | 19 1 1000 1000 1000
379 | 20 1 1000 1000 1000
380 | #endif
381 |
--------------------------------------------------------------------------------
/examples/gromacs/unitcell_whole.g96:
--------------------------------------------------------------------------------
1 | TITLE
2 |
3 | END
4 | POSITION
5 | 1 LIG C 1 0.696250379 0.159491107 0.597945929
6 | 1 LIG C1 2 0.772837758 0.245488673 0.520257413
7 | 1 LIG C2 3 0.806519985 0.211185798 0.387908250
8 | 1 LIG C3 4 0.883022904 0.297890544 0.306874543
9 | 1 LIG C4 5 0.916235626 0.261567384 0.176771417
10 | 1 LIG C5 6 0.872784317 0.139413029 0.124627687
11 | 1 LIG C6 7 0.796772480 0.052692786 0.202105612
12 | 1 LIG C7 8 0.762530506 0.086980678 0.334672570
13 | 1 LIG C8 9 0.685729742 0.000964948 0.415279627
14 | 1 LIG C9 10 0.653187573 0.037162747 0.545608401
15 | 1 LIG C10 11 0.463161379 0.457676202 0.124709129
16 | 1 LIG C11 12 0.386604607 0.544187307 0.202052191
17 | 1 LIG C12 13 0.353085220 0.509858549 0.334774256
18 | 1 LIG C13 14 0.276272297 0.596043110 0.415312976
19 | 1 LIG C14 15 0.243097499 0.559585333 0.545448482
20 | 1 LIG C15 16 0.286702573 0.437465638 0.597968161
21 | 1 LIG C16 17 0.362549573 0.350700080 0.520177841
22 | 1 LIG C17 18 0.396925867 0.385152072 0.387947112
23 | 1 LIG C18 19 0.473605514 0.299005657 0.306869596
24 | 1 LIG C19 20 0.506069362 0.335320830 0.176671669
25 | 1 LIG H 21 0.671299517 0.188004538 0.699164808
26 | 1 LIG H1 22 0.806335211 0.340905368 0.560037971
27 | 1 LIG H2 23 0.917429507 0.392934293 0.346936822
28 | 1 LIG H3 24 0.976527929 0.328179300 0.116840400
29 | 1 LIG H4 25 0.898406923 0.111048684 0.023076344
30 | 1 LIG H5 26 0.762473583 -0.042025328 0.161898747
31 | 1 LIG H6 27 0.651356399 -0.093947887 0.375068694
32 | 1 LIG H7 28 0.592499435 -0.029937029 0.605925918
33 | 1 LIG H8 29 0.488060594 0.485954314 0.023036707
34 | 1 LIG H9 30 0.353015065 0.639076769 0.161891058
35 | 1 LIG H10 31 0.241957545 0.690950751 0.375063717
36 | 1 LIG H11 32 0.182933033 0.626122892 0.606041372
37 | 1 LIG H12 33 0.260952055 0.409006685 0.699119568
38 | 1 LIG H13 34 0.396926105 0.255959421 0.560100317
39 | 1 LIG H14 35 0.508044183 0.204050004 0.346923292
40 | 1 LIG H15 36 0.567036867 0.268886328 0.116893314
41 | END
42 | BOX
43 | 0.81940 0.59680 0.72231 0.00000 0.00000 0.00000 0.00000 0.34004 0.00000
44 | END
45 |
--------------------------------------------------------------------------------
/examples/tinker/POSCAR:
--------------------------------------------------------------------------------
1 | Generated using phonoLAMMPS
2 | 1.0
3 | 8.7954010000 0.0000000000 0.0000000000
4 | 0.0000000000 8.7954010000 0.0000000000
5 | 0.0000000000 0.0000000000 30.0676020000
6 | O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H O C O C O C O C O C H
7 | 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20 1 2 1 2 1 2 1 2 1 2 20
8 | Direct
9 | -0.122397261932685 0.121784669056021 -0.343548281635496
10 | -0.202313459045244 0.260779468724621 -0.348562848477241
11 | -0.368651071167761 0.230969457788224 -0.338178748009236
12 | -0.451214674578226 0.368990453078831 -0.341629172821963
13 | -0.597342633951539 0.348925762452445 -0.360906466701269
14 | -0.593318258030532 0.396366464701268 -0.409648597849606
15 | -0.498923130395078 0.295623474131538 -0.433995201878753
16 | -0.487522740577718 0.336287225562541 -0.479607419307998
17 | -0.369224325303644 0.234121104881972 -0.501342607900690
18 | -0.224650018799598 0.271677095791312 -0.483438818965343
19 | -0.108950916507388 0.165781412354025 -0.494553972079316
20 | 0.040281733601458 0.221893123463046 -0.474785950672089
21 | 0.028332306849909 0.238057252875679 -0.427925213324295
22 | 0.062703565192764 0.104215828249332 -0.403694182196505
23 | 0.034397635764418 0.131184354186921 -0.354311461219954
24 | -0.155523778847605 0.347314579517182 -0.325476571094695
25 | -0.191279510735213 0.303424255471695 -0.383063105597846
26 | -0.381862293714636 0.185140279562012 -0.304069476508303
27 | -0.413606952087801 0.144377271712796 -0.361379667058251
28 | -0.678875698788492 0.422418034152167 -0.342796209687756
29 | -0.639070691603487 0.230786862361364 -0.356734467883405
30 | -0.550030180545492 0.514279223880753 -0.412582586399807
31 | -0.709784238376397 0.393930418863222 -0.423644592608350
32 | -0.454190206904722 0.457406546898771 -0.483117476411987
33 | -0.599568569983336 0.321089510302032 -0.495962830690655
34 | -0.396722673588163 0.113045101638913 -0.495123954347939
35 | -0.368210613705958 0.251646627595490 -0.537866771018188
36 | -0.137897635366483 0.051245645309407 -0.481919775311646
37 | -0.098509891703630 0.157554158133324 -0.531208408306056
38 | 0.135926946366630 0.145370972852744 -0.483632050204735
39 | 0.067841022825452 0.334740621831796 -0.489048079058649
40 | 0.183959662555465 0.074620929733619 -0.408919740257304
41 | -0.006664164601478 0.007713008195988 -0.415731656950894
42 | 0.094047104844907 0.041964431183979 -0.335034632958092
43 | 0.082784514316061 0.241206626053775 -0.343261128705907
44 | -0.121784782751804 -0.122397261932685 -0.093548265006301
45 | -0.260779582420404 -0.202313459045244 -0.098562865106436
46 | -0.230969571484006 -0.368651071167761 -0.088178731380042
47 | -0.368990566774613 -0.451214674578226 -0.091629189451157
48 | -0.348925876148228 -0.597342520255756 -0.110906450072074
49 | -0.396366578397051 -0.593318258030532 -0.159648614478800
50 | -0.295623587827320 -0.498923130395078 -0.183995185249559
51 | -0.336287339258324 -0.487522740577718 -0.229607402678804
52 | -0.234121218577754 -0.369224325303644 -0.251342591271495
53 | -0.271677209487094 -0.224650018799598 -0.233438835594538
54 | -0.165781526049807 -0.108950916507388 -0.244553955450122
55 | -0.221893237158829 0.040281733601458 -0.224785934042894
56 | -0.238057366571462 0.028332306849909 -0.177925196695101
57 | -0.104215941945114 0.062703565192764 -0.153694165567311
58 | -0.131184467882704 0.034397635764418 -0.104311444590759
59 | -0.347314693212964 -0.155523778847605 -0.075476587723890
60 | -0.303424369167477 -0.191279510735213 -0.133063088968651
61 | -0.185140393257795 -0.381862293714636 -0.054069493137497
62 | -0.144377385408579 -0.413606952087801 -0.111379683687445
63 | -0.422418147847949 -0.678875698788492 -0.092796193058562
64 | -0.230786862361364 -0.639070691603487 -0.106734484512599
65 | -0.514279223880753 -0.550030180545492 -0.162582569770612
66 | -0.393930532559004 -0.709784238376397 -0.173644609237544
67 | -0.457406660594554 -0.454190206904722 -0.233117493041181
68 | -0.321089623997814 -0.599568569983336 -0.245962814061461
69 | -0.113045215334696 -0.396722673588163 -0.245123970977133
70 | -0.251646741291273 -0.368210613705958 -0.287866787647382
71 | -0.051245759005189 -0.137897635366483 -0.231919791940841
72 | -0.157554271829107 -0.098509891703630 -0.281208391676862
73 | -0.145371086548527 0.135926946366630 -0.233632033575541
74 | -0.334740735527579 0.067841022825452 -0.239048062429455
75 | -0.074621043429401 0.183959662555465 -0.158919723628110
76 | -0.007713121891770 -0.006664164601478 -0.165731640321699
77 | -0.041964544879762 0.094047104844907 -0.085034616328898
78 | -0.241206739749558 0.082784514316061 -0.093261145335102
79 | 0.122397148236902 -0.121784782751804 0.156451718364504
80 | 0.202313345349462 -0.260779582420404 0.151437151522759
81 | 0.368650957471979 -0.230969571484006 0.161821251990764
82 | 0.451214560882443 -0.368990566774613 0.158370827178037
83 | 0.597342520255756 -0.348925876148228 0.139093533298731
84 | 0.593318144334749 -0.396366578397051 0.090351402150394
85 | 0.498923016699295 -0.295623587827320 0.066004798121247
86 | 0.487522626881935 -0.336287339258324 0.020392580692002
87 | 0.369224211607862 -0.234121218577754 -0.001342607900690
88 | 0.224649905103815 -0.271677209487094 0.016561181034657
89 | 0.108950802811606 -0.165781526049807 0.005446027920684
90 | -0.040281847297241 -0.221893237158829 0.025214049327911
91 | -0.028332420545692 -0.238057366571462 0.072074786675705
92 | -0.062703678888546 -0.104215941945114 0.096305817803495
93 | -0.034397749460201 -0.131184467882704 0.145688538780046
94 | 0.155523665151822 -0.347314693212964 0.174523428905305
95 | 0.191279397039430 -0.303424369167477 0.116936894402154
96 | 0.381862180018853 -0.185140393257795 0.195930523491697
97 | 0.413606838392019 -0.144377385408579 0.138620332941749
98 | 0.678875585092709 -0.422418147847949 0.157203790312244
99 | 0.639070577907704 -0.230786862361364 0.143265532116595
100 | 0.550030066849709 -0.514279223880753 0.087417413600193
101 | 0.709784124680614 -0.393930532559004 0.076355407391650
102 | 0.454190093208940 -0.457406660594554 0.016882523588013
103 | 0.599568456287553 -0.321089623997814 0.004037169309345
104 | 0.396722559892380 -0.113045215334696 0.004876045652061
105 | 0.368210500010176 -0.251646741291273 -0.037866771018188
106 | 0.137897521670700 -0.051245759005189 0.018080224688354
107 | 0.098509778007848 -0.157554271829107 -0.031208408306056
108 | -0.135927060062412 -0.145371086548527 0.016367949795265
109 | -0.067841136521234 -0.334740735527579 0.010951920941351
110 | -0.183959776251248 -0.074621043429401 0.091080259742696
111 | 0.006664050905695 -0.007713121891770 0.084268343049106
112 | -0.094047218540690 -0.041964544879762 0.164965367041908
113 | -0.082784628011844 -0.241206739749558 0.156738871294093
114 | 0.121784669056021 0.122397148236902 0.406451701735310
115 | 0.260779468724621 0.202313345349462 0.401437134893564
116 | 0.230969457788224 0.368650957471979 0.411821268619958
117 | 0.368990453078831 0.451214560882443 0.408370810548843
118 | 0.348925762452445 0.597342520255756 0.389093549927926
119 | 0.396366464701268 0.593318144334749 0.340351385521200
120 | 0.295623474131538 0.498923016699295 0.316004814750441
121 | 0.336287225562541 0.487522626881935 0.270392597321196
122 | 0.234121104881972 0.369224211607862 0.248657408728505
123 | 0.271677095791312 0.224649905103815 0.266561164405462
124 | 0.165781412354025 0.108950802811606 0.255446044549878
125 | 0.221893123463046 -0.040281847297241 0.275214065957106
126 | 0.238057252875679 -0.028332420545692 0.322074803304899
127 | 0.104215828249332 -0.062703678888546 0.346305834432689
128 | 0.131184354186921 -0.034397749460201 0.395688555409241
129 | 0.347314579517182 0.155523665151822 0.424523412276110
130 | 0.303424255471695 0.191279397039430 0.366936911031349
131 | 0.185140279562012 0.381862180018853 0.445930506862503
132 | 0.144377271712796 0.413606838392019 0.388620316312555
133 | 0.422418034152167 0.678875585092709 0.407203806941438
134 | 0.230786748665581 0.639070577907704 0.393265515487401
135 | 0.514279110184971 0.550030066849709 0.337417430229388
136 | 0.393930418863222 0.709784124680614 0.326355390762456
137 | 0.457406546898771 0.454190093208940 0.266882506958819
138 | 0.321089510302032 0.599568456287553 0.254037185938539
139 | 0.113045101638913 0.396722559892380 0.254876029022867
140 | 0.251646627595490 0.368210500010176 0.212133212352618
141 | 0.051245645309407 0.137897521670700 0.268080208059159
142 | 0.157554158133324 0.098509778007848 0.218791608323138
143 | 0.145370972852744 -0.135927060062412 0.266367966424459
144 | 0.334740621831796 -0.067841136521234 0.260951904312156
145 | 0.074620929733619 -0.183959776251248 0.341080276371890
146 | 0.007713008195988 0.006664050905695 0.334268359678301
147 | 0.041964431183979 -0.094047218540690 0.414965383671102
148 | 0.241206626053775 -0.082784628011844 0.406738854664898
149 | -0.316631271274613 -0.205998453055182 0.400167063539021
150 | -0.245354248203123 -0.275115142561436 0.437277172951804
151 | -0.239429219884346 -0.445397543557139 0.429136317555354
152 | -0.155542083868604 -0.472470442223157 0.389642745703498
153 | -0.182100736509910 -0.620110669200870 0.372362352009316
154 | -0.099226629917158 -0.638294490495658 0.328283246532264
155 | -0.171884260876792 -0.561223644038515 0.292615021310978
156 | -0.160962075521059 -0.400602314777916 0.295476639606976
157 | -0.196196853332782 -0.333256778173047 0.250018741102134
158 | -0.195896923858276 -0.172279126329772 0.253329979557399
159 | -0.342515594229302 -0.111576038431903 0.262210867364813
160 | -0.324665924839584 0.039763621920138 0.286242580968047
161 | -0.275528085643850 0.012715736326291 0.330469054366224
162 | -0.396173181870844 0.015472517967060 0.361754189775427
163 | -0.338014719283407 -0.047403182640564 0.405601750349097
164 | -0.129334978587105 -0.228870861032942 0.441700871256710
165 | -0.311570217207834 -0.251034603197739 0.467839503795481
166 | -0.183646544370177 -0.504169281195934 0.457366603429166
167 | -0.356427864971705 -0.490744765360897 0.426150811760778
168 | -0.141015855900146 -0.706045238869723 0.396555900932838
169 | -0.305574583808061 -0.639205648497436 0.367424246203605
170 | 0.020667278274180 -0.601683084148182 0.330831105187570
171 | -0.095408157058445 -0.760534056377873 0.319836247666176
172 | -0.044568291997147 -0.366770884010860 0.305629960114545
173 | -0.242060026597991 -0.357351870596918 0.320637342479124
174 | -0.106529651121080 -0.367878508324976 0.226121690715475
175 | -0.306086897004469 -0.375268279411024 0.236709033197925
176 | -0.411261294396924 -0.190940583607274 0.282608603107092
177 | -0.402743433755891 -0.095006583554292 0.230152673964488
178 | -0.237724124232653 0.109554868504574 0.269115874288877
179 | -0.431840572135369 0.106338983293655 0.285890806988865
180 | -0.435976142531762 0.134110997326898 0.366085961893469
181 | -0.493318383095893 -0.053598238443023 0.349862785864998
182 | -0.229946309440582 0.008742864594804 0.415079692753682
183 | -0.422072057885706 -0.026728627836298 0.432392812702523
184 | 0.205998339359399 -0.316631271274613 -0.349832919831784
185 | 0.275115028865654 -0.245354248203123 -0.312722810419002
186 | 0.445397429861356 -0.239429219884346 -0.320863699073840
187 | 0.472470328527375 -0.155542083868604 -0.360357237667307
188 | 0.620110555505087 -0.182100736509910 -0.377637664619879
189 | 0.638294376799875 -0.099226629917158 -0.421716736838541
190 | 0.561223530342733 -0.171884260876792 -0.457384995318217
191 | 0.400602201082134 -0.160962075521059 -0.454523377022218
192 | 0.333256664477265 -0.196196853332782 -0.499981242268672
193 | 0.172279012633989 -0.195896923858276 -0.496670037071796
194 | 0.111575924736121 -0.342515594229302 -0.487789116005992
195 | -0.039763735615920 -0.324665924839584 -0.463757402402759
196 | -0.012715850022074 -0.275528085643850 -0.419530962262970
197 | -0.015472631662843 -0.396173181870844 -0.388245793595379
198 | 0.047403068944781 -0.338014719283407 -0.344398233021709
199 | 0.228870747337160 -0.129334978587105 -0.308299145372484
200 | 0.251034489501957 -0.311570217207834 -0.282160479575325
201 | 0.504169167500152 -0.183646544370177 -0.292633379941639
202 | 0.490744651665115 -0.356427864971705 -0.323849171610027
203 | 0.706045011478158 -0.141015855900146 -0.353444115696356
204 | 0.639205534801654 -0.305574583808061 -0.382575737167201
205 | 0.601682970452399 0.020667278274180 -0.419168911441624
206 | 0.760533942682090 -0.095408157058445 -0.430163735704630
207 | 0.366770770315077 -0.044568291997147 -0.444370056514650
208 | 0.357351756901135 -0.242060026597991 -0.429362674150070
209 | 0.367878394629193 -0.106529651121080 -0.523878325913719
210 | 0.375268165715241 -0.306086897004469 -0.513290983431269
211 | 0.190940469911491 -0.411261294396924 -0.467391413522103
212 | 0.095006469858509 -0.402743433755891 -0.519847309406317
213 | -0.109554982200357 -0.237724124232653 -0.480884142340317
214 | -0.106339210685221 -0.431840572135369 -0.464109209640330
215 | -0.134111111022681 -0.435976142531762 -0.383914054735725
216 | 0.053598124747240 -0.493318383095893 -0.400137197505807
217 | -0.008742978290586 -0.229946309440582 -0.334920290617123
218 | 0.026728400444732 -0.422072057885706 -0.317607170668283
219 | 0.316631157578830 0.205998339359399 -0.099832936460979
220 | 0.245354134507341 0.275115028865654 -0.062722827048196
221 | 0.239429106188564 0.445397429861356 -0.070863682444646
222 | 0.155541970172821 0.472470328527375 -0.110357254296502
223 | 0.182100622814128 0.620110555505087 -0.127637647990684
224 | 0.099226516221375 0.638294376799875 -0.171716753467736
225 | 0.171884147181010 0.561223530342733 -0.207384978689022
226 | 0.160961961825277 0.400602201082134 -0.204523360393024
227 | 0.196196739636999 0.333256664477265 -0.249981258897866
228 | 0.195896810162493 0.172279012633989 -0.246670020442601
229 | 0.342515480533520 0.111575924736121 -0.237789132635187
230 | 0.324665811143801 -0.039763735615920 -0.213757419031953
231 | 0.275527971948067 -0.012715850022074 -0.169530945633775
232 | 0.396173068175061 -0.015472631662843 -0.138245810224573
233 | 0.338014605587625 0.047403182640564 -0.094398249650903
234 | 0.129334864891322 0.228870747337160 -0.058299128743290
235 | 0.311570103512051 0.251034489501957 -0.032160496204519
236 | 0.183646430674394 0.504169167500152 -0.042633396570834
237 | 0.356427751275923 0.490744651665115 -0.073849188239222
238 | 0.141015742204363 0.706045125173940 -0.103444132325551
239 | 0.305574470112278 0.639205534801654 -0.132575753796395
240 | -0.020667391969962 0.601682970452399 -0.169168894812430
241 | 0.095408043362662 0.760533942682090 -0.180163752333824
242 | 0.044568178301365 0.366770770315077 -0.194370039885455
243 | 0.242059912902209 0.357351756901135 -0.179362657520876
244 | 0.106529537425298 0.367878394629193 -0.273878309284525
245 | 0.306086783308686 0.375268165715241 -0.263290966802075
246 | 0.411261180701141 0.190940469911491 -0.217391396892908
247 | 0.402743320060109 0.095006469858509 -0.269847326035512
248 | 0.237724010536870 -0.109554982200357 -0.230884125711123
249 | 0.431840458439587 -0.106339096989438 -0.214109193011135
250 | 0.435976028835979 -0.134111111022681 -0.133914038106531
251 | 0.493318269400110 0.053598124747240 -0.150137214135002
252 | 0.229946195744799 -0.008742978290586 -0.084920307246318
253 | 0.422071944189924 0.026728514140515 -0.067607187297477
254 | -0.205998453055182 0.316631157578830 0.150167080168216
255 | -0.275115142561436 0.245354134507341 0.187277189580998
256 | -0.445397543557139 0.239429106188564 0.179136300926160
257 | -0.472470442223157 0.155541970172821 0.139642729074304
258 | -0.620110669200870 0.182100622814128 0.122362335380121
259 | -0.638294490495658 0.099226516221375 0.078283263161459
260 | -0.561223644038515 0.171884147181010 0.042615004681783
261 | -0.400602314777916 0.160961961825277 0.045476622977782
262 | -0.333256778173047 0.196196739636999 0.000018757731328
263 | -0.172279126329772 0.195896810162493 0.003329962928204
264 | -0.111576038431903 0.342515480533520 0.012210883994008
265 | 0.039763621920138 0.324665811143801 0.036242597597241
266 | 0.012715736326291 0.275527971948067 0.080469037737030
267 | 0.015472517967060 0.396173068175061 0.111754206404621
268 | -0.047403182640564 0.338014605587625 0.155601766978291
269 | -0.228870861032942 0.129334864891322 0.191700854627516
270 | -0.251034603197739 0.311570103512051 0.217839520424675
271 | -0.504169281195934 0.183646430674394 0.207366620058360
272 | -0.490744765360897 0.356427751275923 0.176150828389973
273 | -0.706045238869723 0.141015742204363 0.146555884303643
274 | -0.639205648497436 0.305574470112278 0.117424262832799
275 | -0.601683084148182 -0.020667391969962 0.080831088558376
276 | -0.760534056377873 0.095408043362662 0.069836264295370
277 | -0.366770884010860 0.044568178301365 0.055629943485350
278 | -0.357351870596918 0.242059912902209 0.070637325849930
279 | -0.367878508324976 0.106529537425298 -0.023878325913719
280 | -0.375268279411024 0.306086783308686 -0.013290983431269
281 | -0.190940583607274 0.411261180701141 0.032608586477897
282 | -0.095006583554292 0.402743320060109 -0.019847309406317
283 | 0.109554868504574 0.237724010536870 0.019115857659683
284 | 0.106339096989438 0.431840458439587 0.035890823618059
285 | 0.134110997326898 0.435976028835979 0.116085945264275
286 | -0.053598238443023 0.493318269400110 0.099862802494193
287 | 0.008742864594804 0.229946195744799 0.165079709382877
288 | -0.026728627836298 0.422071944189924 0.182392829331717
289 |
--------------------------------------------------------------------------------
/examples/tinker/api_tinker.py:
--------------------------------------------------------------------------------
1 | # API example to calculate force constants with tinker (on development)
2 | # Only works for Orthorhombic crystals
3 |
4 | from phonolammps import PhonoTinker
5 | import numpy as np
6 |
7 | phtinker = PhonoTinker(txyz_input_file='structure.txyz',
8 | key_input_file='structure.key',
9 | force_field_file='mm3.prm',
10 | supercell_matrix=np.diag([2, 2, 2]),
11 | show_progress=True)
12 |
13 | phtinker.write_force_constants()
14 | print('Force constants generated')
15 |
16 | phtinker.write_unitcell_POSCAR()
17 | print('POSCAR generated')
18 |
19 | #phtinker.plot_phonon_dispersion_bands()
20 |
21 |
--------------------------------------------------------------------------------
/examples/tinker/structure.key:
--------------------------------------------------------------------------------
1 |
2 | #periodic cell specifications
3 | a-axis 8.795401
4 | b-axis 8.795401
5 | c-axis 30.067602
6 | ALPHA 90.
7 | BETA 90.
8 | GAMMA 90.
9 |
10 |
--------------------------------------------------------------------------------
/examples/tinker/structure.txyz:
--------------------------------------------------------------------------------
1 | 280 2214084 MM2 parameters
2 | 8.795401 8.795401 30.067602 90.000000 90.000000 90.000000
3 | 1 O -1.076533 1.071145 -10.329673 6 2 15
4 | 2 C -1.779428 2.293660 -10.480449 1 1 3 16 17
5 | 3 C -3.242434 2.031469 -10.168224 1 2 4 18 19
6 | 4 O -3.968614 3.245419 -10.271970 6 3 5
7 | 5 C -5.253868 3.068942 -10.851592 1 4 6 20 21
8 | 6 C -5.218472 3.486202 -12.317151 1 5 7 22 23
9 | 7 O -4.388229 2.600127 -13.049195 6 6 8
10 | 8 C -4.287958 2.957781 -14.420645 1 7 9 24 25
11 | 9 C -3.247476 2.059189 -15.074170 1 8 10 26 27
12 | 10 O -1.975887 2.389509 -14.535846 6 9 11
13 | 11 C -0.958267 1.458114 -14.870052 1 10 12 28 29
14 | 12 C 0.354294 1.951639 -14.275675 1 11 13 30 31
15 | 13 O 0.249194 2.093809 -12.866685 6 12 14
16 | 14 C 0.551503 0.916620 -12.138116 1 13 15 32 33
17 | 15 C 0.302541 1.153819 -10.653296 1 1 14 34 35
18 | 16 H -1.367894 3.054771 -9.786300 5 2
19 | 17 H -1.682380 2.668738 -11.517789 5 2
20 | 18 H -3.358632 1.628383 -9.142640 5 3
21 | 19 H -3.637839 1.269856 -10.865820 5 3
22 | 20 H -5.970984 3.715336 -10.307060 5 5
23 | 21 H -5.620883 2.029863 -10.726150 5 5
24 | 22 H -4.837736 4.523292 -12.405369 5 6
25 | 23 H -6.242837 3.464776 -12.737977 5 6
26 | 24 H -3.994785 4.023074 -14.526184 5 8
27 | 25 H -5.273446 2.824111 -14.912413 5 8
28 | 26 H -3.489335 0.994277 -14.887190 5 9
29 | 27 H -3.238560 2.213333 -16.172364 5 9
30 | 28 H -1.212865 0.450726 -14.490172 5 11
31 | 29 H -0.866434 1.385752 -15.972163 5 11
32 | 30 H 1.195532 1.278596 -14.541656 5 12
33 | 31 H 0.596689 2.944178 -14.704503 5 12
34 | 32 H 1.617999 0.656321 -12.295236 5 14
35 | 33 H -0.058614 0.067839 -12.500054 5 14
36 | 34 H 0.827182 0.369094 -10.073688 5 15
37 | 35 H 0.728123 2.121509 -10.321039 5 15
38 | 36 O -1.071146 -1.076533 -2.812772 6 37 50
39 | 37 C -2.293661 -1.779428 -2.963549 1 36 38 51 52
40 | 38 C -2.031470 -3.242434 -2.651323 1 37 39 53 54
41 | 39 O -3.245420 -3.968614 -2.755070 6 38 40
42 | 40 C -3.068943 -5.253867 -3.334691 1 39 41 55 56
43 | 41 C -3.486203 -5.218472 -4.800251 1 40 42 57 58
44 | 42 O -2.600128 -4.388229 -5.532294 6 41 43
45 | 43 C -2.957782 -4.287958 -6.903744 1 42 44 59 60
46 | 44 C -2.059190 -3.247476 -7.557269 1 43 45 61 62
47 | 45 O -2.389510 -1.975887 -7.018946 6 44 46
48 | 46 C -1.458115 -0.958267 -7.353151 1 45 47 63 64
49 | 47 C -1.951640 0.354294 -6.758774 1 46 48 65 66
50 | 48 O -2.093810 0.249194 -5.349784 6 47 49
51 | 49 C -0.916621 0.551503 -4.621215 1 48 50 67 68
52 | 50 C -1.153820 0.302541 -3.136395 1 36 49 69 70
53 | 51 H -3.054772 -1.367894 -2.269400 5 37
54 | 52 H -2.668739 -1.682380 -4.000888 5 37
55 | 53 H -1.628384 -3.358632 -1.625740 5 38
56 | 54 H -1.269857 -3.637839 -3.348920 5 38
57 | 55 H -3.715337 -5.970984 -2.790159 5 40
58 | 56 H -2.029863 -5.620883 -3.209250 5 40
59 | 57 H -4.523292 -4.837736 -4.888468 5 41
60 | 58 H -3.464777 -6.242837 -5.221077 5 41
61 | 59 H -4.023075 -3.994785 -7.009284 5 43
62 | 60 H -2.824112 -5.273446 -7.395512 5 43
63 | 61 H -0.994278 -3.489335 -7.370290 5 44
64 | 62 H -2.213334 -3.238560 -8.655464 5 44
65 | 63 H -0.450727 -1.212865 -6.973272 5 46
66 | 64 H -1.385753 -0.866434 -8.455262 5 46
67 | 65 H -1.278597 1.195532 -7.024755 5 47
68 | 66 H -2.944179 0.596689 -7.187602 5 47
69 | 67 H -0.656322 1.617999 -4.778335 5 49
70 | 68 H -0.067840 -0.058614 -4.983153 5 49
71 | 69 H -0.369095 0.827182 -2.556787 5 50
72 | 70 H -2.121510 0.728123 -2.804139 5 50
73 | 71 O 1.076532 -1.071146 4.704128 6 72 85
74 | 72 C 1.779427 -2.293661 4.553352 1 71 73 86 87
75 | 73 C 3.242433 -2.031470 4.865577 1 72 74 88 89
76 | 74 O 3.968613 -3.245420 4.761831 6 73 75
77 | 75 C 5.253867 -3.068943 4.182209 1 74 76 90 91
78 | 76 C 5.218471 -3.486203 2.716650 1 75 77 92 93
79 | 77 O 4.388228 -2.600128 1.984606 6 76 78
80 | 78 C 4.287957 -2.957782 0.613156 1 77 79 94 95
81 | 79 C 3.247475 -2.059190 -0.040369 1 78 80 96 97
82 | 80 O 1.975886 -2.389510 0.497955 6 79 81
83 | 81 C 0.958266 -1.458115 0.163749 1 80 82 98 99
84 | 82 C -0.354295 -1.951640 0.758126 1 81 83 100 101
85 | 83 O -0.249195 -2.093810 2.167116 6 82 84
86 | 84 C -0.551504 -0.916621 2.895685 1 83 85 102 103
87 | 85 C -0.302542 -1.153820 4.380505 1 71 84 104 105
88 | 86 H 1.367893 -3.054772 5.247501 5 72
89 | 87 H 1.682379 -2.668739 3.516012 5 72
90 | 88 H 3.358631 -1.628384 5.891161 5 73
91 | 89 H 3.637838 -1.269857 4.167981 5 73
92 | 90 H 5.970983 -3.715337 4.726741 5 75
93 | 91 H 5.620882 -2.029863 4.307651 5 75
94 | 92 H 4.837735 -4.523292 2.628432 5 76
95 | 93 H 6.242836 -3.464777 2.295824 5 76
96 | 94 H 3.994784 -4.023075 0.507617 5 78
97 | 95 H 5.273445 -2.824112 0.121388 5 78
98 | 96 H 3.489334 -0.994278 0.146611 5 79
99 | 97 H 3.238559 -2.213334 -1.138563 5 79
100 | 98 H 1.212864 -0.450727 0.543629 5 81
101 | 99 H 0.866433 -1.385753 -0.938362 5 81
102 | 100 H -1.195533 -1.278597 0.492145 5 82
103 | 101 H -0.596690 -2.944179 0.329298 5 82
104 | 102 H -1.618000 -0.656322 2.738565 5 84
105 | 103 H 0.058613 -0.067840 2.533747 5 84
106 | 104 H -0.827183 -0.369095 4.960113 5 85
107 | 105 H -0.728124 -2.121510 4.712762 5 85
108 | 106 O 1.071145 1.076532 12.221028 6 107 120
109 | 107 C 2.293660 1.779427 12.070252 1 106 108 121 122
110 | 108 C 2.031469 3.242433 12.382478 1 107 109 123 124
111 | 109 O 3.245419 3.968613 12.278731 6 108 110
112 | 110 C 3.068942 5.253867 11.699110 1 109 111 125 126
113 | 111 C 3.486202 5.218471 10.233550 1 110 112 127 128
114 | 112 O 2.600127 4.388228 9.501507 6 111 113
115 | 113 C 2.957781 4.287957 8.130057 1 112 114 129 130
116 | 114 C 2.059189 3.247475 7.476532 1 113 115 131 132
117 | 115 O 2.389509 1.975886 8.014855 6 114 116
118 | 116 C 1.458114 0.958266 7.680650 1 115 117 133 134
119 | 117 C 1.951639 -0.354295 8.275027 1 116 118 135 136
120 | 118 O 2.093809 -0.249195 9.684017 6 117 119
121 | 119 C 0.916620 -0.551504 10.412586 1 118 120 137 138
122 | 120 C 1.153819 -0.302542 11.897406 1 106 119 139 140
123 | 121 H 3.054771 1.367893 12.764401 5 107
124 | 122 H 2.668738 1.682379 11.032913 5 107
125 | 123 H 1.628383 3.358631 13.408061 5 108
126 | 124 H 1.269856 3.637838 11.684881 5 108
127 | 125 H 3.715336 5.970983 12.243642 5 110
128 | 126 H 2.029862 5.620882 11.824551 5 110
129 | 127 H 4.523291 4.837735 10.145333 5 111
130 | 128 H 3.464776 6.242836 9.812724 5 111
131 | 129 H 4.023074 3.994784 8.024517 5 113
132 | 130 H 2.824111 5.273445 7.638289 5 113
133 | 131 H 0.994277 3.489334 7.663511 5 114
134 | 132 H 2.213333 3.238559 6.378337 5 114
135 | 133 H 0.450726 1.212864 8.060529 5 116
136 | 134 H 1.385752 0.866433 6.578539 5 116
137 | 135 H 1.278596 -1.195533 8.009046 5 117
138 | 136 H 2.944178 -0.596690 7.846198 5 117
139 | 137 H 0.656321 -1.618000 10.255466 5 119
140 | 138 H 0.067839 0.058613 10.050648 5 119
141 | 139 H 0.369094 -0.827183 12.477014 5 120
142 | 140 H 2.121509 -0.728124 12.229662 5 120
143 | 141 O -2.784899 -1.811839 12.032064 6 142 155
144 | 142 C -2.157989 -2.419748 13.147876 1 141 143 156 157
145 | 143 C -2.105876 -3.917450 12.903100 1 142 144 158 159
146 | 144 O -1.368055 -4.155567 11.715623 6 143 145
147 | 145 C -1.601649 -5.454122 11.196043 1 144 146 160 161
148 | 146 C -0.872738 -5.614056 9.870690 1 145 147 162 163
149 | 147 O -1.511791 -4.936187 8.798232 6 146 148
150 | 148 C -1.415726 -3.523458 8.884274 1 147 149 164 165
151 | 149 C -1.725630 -2.931127 7.517464 1 148 150 166 167
152 | 150 O -1.722992 -1.515264 7.617025 6 149 151
153 | 151 C -3.012562 -0.981356 7.884052 1 150 152 168 169
154 | 152 C -2.855567 0.349737 8.606628 1 151 153 170 171
155 | 153 O -2.423380 0.111840 9.936412 6 152 154
156 | 154 C -3.484502 0.136087 10.877081 1 153 155 172 173
157 | 155 C -2.972975 -0.416930 12.195472 1 141 154 174 175
158 | 156 H -1.137553 -2.013011 13.280886 5 142
159 | 157 H -2.740385 -2.207950 14.066812 5 142
160 | 158 H -1.615245 -4.434371 13.751917 5 143
161 | 159 H -3.134926 -4.316297 12.813333 5 143
162 | 160 H -1.240291 -6.209951 11.923485 5 145
163 | 161 H -2.687651 -5.622070 11.047566 5 145
164 | 162 H 0.181777 -5.292044 9.947298 5 146
165 | 163 H -0.839153 -6.689202 9.616709 5 146
166 | 164 H -0.391996 -3.225897 9.189560 5 148
167 | 165 H -2.129015 -3.143053 9.640796 5 148
168 | 166 H -0.936971 -3.235639 6.798937 5 149
169 | 167 H -2.692157 -3.300635 7.117273 5 149
170 | 168 H -3.617208 -1.679399 8.497363 5 151
171 | 169 H -3.542290 -0.835621 6.920139 5 151
172 | 170 H -2.090879 0.963579 8.091669 5 152
173 | 171 H -3.798211 0.935294 8.596051 5 152
174 | 172 H -3.834585 1.179560 11.007327 5 154
175 | 173 H -4.338933 -0.471418 10.519535 5 154
176 | 174 H -2.022470 0.076897 12.480451 5 155
177 | 175 H -3.712293 -0.235089 13.001015 5 155
178 | 176 O 1.811838 -2.784899 -10.518637 6 177 190
179 | 177 C 2.419747 -2.157989 -9.402825 1 176 178 191 192
180 | 178 C 3.917449 -2.105876 -9.647602 1 177 179 193 194
181 | 179 O 4.155566 -1.368055 -10.835078 6 178 180
182 | 180 C 5.454121 -1.601649 -11.354659 1 179 181 195 196
183 | 181 C 5.614055 -0.872738 -12.680011 1 180 182 197 198
184 | 182 O 4.936186 -1.511791 -13.752470 6 181 183
185 | 183 C 3.523457 -1.415726 -13.666428 1 182 184 199 200
186 | 184 C 2.931126 -1.725630 -15.033237 1 183 185 201 202
187 | 185 O 1.515263 -1.722992 -14.933677 6 184 186
188 | 186 C 0.981355 -3.012562 -14.666649 1 185 187 203 204
189 | 187 C -0.349738 -2.855567 -13.944073 1 186 188 205 206
190 | 188 O -0.111841 -2.423380 -12.614290 6 187 189
191 | 189 C -0.136088 -3.484502 -11.673620 1 188 190 207 208
192 | 190 C 0.416929 -2.972975 -10.355229 1 176 189 209 210
193 | 191 H 2.013010 -1.137553 -9.269816 5 177
194 | 192 H 2.207949 -2.740385 -8.483889 5 177
195 | 193 H 4.434370 -1.615245 -8.798784 5 178
196 | 194 H 4.316296 -3.134926 -9.737368 5 178
197 | 195 H 6.209949 -1.240291 -10.627217 5 180
198 | 196 H 5.622069 -2.687651 -11.503135 5 180
199 | 197 H 5.292043 0.181777 -12.603404 5 181
200 | 198 H 6.689201 -0.839153 -12.933992 5 181
201 | 199 H 3.225896 -0.391996 -13.361142 5 183
202 | 200 H 3.143052 -2.129015 -12.909906 5 183
203 | 201 H 3.235638 -0.936971 -15.751765 5 184
204 | 202 H 3.300634 -2.692157 -15.433429 5 184
205 | 203 H 1.679398 -3.617208 -14.053339 5 186
206 | 204 H 0.835620 -3.542290 -15.630562 5 186
207 | 205 H -0.963580 -2.090879 -14.459033 5 187
208 | 206 H -0.935296 -3.798211 -13.954651 5 187
209 | 207 H -1.179561 -3.834585 -11.543375 5 189
210 | 208 H 0.471417 -4.338933 -12.031166 5 189
211 | 209 H -0.076898 -2.022470 -10.070250 5 190
212 | 210 H 0.235087 -3.712293 -9.549686 5 190
213 | 211 O 2.784898 1.811838 -3.001737 6 212 225
214 | 212 C 2.157988 2.419747 -1.885925 1 211 213 226 227
215 | 213 C 2.105875 3.917449 -2.130701 1 212 214 228 229
216 | 214 O 1.368054 4.155566 -3.318178 6 213 215
217 | 215 C 1.601648 5.454121 -3.837758 1 214 216 230 231
218 | 216 C 0.872737 5.614055 -5.163111 1 215 217 232 233
219 | 217 O 1.511790 4.936186 -6.235569 6 216 218
220 | 218 C 1.415725 3.523457 -6.149527 1 217 219 234 235
221 | 219 C 1.725629 2.931126 -7.516337 1 218 220 236 237
222 | 220 O 1.722991 1.515263 -7.416776 6 219 221
223 | 221 C 3.012561 0.981355 -7.149749 1 220 222 238 239
224 | 222 C 2.855566 -0.349738 -6.427173 1 221 223 240 241
225 | 223 O 2.423379 -0.111841 -5.097389 6 222 224
226 | 224 C 3.484501 -0.136088 -4.156720 1 223 225 242 243
227 | 225 C 2.972974 0.416930 -2.838329 1 211 224 244 245
228 | 226 H 1.137552 2.013010 -1.752915 5 212
229 | 227 H 2.740384 2.207949 -0.966989 5 212
230 | 228 H 1.615244 4.434370 -1.281884 5 213
231 | 229 H 3.134925 4.316296 -2.220468 5 213
232 | 230 H 1.240290 6.209950 -3.110317 5 215
233 | 231 H 2.687650 5.622069 -3.986235 5 215
234 | 232 H -0.181778 5.292043 -5.086503 5 216
235 | 233 H 0.839152 6.689201 -5.417092 5 216
236 | 234 H 0.391995 3.225896 -5.844241 5 218
237 | 235 H 2.129014 3.143052 -5.393005 5 218
238 | 236 H 0.936970 3.235638 -8.234864 5 219
239 | 237 H 2.692156 3.300634 -7.916528 5 219
240 | 238 H 3.617207 1.679398 -6.536438 5 221
241 | 239 H 3.542289 0.835620 -8.113662 5 221
242 | 240 H 2.090878 -0.963580 -6.942132 5 222
243 | 241 H 3.798210 -0.935295 -6.437750 5 222
244 | 242 H 3.834584 -1.179561 -4.026474 5 224
245 | 243 H 4.338932 0.471417 -4.514266 5 224
246 | 244 H 2.022469 -0.076898 -2.553350 5 225
247 | 245 H 3.712292 0.235088 -2.032786 5 225
248 | 246 O -1.811839 2.784898 4.515164 6 247 260
249 | 247 C -2.419748 2.157988 5.630976 1 246 248 261 262
250 | 248 C -3.917450 2.105875 5.386199 1 247 249 263 264
251 | 249 O -4.155567 1.368054 4.198722 6 248 250
252 | 250 C -5.454122 1.601648 3.679142 1 249 251 265 266
253 | 251 C -5.614056 0.872737 2.353790 1 250 252 267 268
254 | 252 O -4.936187 1.511790 1.281331 6 251 253
255 | 253 C -3.523458 1.415725 1.367373 1 252 254 269 270
256 | 254 C -2.931127 1.725629 0.000564 1 253 255 271 272
257 | 255 O -1.515264 1.722991 0.100124 6 254 256
258 | 256 C -0.981356 3.012561 0.367152 1 255 257 273 274
259 | 257 C 0.349737 2.855566 1.089728 1 256 258 275 276
260 | 258 O 0.111840 2.423379 2.419511 6 257 259
261 | 259 C 0.136087 3.484501 3.360181 1 258 260 277 278
262 | 260 C -0.416930 2.972974 4.678572 1 246 259 279 280
263 | 261 H -2.013011 1.137552 5.763985 5 247
264 | 262 H -2.207950 2.740384 6.549912 5 247
265 | 263 H -4.434371 1.615244 6.235017 5 248
266 | 264 H -4.316297 3.134925 5.296433 5 248
267 | 265 H -6.209951 1.240290 4.406584 5 250
268 | 266 H -5.622070 2.687650 3.530666 5 250
269 | 267 H -5.292044 -0.181778 2.430397 5 251
270 | 268 H -6.689202 0.839152 2.099809 5 251
271 | 269 H -3.225897 0.391995 1.672659 5 253
272 | 270 H -3.143053 2.129014 2.123895 5 253
273 | 271 H -3.235639 0.936970 -0.717964 5 254
274 | 272 H -3.300635 2.692156 -0.399628 5 254
275 | 273 H -1.679399 3.617207 0.980462 5 256
276 | 274 H -0.835621 3.542289 -0.596761 5 256
277 | 275 H 0.963579 2.090878 0.574768 5 257
278 | 276 H 0.935295 3.798210 1.079151 5 257
279 | 277 H 1.179560 3.834584 3.490426 5 259
280 | 278 H -0.471418 4.338932 3.002635 5 259
281 | 279 H 0.076897 2.022469 4.963551 5 260
282 | 280 H -0.235089 3.712292 5.484115 5 260
283 |
--------------------------------------------------------------------------------
/phonolammps/__init__.py:
--------------------------------------------------------------------------------
1 | __version__ = '0.9.3'
2 |
3 | import numpy as np
4 | import warnings
5 |
6 | from phonopy.file_IO import write_FORCE_CONSTANTS, write_force_constants_to_hdf5, write_FORCE_SETS
7 | from phonolammps.arrange import get_correct_arrangement, rebuild_connectivity_tinker
8 | from phonolammps.phonopy_link import obtain_phonon_dispersion_bands, get_phonon
9 | from phonolammps.iofile import get_structure_from_poscar, generate_VASP_structure
10 | from phonolammps.iofile import generate_tinker_key_file, generate_tinker_txyz_file, parse_tinker_forces
11 | from phonolammps.iofile import get_structure_from_lammps, get_structure_from_txyz
12 | from phonolammps.iofile import get_structure_from_g96, get_structure_from_gro
13 | from phonolammps.iofile import generate_gro, generate_g96
14 |
15 | import shutil, os
16 |
17 |
18 | # define the force unit conversion factors to LAMMPS metal style (eV/Angstrom)
19 | unit_factors = {'real': 4.336410389526464e-2,
20 | 'metal': 1.0,
21 | 'si': 624150636.3094,
22 | 'gromacs': 0.00103642723,
23 | 'tinker': 0.043 # kcal/mol to eV
24 | }
25 |
26 |
27 | class PhonoBase:
28 | """
29 | Base class for PhonoLAMMPS
30 | This class is not designed to be called directly.
31 | To use it make a subclass and implement the following methods:
32 |
33 | * __init__()
34 | * get_forces()
35 |
36 | """
37 |
38 | def get_path_using_seek_path(self):
39 |
40 | """ Obtain the path in reciprocal space to plot the phonon band structure
41 |
42 | :return: dictionary with list of q-points and labels of high symmetry points
43 | """
44 |
45 | try:
46 | import seekpath
47 |
48 | cell = self._structure.get_cell()
49 | positions = self._structure.get_scaled_positions()
50 | numbers = np.unique(self._structure.get_chemical_symbols(), return_inverse=True)[1]
51 |
52 | path_data = seekpath.get_path((cell, positions, numbers))
53 |
54 | labels = path_data['point_coords']
55 |
56 | band_ranges = []
57 | for set in path_data['path']:
58 | band_ranges.append([labels[set[0]], labels[set[1]]])
59 |
60 | return {'ranges': band_ranges,
61 | 'labels': path_data['path']}
62 | except ImportError:
63 | print ('Seekpath not installed. Autopath is deactivated')
64 | band_ranges = ([[[0.0, 0.0, 0.0], [0.5, 0.0, 0.5]]])
65 | return {'ranges': band_ranges,
66 | 'labels': [['GAMMA', '1/2 0 1/2']]}
67 |
68 | def get_force_constants(self, include_data_set=False):
69 | """
70 | calculate the force constants with phonopy using lammps to calculate forces
71 |
72 | :return: ForceConstants type object containing force constants
73 | """
74 |
75 | if self._force_constants is None:
76 | phonon = get_phonon(self._structure,
77 | setup_forces=False,
78 | super_cell_phonon=self._supercell_matrix,
79 | primitive_matrix=self._primitive_matrix,
80 | NAC=self._NAC,
81 | symmetrize=self._symmetrize)
82 |
83 | phonon.get_displacement_dataset()
84 | phonon.generate_displacements(distance=self._displacement_distance)
85 | cells_with_disp = phonon.get_supercells_with_displacements()
86 | data_set = phonon.get_displacement_dataset()
87 |
88 | # Check forces for non displaced supercell
89 | forces_supercell = self.get_forces(phonon.get_supercell())
90 | if np.max(forces_supercell) > 1e-1:
91 | warnings.warn('Large atomic forces found for non displaced structure: '
92 | '{}. Make sure your unit cell is properly optimized'.format(np.max(forces_supercell)))
93 |
94 | # Get forces from lammps
95 | for i, cell in enumerate(cells_with_disp):
96 | if self._show_progress:
97 | print('displacement {} / {}'.format(i+1, len(cells_with_disp)))
98 | forces = self.get_forces(cell)
99 | data_set['first_atoms'][i]['forces'] = forces
100 |
101 | phonon.set_displacement_dataset(data_set)
102 | phonon.produce_force_constants()
103 | self._force_constants = phonon.get_force_constants()
104 | self._data_set = data_set
105 |
106 | if include_data_set:
107 | return [self._force_constants, self._data_set]
108 | else:
109 | return self._force_constants
110 |
111 | def plot_phonon_dispersion_bands(self, bands_and_labels=None):
112 | """
113 | Plot phonon band structure using seekpath automatic k-path
114 | Warning: The labels may be wrong if the structure is not standarized
115 |
116 | :param bands_and_labels: Custom energy band path
117 | """
118 | import matplotlib.pyplot as plt
119 |
120 | def replace_list(text_string):
121 | substitutions = {'GAMMA': u'$\Gamma$',
122 | }
123 |
124 | for item in substitutions.items():
125 | text_string = text_string.replace(item[0], item[1])
126 | return text_string
127 |
128 | force_constants = self.get_force_constants()
129 | if bands_and_labels is None:
130 | bands_and_labels = self.get_path_using_seek_path()
131 |
132 | _bands = obtain_phonon_dispersion_bands(self._structure,
133 | bands_and_labels['ranges'],
134 | force_constants,
135 | self._supercell_matrix,
136 | primitive_matrix=self._primitive_matrix,
137 | band_resolution=30)
138 |
139 | for i, freq in enumerate(_bands[1]):
140 | plt.plot(_bands[1][i], _bands[2][i], color='r')
141 |
142 | plt.ylabel('Frequency [THz]')
143 | plt.xlabel('Wave vector')
144 | plt.xlim([0, _bands[1][-1][-1]])
145 | plt.axhline(y=0, color='k', ls='dashed')
146 | plt.suptitle('Phonon dispersion')
147 |
148 | if 'labels' in bands_and_labels:
149 | plt.rcParams.update({'mathtext.default': 'regular'})
150 |
151 | labels = bands_and_labels['labels']
152 |
153 | labels_e = []
154 | x_labels = []
155 | for i, freq in enumerate(_bands[1]):
156 | if labels[i][0] == labels[i - 1][1]:
157 | labels_e.append(replace_list(labels[i][0]))
158 | else:
159 | labels_e.append(
160 | replace_list(labels[i - 1][1]) + '/' + replace_list(labels[i][0]))
161 | x_labels.append(_bands[1][i][0])
162 | x_labels.append(_bands[1][-1][-1])
163 | labels_e.append(replace_list(labels[-1][1]))
164 | labels_e[0] = replace_list(labels[0][0])
165 |
166 | plt.xticks(x_labels, labels_e, rotation='horizontal')
167 |
168 | plt.show()
169 |
170 | def write_force_constants(self, filename='FORCE_CONSTANTS', hdf5=False):
171 | """
172 | Write the force constants in a file in phonopy plain text format
173 |
174 | :param filename: Force constants filename
175 | """
176 |
177 | force_constants = self.get_force_constants()
178 | if hdf5:
179 | write_force_constants_to_hdf5(force_constants, filename=filename)
180 | else:
181 | write_FORCE_CONSTANTS(force_constants, filename=filename)
182 |
183 | def write_force_sets(self, filename='FORCE_SETS'):
184 | """
185 | Write the force sets in a file in phonopy plain text format
186 |
187 | :param filename: Force sets filename
188 | """
189 |
190 | data_set = self.get_force_constants(include_data_set=True)[1]
191 |
192 | write_FORCE_SETS(data_set, filename=filename)
193 |
194 | def get_unitcell(self):
195 | """
196 | Get unit cell structure
197 |
198 | :return unitcell: unit cell 3x3 matrix (lattice vectors in rows)
199 | """
200 | return self._structure
201 |
202 | def get_supercell_matrix(self):
203 | """
204 | Get the supercell matrix
205 |
206 | :return supercell: the supercell 3x3 matrix (list of lists)
207 | """
208 | return self._supercell_matrix
209 |
210 | def get_primitve_matrix(self):
211 | return self._primitive_matrix
212 |
213 | def get_seekpath_bands(self, band_resolution=30):
214 | ranges = self.get_path_using_seek_path()['ranges']
215 | bands =[]
216 | for q_start, q_end in ranges:
217 | band = []
218 | for i in range(band_resolution+1):
219 | band.append(np.array(q_start) + (np.array(q_end) - np.array(q_start)) / band_resolution * i)
220 | bands.append(band)
221 |
222 | return bands
223 |
224 | def write_unitcell_POSCAR(self, filename='POSCAR'):
225 | """
226 | Write unit cell in VASP POSCAR type file
227 |
228 | :param filename: POSCAR file name (Default: POSCAR)
229 | """
230 | poscar_txt = generate_VASP_structure(self._structure)
231 |
232 | with open(filename, mode='w') as f:
233 | f.write(poscar_txt)
234 |
235 | def get_phonopy_phonon(self):
236 | """
237 | Return phonopy phonon object with unitcell, primitive cell and
238 | the force constants set.
239 |
240 | :return:
241 | """
242 |
243 | phonon = get_phonon(self._structure,
244 | setup_forces=False,
245 | super_cell_phonon=self._supercell_matrix,
246 | primitive_matrix=self._primitive_matrix,
247 | NAC=self._NAC,
248 | symmetrize=self._symmetrize)
249 |
250 | phonon.set_force_constants(self.get_force_constants())
251 |
252 | return phonon
253 |
254 | ################################
255 | # LAMMPS #
256 | ################################
257 | class Phonolammps(PhonoBase):
258 | def __init__(self,
259 | lammps_input,
260 | supercell_matrix=np.identity(3),
261 | primitive_matrix=np.identity(3),
262 | displacement_distance=0.01,
263 | show_log=False,
264 | show_progress=False,
265 | use_NAC=False,
266 | symmetrize=True):
267 | """
268 | Main PhonoLAMMPS class
269 |
270 | :param lammps_input: LAMMPS input file name or list of commands
271 | :param supercell_matrix: 3x3 matrix supercell
272 | :param primitive cell: 3x3 matrix primitive cell
273 | :param displacement_distance: displacement distance in Angstroms
274 | :param show_log: Set true to display lammps log info
275 | :param show_progress: Set true to display progress of calculation
276 | """
277 |
278 | # Check if input is file or list of commands
279 | if type(lammps_input) is str:
280 | # read from file name
281 | self._lammps_input_file = lammps_input
282 | self._lammps_commands_list = open(lammps_input).read().split('\n')
283 | else:
284 | # read from commands
285 | self._lammps_commands_list = lammps_input
286 |
287 | self._structure = get_structure_from_lammps(self._lammps_commands_list, show_log=show_log)
288 |
289 | self._supercell_matrix = supercell_matrix
290 | self._primitive_matrix = primitive_matrix
291 | self._displacement_distance = displacement_distance
292 | self._show_log = show_log
293 | self._show_progress = show_progress
294 | self._symmetrize = symmetrize
295 | self._NAC = use_NAC
296 |
297 | self._force_constants = None
298 | self._data_set = None
299 |
300 | self.units = self.get_units(self._lammps_commands_list)
301 |
302 | if not self.units in unit_factors.keys():
303 | print ('Units style not supported, use: {}'.format(unit_factors.keys()))
304 | exit()
305 |
306 | def get_units(self, commands_list):
307 | """
308 | Get the units label for LAMMPS "units" command from a list of LAMMPS input commands
309 |
310 | :param commands_list: list of LAMMPS input commands (strings)
311 | :return units: string containing the units
312 | """
313 | for line in commands_list:
314 | if line.startswith('units'):
315 | return line.split()[1]
316 | return 'lj'
317 |
318 | def get_forces(self, cell_with_disp):
319 | """
320 | Calculate the forces of a supercell using lammps
321 |
322 | :param cell_with_disp: supercell from which determine the forces
323 | :return: numpy array matrix with forces of atoms [Natoms x 3]
324 | """
325 |
326 | import lammps
327 |
328 | supercell_sizes = np.diag(self._supercell_matrix)
329 |
330 | cmd_list = ['-log', 'none']
331 | if not self._show_log:
332 | cmd_list += ['-echo', 'none', '-screen', 'none']
333 |
334 | lmp = lammps.lammps(cmdargs=cmd_list)
335 | lmp.commands_list(self._lammps_commands_list)
336 | lmp.command('replicate {} {} {}'.format(*supercell_sizes))
337 | lmp.command('run 0')
338 |
339 | na = lmp.get_natoms()
340 | # xc = lmp.gather_atoms("x", 1, 3)
341 | # reference2 = np.array([xc[i] for i in range(na * 3)]).reshape((na, 3))
342 |
343 | id = lmp.extract_atom("id", 0)
344 | id = np.array([id[i]-1 for i in range(na)], dtype=int)
345 |
346 | xp = lmp.extract_atom("x", 3)
347 | reference = np.array([[xp[i][0], xp[i][1], xp[i][2]] for i in range(na)], dtype=float)
348 |
349 | template = get_correct_arrangement(reference, self._structure, self._supercell_matrix)
350 |
351 | coordinates = cell_with_disp.get_positions()
352 |
353 | for i in range(na):
354 | lmp.command('set atom {} x {} y {} z {}'.format(id[i]+1,
355 | coordinates[template[i], 0],
356 | coordinates[template[i], 1],
357 | coordinates[template[i], 2])
358 | )
359 |
360 | lmp.command('run 0')
361 |
362 | fp = lmp.extract_atom("f", 3)
363 | forces = np.array([[fp[i][0], fp[i][1], fp[i][2]] for i in range(na)], dtype=float)
364 |
365 | xp = lmp.extract_atom("x", 3)
366 | reference = np.array([[xp[i][0], xp[i][1], xp[i][2]] for i in range(na)], dtype=float)
367 |
368 | template = get_correct_arrangement(reference, self._structure, self._supercell_matrix)
369 | indexing = np.argsort(template)
370 |
371 | forces = forces[indexing, :] * unit_factors[self.units]
372 |
373 | lmp.close()
374 |
375 | return forces
376 |
377 | def optimize_unitcell(self, energy_tol=0, force_tol=1e-10, max_iter=1000000, max_eval=1000000):
378 | """
379 | Optimize atoms position of the unitcell using lammps minimizer.
380 | Check https://docs.lammps.org/minimize.html for details
381 |
382 | :param energy_tol: stopping tolerance for energ
383 | :param force_tol: stopping tolerance for force (force units)
384 | :param max_iter: max iterations of minimizer
385 | :param max_eval: max number of force/energy evaluations
386 | """
387 |
388 | import lammps
389 |
390 | cmd_list = ['-log', 'none']
391 | if not self._show_log:
392 | cmd_list += ['-echo', 'none', '-screen', 'none']
393 |
394 | lmp = lammps.lammps(cmdargs=cmd_list)
395 | lmp.commands_list(self._lammps_commands_list)
396 |
397 | lmp.command(' thermo 10 ')
398 | lmp.command('thermo_style custom step temp etotal press vol enthalpy')
399 | #lmp.command(' fix 2 all box/relax aniso 1000000 dilate all')
400 | lmp.command('minimize {} {} {} {} '.format(energy_tol, force_tol, max_iter, max_eval))
401 | #lmp.command('run 0 ')
402 |
403 | na = lmp.get_natoms()
404 | xp = lmp.extract_atom("x", 3)
405 | positions = np.array([[xp[i][0], xp[i][1], xp[i][2]] for i in range(na)], dtype=float)
406 |
407 | fp = lmp.extract_atom("f", 3)
408 | forces = np.array([[fp[i][0], fp[i][1], fp[i][2]] for i in range(na)], dtype=float)
409 |
410 | lmp.close()
411 |
412 | self._structure.set_positions(positions)
413 |
414 | norm = np.linalg.norm(forces.flatten())
415 | maxforce = np.max(np.abs(forces))
416 |
417 | print('Force two-norm: ', norm)
418 | print('Force max component: ', maxforce)
419 |
420 | return norm, maxforce
421 |
422 |
423 | ################################
424 | # TINKER #
425 | ################################
426 | class PhonoTinker(PhonoBase):
427 |
428 | def __init__(self,
429 | txyz_input_file,
430 | key_input_file,
431 | force_field_file,
432 | supercell_matrix=np.identity(3),
433 | primitive_matrix=np.identity(3),
434 | displacement_distance=0.01,
435 | show_log=False,
436 | show_progress=False,
437 | use_NAC=False,
438 | symmetrize=True):
439 | """
440 | Experimental class to use Tinker to calculate forces, can be used
441 | as an example to how to expand phonoLAMMPS to other software
442 |
443 | :param txyz_input_file: TXYZ input file name (see example)
444 | :param supercell_matrix: 3x3 matrix supercell
445 | :param primitive cell: 3x3 matrix primitive cell
446 | :param displacement_distance: displacement distance in Angstroms
447 | :param show_log: set true to display lammps log info
448 | :param show_progress: set true to display progress of calculation
449 | :param use_NAC: set true to use Non-Analytical corrections or not
450 | :param symmetrize: set true to use symmetrization of the force constants
451 | """
452 |
453 | self._structure = get_structure_from_txyz(txyz_input_file, key_input_file)
454 | self._txyz_input_file = txyz_input_file
455 |
456 | self._supercell_matrix = supercell_matrix
457 | self._primitive_matrix = primitive_matrix
458 | self._displacement_distance = displacement_distance
459 | self._show_log = show_log
460 | self._show_progress = show_progress
461 | self._symmetrize = symmetrize
462 | self._NAC = use_NAC
463 |
464 | self._force_constants = None
465 | self._data_set = None
466 |
467 | self.units = 'tinker'
468 |
469 | self.force_field = force_field_file
470 |
471 | if not self.units in unit_factors.keys():
472 | print ('Units style not supported, use: {}'.format(unit_factors.keys()))
473 | exit()
474 |
475 | def get_forces(self, cell_with_disp):
476 | """
477 | Calculate the forces of a supercell using tinker
478 | :param cell_with_disp: supercell (PhonopyAtoms) from which determine the forces
479 | :return array: numpy array matrix with forces of atoms [Natoms x 3]
480 | """
481 |
482 | import tempfile
483 | import subprocess
484 | from subprocess import PIPE
485 |
486 | temp_file_name = tempfile.gettempdir() + '/tinker_temp' + '_' + str(os.getpid())
487 |
488 | # temp_file_name = 'test_calc'
489 |
490 | supercell_wd = rebuild_connectivity_tinker(self._structure,
491 | cell_with_disp,
492 | self._supercell_matrix)
493 |
494 | tinker_input_file = open(temp_file_name + '.txyz', mode='w')
495 | tinker_input_file.write(generate_tinker_txyz_file(supercell_wd))
496 |
497 | tinker_key_file = open(temp_file_name + '.key', mode='w')
498 | tinker_key_file.write(generate_tinker_key_file(supercell_wd))
499 |
500 | tinker_input_file.close()
501 | tinker_key_file.close()
502 |
503 | tinker_command = './testgrad ' + tinker_input_file.name + \
504 | ' ' + self.force_field + ' Y N N ' + ' -k ' + tinker_key_file.name
505 |
506 | tinker_process = subprocess.Popen(tinker_command, stdin=PIPE, stderr=PIPE, stdout=PIPE, shell=True)
507 | (output, err) = tinker_process.communicate()
508 | tinker_process.wait()
509 |
510 | if len(err.split()) != 0:
511 | print(err)
512 | print('Something wrong in forces calculation!')
513 | exit()
514 |
515 | # print(output)
516 | os.unlink(tinker_input_file.name)
517 | os.unlink(tinker_key_file.name)
518 |
519 | forces = parse_tinker_forces(output) * unit_factors[self.units]
520 |
521 | return forces
522 |
523 |
524 | ################################
525 | # GROMACS #
526 | ################################
527 | class PhonoGromacs(PhonoBase):
528 |
529 | _work_dir = 'gromorg_{}/'.format(os.getpid())
530 |
531 | # _work_dir = 'gromorg_test/'
532 |
533 | def __init__(self,
534 | gro_file,
535 | supercell_matrix=np.identity(3),
536 | primitive_matrix=np.identity(3),
537 | displacement_distance=0.01,
538 | show_log=False,
539 | show_progress=False,
540 | use_NAC=False,
541 | symmetrize=True,
542 | gmx_params=None,
543 | base_ff='charmm27.ff/forcefield.itp',
544 | itp_file=None,
545 | silent=True,
546 | omp_num_threads=1):
547 |
548 | """
549 | Experimental class to use Tinker to calculate forces, can be used
550 | as an example to how to expand phonoLAMMPS to other software
551 |
552 | :param xyz_input_file: XYZ input file name (see example)
553 | :param supercell_matrix: 3x3 matrix supercell
554 | :param primitive cell: 3x3 matrix primitive cell
555 | :param displacement_distance: displacement distance in Angstroms
556 | :param show_log: set true to display lammps log info
557 | :param show_progress: set true to display progress of calculation
558 | :param use_NAC: set true to use Non-Analytical corrections or not
559 | :param symmetrize: set true to use symmetrization of the force constants
560 | """
561 |
562 | self._supercell_matrix = supercell_matrix
563 | self._primitive_matrix = primitive_matrix
564 | self._displacement_distance = displacement_distance
565 | self._show_log = show_log
566 | self._show_progress = show_progress
567 | self._symmetrize = symmetrize
568 | self._NAC = use_NAC
569 |
570 | self._force_constants = None
571 | self._data_set = None
572 | self._silent = silent
573 |
574 | self._base_fcc = base_ff
575 |
576 | self.units = 'gromacs'
577 |
578 | if not self.units in unit_factors.keys():
579 | print ('Units style not supported, use: {}'.format(unit_factors.keys()))
580 | exit()
581 |
582 | # import openbabel
583 |
584 | # a, b, c = [8.194, 5.968, 8.669]
585 | # alpha, beta, gamma = [90.0, 123.57, 90.0]
586 |
587 | # a1 = a
588 | # b1 = b * np.cos(np.deg2rad(gamma))
589 | # b2 = np.sqrt(b ** 2 - b1 ** 2)
590 | # c1 = c * np.cos(np.deg2rad(beta))
591 | # c2 = (b * c * np.cos(np.deg2rad(alpha)) - b1 * c1) / b2
592 | # c3 = np.sqrt(c ** 2 - c1 ** 2 - c2 ** 2)
593 |
594 | # unitcell = [[a1, 0, 0],
595 | # [b1, b2, 0],
596 | # [c1, c2, c3]]
597 |
598 |
599 | self._structure = get_structure_from_g96(gro_file)
600 |
601 |
602 | os.putenv('GMX_MAXBACKUP', '-1')
603 | os.putenv('OMP_NUM_THREADS', '{}'.format(omp_num_threads))
604 |
605 | self._filename = 'test'
606 |
607 | # os.mkdir(self._work_dir)
608 | try:
609 | os.mkdir(self._work_dir)
610 | except FileExistsError:
611 | pass
612 |
613 | self._filename_dir = self._work_dir + self._filename
614 |
615 | # Default parameters
616 |
617 | # Run paramters
618 | if gmx_params is None:
619 | gmx_params = {}
620 |
621 | gmx_params.update({'integrator': 'steep', # Verlet integrator
622 | 'nsteps': 1, # 0.001 * 5000 = 50 ps
623 | 'nstxout': 1, # save coordinates every 0.001 ps
624 | 'nstvout': 1, # save velocities every 0.001 ps
625 | 'nstfout': 1, # save forces every 0.001 ps
626 | 'dt': 0.1})
627 |
628 | self._params = gmx_params
629 |
630 |
631 | self._supercell = np.diag(supercell_matrix)
632 | self._box = [v/10 for v in self.cell_lengths(self._structure.cell)]
633 | self._angles = self.cell_angles(self._structure.cell)
634 | # alpha, beta, gamma = [90.0, 123.57, 90.0]
635 |
636 | from phonolammps.swissparam import SwissParams
637 |
638 | if itp_file is None:
639 | sw = SwissParams(self._structure, silent=False)
640 |
641 | files = {'itp': sw.get_itp_data(),
642 | 'pdb': sw.get_pdb_data(),
643 | 'top': self.get_topology(),
644 | 'mdp': self.get_mdp()}
645 |
646 | for ext, data in files.items():
647 | with open(self._filename_dir + '.{}'.format(ext), 'w') as f:
648 | f.write(data)
649 | else:
650 | shutil.copy(itp_file, self._filename_dir + '.itp')
651 |
652 | with open(self._filename_dir + '.top', 'w') as f:
653 | f.write(self.get_topology())
654 |
655 | with open(self._filename_dir + '.mdp', 'w') as f:
656 | f.write(self.get_mdp())
657 |
658 | def cell_lengths(self, cell):
659 | """
660 | Get the lengths of cell lattice vectors in angstroms.
661 | """
662 | import numpy
663 |
664 | return [
665 | numpy.linalg.norm(cell[0]),
666 | numpy.linalg.norm(cell[1]),
667 | numpy.linalg.norm(cell[2]),
668 | ]
669 |
670 | def cell_angles(self, cell):
671 | """
672 | Get the angles between the cell lattice vectors in degrees.
673 | """
674 | import numpy
675 |
676 | lengths = self.cell_lengths(cell)
677 | return [
678 | float(numpy.arccos(x) / numpy.pi * 180) for x in [
679 | numpy.vdot(cell[1], cell[2]) / lengths[1] / lengths[2],
680 | numpy.vdot(cell[0], cell[2]) / lengths[0] / lengths[2],
681 | numpy.vdot(cell[0], cell[1]) / lengths[0] / lengths[1],
682 | ]
683 | ]
684 |
685 | def get_mdp(self):
686 | file = ';Autogenerated MDP\n'
687 | for keys, values in self._params.items():
688 | file += '{:30} = {}\n'.format(keys, values)
689 |
690 | return file
691 |
692 | def get_topology(self):
693 |
694 | num_mol = np.prod(self._supercell)
695 | file = '; Autogenerated Topology\n'
696 |
697 | itp_files = [self._base_fcc, '{}.itp'.format(self._filename)]
698 |
699 | params = {'system': ['molecular system name'],
700 | 'molecules': ['{} {}\n'.format(self._filename, num_mol)]}
701 |
702 | for itp in itp_files:
703 | file += '#include "{}"\n'.format(itp)
704 |
705 | for section, lines in params.items():
706 | file += '[ {} ]\n'.format(section)
707 | for line in lines:
708 | file += '{}\n'.format(line)
709 |
710 | return file
711 |
712 | def get_tpr(self, supercell_wd):
713 | import gmxapi as gmx
714 |
715 | #gmx genconf -f molecule.gro -o multi_mol.gro -nbox 2 2 2
716 |
717 | # print(self._filename_dir + '.gro')
718 |
719 | #create_gro(supercell_wd, self._structure, self._filename_dir + '.gro')
720 |
721 | generate_g96(supercell_wd, self._structure, self._filename_dir + '.g96')
722 |
723 |
724 | grompp = gmx.commandline_operation('gmx', 'grompp',
725 | input_files={'-f': self._filename_dir + '.mdp',
726 | # '-c': self._filename_dir + '.gro',
727 | '-c': self._filename_dir + '.g96',
728 | '-p': self._filename_dir + '.top',
729 | '-po': self._filename_dir + '_log.mdp'},
730 | output_files={'-o': self._filename_dir + '.tpr'})
731 | grompp.run()
732 |
733 | if grompp.output.returncode.result() != 0:
734 | print(grompp.output.erroroutput.result())
735 |
736 | tpr_data = gmx.read_tpr(self._filename_dir + '.tpr')
737 |
738 | return tpr_data
739 |
740 | def get_forces(self, cell_with_disp):
741 | """
742 | Calculate the forces of a supercell using tinker
743 | :param cell_with_disp: supercell (PhonopyAtoms) from which determine the forces
744 | :return array: numpy array matrix with forces of atoms [Natoms x 3]
745 | """
746 |
747 | import gmxapi as gmx
748 | from phonolammps.capture import captured_stdout
749 |
750 | supercell_wd = rebuild_connectivity_tinker(self._structure,
751 | cell_with_disp,
752 | self._supercell_matrix)
753 |
754 | # simulation_input = gmx.modify_input(input=self.get_tpr(supercell_wd), parameters={'nsteps': 1})
755 |
756 | md = gmx.mdrun(input=self.get_tpr(supercell_wd))
757 |
758 | if self._silent:
759 | with captured_stdout(self._filename_dir + '.log'):
760 | md.run()
761 | else:
762 | md.run()
763 |
764 |
765 | trajectory_file = md.output.trajectory.result()
766 | md_data_dir = md.output._work_dir.result()
767 |
768 | # print('trajectory file:', trajectory_file)
769 | # print('workdir: ', md.output._work_dir.result())
770 |
771 | # reference = get_structure_from_gro(self._filename_dir + '.gro').positions
772 | reference = get_structure_from_g96(self._filename_dir + '.g96').positions
773 |
774 | template = get_correct_arrangement(reference, self._structure, self._supercell_matrix)
775 | indexing = np.argsort(template)
776 |
777 | # print('{}\n'.format(len(supercell_wd.symbols)))
778 | # for s, c in zip(supercell_wd.symbols, supercell_wd.positions):
779 | # print('{:5} '.format(s) + '{:15.5f} {:15.5f} {:15.5f}'.format(*c))
780 |
781 | # import mdtraj
782 | # self._trajectory = mdtraj.load_trr(trajectory_file, top=md_data_dir + '/confout.gro')
783 | # self._trajectory.save('mdtraj.gro')
784 | # exit()
785 |
786 | def extract_forces(trajectory_file, tpr_file, output='forces.xvg', step=0):
787 |
788 | grompp = gmx.commandline_operation('gmx', ['traj', '-of'],
789 | stdin='0',
790 | input_files={'-f': trajectory_file,
791 | '-s': tpr_file,
792 | '-b': '{}'.format(step),
793 | '-e': '{}'.format(step),
794 | },
795 | )
796 |
797 | if grompp.output.returncode.result() != 0:
798 | print(grompp.output.erroroutput.result())
799 |
800 | forces = np.loadtxt('force.xvg', comments=['#', '@'])[1:].reshape(-1, 3)
801 | # print(forces)
802 |
803 | os.remove('force.xvg')
804 |
805 | return forces # KJ/(mol nm) to eV/ang
806 |
807 | # trajectory = mdtraj.load_trr(trajectory_file, top=md_data_dir + '/confout.gro')
808 | # print(trajectory.n_frames)
809 | forces = extract_forces(trajectory_file, self._filename_dir + '.tpr', step=1)
810 |
811 | forces = forces[indexing, :] * unit_factors[self.units]
812 |
813 | shutil.rmtree(md.output._work_dir.result())
814 |
815 | return forces
816 |
817 | def __del__(self):
818 | if os.path.isdir(self._work_dir):
819 | shutil.rmtree(self._work_dir)
820 |
821 |
822 | if __name__ == '__main__':
823 |
824 | params = {'rvdw': 0.28,
825 | 'rlist': 0.28,
826 | 'rcoulomb': 0.28}
827 |
828 | phg = PhonoGromacs('unitcell_whole.g96', supercell_matrix=np.identity(3)*3, displacement_distance=0.15,
829 | itp_file='gromorg_test_ref/test.itp', show_progress=True, gmx_params=params)
830 |
831 | phg.write_unitcell_POSCAR()
832 | phg.plot_phonon_dispersion_bands()
833 | phg.write_force_constants()
834 | phonon = phg.get_phonopy_phonon()
835 | phonon.run_mesh([40, 40, 40])
836 | phonon.run_total_dos()
837 | phonon.plot_total_dos().show()
838 |
839 |
840 | exit()
841 | structure = get_structure_from_txyz('structure_wrap_min.txyz', 'structure.key')
842 | print(structure)
843 | print(structure.get_connectivity())
844 | print(generate_VASP_structure(structure))
845 | print(structure.get_scaled_positions())
846 | print(structure.get_chemical_symbols())
847 |
848 | phonon = get_phonon(structure,
849 | setup_forces=False,
850 | super_cell_phonon=[[2, 0, 0], [0, 2, 0], [0, 0, 2]],
851 | NAC=False,
852 | symmetrize=True)
853 |
854 |
855 | phonon.get_displacement_dataset()
856 | phonon.generate_displacements(distance=0.0001)
857 | cells_with_disp = phonon.get_supercells_with_displacements()
858 | print(cells_with_disp[0])
859 | print(generate_VASP_structure(cells_with_disp[0]))
860 |
861 | supercell_wd = rebuild_connectivity_tinker(structure,
862 | cells_with_disp[0],
863 | phonon.get_supercell_matrix())
864 |
865 | print(generate_tinker_txyz_file(supercell_wd))
866 | print(generate_tinker_key_file(supercell_wd))
867 |
868 | print(generate_VASP_structure(structure))
869 |
870 | import tempfile
871 | import subprocess
872 | import os
873 | from subprocess import PIPE
874 |
875 | force_field = 'mm3'
876 | temp_file_name = tempfile.gettempdir() + '/tinker_temp'+ '_' + str(os.getpid())
877 |
878 |
879 | tinker_input_file = open(temp_file_name + '.txyz',mode='w')
880 | tinker_input_file.write(generate_tinker_txyz_file(supercell_wd))
881 |
882 | tinker_key_file = open(temp_file_name + '.key',mode='w')
883 | tinker_key_file.write(generate_tinker_key_file(supercell_wd))
884 |
885 | tinker_input_file.close()
886 | tinker_key_file.close()
887 |
888 |
889 | print('filename', tinker_input_file)
890 | tinker_command = './testgrad ' + tinker_input_file.name + \
891 | ' ' + force_field + ' Y N N ' + ' -k ' + tinker_key_file.name
892 |
893 | tinker_process = subprocess.Popen(tinker_command, stdin=PIPE, stderr=PIPE, stdout=PIPE, shell=True)
894 | (output, err) = tinker_process.communicate()
895 | tinker_process.wait()
896 |
897 | os.unlink(tinker_input_file.name)
898 | os.unlink(tinker_key_file.name)
899 |
900 | forces = parse_tinker_forces(output)
901 | print(forces)
902 | print(forces.shape)
903 |
--------------------------------------------------------------------------------
/phonolammps/arrange.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 |
3 |
4 | def diff_matrix(array_1, array_2, cell_size):
5 | """
6 | :param array_1: supercell scaled positions respect unit cell
7 | :param array_2: supercell scaled positions respect unit cell
8 | :param cell_size: diference between arrays accounting for periodicity
9 | :return:
10 | """
11 | array_1_norm = np.array(array_1) / np.array(cell_size, dtype=float)[None,:]
12 | array_2_norm = np.array(array_2) / np.array(cell_size, dtype=float)[None,:]
13 |
14 | return array_2_norm - array_1_norm
15 |
16 |
17 | def phonopy_order(i, size):
18 | x = np.mod(i, size[0])
19 | y = np.mod(i, size[0]*size[1])//size[0]
20 | z = np.mod(i, size[0]*size[1]*size[2])//(size[1]*size[0])
21 | k = i//(size[1]*size[0]*size[2])
22 |
23 | return np.array([x, y, z, k])
24 |
25 |
26 | def get_correct_arrangement(reference, structure, supercell_matrix):
27 |
28 | # print structure.get_scaled_positions()
29 | scaled_coordinates = []
30 | for coordinate in reference:
31 | trans = np.dot(coordinate, np.linalg.inv(structure.get_cell()))
32 | scaled_coordinates.append(np.array(trans.real, dtype=float))
33 |
34 | number_of_cell_atoms = structure.get_number_of_atoms()
35 | number_of_supercell_atoms = len(scaled_coordinates)
36 | supercell_dim = np.diag(supercell_matrix)
37 |
38 | # print 'atom', number_of_cell_atoms, number_of_supercell_atoms
39 | unit_cell_scaled_coordinates = scaled_coordinates - np.array(scaled_coordinates, dtype=int)
40 |
41 | # Map supercell atoms to unitcell
42 | atom_unit_cell_index = []
43 | for coordinate in unit_cell_scaled_coordinates:
44 | # Only works for non symmetric cell (must be changed)
45 |
46 | diff = np.abs(np.array([coordinate]*number_of_cell_atoms) - structure.get_scaled_positions())
47 |
48 | diff[diff >= 0.5] -= 1.0
49 | diff[diff < -0.5] += 1.0
50 |
51 | index = np.argmin(np.linalg.norm(diff, axis=1))
52 |
53 | atom_unit_cell_index.append(index)
54 | atom_unit_cell_index = np.array(atom_unit_cell_index)
55 |
56 | original_conf = np.array([phonopy_order(j, supercell_dim)[:3] for j in range(number_of_supercell_atoms)])
57 |
58 | template = []
59 | lp_coordinates = []
60 | for i, coordinate in enumerate(scaled_coordinates):
61 | lattice_points_coordinates = coordinate - structure.get_scaled_positions()[atom_unit_cell_index[i]]
62 |
63 | for k in range(3):
64 | if lattice_points_coordinates[k] > supercell_dim[k] - 0.5:
65 | lattice_points_coordinates[k] = lattice_points_coordinates[k] - supercell_dim[k]
66 | if lattice_points_coordinates[k] < -0.5:
67 | lattice_points_coordinates[k] = lattice_points_coordinates[k] + supercell_dim[k]
68 |
69 | comparison_cell = np.array([lattice_points_coordinates]*number_of_supercell_atoms)
70 | diference = np.linalg.norm(diff_matrix(original_conf, comparison_cell, supercell_dim), axis=1)
71 | template.append(np.argmin(diference) + atom_unit_cell_index[i]*number_of_supercell_atoms//number_of_cell_atoms)
72 |
73 | lp_coordinates.append(lattice_points_coordinates)
74 | template = np.array(template)
75 |
76 | if len(np.unique(template)) < len(template):
77 | print ('Something wrong with crystal structure!\n'
78 | 'POSCAR & LAMMPS structure do not match')
79 | print ('unique: {} / {}'.format(len(np.unique(template)), len(template)))
80 | exit()
81 |
82 | return template
83 |
84 |
85 | def rebuild_connectivity_tinker(structure, supercell, matrix):
86 |
87 | from phonolammps.phonopy_link import PhonopyAtomsConnect
88 |
89 | connectivity = structure.get_connectivity()
90 | atom_types = structure.get_atom_types()
91 | symbols = structure.get_chemical_symbols()
92 | positions_u = structure.get_scaled_positions()
93 |
94 |
95 | positions_s = supercell.get_scaled_positions()
96 | sc = np.array(np.diag(matrix), dtype=float)
97 | cell = supercell.get_cell()
98 | nat = structure.get_number_of_atoms()
99 |
100 | connectivity_s = []
101 | atom_types_s = []
102 | symbol_s = []
103 |
104 | list_con = np.zeros((int(sc[0]), int(sc[1]), int(sc[2]), nat+1), dtype=int)
105 | l = 0
106 | for c, ll in enumerate(range(nat)):
107 | for i in range(int(sc[0])):
108 | for j in range(int(sc[1])):
109 | for k in range(int(sc[2])):
110 | list_con[i, j, k, c] = l
111 | l = l+1
112 |
113 | l=0
114 | for (con, typ), (sym, pos) in zip(zip(connectivity, atom_types), zip(symbols, positions_u)):
115 | for i in range(int(sc[0])):
116 | for j in range(int(sc[1])):
117 | for k in range(int(sc[2])):
118 | #print(pos)
119 | p = pos * np.array([1/sc[0], 1/sc[1], 1/sc[2]]) + np.array([k/sc[0], j/sc[1], i/sc[2]])
120 | #print(p)
121 | #print(positions_s[l])
122 | con2 = []
123 | for c in con:
124 | #con2.append(int(c + i*sc[1]*sc[2]*nat + j*sc[2]*nat + k*nat))
125 | con2.append(list_con[i,j,k,c-1]+1)
126 |
127 | #print(con2)
128 | #exit()
129 | connectivity_s.append(con2)
130 | atom_types_s.append(typ)
131 | symbol_s.append(sym)
132 |
133 | v = np.round(p - positions_s[l])
134 | if np.linalg.norm(v) != 0:
135 | positions_s[l] += v
136 |
137 | l +=1
138 |
139 | return PhonopyAtomsConnect(positions=np.dot(positions_s, cell),
140 | symbols=symbol_s,
141 | cell=cell,
142 | connectivity=connectivity_s,
143 | atom_types=atom_types_s)
144 |
145 |
--------------------------------------------------------------------------------
/phonolammps/capture.py:
--------------------------------------------------------------------------------
1 | import sys, os, io
2 |
3 |
4 | class captured_stdout:
5 | def __init__(self, filename):
6 | self.old_stdout = None
7 | self.fnull = None
8 | self._filename = filename
9 |
10 | def __enter__(self):
11 | self.F = open(self._filename, 'w')
12 | try:
13 | self.old_error = os.dup(sys.stderr.fileno())
14 | os.dup2(self.F.fileno(), sys.stderr.fileno())
15 | except (AttributeError, io.UnsupportedOperation):
16 | self.old_error = None
17 | return self.F
18 |
19 | def __exit__(self, exc_type, exc_value, traceback):
20 | if self.old_error is not None:
21 | os.dup2(self.old_error, sys.stderr.fileno())
22 |
23 | self.F.close()
--------------------------------------------------------------------------------
/phonolammps/iofile.py:
--------------------------------------------------------------------------------
1 | import os
2 | import warnings
3 |
4 | import numpy as np
5 |
6 | from phonopy.structure.atoms import PhonopyAtoms, atom_data
7 | from phonolammps.phonopy_link import PhonopyAtomsConnect
8 |
9 |
10 | def mass_to_symbol(mass):
11 |
12 | total_diff = []
13 | for element in atom_data:
14 | if element[3] is not None:
15 | total_diff.append(abs(mass - element[3]))
16 | else:
17 | total_diff.append(np.inf)
18 |
19 | i_min = np.argmin(total_diff)
20 | return atom_data[i_min][1]
21 |
22 |
23 |
24 | def get_structure_from_poscar(file_name, number_of_dimensions=3):
25 | """
26 | Read crystal structure from a VASP POSCAR type file
27 |
28 | :param file_name: POSCAR filename
29 | :param number_of_dimensions: number of dimensions of the crystal structure
30 | :return: Atoms (phonopy) type object containing the crystal structure
31 | """
32 | # Check file exists
33 | if not os.path.isfile(file_name):
34 | print('Structure file does not exist!')
35 | exit()
36 |
37 | # Read from VASP POSCAR file
38 | poscar_file = open(file_name, 'r')
39 | data_lines = poscar_file.read().split('\n')
40 | poscar_file.close()
41 |
42 | multiply = float(data_lines[1])
43 | direct_cell = np.array([data_lines[i].split()
44 | for i in range(2, 2+number_of_dimensions)], dtype=float)
45 | direct_cell *= multiply
46 | scaled_positions = None
47 | positions = None
48 |
49 | try:
50 | number_of_types = np.array(data_lines[3+number_of_dimensions].split(),dtype=int)
51 |
52 | coordinates_type = data_lines[4+number_of_dimensions][0]
53 | if coordinates_type == 'D' or coordinates_type == 'd' :
54 |
55 | scaled_positions = np.array([data_lines[8+k].split()[0:3]
56 | for k in range(np.sum(number_of_types))],dtype=float)
57 | else:
58 | positions = np.array([data_lines[8+k].split()[0:3]
59 | for k in range(np.sum(number_of_types))],dtype=float)
60 |
61 | atomic_types = []
62 | for i,j in enumerate(data_lines[5].split()):
63 | atomic_types.append([j]*number_of_types[i])
64 | atomic_types = [item for sublist in atomic_types for item in sublist]
65 |
66 | # Old style POSCAR format
67 | except ValueError:
68 | number_of_types = np.array(data_lines[5].split(), dtype=int)
69 | coordinates_type = data_lines[6][0]
70 | if coordinates_type == 'D' or coordinates_type == 'd':
71 | scaled_positions = np.array([data_lines[7+k].split()[0:3]
72 | for k in range(np.sum(number_of_types))], dtype=float)
73 | else:
74 | positions = np.array([data_lines[7+k].split()[0:3]
75 | for k in range(np.sum(number_of_types))], dtype=float)
76 |
77 | atomic_types = []
78 | for i,j in enumerate(data_lines[0].split()):
79 | atomic_types.append([j]*number_of_types[i])
80 | atomic_types = [item for sublist in atomic_types for item in sublist]
81 |
82 | return PhonopyAtoms(symbols=atomic_types,
83 | scaled_positions=scaled_positions,
84 | cell=direct_cell)
85 |
86 |
87 | def get_structure_from_lammps(command_list, show_log=False):
88 | """
89 | Get the crystal structure from lammps input
90 |
91 | :param command_list: LAMMPS input commands in list (one item for line)
92 | :return: numpy array matrix with forces of atoms [Natoms x 3]
93 | """
94 | from lammps import lammps
95 |
96 | cmd_list = ['-log', 'none']
97 | if not show_log:
98 | cmd_list += ['-echo', 'none', '-screen', 'none']
99 |
100 | lmp = lammps(cmdargs=cmd_list)
101 |
102 | lmp.commands_list(command_list)
103 | lmp.command('run 0')
104 |
105 | na = lmp.get_natoms()
106 |
107 | try:
108 | xlo =lmp.extract_global("boxxlo")
109 | xhi =lmp.extract_global("boxxhi")
110 | ylo =lmp.extract_global("boxylo")
111 | yhi =lmp.extract_global("boxyhi")
112 | zlo =lmp.extract_global("boxzlo")
113 | zhi =lmp.extract_global("boxzhi")
114 | xy =lmp.extract_global("xy")
115 | yz =lmp.extract_global("yz")
116 | xz =lmp.extract_global("xz")
117 | except TypeError:
118 | xlo =lmp.extract_global("boxxlo", 1)
119 | xhi =lmp.extract_global("boxxhi", 1)
120 | ylo =lmp.extract_global("boxylo", 1)
121 | yhi =lmp.extract_global("boxyhi", 1)
122 | zlo =lmp.extract_global("boxzlo", 1)
123 | zhi =lmp.extract_global("boxzhi", 1)
124 | xy =lmp.extract_global("xy", 1)
125 | yz =lmp.extract_global("yz", 1)
126 | xz =lmp.extract_global("xz", 1)
127 |
128 | except UnboundLocalError:
129 | boxlo, boxhi, xy, yz, xz, periodicity, box_change = lmp.extract_box()
130 | xlo, ylo, zlo = boxlo
131 | xhi, yhi, zhi = boxhi
132 |
133 | unitcell = np.array([[xhi-xlo, xy, xz],
134 | [0, yhi-ylo, yz],
135 | [0, 0, zhi-zlo]]).T
136 |
137 | type_mass = lmp.extract_atom("mass", 2)
138 | type = lmp.extract_atom("type", 0)
139 |
140 | masses = np.array([type_mass[type[i]] for i in range(na)], dtype=float)
141 | symbols = [mass_to_symbol(masses[i]) for i in range(na)]
142 |
143 | xp = lmp.extract_atom("x", 3)
144 | positions = np.array([[xp[i][0], xp[i][1], xp[i][2]] for i in range(na)], dtype=float)
145 |
146 | # set order of ID's
147 | id = lmp.extract_atom("id", 0)
148 | id = np.array([id[i] - 1 for i in range(na)], dtype=int)
149 |
150 | positions = positions[id.argsort()]
151 | symbols = [symbols[i] for i in id.argsort()]
152 | masses = masses[id.argsort()]
153 |
154 | return PhonopyAtoms(positions=positions,
155 | masses=masses,
156 | symbols=symbols,
157 | cell=unitcell)
158 |
159 | def generate_VASP_structure(structure, scaled=True, supercell=(1, 1, 1)):
160 |
161 | cell = structure.get_cell()
162 | types = structure.get_chemical_symbols()
163 |
164 | elements = [types[0]]
165 | elements_count = [1]
166 |
167 | for t in types[1:]:
168 | if t == elements[-1]:
169 | elements_count[-1] += 1
170 | else:
171 | elements.append(t)
172 | elements_count.append(1)
173 |
174 | #atom_type_unique = np.unique(types, return_index=True)
175 |
176 | # To use unique without sorting
177 | #sort_index = np.argsort(atom_type_unique[1])
178 | #elements = np.array(atom_type_unique[0])[sort_index]
179 |
180 | #elements_count= np.diff(np.append(np.array(atom_type_unique[1])[sort_index], [len(types)]))
181 | #print(elements_count)
182 |
183 | vasp_POSCAR = 'Generated using phonoLAMMPS\n'
184 | vasp_POSCAR += '1.0\n'
185 | for row in cell:
186 | vasp_POSCAR += '{0:20.10f} {1:20.10f} {2:20.10f}\n'.format(*row)
187 | vasp_POSCAR += ' '.join(elements)
188 | vasp_POSCAR += ' \n'
189 | vasp_POSCAR += ' '.join([str(i) for i in elements_count])
190 |
191 | if scaled:
192 | scaled_positions = structure.get_scaled_positions()
193 | vasp_POSCAR += '\nDirect\n'
194 | for row in scaled_positions:
195 | vasp_POSCAR += '{0:15.15f} {1:15.15f} {2:15.15f}\n'.format(*row)
196 |
197 | else:
198 | positions = structure.get_positions()
199 | vasp_POSCAR += '\nCartesian\n'
200 | for row in positions:
201 | vasp_POSCAR += '{0:20.10f} {1:20.10f} {2:20.10f}\n'.format(*row)
202 |
203 | return vasp_POSCAR
204 |
205 |
206 | def get_structure_from_txyz(file_name, key_file):
207 |
208 | tinker_file = open(file_name, 'r')
209 |
210 | coordinates = []
211 | atomic_numbers = []
212 | atomic_elements = []
213 | atom_types = []
214 | connectivity = []
215 |
216 | number_of_atoms = int(tinker_file.readline().split()[0])
217 |
218 | # print(number_of_atoms)
219 | for i in range(number_of_atoms):
220 | line = tinker_file.readline().split()
221 | # Check if txyz contains cell parameters
222 | if line[1].replace('.','',1).isdigit():
223 | line = tinker_file.readline().split()
224 |
225 | coordinates.append(line[2:5])
226 | atomic_numbers.append(int(line[0]))
227 | atomic_elements.append(line[1])
228 | atom_types.append(line[5])
229 | connectivity.append([int(f) for f in line[6:]])
230 | # print(np.array(coordinates,dtype=float))
231 |
232 | tinker_file.close()
233 |
234 | lines = open(key_file, 'r').readlines()
235 | # print lines
236 |
237 | params = []
238 | for label in ['a-axis', 'b-axis', 'c-axis', 'alpha', 'beta', 'gamma']:
239 | for line in lines:
240 | if label in line.lower():
241 | params.append(float(line.split()[1]))
242 | a, b, c, alpha, beta, gamma = params
243 |
244 | a1 = a
245 | b1 = b*np.cos(np.deg2rad(gamma))
246 | b2 = np.sqrt(b**2 - b1**2)
247 | c1 = c*np.cos(np.deg2rad(beta))
248 | c2 = (b*c*np.cos(np.deg2rad(alpha)) - b1*c1)/b2
249 | c3 = np.sqrt(c**2-c1**2-c2**2)
250 |
251 | unitcell = [[a1, 0, 0],
252 | [b1, b2, 0],
253 | [c1, c2, c3]]
254 |
255 | return PhonopyAtomsConnect(positions=np.array(coordinates, dtype=float),
256 | symbols=atomic_elements,
257 | cell=unitcell,
258 | connectivity=connectivity,
259 | atom_types=atom_types)
260 |
261 |
262 | def generate_tinker_txyz_file(structure):
263 | pos = structure.get_positions()
264 | sym = structure.get_chemical_symbols()
265 | con = structure.get_connectivity()
266 | typ = structure.get_atom_types()
267 |
268 | tinker_txt = '{} MM2 parameters\n'.format(len(pos))
269 | for i, p in enumerate(pos):
270 | tinker_txt += ' {} {} '.format(i+1, sym[i]) + '{} {} {} '.format(*p) + ' {} '.format(typ[i]) + ' '.join(np.array(con[i], dtype=str)) + '\n'
271 |
272 | return tinker_txt
273 |
274 |
275 | def generate_tinker_key_file(structure,
276 | archive='overwrite',
277 | wdv_cutoff=20):
278 |
279 | cell = structure.get_cell()
280 |
281 | a, b, c = np.sqrt(np.dot(cell, cell.transpose()).diagonal())
282 | alpha = np.rad2deg(np.arccos(np.vdot(cell[1], cell[2]) / b / c))
283 | beta = np.rad2deg(np.arccos(np.vdot(cell[2], cell[0]) / c / a))
284 | gamma = np.rad2deg(np.arccos(np.vdot(cell[0], cell[1]) / a / b))
285 |
286 | tinker_txt = '# Cell parameters\n'
287 | tinker_txt += 'a-axis {}\n'.format(a)
288 | tinker_txt += 'b-axis {}\n'.format(b)
289 | tinker_txt += 'c-axis {}\n'.format(c)
290 |
291 | tinker_txt += 'ALPHA {}\n'.format(alpha)
292 | tinker_txt += 'BETA {}\n'.format(beta)
293 | tinker_txt += 'GAMMA {}\n'.format(gamma)
294 |
295 | tinker_txt += '# Other parameters\n'.format(c)
296 | tinker_txt += 'VDW-CUTOFF {}\n'.format(wdv_cutoff)
297 | tinker_txt += 'archive {}\n'.format(archive)
298 |
299 | return tinker_txt
300 |
301 |
302 | def parse_tinker_forces(output):
303 |
304 | data = output.decode().split('Anlyt')[1:-2]
305 |
306 | gradient = []
307 | for d in data:
308 | gradient.append(d.split()[1:4])
309 | forces = -np.array(gradient, dtype=float)
310 | return forces
311 |
312 |
313 | def get_connectivity(positions, symbols):
314 | import openbabel
315 |
316 | obConversion = openbabel.OBConversion()
317 | obConversion.SetInAndOutFormats("xyz", "mol2")
318 |
319 | mol = openbabel.OBMol()
320 |
321 | xyz_file = '{}\n\n'.format(len(symbols))
322 |
323 | for s, c in zip(symbols, positions):
324 | xyz_file += '{} '.format(s) + '{:15.10f} {:15.10f} {:15.10f}\n'.format(*c)
325 |
326 |
327 | obConversion.ReadString(mol, xyz_file)
328 |
329 | conn_index = []
330 | for i in range(mol.NumBonds()):
331 | conn_index.append((mol.GetBond(i).GetBeginAtomIdx() - 1, mol.GetBond(i).GetEndAtomIdx() - 1))
332 |
333 | return conn_index
334 |
335 |
336 | def get_structure_from_g96(filename):
337 |
338 | coordinates = []
339 | atom_types = []
340 |
341 | with open(filename, 'r') as f:
342 | for i in range(4):
343 | f.readline()
344 |
345 | while True:
346 | line = f.readline()
347 | if 'END' in line:
348 | break
349 | coordinates.append(line.split()[4:7])
350 | atom_types.append(line.split()[2])
351 |
352 | f.readline()
353 | unitcell_list = np.array(f.readline().split(), dtype=float)
354 |
355 | coordinates = np.array(coordinates, dtype=float) * 10
356 |
357 | uc = np.zeros((3, 3))
358 | uc[0,0], uc[1,1], uc[2,2], uc[0,1], uc[0,2], uc[1,0], uc[1,2], uc[2,0], uc[2,1] = unitcell_list
359 | uc *= 10
360 |
361 | def types_to_element(types):
362 | elements = []
363 | for t in types:
364 | elements.append(''.join([i for i in t if not i.isdigit()]))
365 |
366 | return elements
367 |
368 | atomic_elements = types_to_element(atom_types)
369 |
370 | return PhonopyAtomsConnect(positions=coordinates,
371 | symbols=atomic_elements,
372 | cell=uc,
373 | connectivity=get_connectivity(np.array(coordinates, dtype=float), atomic_elements),
374 | atom_types=atom_types)
375 |
376 |
377 | def get_structure_from_gro(file_name):
378 |
379 | gro_file = open(file_name, 'r')
380 |
381 | coordinates = []
382 | atom_types = []
383 |
384 | gro_file.readline()
385 | number_of_atoms = int(gro_file.readline().split()[0])
386 |
387 | for i in range(number_of_atoms):
388 | line = gro_file.readline().split()
389 |
390 | coordinates.append(line[3:6])
391 | # atomic_elements.append(line[1])
392 | atom_types.append(line[1])
393 |
394 | coordinates = np.array(coordinates, dtype=float) * 10
395 |
396 | uc = np.zeros((3, 3))
397 | uc[0,0], uc[1,1], uc[2,2], uc[0,1], uc[0,2], uc[1,0], uc[1,2], uc[2,0], uc[2,1] = gro_file.readline().split()
398 | uc *= 10
399 |
400 | # [[8.194, 0.000, 0.00],
401 | # [ 0.000, 5.968, 0.00],
402 | # [-4.790, 0.000, 7.22]]
403 | # 0.81940 0.59680 0.72231
404 | # 0.00000 0.00000 0.00000
405 | # 0.00000 0.34004 0.00000
406 | # v1(x) v2(y) v3(z)
407 | # v1(y) v1(z) v2(x)
408 | # v2(z) v3(x) v3(y)
409 |
410 |
411 | gro_file.close()
412 |
413 | def types_to_element(types):
414 | elements = []
415 | for t in types:
416 | elements.append(''.join([i for i in t if not i.isdigit()]))
417 |
418 | return elements
419 |
420 | atomic_elements = types_to_element(atom_types)
421 |
422 |
423 | return PhonopyAtomsConnect(positions=coordinates,
424 | symbols=atomic_elements,
425 | cell=uc,
426 | connectivity=get_connectivity(np.array(coordinates, dtype=float), atomic_elements),
427 | atom_types=atom_types)
428 |
429 | def generate_gro(structure_wd, structure_uc, filename):
430 | n_at_uc = len(structure_uc.symbols)
431 | n_at = len(structure_wd.symbols)
432 |
433 | index_list = []
434 | for i in range(n_at_uc):
435 | for j in range(n_at_uc):
436 | index_list.append(j * n_at // n_at_uc + i)
437 | # print(index_list[-1])
438 |
439 | with open(filename, 'w') as f:
440 | f.write('cell with displacements\n')
441 | f.write(' {}\n'.format(n_at))
442 | for i in range(n_at):
443 | iuc = np.mod(i, n_at_uc)
444 | # pre_lie = ' {:3}LIG {:>6} {:4}'.format(iuc+1, structure_wd.get_atom_types()[i], i+1)
445 | pre_lie = ' {:3}LIG {:>6} {:4}'.format(i // n_at_uc + 1, structure_uc.get_atom_types()[iuc], i + 1)
446 |
447 | # pos_line = ' {:7.3f} {:7.3f} {:7.3f} '.format(*structure_wd.positions[i]/10)
448 | pos_line = ' {:7.3f} {:7.3f} {:7.3f} '.format(*structure_wd.positions[index_list[i]] / 10)
449 | # pos_line = ' {:12.6f} {:12.6f} {:12.6f} '.format(*structure_wd.positions[index_list[i]]/10)
450 |
451 | f.write(pre_lie + pos_line + ' 0.0000 0.0000 0.0000\n')
452 |
453 | uc = structure_wd.cell / 10
454 |
455 | f.write('{} {} {} {} {} {} {} {} {}\n'.format(uc[0, 0], uc[1, 1], uc[2, 2],
456 | uc[0, 1], uc[0, 2], uc[1, 0],
457 | uc[1, 2], uc[2, 0], uc[2, 1]))
458 |
459 |
460 | def generate_g96(structure_wd, structure_uc, filename):
461 | n_at_uc = len(structure_uc.symbols)
462 | n_at = len(structure_wd.symbols)
463 |
464 | index_list = []
465 | for i in range(n_at):
466 | for j in range(n_at_uc):
467 | index_list.append(j * n_at // n_at_uc + i)
468 | # print(index_list[-1])
469 |
470 |
471 | with open(filename, 'w') as f:
472 | f.write('TITLE\ncell with displacements\nEND\nPOSITION\n')
473 |
474 | for i in range(n_at):
475 | iuc = np.mod(i, n_at_uc)
476 | # pre_lie = ' {:3}LIG {:>6} {:4}'.format(iuc+1, structure_wd.get_atom_types()[i], i+1)
477 | pre_lie = ' {:3} LIG {:<7} {:4}'.format(i // n_at_uc + 1, structure_uc.get_atom_types()[iuc], i + 1)
478 |
479 | # pos_line = ' {:7.3f} {:7.3f} {:7.3f} '.format(*structure_wd.positions[i]/10)
480 | # pos_line = ' {:7.3f} {:7.3f} {:7.3f} '.format(*structure_wd.positions[index_list[i]] / 10)
481 | # print(structure_wd.positions[index_list[i]])
482 |
483 | pos_line = ' {:14.9f} {:14.9f} {:14.9f} '.format(*structure_wd.positions[index_list[i]]/10)
484 |
485 | f.write(pre_lie + pos_line + '\n')
486 |
487 | f.write('END\n')
488 | f.write('BOX\n')
489 |
490 | uc = structure_wd.cell / 10
491 |
492 | f.write(' {:14.9f} {:14.9f} {:14.9f} {:14.9f} {:14.9f} {:14.9f} {:14.9f} {:14.9f} {:14.9f}\n'.format(
493 | uc[0, 0], uc[1, 1], uc[2, 2],
494 | uc[0, 1], uc[0, 2], uc[1, 0],
495 | uc[1, 2], uc[2, 0], uc[2, 1]))
496 |
497 | f.write('END\n')
498 |
499 |
500 | if __name__ == '__main__':
501 |
502 | masses = []
503 | elements = []
504 | for element in atom_data:
505 | if element[3] is not None:
506 | masses.append(element[3])
507 | elements.append(element[1])
508 |
509 | for mass, ref in zip(masses, elements):
510 | symbol = mass_to_symbol(mass)
511 | print(symbol, symbol == ref)
512 |
--------------------------------------------------------------------------------
/phonolammps/phonopy_link.py:
--------------------------------------------------------------------------------
1 | from phonopy.api_phonopy import Phonopy
2 | from phonopy.structure.atoms import PhonopyAtoms
3 | from phonopy.file_IO import parse_BORN
4 | import numpy as np
5 |
6 |
7 | # Subclassing PhonopyAtoms to include connectivity & atom types (for tinker & gromacs)
8 | class PhonopyAtomsConnect(PhonopyAtoms):
9 | def __init__(self, **kwargs):
10 | # Extract connectivity & atom types
11 | connectivity = kwargs.pop('connectivity', None)
12 | atom_types = kwargs.pop('atom_types', None)
13 | self._connectivity = connectivity
14 | self._atom_types = atom_types
15 |
16 | super(PhonopyAtomsConnect, self).__init__(**kwargs)
17 |
18 | def get_connectivity(self):
19 | return self._connectivity
20 |
21 | def get_atom_types(self):
22 | return self._atom_types
23 |
24 |
25 | class ForceConstants:
26 | """
27 | Define Force constants object
28 | """
29 | def __init__(self, force_constants, supercell=np.identity(3)):
30 | """
31 | Initialize force constants
32 |
33 | :param force_constants: array matrix containing the force constants (phonopy format)
34 | :param supercell: 3x3 array (or list of lists) containing the supercell definition
35 | """
36 |
37 | self._force_constants = np.array(force_constants)
38 | self._supercell = np.array(supercell)
39 |
40 | def get_array(self):
41 | """
42 | get the force constants array in phonopy format
43 |
44 | :return: force constants array
45 | """
46 | return self._force_constants
47 |
48 | def get_supercell(self):
49 | """
50 | get the supercell (respect to the unit cell) in which the force constants are defined
51 |
52 | :return: 3x3 array containing the supercell
53 | """
54 | return self._supercell
55 |
56 |
57 | def get_phonon(structure,
58 | NAC=False,
59 | setup_forces=True,
60 | super_cell_phonon=np.identity(3),
61 | primitive_matrix=np.identity(3),
62 | symmetrize=True):
63 | """
64 | Return a phonopy phonon object (instance of the class Phonon)
65 |
66 | :param structure: unit cell matrix (lattice vectors in rows)
67 | :param NAC: (Bool) activate/deactivate Non-analytic corrections
68 | :param setup_forces: (Bool) decide if pre-calculate harmonic forces in phonon object
69 | :param super_cell_phonon: 3x3 array containing the supercell to be used to calculate the force constants
70 | :param primitive_matrix: 3x3 array containing the primitive axis (in rows) which define the primitive cell
71 | :param symmetrize: decide if symmetrize the force constants
72 | :return: phonopy phonon object
73 | """
74 |
75 | phonon = Phonopy(structure, super_cell_phonon,
76 | primitive_matrix=primitive_matrix,
77 | symprec=1e-5, is_symmetry=symmetrize)
78 |
79 | # Non Analytical Corrections (NAC) from Phonopy [Frequencies only, eigenvectors no affected by this option]
80 |
81 | if setup_forces:
82 | if structure.get_force_constants() is not None:
83 | phonon.set_force_constants(structure.get_force_constants().get_array())
84 | elif structure.get_force_sets() is not None:
85 | phonon.set_displacement_dataset(structure.get_force_sets().get_dict())
86 | phonon.produce_force_constants()
87 | structure.set_force_constants(ForceConstants(phonon.get_force_constants(),
88 | supercell=structure.get_force_sets().get_supercell()))
89 | else:
90 | print('No force sets/constants available!')
91 | exit()
92 |
93 | if NAC:
94 | print("Using non-analytical corrections")
95 | primitive = phonon.get_primitive()
96 | try:
97 | nac_params = parse_BORN(primitive, is_symmetry=True)
98 | phonon.set_nac_params(nac_params=nac_params)
99 | except OSError:
100 | print('Required BORN file not found!')
101 | exit()
102 |
103 | return phonon
104 |
105 |
106 | def obtain_phonon_dispersion_bands(structure, bands_ranges, force_constants, supercell,
107 | NAC=False, band_resolution=30, band_connection=False,
108 | primitive_matrix=np.identity(3)):
109 | """
110 | Get the phonon dispersion bands in phonopy format
111 |
112 | :param structure: unit cell matrix (lattice vectors in rows)
113 | :param bands_ranges: define the path in the reciprocal space (phonopy format)
114 | :param force_constants: force constants array ( in phonopy format)
115 | :param supercell: 3x3 array containing the supercell to be used to calculate the force constants
116 | :param NAC: (Bool) activate/deactivate Non-analytic corrections
117 | :param band_resolution: define number of points in path in the reciprocal space
118 | :param band_connection: decide if bands will be all connected or in segments
119 | :param primitive_matrix: 3x3 array containing the primitive axis (in rows) which define the primitive cell
120 | :return:
121 | """
122 | phonon = get_phonon(structure, NAC=NAC, setup_forces=False,
123 | super_cell_phonon=supercell,
124 | primitive_matrix=primitive_matrix)
125 |
126 | phonon.set_force_constants(force_constants)
127 |
128 | bands =[]
129 | for q_start, q_end in bands_ranges:
130 | band = []
131 | for i in range(band_resolution+1):
132 | band.append(np.array(q_start) + (np.array(q_end) - np.array(q_start)) / band_resolution * i)
133 | bands.append(band)
134 |
135 | try:
136 | phonon.run_band_structure(bands, is_band_connection=band_connection, with_eigenvectors=True)
137 | bands_dict = phonon.get_band_structure_dict()
138 | bands_phonopy = (bands_dict['qpoints'],
139 | bands_dict['distances'],
140 | bands_dict['frequencies'],
141 | bands_dict['eigenvectors'])
142 |
143 | except AttributeError:
144 | # phonopy 1.9.x+ support
145 | phonon.set_band_structure(bands, is_band_connection=band_connection, is_eigenvectors=True)
146 | bands_phonopy = phonon.get_band_structure()
147 |
148 | return bands_phonopy
149 |
150 |
151 | def get_primitive_structure(structure, primitive_matrix=np.eye(3)):
152 | from phonopy.structure.cells import get_primitive
153 | return get_primitive(structure, primitive_matrix)
154 |
155 |
156 | def standarize_structure(structure):
157 | from phonopy.structure.spglib import standardize_cell
158 |
159 | lattice, positions, numbers = standardize_cell(structure, to_primitive=False, no_idealize=False, symprec=1e-5)
160 |
161 | return PhonopyAtoms(positions=positions,
162 | numbers=numbers,
163 | cell=lattice)
164 |
--------------------------------------------------------------------------------
/phonolammps/swissparam.py:
--------------------------------------------------------------------------------
1 | import requests as req
2 | from lxml import html
3 | import time
4 | import io
5 | from zipfile import ZipFile
6 | import openbabel
7 | import numpy as np
8 |
9 |
10 | class SwissParams:
11 |
12 | def __init__(self, structure, silent=False):
13 | self._structure = structure
14 | self._filename = 'test'
15 | self._silent = silent
16 |
17 | self._zip_data = None
18 | self._url_data = None
19 |
20 | def get_mol2(self):
21 | obConversion = openbabel.OBConversion()
22 | obConversion.SetInAndOutFormats("xyz", "mol2")
23 |
24 | mol = openbabel.OBMol()
25 |
26 | xyz_file = '{}\n\n'.format(len(self._structure.symbols))
27 |
28 | for s, c in zip(self._structure.symbols, self._structure.positions):
29 | xyz_file += '{} '.format(s) + '{:15.10} {:15.10} {:15.10}\n'.format(*c)
30 |
31 | obConversion.ReadString(mol, xyz_file)
32 |
33 | return obConversion.WriteString(mol)
34 |
35 | def get_zip_file(self, wait_time=10):
36 |
37 | if self._zip_data is not None:
38 | return self._zip_data
39 |
40 | url_data = self.submit_file()
41 |
42 | url_zip = url_data.replace('index.html', self._filename + '.zip')
43 |
44 | r_data = req.get(url_data, allow_redirects=True)
45 |
46 | if not self._silent:
47 | print('connecting to SwissParam...')
48 | print('url: {}'.format(url_data))
49 |
50 | n = 0
51 | while 'Your job is currently being performed' in r_data.text:
52 | r_data = req.get(url_data, allow_redirects=True)
53 | if not self._silent:
54 | print('\b' * (np.mod(n - 1, 10) + 7), end="", flush=True)
55 | print('waiting' + '.' * np.mod(n, 10), end="", flush=True)
56 | n += 1
57 |
58 | time.sleep(wait_time)
59 |
60 | r = req.get(url_zip, allow_redirects=True)
61 |
62 | if r.status_code == 404:
63 | print(r_data.text)
64 | raise Exception('Failed retrieving parameters from SwissParam')
65 |
66 | if not self._silent:
67 | print('.done')
68 |
69 | self._zip_data = r.content
70 |
71 | r.close()
72 | r_data.close()
73 |
74 | return self._zip_data
75 |
76 | def store_param_zip(self, filename='params.zip'):
77 | with open(filename, 'wb') as f:
78 | f.write(self.get_zip_file())
79 |
80 | def submit_file(self):
81 |
82 | if self._url_data is not None:
83 | return self._url_data
84 |
85 | url = 'https://www.swissparam.ch/submit.php'
86 |
87 | files = {'MAX_FILE_SIZE': '30000000',
88 | 'mol2Files': (self._filename + '.mol2',
89 | io.StringIO(self.get_mol2()),
90 | 'multipart/form-data')}
91 |
92 | r = req.post(url, files=files)
93 |
94 | tree = html.fromstring(r.content)
95 |
96 | self._url_data = tree.xpath('//a[@class="sib_link"]/text()')[0]
97 |
98 | r.close()
99 |
100 | return self._url_data
101 |
102 | def get_data_contents(self):
103 |
104 | input_zip = ZipFile(io.BytesIO(self.get_zip_file()))
105 | files_dict = {name: input_zip.read(name) for name in input_zip.namelist()}
106 |
107 | return files_dict
108 |
109 | def get_itp_data(self):
110 | return self.get_data_contents()[self._filename + '.itp'].decode()
111 |
112 | def get_pdb_data(self):
113 | return self.get_data_contents()[self._filename + '.pdb'].decode()
114 |
115 |
116 | if __name__ == '__main__':
117 | from phonopy.structure.atoms import PhonopyAtoms
118 |
119 | structure = PhonopyAtoms(symbols=['C', 'C', 'H', 'H', 'H', 'H'],
120 | positions=[[ 0.6952, 0.0000, 0.0000],
121 | [-0.6695, 0.0000, 0.0000],
122 | [ 1.2321, 0.9289, 0.0000],
123 | [ 1.2321,-0.9289, 0.0000],
124 | [-1.2321, 0.9289, 0.0000],
125 | [-1.2321,-0.9289, 0.0000]],
126 | cell=[[10, 0, 0], [0, 10, 0], [0, 0, 10]]
127 | )
128 |
129 | sp = SwissParams(structure)
130 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | #####################################
2 | # Required packages for phonolammps #
3 | #####################################
4 |
5 | # mandatory
6 | numpy>=1.8.2
7 | phonopy
8 | # lammps (Need to be installed manually from LAMMPS source)
9 |
10 | # (optional) for plotting phonon band structure
11 | matplotlib
12 | seekpath
13 |
14 | # (optional) for finite temperature FC calculations
15 | dynaphopy
16 |
--------------------------------------------------------------------------------
/scripts/phonolammps:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from contextlib import contextmanager
4 | from phonolammps import Phonolammps
5 | from lammps import lammps
6 | from datetime import date
7 | import numpy as np
8 | import argparse
9 | import os, sys
10 | import phonopy
11 |
12 |
13 | # Define function to silence output
14 | @contextmanager
15 | def silence_stdout(deactivate):
16 | if deactivate:
17 | yield None
18 | else:
19 | new_target = open(os.devnull, "w")
20 | old_target, sys.stdout = sys.stdout, new_target
21 | try:
22 | yield new_target
23 | finally:
24 | sys.stdout = old_target
25 |
26 | @contextmanager
27 | def show_stdout():
28 | yield None
29 |
30 |
31 | parser = argparse.ArgumentParser(description='phonoLAMMPS options')
32 |
33 | parser.add_argument('lammps_input_file', metavar='lammps_file', type=str,
34 | help='lammps input file', nargs='?')
35 |
36 | parser.add_argument('-o', metavar='file', type=str, default='FORCE_CONSTANTS',
37 | help='force constants output file [default: FORCE_CONSTANTS]')
38 |
39 | parser.add_argument('--dim', metavar='N', type=int, nargs=3, default=[1, 1, 1],
40 | help='dimensions of the supercell')
41 |
42 | parser.add_argument('-p', action='store_true',
43 | help='plot phonon band structure')
44 |
45 | parser.add_argument('-c', '--cell', metavar='file', type=str, default=None,
46 | help='generates a POSCAR type file containing the unit cell')
47 |
48 | parser.add_argument('-pa', '--primitive_axis', metavar='F', type=float, nargs=9, default=[1, 0, 0,
49 | 0, 1, 0,
50 | 0, 0, 1],
51 | help='primitive axis')
52 |
53 | parser.add_argument('-t', metavar='F', type=float, default=None,
54 | help='temperature in K')
55 |
56 | parser.add_argument('--optimize', action='store_true',
57 | help='optimize atoms position of unitcell ')
58 |
59 | parser.add_argument('--force_tol', metavar='F', type=float, default=1e-10,
60 | help='forces tolerance for optimization')
61 |
62 | parser.add_argument('--amplitude', metavar='F', type=float, default=0.01,
63 | help='displacement distance [default: 0.01 angstrom]')
64 |
65 | parser.add_argument('--total_time', metavar='F', type=float, default=20,
66 | help='total MD time in picoseconds [default: 20 ps]')
67 |
68 | parser.add_argument('--relaxation_time', metavar='F', type=float, default=5,
69 | help='MD relaxation time in picoseconds [default: 5 ps]')
70 |
71 | parser.add_argument('--timestep', metavar='F', type=float, default=0.001,
72 | help='MD time step in picoseconds [default: 0.001 ps]')
73 |
74 | parser.add_argument('--logshow', action='store_true',
75 | help='show LAMMPS & dynaphopy log on screen')
76 |
77 | parser.add_argument('--no_symmetrize', action='store_true',
78 | help='deactivate force constant symmetrization')
79 |
80 | parser.add_argument('--use_NAC', action='store_true',
81 | help='include non analytical corrections (Requires BORN file in work directory)')
82 |
83 | parser.add_argument('--write_force_sets', action='store_true',
84 | help='write FORCE_SETS file')
85 |
86 | parser.add_argument('--version', action='store_true',
87 | help='print version')
88 |
89 |
90 | args = parser.parse_args()
91 |
92 |
93 |
94 | #raise argparse.ArgumentError(args, 'message')
95 |
96 | if args.version:
97 | from phonolammps import __version__ as ph_lammps_version
98 |
99 | lmp = lammps(cmdargs=['-screen', 'none'])
100 | version_date = str(lammps.version(lmp))
101 |
102 | date_lammps = date(int(version_date[0:4]),
103 | int(version_date[4:6]),
104 | int(version_date[6:8]))
105 |
106 | print('PHONOLAMMPS: {}'.format(ph_lammps_version))
107 | print('LAMMPS: {}'.format(date_lammps.strftime("%d %B %Y")))
108 | print('PHONOPY: {}'.format(phonopy.__version__))
109 | print('PYTHON: {}'.format(sys.version.split('\n')[0]))
110 |
111 | exit()
112 |
113 | if args.lammps_input_file is None:
114 | parser.error("too few arguments")
115 |
116 | phlammps = Phonolammps(args.lammps_input_file,
117 | supercell_matrix=np.diag(args.dim),
118 | primitive_matrix=np.array(args.primitive_axis).reshape((3, 3)),
119 | displacement_distance=args.amplitude,
120 | show_log=args.logshow,
121 | show_progress=True,
122 | use_NAC=args.use_NAC,
123 | symmetrize=not(args.no_symmetrize))
124 |
125 |
126 | if args.optimize:
127 | phlammps.optimize_unitcell(force_tol=args.force_tol)
128 |
129 | # If temperature is set then do dynaphopy calculation
130 | if args.t is not None:
131 | from dynaphopy import Quasiparticle
132 | from dynaphopy.atoms import Structure
133 | from dynaphopy.interface.lammps_link import generate_lammps_trajectory
134 | from dynaphopy.interface.phonopy_link import ForceConstants
135 | from phonopy.file_IO import write_FORCE_CONSTANTS, write_force_constants_to_hdf5
136 |
137 | unitcell = phlammps.get_unitcell()
138 | force_constants = phlammps.get_force_constants()
139 | structure = Structure(cell=unitcell.get_cell(), # cell_matrix, lattice vectors in rows
140 | scaled_positions=unitcell.get_scaled_positions(),
141 | atomic_elements=unitcell.get_chemical_symbols(),
142 | primitive_matrix=np.array(args.primitive_axis).reshape((3, 3)))
143 |
144 | structure.set_force_constants(ForceConstants(force_constants,
145 | supercell=np.diag(args.dim)))
146 |
147 | structure.set_supercell_matrix(np.diag(args.dim))
148 | # generate LAMMPS MD trajectory (requires dynaphopy development)
149 | trajectory = generate_lammps_trajectory(structure, 'in.lammps',
150 | total_time=args.total_time,
151 | time_step=args.timestep,
152 | relaxation_time=args.relaxation_time,
153 | silent=False,
154 | supercell=args.dim,
155 | memmap=False,
156 | velocity_only=True,
157 | temperature=args.t)
158 |
159 | # Calculate renormalized force constants with dynaphopy
160 | calculation = Quasiparticle(trajectory)
161 | with silence_stdout(args.logshow):
162 | calculation.select_power_spectra_algorithm(2)
163 | renormalized_force_constants = calculation.get_renormalized_force_constants().get_array()
164 |
165 | if args.p:
166 | calculation.plot_renormalized_phonon_dispersion_bands()
167 |
168 | print('writing renormalized force constants')
169 | write_FORCE_CONSTANTS(renormalized_force_constants, filename=args.o)
170 |
171 | else:
172 | if args.p:
173 | phlammps.plot_phonon_dispersion_bands()
174 |
175 | if args.write_force_sets:
176 | print('writing force sets')
177 | phlammps.write_force_sets(filename='FORCE_SETS')
178 | print('writing force constants')
179 | phlammps.write_force_constants(filename=args.o)
180 |
181 |
182 | if args.cell is not None:
183 | print ('writing POSCAR file: {}'.format(args.cell))
184 | phlammps.write_unitcell_POSCAR(args.cell)
185 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | try:
2 | from setuptools import setup, Extension
3 | use_setuptools = True
4 | print("setuptools is used.")
5 | except ImportError:
6 | from distutils.core import setup, Extension
7 | use_setuptools = False
8 | print("distutils is used.")
9 |
10 |
11 | def get_version_number():
12 | for l in open('phonolammps/__init__.py', 'r').readlines():
13 | if not(l.find('__version__')):
14 | exec(l, globals())
15 | return __version__
16 |
17 | setup(name='phonoLAMMPS',
18 | version=get_version_number(),
19 | description='phonoLAMMPS module',
20 | long_description=open('README.md').read(),
21 | long_description_content_type='text/markdown',
22 | author='Abel Carreras',
23 | url='https://github.com/abelcarreras/phonolammps',
24 | author_email='abelcarreras83@gmail.com',
25 | packages=['phonolammps'],
26 | scripts=['scripts/phonolammps'],
27 | install_requires=['phonopy', 'numpy', 'matplotlib', 'seekpath', 'dynaphopy'],
28 | license='MIT License'
29 | )
30 |
--------------------------------------------------------------------------------