Merge branch 'rc'

This commit is contained in:
Atsushi Togo 2017-10-20 12:55:47 +09:00
commit 9a01e0d871
31 changed files with 696 additions and 729 deletions

46
doc/MacOSX.inc Normal file
View File

@ -0,0 +1,46 @@
.. _install_MacOSX:
Using phonopy on Mac OS X
--------------------------
This is one way to install phonopy on Mac OS X. This procedure was
tested with MacPorts version 2.4.1 and Homebrew 1.3.6. In the
following case, gcc-7 is used as the default C-compiler.
1) Install necessary python libraries by conda (see the detail about
conda, e.g., https://conda.io/miniconda.html)::
% conda install numpy scipy h5py pyyaml matplotlib
2) Install gcc
Using Homebrew. This is normally easier than using MacPorts. See
how to install homebrew https://brew.sh/ and follow the
installation instruction. Then::
% brew install gcc
Using MacPorts, download MacPorts from http://www.macports.org/
and follow the installation instruction. Then::
% sudo port install gcc7
% sudo port select --set gcc mp-gcc7
4) Install phonopy following :ref:`install_setup_py`.
Before running setup.py, the environment variable of ``CC=gcc-7``
(Homebrew) or ``CC=gcc`` (MacPorts) must be set so that installed
gcc is used as the C-compiler instead of build-in clang for compiling
the phonopy C-extension module.
For Homebrew::
% export CC=gcc-7
For MacPorts::
% export CC=gcc (MacPorts)
Then::
% python setup.py install --user

View File

@ -1,34 +0,0 @@
.. _install_MacOSX:
Using phonopy on Mac OS X
==========================
Installation using MacPorts
----------------------------
This is one way to install phonopy on Mac OS X. This procedure was
tested on Sierra with MacPorts version 2.4.1. In the following case,
gcc-7 is used as the default C-compiler.
1) Install MacPorts. Download MacPorts from http://www.macports.org/
and follow the installation instruction.
2) Install ``gcc`` by
::
% sudo port install gcc7
% sudo port select --set gcc mp-gcc7
3) Install necessary python libraries by conda::
% conda install numpy scipy h5py pyyaml matplotlib
4) Install phonopy following :ref:`install_setup_py`.
Before running setup.py, the environment variable of ``CC=gcc`` is
set so that gcc can be used as the C-compiler instead
of clang for compiling phonopy C-extension as follows::
% export CC=gcc
% python setup.py install --user

View File

@ -42,7 +42,7 @@ A procedure of Abinit-phonopy calculation is as follows:
3) Create ``FORCE_SETS`` by
::
% phonopy --abinit -f disp-001/supercell-001.out disp-002/supercell-002.out ...
To run this command, ``disp.yaml`` has to be located in the current
@ -57,6 +57,5 @@ A procedure of Abinit-phonopy calculation is as follows:
% phonopy --abinit -c NaCl.in -p band.conf
or::
% phonopy --abinit -c NaCl.in --dim="2 2 2" [other-OPTIONS] [setting-file]
% phonopy --abinit -c NaCl.in --dim="2 2 2" [other-OPTIONS] [setting-file]

View File

@ -6,10 +6,14 @@ Auxiliary tools
A few auxiliary tools are prepared. They are stored in ``bin``
directory as well as ``phonopy``.
.. contents::
:depth: 3
:local:
.. _bandplot_tool:
``bandplot``
------------
``phonopy-bandplot``
---------------------
Band structure is plotted reading phonopy output in ``band.yaml``
format. ``-o`` option with a file name is used to save the plot into a
@ -19,16 +23,16 @@ plotted together.
::
bandplot band.yaml
phonopy-bandplot band.yaml
To obtain a simple text format data::
bandplot --gnuplot band.yaml
phonopy-bandplot --gnuplot band.yaml
.. _pdosplot_tool:
``pdosplot``
------------
``phonopy-pdosplot``
---------------------
Partial density of states (PDOS) are plotted.
@ -36,7 +40,7 @@ Partial density of states (PDOS) are plotted.
::
pdosplot -i '1 2 4 5, 3 6' -o 'pdos.pdf' partial_dos.dat
phonopy-pdosplot -i '1 2 4 5, 3 6' -o 'pdos.pdf' partial_dos.dat
The indices and comma in '1 2 3 4, 5 6' mean as follows. The indices
are separated into blocks by comma (1 2 4 5 and 3 6). PDOS specified
@ -47,8 +51,8 @@ correspond to atoms. A few more options are prepared and shown by
.. _propplot_tool:
``propplot``
------------
``phonopy-propplot``
---------------------
Thermal properties are plotted. Options are prepared and shown by
``-h`` option. If you specify more than two yaml files, they are
@ -56,7 +60,7 @@ plotted together.
::
proplot thermal_properties_A.yaml thermal_properties_B.yaml
phonopy-proplot thermal_properties_A.yaml thermal_properties_B.yaml
.. ``tdplot``
.. ------------
@ -71,8 +75,8 @@ plotted together.
.. _dispmanager_tool:
``dispmanager``
----------------
``phonopy-dispmanager``
-------------------------
This is used for two purposes.
@ -92,7 +96,7 @@ and specify the displacement amplitude. An example is as follows:
::
dispmanager disp.yaml -o disp-new.yaml -a "33 1 1 0" --amplitude 0.05
phonopy-dispmanager disp.yaml -o disp-new.yaml -a "33 1 1 0" --amplitude 0.05
``disp-new.yaml`` is created from ``disp.yaml`` with a new
displacement of the thirty-third atom (index 33) with the direction of
@ -101,11 +105,11 @@ lattice vectors. The amplitude unit is same as the lattice vectors.
``-s`` is specified with displacement indices. For example when there
are four dependent displacements and only the first and third
displacements are needed, ``dispmanager`` is used like
displacements are needed, ``phonopy-dispmanager`` is used like
::
dispmanager disp.yaml -o disp-new.yaml -s "1 3"
phonopy-dispmanager disp.yaml -o disp-new.yaml -s "1 3"
``-w``
^^^^^^^
@ -122,8 +126,8 @@ The old style displacement file ``DISP`` is compared with
equivalent or not.
``outcar-born``
----------------
``phonopy-vasp-born``
----------------------
This script is used to create a ``BORN`` style file from VASP output
file of ``OUTCAR``. The first and second arguments are ``OUTCAR``
@ -132,11 +136,11 @@ type file and ``POSCAR`` type file, respectively. If both are omitted,
::
outcar-born
phonopy-vasp-born
::
outcar-born --st OUTCAR POSCAR
phonopy-vasp-born --st OUTCAR POSCAR
``--pa``, ``--primitive_axis``
@ -162,8 +166,8 @@ specified, ``vasprun.xml`` is read.
::
outcar-born --vasprunxml
phonopy-vasp-born --vasprunxml
::
outcar-born --st --vasprunxml vasprun.xml POSCAR
phonopy-vasp-born --st --vasprunxml vasprun.xml

View File

@ -3,6 +3,17 @@
Change Log
==========
Oct-19-2017: Version 1.12.0
-----------------------------
* The names of auxiliary tools and ``gruneisen`` are changed, for
which the prefix ``phonopy-`` is added to the old names to avoid
accidental conflict with other filenames already existing under
``bin``. ``outcar-born`` is renamed to
``phonopy-vasp-born``. Similarly ``gruneisen`` is renamed
``phonopy-gruneisen``. Please find these changes at
:ref:`auxiliary_tools` and :ref:`phonopy_gruneisen`.
Oct-2-2017: Version 1.11.14
-------------------------------

View File

@ -49,9 +49,9 @@ copyright = u'2009, Atsushi Togo'
# built documents.
#
# The short X.Y version.
version = '1.11.14'
version = '1.12.0'
# The full version, including alpha/beta/rc tags.
release = '1.11.14'
release = '1.12.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -246,7 +246,7 @@ htmlhelp_basename = 'phonopydoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('contents', 'phonopy.tex', u'phonopy manual',
('documentation', 'phonopy.tex', u'phonopy manual',
u'Atsushi Togo', 'manual'),
]

View File

@ -229,8 +229,10 @@ non-analytical term is given by,
D_{\alpha\beta}(jj',\mathbf{q}\to \mathbf{0}) =
D_{\alpha\beta}(jj',\mathbf{q}=\mathbf{0})
+ \frac{1}{\sqrt{m_j m_j}} \frac{4\pi}{\Omega_0}
\frac{[\sum_{\gamma}q_{\gamma}Z^{*}_{j,\gamma\alpha}][\sum_{\gamma'}q_{\gamma'}Z^{*}_{j',\gamma'\beta}]}
{\sum_{\alpha\beta}q_{\alpha}\epsilon_{\alpha\beta}^{\infty} q_{\beta}}.
\frac{\left[\sum_{\gamma}q_{\gamma}Z^{*}_{j,\gamma\alpha}\right]
\left[\sum_{\gamma'}q_{\gamma'}Z^{*}_{j',\gamma'\beta}\right]}
{\sum_{\alpha\beta}q_{\alpha}\epsilon_{\alpha\beta}^{\infty}
q_{\beta}}.
Phonon frequencies at general **q**-points are interpolated by the
method of Wang *et al.* (:ref:`reference_wang_NAC`).
@ -293,22 +295,15 @@ Entropy
.. math::
S &= -\frac{\partial F}{\partial T} \\
&= \frac{1}{2T}\sum_{\mathbf{q}\nu}\hbar\omega(\mathbf{q}\nu)\coth(\hbar\omega(\mathbf{q}\nu)/2k_\mathrm{B}T)-k_\mathrm{B} \sum_{\mathbf{q}\nu}\ln\left[2\sinh(\hbar\omega(\mathbf{q}\nu)/2k_\mathrm{B}T)\right]
S &= -\frac{\partial F}{\partial T} \\ &= \frac{1}{2T}
\sum_{\mathbf{q}\nu} \hbar\omega(\mathbf{q}\nu)
\coth(\hbar\omega(\mathbf{q}\nu)/2k_\mathrm{B}T)-k_\mathrm{B}
\sum_{\mathbf{q}\nu}
\ln\left[2\sinh(\hbar\omega(\mathbf{q}\nu)/2k_\mathrm{B}T)\right]
Thermal displacement
---------------------
.. include:: thermal-displacement.inc
.. toctree::
thermal-displacement
Group velocity
---------------
.. toctree::
group-velocity
.. include:: group-velocity.inc
.. _physical_unit_conversion:

View File

@ -1,7 +1,10 @@
.. _group_velocity:
Group velocity
---------------
Method
------------
~~~~~~~
Phonopy calculates group velocity of phonon as follows:
@ -14,17 +17,17 @@ Phonopy calculates group velocity of phonon as follows:
=&\frac{1}{2\omega(\mathbf{q}\nu)}\left<\mathbf{e}(\mathbf{q}\nu)\biggl|
\frac{\partial D(\mathbf{q})} {\partial
\mathbf{q}}\biggl|\mathbf{e}(\mathbf{q}\nu)\right>,
where the meanings of the variables are found at :ref:`formulations`.
Finite difference method
-------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~
In the previous versions, group velocity was calculated using finite
difference method:
.. math::
\mathbf{v}_\mathrm{g}(\mathbf{q}\nu) =
\frac{1}{2\omega(\mathbf{q}\nu)}\left<\mathbf{e}(\mathbf{q}\nu)\biggl|
\frac{\partial D(\mathbf{q})} {\partial
@ -44,4 +47,3 @@ velocity, where :math:`\alpha` is the Cartesian index in reciprocal
space. :math:`\Delta q_\alpha` is specified in the unit of reciprocal
space distance (:math:`\mathrm{\AA}^{-1}` for the default case) by
``--gv_delta_q`` option or ``GV_DELTA_Q`` tag.

View File

@ -28,7 +28,7 @@ prepared. A calculation along paths in reciprocal space can be made by
::
% gruneisen orig plus minus --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --band="1/2 1/4 3/4 0 0 0 1/2 1/2 1/2 1/2 0.0 1/2" -p -c POSCAR-unitcell
% phonopy-gruneisen orig plus minus --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --band="1/2 1/4 3/4 0 0 0 1/2 1/2 1/2 1/2 0.0 1/2" -p -c POSCAR-unitcell
.. |i0| image:: Si-gruneisen-band.png
:scale: 50
@ -45,7 +45,7 @@ A calculation on a reciprocal mesh is made by
::
% gruneisen orig plus minus --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --mesh="20 20 20" -p -c POSCAR-unitcell --color="RB"
% phonopy-gruneisen orig plus minus --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --mesh="20 20 20" -p -c POSCAR-unitcell --color="RB"
.. |i1| image:: Si-gruneisen-mesh.png
:scale: 50
@ -57,9 +57,10 @@ are set for band indices with ascending order of phonon frequencies.
Mode Grüneinen parameter may diverge around :math:`\Gamma`-point. In
the above example for band paths, mode Grüneinen parameters are
calculated at :math:`\Gamma`-point, but ``gruneisen`` script avoids
showing the values on the plot. Instead the values at the neighboring
**q**-points of :math:`\Gamma`-point are used for the plot.
calculated at :math:`\Gamma`-point, but ``phonopy-gruneisen`` script
avoids showing the values on the plot. Instead the values at the
neighboring **q**-points of :math:`\Gamma`-point are used for the
plot.
.. _gruneisen_calculators:
@ -71,7 +72,7 @@ for corresponding calculators and the crystal structure file format
should be different from that of the VASP format. An Abinit example is
as follows::
% gruneisen orig plus minus --abinit --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --band="1/2 1/4 3/4 0 0 0 1/2 1/2 1/2 1/2 0.0 1/2" -p -c Si.in
% phonopy-gruneisen orig plus minus --abinit --dim="2 2 2" --pa="0 1/2 1/2 1/2 0 1/2 1/2 1/2 0" --band="1/2 1/4 3/4 0 0 0 1/2 1/2 1/2 1/2 0.0 1/2" -p -c Si.in
.. _gruneisen_command_options:
@ -133,8 +134,8 @@ approximated by the finite difference method:
\frac{\Delta D(\mathbf{q})}
{\Delta V}\biggl|\mathbf{e}(\mathbf{q}\nu)\right>.
The ``gruneisen`` script requires three phonon calculations
at corresponding three volume points. One is for eigenvectors at the
equilibrium volume (:math:`V`) and the remaining two are for :math:`\Delta
D(\mathbf{q})` with slightly larger and smaller volumes than
:math:`V`.
The ``phonopy-gruneisen`` script requires three phonon calculations at
corresponding three volume points. One is for eigenvectors at the
equilibrium volume (:math:`V`) and the remaining two are for
:math:`\Delta D(\mathbf{q})` with slightly larger and smaller volumes
than :math:`V`.

View File

@ -16,9 +16,9 @@ System requirement
The procedure to setup phonopy is explained in this section. It is
supposed that phonopy is installed on the recent linux distribution
like Ubuntu or Fedora with Python version 2.6 or later. Python version
3.4 or later is expected to work. Mac OS X users may use conda packages
and also find some more information at :ref:`install_MacOSX`.
Windows users should use conda packages as well.
3.4 or later is expected to work. Mac OS X users may use conda packages
and also find some more information at :ref:`install_MacOSX`.
Windows users should use conda packages as well.
Prepare the following Python libraries:
@ -31,21 +31,21 @@ Prepare the following Python libraries:
By Ubuntu package manager
^^^^^^^^^^^^^^^^^^^^^^^^^^
The most recommended system is Ubuntu linux version 14.04 or later. If
you have any installation problem that you may feel difficult to
solve, please use a ubuntu virtual machine (see
:ref:`virtualmachine`).
The most recommended system is Ubuntu linux version 14.04 (64-bit) or
later. If you have any installation problem that you may feel
difficult to solve, please use a virtual machine environment such as
VirtualBox and install Ubuntu linux on it.
The python libraries are installed by::
% sudo apt-get install python-dev python-numpy python-matplotlib python-yaml python-h5py
``python-scipy`` is also required to use ``phonopy-qha`` or
``DEBYE_MODEL`` tag.
The ``texlive-fonts-recommended`` package may be required, if you
see the following message in ploting results::
! I can't find file `pncr7t'.
By conda
@ -105,25 +105,16 @@ needed.
export PYTH=~/.local/bin:$PATH
in your ``.bashrc`` (or maybe ``.bash_profile``), ``.zshenv``, or
other script for the other shells.
other script for the other shells.
Tips on setup.py installation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. toctree::
:maxdepth: 1
MacOSX
virtualmachine
.. _install_conda:
conda
------
Conda is a good choice for all users (Linux/MacOSX/Windows).
The Linux (64bit) conda packages are prepared by the author and
Conda is a good choice for all users (Linux/MacOSX/Windows).
The Linux (64bit) conda packages are prepared by the author and
can be installed using::
% conda install numpy scipy h5py pyyaml matplotlib
@ -134,8 +125,8 @@ of Linux), are prepared by conda-forge project and may be installed using::
% conda install -c conda-forge phonopy
The conda-forge packages are usually available within few days after
the release.
The conda-forge packages are usually available within few days after
the release.
pip
@ -164,7 +155,7 @@ Multithreading support
Two kinds of multithreadings can be used in phonopy.
1. Multithreaded BLAS linked numpy
Phonopy uses numpy to run singular value decomposition in the
calculation of force constants and diagonalizaion of dynamical
matrices. For these, numpy internally calls the LAPACK
@ -184,6 +175,9 @@ Two kinds of multithreadings can be used in phonopy.
False`` must be changed to ``with_openmp = True``. For this,
currently only gcc is supported.
.. include:: MacOSX.inc
Trouble shooting
-----------------

View File

@ -5,7 +5,7 @@ Interfaces to calculators
The interfaces for VASP, Wien2k, Pwscf, Abinit, Elk and CRYSTAL are built in
to the usual phonopy command. See the command options and how to
invoke each of them at :ref:`force_calculators`.
invoke each of them at :ref:`force_calculators`.
Physical unit system for calculator
------------------------------------
@ -34,7 +34,7 @@ Default unit cell file name for calculator
Without specifying ``-c`` option, default file name for unit cell is
used as shown below::
VASP | POSCAR
VASP | POSCAR
Wien2k | case.struct
Pwscf | unitcell.in
Abinit | unitcell.in
@ -75,15 +75,20 @@ Default unit conversion factor for non-analytical term correction
CRYSTAL | 14.399652
Interface to force calculator
------------------------------
.. _tutorials_for_calculators:
Tutorials for calculators
--------------------------
Force calculators
^^^^^^^^^^^^^^^^^^^
Short tutorials for force calculators are found in the following pages.
.. toctree::
:maxdepth: 2
:maxdepth: 1
procedure
vasp
wien2k
pwscf
abinit
@ -91,27 +96,26 @@ Short tutorials for force calculators are found in the following pages.
elk
crystal
Interface to VASP DFPT force constants
---------------------------------------
VASP DFPT force constants
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Using VASP DFPT feature, force constants are directly
calculated. Phonopy VASP DFPT interface reads ``vasprun.xml`` and
creates ``FORCE_CONSTANTS`` file.
.. toctree::
:maxdepth: 2
:maxdepth: 1
vasp
vasp-dfpt
Interface to FHI-aims forces
-----------------------------
For FHI-aims
^^^^^^^^^^^^^
For FHI-aims, there is a special command, ``phonopy-FHI-aims``. This
tool is maintained by FHI-aims community and questions may be sent to the
FHI-aims mailing list.
.. toctree::
:maxdepth: 2
:maxdepth: 1
FHI-aims

View File

@ -1,216 +1,8 @@
.. _tutorial:
VASP & phonopy calculation
==================================
Short tutorials
================
Pre-process
~~~~~~~~~~~~
The input stureture of ``POSCAR`` (:ref:`this <example_POSCAR1>`) is
used as an example here. Most files are found at `SiO2-HP example <https://github.com/atztogo/phonopy/tree/master/example/SiO2-HP/>`_.
In the pre-process, supercell structures with (or without)
displacements are created from a unit cell fully consiering crystal
symmetry.
To obtain supercells (:math:`2\times 2\times 3`) with displacements,
run phonopy::
phonopy -d --dim="2 2 3"
You should find the files, ``SPOSCAR``, ``disp.yaml``, and ``POSCAR-{number}`` as
follows::
% ls
disp.yaml POSCAR POSCAR-001 POSCAR-002 POSCAR-003 SPOSCAR
``SPOSCAR`` is the perfect supercell structure, ``disp.yaml`` contains
the information on displacements, and ``POSCAR-{number}`` are the
supercells with atomic displacements. ``POSCAR-{number}`` corresponds
to the different atomic displacements written in ``disp.yaml``.
Calculation of sets of forces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Force constants are calculated using the structure files ``POSCAR-{number}``
(from forces on atoms) or using the ``SPOSCAR`` file (direct calculation of force
constants) by your favorite calculator. See the
:ref:`details<details_of_procedure>`.
In the case of VASP, the calculations for the finite displacement method can be proceeded just using the ``POSCAR-{number}`` files as ``POSCAR`` of VASP calculations. An example of the ``INCAR`` is as follows::
PREC = Accurate
IBRION = -1
ENCUT = 500
EDIFF = 1.0e-08
ISMEAR = 0; SIGMA = 0.01
IALGO = 38
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.
Be careful not to relax the structures. Then create ``FORCE_SETS``
file using :ref:`vasp_force_sets_option`::
% phonopy -f disp-001/vasprun.xml disp-002/vasprun.xml disp-003/vasprun.xml
or
::
% phonopy -f disp-{001..003}/vasprun.xml
If you want to calculate force constants by VASP-DFPT directory, see :ref:`vasp_dfpt_interface`.
Post-process
~~~~~~~~~~~~~
In the post-process,
1. Force constants are calculated from the sets of forces
2. A part of dynamical matrix is built from the force constants
3. Phonon frequencies and eigenvectors are calculated from the
dynamical matrices with the specified *q*-points.
For mesh sampling calculation, prepare the following setting file named, e.g.,
``mesh.conf``::
ATOM_NAME = Si O
DIM = 2 2 3
MP = 8 8 8
The density of states (DOS) is plotted by::
% phonopy -p mesh.conf
Thermal properties are calculated with the sampling mesh by::
% phonopy -t mesh.conf
You should check the convergence with respect to the mesh numbers.
Thermal properties can be plotted by::
% phonopy -t -p mesh.conf
Projected DOS is calculated by the following setting file named, e.g., ``pdos.conf``::
ATOM_NAME = Si O
DIM = 2 2 3
MP = 8 8 8
PDOS = 1 2, 3 4 5 6
and plotted by::
% phonopy -p pdos.conf
Band structure is calculated with the following setting file named, e.g., `band.conf` by::
ATOM_NAME = Si O
DIM = 2 2 3
BAND = 0.5 0.5 0.5 0.0 0.0 0.0 0.5 0.5 0.0 0.0 0.5 0.0
The band structure is plotted by::
% phonopy -p band.conf
In either case, by setting the ``-s`` option, the plot is going to be saved in the PDF
format. If you don't need to plot DOS, the (partial) DOS
is just calculated using the ``--dos`` option.
Non-analytical term correction (Optional)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To activate non-analytical term correction, :ref:`born_file` is
required. This file contains the information of Born effective charge
and dielectric constant. These physical values are also obtained from
the first-principles calculations, e.g., by using VASP, pwscf, etc. In
the case of VASP, an example of ``INCAR`` will be as shown below::
PREC = Accurate
IBRION = -1
NELMIN = 5
ENCUT = 500
EDIFF = 1.000000e-08
ISMEAR = 0
SIGMA = 1.000000e-02
IALGO = 38
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.
LEPSILON = .TRUE.
In addition, it is recommended to increase the number of k-points to
be sampled. Twice the number for each axis may be a choice. After
running this VASP calculation, ``BORN`` file has to be created
following the ``BORN`` format (:ref:`born_file`). However for VASP, an
auxiliary tool is prepared, which is ``outcar-born``. There is an
option ``--pa`` for this command to set a transformation matrix from
supercell or unit cell with centring to the primitive cell. Since this
rutile-type SiO2 has the primitive lattice, it is unnecessary to set
this option. Running ``outcar-born`` in the directory containing
``OUTCAR`` of this VASP calculation::
% outcar-born
# epsilon and Z* of atoms 1 3
3.2605670 0.0000000 0.0000000 0.0000000 3.2605670 0.0000000 0.0000000 0.0000000 3.4421330
3.7558600 0.3020100 0.0000000 0.3020100 3.7558600 0.0000000 0.0000000 0.0000000 3.9965200
-1.8783900 -0.5270900 0.0000000 -0.5270900 -1.8783900 0.0000000 0.0000100 0.0000100 -1.9987900
To employ symmetry constraints, ``--st`` option may used as follows::
% outcar-born --st
# epsilon and Z* of atoms 1 3
3.2605670 0.0000000 0.0000000 0.0000000 3.2605670 0.0000000 0.0000000 0.0000000 3.4421330
3.7561900 0.3020100 0.0000000 0.3020100 3.7561900 0.0000000 0.0000000 0.0000000 3.9968733
-1.8780950 -0.5270900 0.0000000 -0.5270900 -1.8780950 0.0000000 0.0000000 0.0000000 -1.9984367
The values are slightly modified by symmetry, but we can see the
original values obtained directly from VASP was already very good.
To put ``BORN`` file in the current directly, and running phonopy with
``--nac`` option, non-analytical term correction is activated, such as::
% phonopy -p --nac band.conf
Please watch the example of NaCl with and without ``--nac`` option shown in
:ref:`examples_link`.
.. _details_of_procedure:
Some more details
------------------
The structure file names are different in different force calculators,
see :ref:`calculator_interfaces`. To notify this, (*) is put
after the structure file name. By refering
:ref:`calculator_interfaces`, please read the file name according to
those for the other calculators.
Following files are required in your working directory.
- ``POSCAR`` (*), and ``FORCE_SETS`` or ``FORCE_CONSTANTS``
- ``disp.yaml`` is required to create ``FORCE_SETS``.
In the case of finite difference approach, there are three steps.
1. Create supercells and introduce atomic displacements. Each
supercell contains one atomic displacement. It is done by using
``-d`` option with ``--dim`` option that specifies supercell
dimension. The files of supercells with atomic displacements like
as ``POSCAR-001``, ``POSCAR-002``, ..., (*) are created in current
directory by running phonopy. The files ``disp.yaml`` and
``SPOSCAR`` are also created. The file ``SPOSCAR`` is the perfect
supercell that contains no atomic displacement. This file is not
usually used.
2. Calculate forces on atoms of the supercells with atomic
displacements. After obtaining forces on atoms that calculated by
some calculator (it's out of phonopy), the forces are summarized in
``FORCE_SETS`` file following the :ref:`format <file_forces>`.
3. Calculate phonon related properties.
If you already have force constants, the first and second steps can be
omitted. However your force constants have to be converted to the
:ref:`format <file_force_constants>` that phonopy can read. The
:ref:`VASP interface <vasp_force_constants>` to convert force
constants is prepared in phonopy.
Tutorials for different force calculators, VASP, WIEN2k, PWscf (QE),
ABINIT, SIESTA, Elk, and, CRYSTAL, are found at
:ref:`tutorials_for_calculators`.

View File

@ -1,7 +1,10 @@
.. _thermal_displacement:
Thermal displacement
---------------------
Mean square displacement
--------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~
From Eq. (10.71) in the book "Thermodynamics of Crystal", atomic
displacement, **u**, is written by
@ -42,7 +45,7 @@ where :math:`n_\nu(\mathbf{q},T)` is the phonon population, which is give by,
where *T* is the temperature, and :math:`\mathrm{k_B}` is the
Boltzmann constant. The equation is calculated using the commutation
relation of the creation and annihilation operators and the
relation of the creation and annihilation operators and the
expectation values of the combination of the operations, e.g.,
.. math::
@ -58,7 +61,7 @@ expectation values of the combination of the operations, e.g.,
.. _thermal_displacement_matrix:
Mean square displacement matrix
--------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mean square displacement matrix is defined as follows:
@ -73,7 +76,7 @@ This is a symmetry matrix and diagonal elements are same as mean
square displacement calculated along Cartesian x, y, z directions.
Projection to an arbitrary axis from the Cartesian axes
--------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In phonopy, eigenvectors are calculated in the Cartesian axes that are
defined in the input structure file. Mean square displacement along an
@ -90,7 +93,7 @@ axes as follows:
where :math:`\hat{\mathbf{n}}` is an arbitrary unit direction.
Mean square displacement matrix in cif format
----------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
According to the paper by Grosse-Kunstleve and Adams [J. Appl. Cryst.,
35, 477-480 (2002)], mean square displacement matrix in the cif
@ -125,8 +128,3 @@ and
\end{pmatrix}.
:math:`a^*`, :math:`b^*`, :math:`c^*` are defined without :math:`2\pi`.

102
doc/vasp-dfpt.rst Normal file
View File

@ -0,0 +1,102 @@
.. _vasp_dfpt_interface:
VASP-DFPT & phonopy calculation
===========================================
How to run
-----------
VASP can calculate force constants in real space using DFPT. The
procedure to calculate phonon properties may be as follows:
1) Prepare unit cell structure named, e.g., ``POSCAR-unitcell``. The
following structure is a conventional unit cell of NaCl.
::
Na Cl
1.00000000000000
5.6903014761756712 0.0000000000000000 0.0000000000000000
0.0000000000000000 5.6903014761756712 0.0000000000000000
0.0000000000000000 0.0000000000000000 5.6903014761756712
4 4
Direct
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.5000000000000000 0.5000000000000000
0.5000000000000000 0.0000000000000000 0.5000000000000000
0.5000000000000000 0.5000000000000000 0.0000000000000000
0.5000000000000000 0.5000000000000000 0.5000000000000000
0.5000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.5000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.5000000000000000
2) Prepare a perfect supercell structure from ``POSCAR-unitcell``,
e.g.,
::
% phonopy -d --dim="2 2 2" -c POSCAR-unitcell
3) Rename ``SPOSCAR`` created in (2) to
``POSCAR`` (``POSCAR-{number}`` and ``disp.yaml`` files will never be used.)
::
% mv SPOSCAR POSCAR
4) Calculate force constants of the perfect supercell by running VASP
with ``IBRION = 8`` and ``NSW = 1``. An example of ``INCAR`` for
insulator may be such like (**just an example!**)::
PREC = Accurate
ENCUT = 500
IBRION = 8
EDIFF = 1.0e-08
IALGO = 38
ISMEAR = 0; SIGMA = 0.1
LREAL = .FALSE.
ADDGRID = .TRUE.
LWAVE = .FALSE.
LCHARG = .FALSE.
5) After finishing the VASP calculation, confirm ``vasprun.xml``
contains ``hessian`` elements, and then create ``FORCE_CONSTANTS``::
% phonopy --fc vasprun.xml
6) Run phonopy with the original unit cell ``POSCAR-unitcell`` and
setting tag ``FORCE_CONSTANTS = READ`` or ``--readfc`` option,
e.g., as found in ``example/NaCl-VASPdfpt``
::
% phonopy --dim="2 2 2" -c POSCAR-unitcell band.conf
_
_ __ | |__ ___ _ __ ___ _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ | '_ \| | | |
| |_) | | | | (_) | | | | (_) || |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___(_) .__/ \__, |
|_| |_| |___/
1.1
Band structure mode
Settings:
Force constants: read
Supercell: [2 2 2]
Primitive axis:
[ 0. 0.5 0.5]
[ 0.5 0. 0.5]
[ 0.5 0.5 0. ]
Spacegroup: Fm-3m (225)
Paths in reciprocal reduced coordinates:
[ 0.00 0.00 0.00] --> [ 0.50 0.00 0.00]
[ 0.50 0.00 0.00] --> [ 0.50 0.50 0.00]
[ 0.50 0.50 0.00] --> [-0.00 -0.00 0.00]
[ 0.00 0.00 0.00] --> [ 0.50 0.50 0.50]
.. |NaCl-VASPdfpt| image:: NaCl-VASPdfpt.png
:scale: 50
|NaCl-VASPdfpt|

View File

@ -1,111 +1,179 @@
.. _vasp_fd_interface:
.. _vasp_interface:
VASP & phonopy calculation
===========================
==================================
Please follow the page :ref:`tutorial` and :ref:`examples_link`.
Pre-process
~~~~~~~~~~~~
.. _vasp_dfpt_interface:
The input stureture of ``POSCAR`` (:ref:`this <example_POSCAR1>`) is
used as an example here. Most files are found at `SiO2-HP example
<https://github.com/atztogo/phonopy/tree/master/example/SiO2-HP/>`_.
VASP-DFPT & phonopy calculation
===========================================
In the pre-process, supercell structures with (or without)
displacements are created from a unit cell fully consiering crystal
symmetry.
How to run
-----------
To obtain supercells (:math:`2\times 2\times 3`) with displacements,
run phonopy::
VASP can calculate force constants in real space using DFPT. The
procedure to calculate phonon properties may be as follows:
phonopy -d --dim="2 2 3"
1) Prepare unit cell structure named, e.g., ``POSCAR-unitcell``. The
following structure is a conventional unit cell of NaCl.
You should find the files, ``SPOSCAR``, ``disp.yaml``, and
``POSCAR-{number}`` as follows::
::
% ls
disp.yaml POSCAR POSCAR-001 POSCAR-002 POSCAR-003 SPOSCAR
Na Cl
1.00000000000000
5.6903014761756712 0.0000000000000000 0.0000000000000000
0.0000000000000000 5.6903014761756712 0.0000000000000000
0.0000000000000000 0.0000000000000000 5.6903014761756712
4 4
Direct
0.0000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.5000000000000000 0.5000000000000000
0.5000000000000000 0.0000000000000000 0.5000000000000000
0.5000000000000000 0.5000000000000000 0.0000000000000000
0.5000000000000000 0.5000000000000000 0.5000000000000000
0.5000000000000000 0.0000000000000000 0.0000000000000000
0.0000000000000000 0.5000000000000000 0.0000000000000000
0.0000000000000000 0.0000000000000000 0.5000000000000000
``SPOSCAR`` is the perfect supercell structure, ``disp.yaml`` contains
the information on displacements, and ``POSCAR-{number}`` are the
supercells with atomic displacements. ``POSCAR-{number}`` corresponds
to the different atomic displacements written in ``disp.yaml``.
Calculation of sets of forces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2) Prepare a perfect supercell structure from ``POSCAR-unitcell``,
e.g.,
Force constants are calculated using the structure files
``POSCAR-{number}`` (from forces on atoms) or using the ``SPOSCAR``
file. In the case of VASP, the calculations for the finite
displacement method can be proceeded just using the
``POSCAR-{number}`` files as ``POSCAR`` of VASP calculations. An
example of the ``INCAR`` is as follows::
::
PREC = Accurate
IBRION = -1
ENCUT = 500
EDIFF = 1.0e-08
ISMEAR = 0; SIGMA = 0.01
IALGO = 38
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.
% phonopy -d --dim="2 2 2" -c POSCAR-unitcell
Be careful not to relax the structures. Then create ``FORCE_SETS``
file using :ref:`vasp_force_sets_option`::
3) Rename ``SPOSCAR`` created in (2) to
``POSCAR`` (``POSCAR-{number}`` and ``disp.yaml`` files will never be used.)
% phonopy -f disp-001/vasprun.xml disp-002/vasprun.xml disp-003/vasprun.xml
::
or
% mv SPOSCAR POSCAR
::
4) Calculate force constants of the perfect supercell by running VASP
with ``IBRION = 8`` and ``NSW = 1``. An example of ``INCAR`` for
insulator may be such like (**just an example!**)::
% phonopy -f disp-{001..003}/vasprun.xml
PREC = Accurate
ENCUT = 500
IBRION = 8
EDIFF = 1.0e-08
IALGO = 38
ISMEAR = 0; SIGMA = 0.1
LREAL = .FALSE.
ADDGRID = .TRUE.
LWAVE = .FALSE.
LCHARG = .FALSE.
If you want to calculate force constants by VASP-DFPT directory, see
:ref:`vasp_dfpt_interface`.
5) After finishing the VASP calculation, confirm ``vasprun.xml``
contains ``hessian`` elements, and then create ``FORCE_CONSTANTS``::
Post-process
~~~~~~~~~~~~~
% phonopy --fc vasprun.xml
6) Run phonopy with the original unit cell ``POSCAR-unitcell`` and
setting tag ``FORCE_CONSTANTS = READ`` or ``--readfc`` option,
e.g., as found in ``example/NaCl-VASPdfpt``
In the post-process,
::
1. Force constants are calculated from the sets of forces
2. A part of dynamical matrix is built from the force constants
3. Phonon frequencies and eigenvectors are calculated from the
dynamical matrices with the specified *q*-points.
% phonopy --dim="2 2 2" -c POSCAR-unitcell band.conf
_
_ __ | |__ ___ _ __ ___ _ __ _ _
| '_ \| '_ \ / _ \| '_ \ / _ \ | '_ \| | | |
| |_) | | | | (_) | | | | (_) || |_) | |_| |
| .__/|_| |_|\___/|_| |_|\___(_) .__/ \__, |
|_| |_| |___/
1.1
Band structure mode
Settings:
Force constants: read
Supercell: [2 2 2]
Primitive axis:
[ 0. 0.5 0.5]
[ 0.5 0. 0.5]
[ 0.5 0.5 0. ]
Spacegroup: Fm-3m (225)
Paths in reciprocal reduced coordinates:
[ 0.00 0.00 0.00] --> [ 0.50 0.00 0.00]
[ 0.50 0.00 0.00] --> [ 0.50 0.50 0.00]
[ 0.50 0.50 0.00] --> [-0.00 -0.00 0.00]
[ 0.00 0.00 0.00] --> [ 0.50 0.50 0.50]
For mesh sampling calculation, prepare the following setting file
named, e.g., ``mesh.conf``::
.. |NaCl-VASPdfpt| image:: NaCl-VASPdfpt.png
:scale: 50
ATOM_NAME = Si O
DIM = 2 2 3
MP = 8 8 8
|NaCl-VASPdfpt|
The density of states (DOS) is plotted by::
% phonopy -p mesh.conf
Thermal properties are calculated with the sampling mesh by::
% phonopy -t mesh.conf
You should check the convergence with respect to the mesh numbers.
Thermal properties can be plotted by::
% phonopy -t -p mesh.conf
Projected DOS is calculated by the following setting file named, e.g.,
``pdos.conf``::
ATOM_NAME = Si O
DIM = 2 2 3
MP = 8 8 8
PDOS = 1 2, 3 4 5 6
and plotted by::
% phonopy -p pdos.conf
Band structure is calculated with the following setting file named,
e.g., `band.conf` by::
ATOM_NAME = Si O
DIM = 2 2 3
BAND = 0.5 0.5 0.5 0.0 0.0 0.0 0.5 0.5 0.0 0.0 0.5 0.0
The band structure is plotted by::
% phonopy -p band.conf
In either case, by setting the ``-s`` option, the plot is going to be
saved in the PDF format. If you don't need to plot DOS, the (partial)
DOS is just calculated using the ``--dos`` option.
Non-analytical term correction (Optional)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To activate non-analytical term correction, :ref:`born_file` is
required. This file contains the information of Born effective charge
and dielectric constant. These physical values are also obtained from
the first-principles calculations, e.g., by using VASP, pwscf, etc. In
the case of VASP, an example of ``INCAR`` will be as shown below::
PREC = Accurate
IBRION = -1
NELMIN = 5
ENCUT = 500
EDIFF = 1.000000e-08
ISMEAR = 0
SIGMA = 1.000000e-02
IALGO = 38
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.
LEPSILON = .TRUE.
In addition, it is recommended to increase the number of k-points to
be sampled. Twice the number for each axis may be a choice. After
running this VASP calculation, ``BORN`` file has to be created
following the ``BORN`` format (:ref:`born_file`). However for VASP, an
auxiliary tool is prepared, which is ``phonopy-vasp-born``. There is
an option ``--pa`` for this command to set a transformation matrix
from supercell or unit cell with centring to the primitive cell. Since
this rutile-type SiO2 has the primitive lattice, it is unnecessary to
set this option. Running ``phonopy-vasp-born`` in the directory
containing ``vasprun.xml`` (or ``OUTCAR``) of this VASP calculation::
% phonopy-vasp-born
# epsilon and Z* of atoms 1 3
3.2605670 0.0000000 0.0000000 0.0000000 3.2605670 0.0000000 0.0000000 0.0000000 3.4421330
3.7558600 0.3020100 0.0000000 0.3020100 3.7558600 0.0000000 0.0000000 0.0000000 3.9965200
-1.8783900 -0.5270900 0.0000000 -0.5270900 -1.8783900 0.0000000 0.0000100 0.0000100 -1.9987900
To employ symmetry constraints, ``--st`` option may used as follows::
% phonopy-vasp-born --st
# epsilon and Z* of atoms 1 3
3.2605670 0.0000000 0.0000000 0.0000000 3.2605670 0.0000000 0.0000000 0.0000000 3.4421330
3.7561900 0.3020100 0.0000000 0.3020100 3.7561900 0.0000000 0.0000000 0.0000000 3.9968733
-1.8780950 -0.5270900 0.0000000 -0.5270900 -1.8780950 0.0000000 0.0000000 0.0000000 -1.9984367
The values are slightly modified by symmetry, but we can see the
original values obtained directly from VASP was already very good.
To put ``BORN`` file in the current directly, and running phonopy with
``--nac`` option, non-analytical term correction is activated, such as::
% phonopy -p --nac band.conf
Please watch the example of NaCl with and without ``--nac`` option shown in
:ref:`examples_link`.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

View File

@ -1,127 +0,0 @@
.. _virtualmachine:
Set up Ubuntu linux on VirtualBox
-------------------------------------------
**This document is old and can be partly different for the recent virsion of VirtualBox.**
The following the steps to install Ubuntu linux on VirtualBox. This
document is prepared for the user who failed to install phonopy for
some reason. Basically the questions on this procedure are not
accepted in the phonopy mailing list.
The setup of Ubuntu linux on VirtualBox is quite easy. Ubuntu (server)
linux on VMware player can be set up similarly.
1. Install VirtualBox
VirtualBox is an open source virtualization system. VirtualBox runs
on Windows, Mac, Linux, etc. On Windows and Mac, the explanation
of how to install is unnecessary. On Ubuntu linux, it can be
installed using ``apt-get``::
% sudo apt-get install virtualbox
2. Download Ubuntu Server image
The Ubuntu Server image is found at
http://www.ubuntu.com/download/server/download. Alternatively it
may be downloaded from the mirror sites near your location. For
example, the file name may be like ``ubuntu-14.04-desktop-i386.iso``.
3. Create a new virtual machine
You can specify parameters, but it is also OK just clicking next,
next, ...
|vbox1|
Then you can create an empty virtual machine image.
|vbox2|
To install ubuntu server, set the install image as the virtual CD
device from Settings -> Storage, and click 'OK'.
|vbox3|
Start the virtual machine, then the installation of Ubuntu linux
will start.
|vbox4|
In the install process, you may just click 'continue', ...,
'install', etc. The computer's name and user name are set as you
like.
4. System setting of the virtual machine
Boot the virtual machine and login to the ubuntu linux with the user
name and password.
The terminal emulator is opened by 'Alt' + 'Ctrl' + 'T' or from the
top-left corner seraching 'terminal'. What has to do first is
update the system by::
% sudo apt-get update
::
% sudo apt-get upgrade
Some packages are to be installed for convenience::
% sudo apt-get install openssh-server
'vim', 'zsh', 'screen', 'aptitude' may be also useful.
Then install phonopy following :ref:`install`.
5. Using phonopy from the host computer of the virtual machine
Phonopy can be used from the host computer (the machine where
VirtualBox was installed).
First, the network device of the virtual machine has to be
modified. If NAT is used, the port-forwarding setting is required,
Settings -> Network -> Port forwarding, right click, Insert new
rule, Host port -> 2222, Guest port -> 22. You can login to the
virtual machine, e.g., by terminal::
% ssh -l username -p 2222 localhost
(scp can be used with ``-P 2222`` option.)
If Bridged adapter is used, you have to know the IP address of the
virtual machine. Login to the virtual machine and in the terminal::
% ifconfig
The IP-address is found after ``inet addr`` of (probably)
eth0. Then you can login to the virtual machine by the usual manner
with the IP address.
If the host computer is a usual linux or Mac (with the terminal in
X11), X-forwarding is easily used by::
% ssh -X -l username -p 2222 localhost
or::
% ssh -X IPADDRESS_OF_VIRTUALMACHINE
This is very useful because the plot can be forwarded to the host
computer.
.. |vbox1| image:: virtualbox-new.png
:scale: 50
.. |vbox2| image:: virtualbox-imagenew.png
:scale: 50
.. |vbox3| image:: vitualbox-fromimage.png
:scale: 50
.. |vbox4| image:: Ubuntu-install.png
:scale: 50

View File

@ -546,7 +546,7 @@ class Phonopy(object):
self._mesh.get_weights(),
self._mesh.get_frequencies(),
self._mesh.get_eigenvectors())
def get_mesh_grid_info(self):
if self._mesh is None:
return None
@ -936,7 +936,7 @@ class Phonopy(object):
self._thermal_displacement_matrices = None
if self._mesh is not None:
eigvecs = self._mesh.get_eigenvectors()
eigvecs = self._mesh.get_eigenvectors()
if eigvecs is None:
print("Warning: Eigenvectors have to be calculated.")
return False

View File

@ -339,21 +339,174 @@ def _get_reduced_symbols(symbols):
#
# Non-analytical term
#
def get_born_vasprunxml(filename="vasprun.xml",
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symmetrize_tensors=False,
symprec=1e-5):
import io
borns = []
epsilon = []
with io.open(filename, "rb") as f:
vasprun = VasprunxmlExpat(f)
if vasprun.parse():
epsilon = vasprun.get_epsilon()
borns = vasprun.get_born()
lattice = vasprun.get_lattice()[-1]
points = vasprun.get_points()[-1]
symbols = vasprun.get_symbols()
ucell = Atoms(symbols=symbols,
scaled_positions=points,
cell=lattice)
else:
return None
return _get_borns(ucell,
borns,
epsilon,
primitive_matrix=primitive_matrix,
supercell_matrix=supercell_matrix,
is_symmetry=is_symmetry,
symmetrize_tensors=symmetrize_tensors,
symprec=symprec)
def get_born_OUTCAR(poscar_filename="POSCAR",
outcar_filename=None,
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symmetrize_tensors=False,
read_vasprunxml=False,
symprec=1e-5):
if outcar_filename is None:
if read_vasprunxml:
filename = "vasprun.xml"
else:
filename = "OUTCAR"
filename = "OUTCAR"
else:
filename = outcar_filename
ucell = read_vasp(poscar_filename)
borns, epsilon = _read_born_and_epsilon_from_OUTCAR(filename)
if len(borns) == 0 or len(epsilon) == 0:
return None
else:
return _get_borns(ucell,
borns,
epsilon,
primitive_matrix=primitive_matrix,
supercell_matrix=supercell_matrix,
is_symmetry=is_symmetry,
symmetrize_tensors=symmetrize_tensors,
symprec=symprec)
def symmetrize_borns_and_epsilon(borns,
epsilon,
ucell,
symprec=1e-5,
is_symmetry=True):
lattice = ucell.get_cell()
positions = ucell.get_scaled_positions()
u_sym = Symmetry(ucell, is_symmetry=is_symmetry, symprec=symprec)
rotations = u_sym.get_symmetry_operations()['rotations']
translations = u_sym.get_symmetry_operations()['translations']
ptg_ops = get_pointgroup_operations(rotations)
epsilon_ = symmetrize_2nd_rank_tensor(epsilon, ptg_ops, lattice)
for i, Z in enumerate(borns):
site_sym = get_site_symmetry(i,
lattice,
positions,
rotations,
translations,
symprec)
Z = symmetrize_2nd_rank_tensor(Z, site_sym, lattice)
borns_ = np.zeros_like(borns)
for i in range(len(borns)):
count = 0
for r, t in zip(rotations, translations):
count += 1
diff = np.dot(positions, r.T) + t - positions[i]
diff -= np.rint(diff)
dist = np.sqrt(np.sum(np.dot(diff, lattice) ** 2, axis=1))
j = np.nonzero(dist < symprec)[0][0]
r_cart = similarity_transformation(lattice.T, r)
borns_[i] += similarity_transformation(r_cart, borns[j])
borns_[i] /= count
return borns_, epsilon_
def symmetrize_2nd_rank_tensor(tensor, symmetry_operations, lattice):
sym_cart = [similarity_transformation(lattice.T, r)
for r in symmetry_operations]
sum_tensor = np.zeros_like(tensor)
for sym in sym_cart:
sum_tensor += similarity_transformation(sym, tensor)
return sum_tensor / len(symmetry_operations)
def _get_borns(ucell,
borns,
epsilon,
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symmetrize_tensors=False,
symprec=1e-5):
"""Parse Born effective charges and dielectric constants
Args:
ucell (Atoms): Unit cell structure
borns (np.array): Born effective charges of ucell
epsilon (np.array): Dielectric constant tensor
Returns:
(Born effective charges, dielectric constant)
Raises:
AssertionError: Inconsistency of number of atoms or Born effective
charges.
Warning:
Broken symmetry of Born effective charges
"""
assert len(borns) == ucell.get_number_of_atoms(), \
"num_atom %d != len(borns) %d" % (ucell.get_number_of_atoms(),
len(borns))
if symmetrize_tensors:
borns_, epsilon_ = symmetrize_borns_and_epsilon(borns,
epsilon,
ucell,
symprec=symprec,
is_symmetry=is_symmetry)
if (abs(borns - borns_) > 0.1).any():
lines = ["Born effective charge symmetry is largely broken. "
"Largest different among elements: "
"%s" % np.amax(abs(borns - borns_))]
import warnings
warnings.warn("\n".join(lines))
borns = borns_
epsilon = epsilon_
borns, s_indep_atoms = _extract_independent_borns(
borns,
ucell,
primitive_matrix=primitive_matrix,
supercell_matrix=supercell_matrix,
is_symmetry=is_symmetry,
symprec=symprec)
return borns, epsilon, s_indep_atoms
def _extract_independent_borns(borns,
ucell,
primitive_matrix=None,
supercell_matrix=None,
is_symmetry=True,
symprec=1e-5):
if primitive_matrix is None:
pmat = np.eye(3)
else:
@ -362,41 +515,6 @@ def get_born_OUTCAR(poscar_filename="POSCAR",
smat = np.eye(3, dtype='intc')
else:
smat = supercell_matrix
ucell = read_vasp(poscar_filename)
if read_vasprunxml:
import io
borns = []
epsilon = []
with io.open(outcar_filename, "rb") as f:
vasprun = VasprunxmlExpat(f)
if vasprun.parse():
epsilon = vasprun.get_epsilon()
borns = vasprun.get_born()
else:
borns, epsilon = _read_born_and_epsilon(filename)
num_atom = len(borns)
assert num_atom == ucell.get_number_of_atoms(), \
"num_atom %d != len(borns) %d" % (ucell.get_number_of_atoms(),
len(borns))
if symmetrize_tensors:
lattice = ucell.get_cell()
positions = ucell.get_scaled_positions()
u_sym = Symmetry(ucell, is_symmetry=is_symmetry, symprec=symprec)
rotations = u_sym.get_symmetry_operations()['rotations']
translations = u_sym.get_symmetry_operations()['translations']
ptg_ops = get_pointgroup_operations(rotations)
epsilon = symmetrize_2nd_rank_tensor(epsilon,
ptg_ops,
lattice)
borns = symmetrize_borns(borns,
rotations,
translations,
lattice,
positions,
symprec)
inv_smat = np.linalg.inv(smat)
scell = get_supercell(ucell, smat, symprec=symprec)
@ -408,9 +526,9 @@ def get_born_OUTCAR(poscar_filename="POSCAR",
u_indep_atoms = [u2u[x] for x in s_indep_atoms]
reduced_borns = borns[u_indep_atoms].copy()
return reduced_borns, epsilon, s_indep_atoms
return reduced_borns, s_indep_atoms
def _read_born_and_epsilon(filename):
def _read_born_and_epsilon_from_OUTCAR(filename):
with open(filename) as outcar:
borns = []
epsilon = []
@ -450,61 +568,6 @@ def _read_born_and_epsilon(filename):
return borns, epsilon
def symmetrize_borns(borns,
rotations,
translations,
lattice,
positions,
symprec):
borns_orig = borns.copy()
for i, Z in enumerate(borns):
site_sym = get_site_symmetry(i,
lattice,
positions,
rotations,
translations,
symprec)
Z = symmetrize_2nd_rank_tensor(Z, site_sym, lattice)
borns_copy = np.zeros_like(borns)
for i in range(len(borns)):
count = 0
for r, t in zip(rotations, translations):
count += 1
diff = np.dot(positions, r.T) + t - positions[i]
diff -= np.rint(diff)
dist = np.sqrt(np.sum(np.dot(diff, lattice) ** 2, axis=1))
j = np.nonzero(dist < symprec)[0][0]
r_cart = similarity_transformation(lattice.T, r)
borns_copy[i] += similarity_transformation(r_cart, borns[j])
borns_copy[i] /= count
borns = borns_copy
sum_born = borns.sum(axis=0) / len(borns)
borns -= sum_born
if (np.abs(borns_orig - borns) > 0.1).any():
sys.stderr.write(
"Born effective charge symmetrization might go wrong.\n")
sys.stderr.write("Sum of Born charges:\n")
sys.stderr.write(str(borns_orig.sum(axis=0)))
sys.stderr.write("\n")
# for b_o, b in zip(borns_orig, borns):
# sys.stderr.write(str(b - b_o))
# sys.stderr.write("\n")
return borns
def symmetrize_2nd_rank_tensor(tensor, symmetry_operations, lattice):
sym_cart = [similarity_transformation(lattice.T, r)
for r in symmetry_operations]
sum_tensor = np.zeros_like(tensor)
for sym in sym_cart:
sum_tensor += similarity_transformation(sym, tensor)
return sum_tensor / len(symmetry_operations)
#
# vasprun.xml handling
#
@ -568,7 +631,8 @@ class Vasprun(object):
if element.attrib['name'] == 'hessian':
fc_tmp = []
for v in element.findall('./v'):
fc_tmp.append([float(x) for x in v.text.strip().split()])
fc_tmp.append([float(x)
for x in v.text.strip().split()])
if fc_tmp is None:
return False
@ -577,7 +641,8 @@ class Vasprun(object):
if fc_tmp.shape != (num_atom * 3, num_atom * 3):
return False
# num_atom = fc_tmp.shape[0] / 3
force_constants = np.zeros((num_atom, num_atom, 3, 3), dtype='double')
force_constants = np.zeros((num_atom, num_atom, 3, 3),
dtype='double')
for i in range(num_atom):
for j in range(num_atom):
@ -661,7 +726,7 @@ class VasprunxmlExpat(object):
and 3.x, it is prepared as follows:
import io
io.open(filename, "rb")
io.open(filename, "rb")
"""
@ -679,6 +744,7 @@ class VasprunxmlExpat(object):
self._is_eigenvalues = False
self._is_epsilon = False
self._is_born = False
self._is_efermi = False
self._is_v = False
self._is_i = False
@ -706,6 +772,7 @@ class VasprunxmlExpat(object):
self._energies = None
self._epsilon = None
self._born_atom = None
self._efermi = None
self._k_weights = None
self._eigenvalues = None
self._eig_state = [0, 0]
@ -735,6 +802,9 @@ class VasprunxmlExpat(object):
def get_epsilon(self):
return np.array(self._epsilon)
def get_efermi(self):
return self._efermi
def get_born(self):
return np.array(self._born)
@ -747,15 +817,6 @@ class VasprunxmlExpat(object):
def get_symbols(self):
return self._symbols
def get_cells(self):
cells = []
if len(self._all_points) == len(self._all_lattice):
for p, l in zip(self._all_points, self._all_lattice):
cells.append(Cell(lattice=l,
points=p,
symbols=self._symbols))
return cells
def get_energies(self):
return np.array(self._all_energies)
@ -817,6 +878,12 @@ class VasprunxmlExpat(object):
self._is_basis = True
self._lattice = []
if name == 'i':
if 'name' in attrs.keys():
if attrs['name'] == 'efermi':
self._is_i = True
self._is_efermi = True
if self._is_energy and name == 'i':
self._is_i = True
@ -907,11 +974,11 @@ class VasprunxmlExpat(object):
if self._is_positions:
self._is_positions = False
self._all_points.append(np.transpose(self._points))
self._all_points.append(self._points)
if self._is_basis:
self._is_basis = False
self._all_lattice.append(np.transpose(self._lattice))
self._all_lattice.append(self._lattice)
if self._is_epsilon:
self._is_epsilon = False
@ -932,6 +999,8 @@ class VasprunxmlExpat(object):
if name == 'i':
self._is_i = False
if self._is_efermi:
self._is_efermi = False
if name == 'rc':
self._is_rc = False
@ -992,6 +1061,9 @@ class VasprunxmlExpat(object):
if self._is_energy:
self._energies.append(float(data.strip()))
if self._is_efermi:
self._efermi = float(data.strip())
if self._is_c:
if self._is_symbols:
self._symbols.append(str(data.strip()))

View File

@ -36,7 +36,6 @@ import numpy as np
from phonopy.units import AMU, THzToEv, Kb, EV, Hbar, Angstrom
from phonopy.structure.cells import get_equivalent_smallest_vectors
from phonopy.interface.cif import write_cif_P1
# np.seterr(invalid='raise')
class ThermalMotion(object):
def __init__(self,
@ -51,6 +50,8 @@ class ThermalMotion(object):
self._masses = masses * AMU
self._masses3 = np.array([[m] * 3 for m in masses]).ravel() * AMU
self._temperatures = None
self._np_overflow = None # Switch of error handling of numpy.
# 'raise' to see which phonon it is.
def get_Q2(self, freq, t): # freq in THz
return Hbar * EV / Angstrom ** 2 * (
@ -152,7 +153,7 @@ class ThermalDisplacements(ThermalMotion):
disps[i] += self.get_Q2(f, t) * c
self._displacements = disps / (count + 1)
def write_yaml(self):
natom = len(self._masses)
f = open('thermal_displacements.yaml', 'w')
@ -220,18 +221,9 @@ class ThermalDisplacementMatrices(ThermalMotion):
return (self._temperatures, self._disp_matrices)
def run(self):
disps = np.zeros((len(self._temperatures), len(self._masses),
3, 3), dtype=complex)
for count, (freqs, eigvecs) in enumerate(self._iter_phonons):
for f, vec in zip(freqs, eigvecs.T):
if f > self._cutoff_frequency:
c = []
for v, m in zip(vec.reshape(-1, 3), self._masses):
c.append(np.outer(v, v.conj()) / m)
for i, t in enumerate(self._temperatures):
disps[i] += self.get_Q2(f, t) * np.array(c)
self._disp_matrices = disps / (count + 1)
np.seterr(over=self._np_overflow)
self._get_disp_matrices()
np.seterr(over=None)
if self._ANinv is not None:
self._disp_matrices_cif = np.zeros(self._disp_matrices.shape,
@ -242,6 +234,24 @@ class ThermalDisplacementMatrices(ThermalMotion):
self._ANinv.T)
self._disp_matrices_cif[i, j] = mat_cif
def _get_disp_matrices(self):
disps = np.zeros((len(self._temperatures), len(self._masses),
3, 3), dtype=complex)
for count, (freqs, eigvecs) in enumerate(self._iter_phonons):
for i_band, (f, vec) in enumerate(zip(freqs, eigvecs.T)):
if f > self._cutoff_frequency:
c = []
for v, m in zip(vec.reshape(-1, 3), self._masses):
c.append(np.outer(v, v.conj()) / m)
for i, t in enumerate(self._temperatures):
try:
disps[i] += self.get_Q2(f, t) * np.array(c)
except FloatingPointError as e:
# Probably, overflow in exp(freq / (kB * T))
print("%s: T=%.1f freq=%.2f (band #%d)" %
(e, t, f, i_band))
self._disp_matrices = disps / (count + 1)
def write_cif(self, cell, temperature_index):
write_cif_P1(cell,
U_cif=self._disp_matrices_cif[temperature_index],
@ -265,8 +275,8 @@ class ThermalDisplacementMatrices(ThermalMotion):
# lines.append(" - # atom %d" % (i + 1))
# for v in mat:
# lines.append(
# " [ %8.5f, %8.5f, %8.5f, %8.5f, %8.5f, %8.5f ]" %
# (tuple(v.real) + tuple(v.imag)))
# " [ %8.5f, %8.5f, %8.5f, %8.5f, %8.5f, %8.5f ]"
# % (tuple(v.real) + tuple(v.imag)))
m = mat.real
lines.append(
(" - [ " + "%8.5f, " * 5 + "%8.5f ] # atom %d") %
@ -315,15 +325,17 @@ class ThermalDistances(ThermalMotion):
def run(self, atom_pairs):
s2p = self._primitive.get_supercell_to_primitive_map()
p2p = self._primitive.get_primitive_to_primitive_map()
dists = np.zeros((len(self._temperatures), len(atom_pairs)), dtype=float)
dists = np.zeros((len(self._temperatures), len(atom_pairs)),
dtype=float)
for i, (atom1, atom2) in enumerate(atom_pairs):
patom1 = p2p[s2p[atom1]]
patom2 = p2p[s2p[atom2]]
delta_r = get_equivalent_smallest_vectors(atom2,
atom1,
self._supercell,
self._primitive.get_cell(),
self._symprec)[0]
delta_r = get_equivalent_smallest_vectors(
atom2,
atom1,
self._supercell,
self._primitive.get_cell(),
self._symprec)[0]
self._project_eigenvectors(delta_r, self._primitive.get_cell())

View File

@ -280,6 +280,15 @@ class PhonopyAtoms(Atoms):
return "\n".join(self.get_yaml_lines())
# Pure Appl. Chem., Vol. 83, No. 2, pp. 359-396, 2011. is available
# but the following list is from 2006.
# Pure Appl. Chem., Vol. 78, No. 11, pp. 2051-2066, 2006.
# The masses of following elements are obtained from wikipedia:
# Ac: 227
# Np: 237
# Pm: 145
# Tc: 98
atom_data = [
[0, "X", "X", None], # 0
[1, "H", "Hydrogen", 1.00794], # 1
@ -324,7 +333,7 @@ atom_data = [
[40, "Zr", "Zirconium", 91.224], # 40
[41, "Nb", "Niobium", 92.90638], # 41
[42, "Mo", "Molybdenum", 95.96], # 42
[43, "Tc", "Technetium", None], # 43
[43, "Tc", "Technetium", 98], # 43 (mass is from wikipedia)
[44, "Ru", "Ruthenium", 101.07], # 44
[45, "Rh", "Rhodium", 102.90550], # 45
[46, "Pd", "Palladium", 106.42], # 46
@ -342,7 +351,7 @@ atom_data = [
[58, "Ce", "Cerium", 140.116], # 58
[59, "Pr", "Praseodymium", 140.90765], # 59
[60, "Nd", "Neodymium", 144.242], # 60
[61, "Pm", "Promethium", None], # 61
[61, "Pm", "Promethium", 145], # 61 (mass is from wikipedia)
[62, "Sm", "Samarium", 150.36], # 62
[63, "Eu", "Europium", 151.964], # 63
[64, "Gd", "Gadolinium", 157.25], # 64
@ -370,11 +379,11 @@ atom_data = [
[86, "Rn", "Radon", None], # 86
[87, "Fr", "Francium", None], # 87
[88, "Ra", "Radium", None], # 88
[89, "Ac", "Actinium", None], # 89
[89, "Ac", "Actinium", 227], # 89 (mass is from wikipedia)
[90, "Th", "Thorium", 232.03806], # 90
[91, "Pa", "Protactinium", 231.03588], # 91
[92, "U", "Uranium", 238.02891], # 92
[93, "Np", "Neptunium", None], # 93
[93, "Np", "Neptunium", 237], # 93 (mass is from wikipedia)
[94, "Pu", "Plutonium", None], # 94
[95, "Am", "Americium", None], # 95
[96, "Cm", "Curium", None], # 96

View File

@ -34,9 +34,10 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import numpy as np
import sys
from phonopy.interface.vasp import get_born_OUTCAR, VasprunxmlExpat
import warnings
import numpy as np
from phonopy.interface.vasp import get_born_OUTCAR, get_born_vasprunxml
def fracval(frac):
if frac.find('/') == -1:
@ -66,7 +67,8 @@ parser.add_option("--tolerance", dest="symprec", type="float",
help="Symmetry tolerance to search")
parser.add_option("--vasprunxml", dest="read_vasprunxml",
action="store_true",
help="Read vasprun.xml instead of OUTCAR")
help=("Read vasprun.xml instead of OUTCAR. "
"POSCAR is not necessary"))
(options, args) = parser.parse_args()
if args:
@ -104,18 +106,35 @@ if options.supercell_matrix:
else:
supercell_matrix = np.eye(3, dtype='intc')
borns, epsilon, atom_indices = get_born_OUTCAR(
poscar_filename=poscar_filename,
outcar_filename=outcar_filename,
primitive_matrix=primitive_axis,
supercell_matrix=supercell_matrix,
symmetrize_tensors=options.symmetrize_tensors,
read_vasprunxml=options.read_vasprunxml,
symprec=options.symprec)
with warnings.catch_warnings() as w:
# To catch warnings as error, set warnings.simplefilter("error")
warnings.simplefilter("always")
text = "# epsilon and Z* of atoms "
text += ' '.join(["%d" % n for n in atom_indices + 1])
print(text)
print(("%13.8f" * 9) % tuple(epsilon.flatten()))
for z in borns:
print(("%13.8f" * 9) % tuple(z.flatten()))
try:
if options.read_vasprunxml:
borns, epsilon, atom_indices = get_born_vasprunxml(
filename=outcar_filename,
primitive_matrix=primitive_axis,
supercell_matrix=supercell_matrix,
symmetrize_tensors=options.symmetrize_tensors,
symprec=options.symprec)
else:
borns, epsilon, atom_indices = get_born_OUTCAR(
poscar_filename=poscar_filename,
outcar_filename=outcar_filename,
primitive_matrix=primitive_axis,
supercell_matrix=supercell_matrix,
symmetrize_tensors=options.symmetrize_tensors,
symprec=options.symprec)
except UserWarning:
sys.exit(1)
else:
text = "# epsilon and Z* of atoms "
text += ' '.join(["%d" % n for n in atom_indices + 1])
print(text)
print(("%13.8f" * 9) % tuple(epsilon.flatten()))
for z in borns:
print(("%13.8f" * 9) % tuple(z.flatten()))
sys.exit(0)
sys.exit(1)

View File

@ -124,13 +124,13 @@ packages_phonopy = ['phonopy',
scripts_phonopy = ['scripts/phonopy',
'scripts/phonopy-qha',
'scripts/phonopy-FHI-aims',
'scripts/bandplot',
'scripts/outcar-born',
'scripts/propplot',
'scripts/tdplot',
'scripts/dispmanager',
'scripts/gruneisen',
'scripts/pdosplot']
'scripts/phonopy-bandplot',
'scripts/phonopy-vasp-born',
'scripts/phonopy-propplot',
'scripts/phonopy-tdplot',
'scripts/phonopy-dispmanager',
'scripts/phonopy-gruneisen',
'scripts/phonopy-pdosplot']
if __name__ == '__main__':