Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorials #171

Merged
merged 24 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
87509af
Add tutorial on the calculation of anharmonic IFCs of BaTiO3.
r-masuki Feb 23, 2024
35558de
Merge branch 'develop' into feature/relax_str_tutorial
r-masuki Feb 25, 2024
02e93fe
Write the tutorial on CV and optimize for anharmonic IFCs of BaTiO3.
r-masuki Feb 25, 2024
4a17b51
Modification on tutorial of IFC calculation for BaTiO3.
r-masuki Feb 26, 2024
7c7b8a9
Fix the tag on bto_ifc.rst
r-masuki Feb 26, 2024
f4ac443
Change directory structure in example/BaTiO3.
r-masuki Feb 26, 2024
37f03c5
Write the tutorial on QHA-based structural optimization of wurtzite ZnO.
r-masuki Feb 26, 2024
e0fc7f3
Minor modification.
r-masuki Feb 26, 2024
d66d056
Collected reference results in example/ZnO/qha_relax/reference.
r-masuki Feb 26, 2024
b1dc191
Write tutorial on SCPH-based structural optimization of BaTiO3.
r-masuki Feb 26, 2024
95fb573
Collect input and output files to example/BaTiO3/scph_relax/
r-masuki Feb 26, 2024
70425ef
Minor change.
r-masuki Feb 26, 2024
249c437
Add some notes on finite-temperature structure calculations.
r-masuki Feb 27, 2024
502d28d
Add discussions on free energies in the tutorial of BaTiO3.
r-masuki Feb 27, 2024
95f94ef
Fix typos in the tutorial of anharmonic IFC calculation.
r-masuki Feb 27, 2024
1edcd86
Fix typos in SCPH-based structural relaxations of BaTiO3.
r-masuki Feb 27, 2024
acdbe48
Improve the tutorial on QHA of ZnO.
r-masuki Feb 27, 2024
7a8a97c
Added notes on the calculation time of SCPH + structural optimization.
r-masuki Feb 27, 2024
905adad
Minor change.
r-masuki Feb 27, 2024
d982a67
Write the tutorial on anharmonic IFC calculation of silicon.
r-masuki Feb 27, 2024
cd931e2
Fix typos.
r-masuki Feb 27, 2024
6adf5be
Minor modification.
r-masuki Feb 27, 2024
ac3691a
Check flow of the new tutorials.
r-masuki Feb 28, 2024
2fec82b
Merge branch 'feature/relax_str_tutorial' into develop
r-masuki Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/img/BTO_IFC_cv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/BaTiO3_scph_relax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/BaTiO3_scph_relax_f.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/ZnO_thermal_strain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ Tutorial
tutorial_pages/silicon_lammps
tutorial_pages/pbte_nonanalytic_correction
tutorial_pages/sto_scph
tutorial_pages/bto_ifc
tutorial_pages/silicon_ifc
tutorial_pages/bto_scph_relax
tutorial_pages/zno_qha_relax
197 changes: 197 additions & 0 deletions docs/source/tutorial_pages/bto_ifc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
.. _label_tutorial_bto_ifc:

.. raw:: html

<style> .red {color:red} </style>

.. role:: red

.. |Angstrom| unicode:: U+00C5

BaTiO\ :sub:`3` : Anharmonic interatomic force constants (IFCs)
---------------------------------------------------

This page explains how to calculate anharmonic interatomic force constants (IFCs) using ALAMODE, especially for strongly anharmonic materials.
The target material is cubic BaTiO\ :sub:`3`, which exhibits a strong lattice anharmonicity.

The example input files are provided in **example/BaTiO3/anharm_IFCs**.

Let's move to the example directory.

.. code-block:: bash

$ cd ${ALAMODE_ROOT}/example/BaTiO3/anharm_IFCs


.. _tutorial_BTO_IFC_step1:

1. Generate the randomly displaced supercells
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::
There is a more efficient way to generate supercells with random displacements
for weakly anharmonic materials or materials without imaginary harmonic frequencies.
Please see :ref:`Tutorial 7.6 <label_tutorial_silicon_ifc>` for details.

We use the *ab initio* molecular dynamics (AIMD) calculations to generate the supercells with random displacements.

The example VASP inputs are provided in **example/BaTiO3/anharm_IFCs/1_vasp_md**.
Prepare the :red:`POTCAR` file by yourself and run the AIMD calculation to obtain :red:`vasprun.xml`
(You can skip this part because :red:`vasprun.xml` is provided in **1_vasp_md/reference**).

Next, we generate the supercells with random atomic displacements from the AIMD trajectory.
First, we move to the **1_configurations** directory and copy :red:`vasprun.xml`

.. code-block:: bash

$ cd 1_configurations
$ cp ../1_vasp_md/vasprun.xml ./ # If you have performed the AIMD calculation
$ cp ../1_vasp_md/reference/vasprun.xml ./ # If you skip the AIMD and use the reference result

:red:`POSCAR_ref_supercell` is the structure of the reference supercell for which we want to calculate the IFCs.

.. code-block:: bash

$ python3 ${ALAMODE_ROOT}/tools/displace.py --VASP POSCAR_ref_supercell -md vasprun.xml -e 1001:5000:50 --random --mag 0.04 --prefix disp_aimd+random_

Here, the option ``-e 1001:5000:50`` means that we sample from the 1001-th snapshot to the 5000-th snapshot with the sampling step of 50 time-steps.
Thus, 80 configurations are generated in this case.

The option ``--random --mag 0.04`` adds random displacements of 0.04 |Angstrom| to each atom in the extracted snapshots to reduce correlations between successive snapshots.


.. note::

We may use a less strict convergence criterion in the AIMD calculation because its purpose is just to generate the random structure,
and the atomic forces obtained in AIMD are not directly used to calculate the IFCs.
In fact, we use the following parameters, which are different from the subsequent calculation of the displacement-force data.

* ENCUT = 400, EDIFF = 1.0E-6

* 2x2x2 kmesh

The temperature in the AIMD calculation is chosen so that the generated trajectory widely samples the
low-energy landscape of the potential energy surface. We choose 300 K in this case, which is comparable to
or lower than the structural transition temperatures of the target material.

.. note::

The number of random configurations should be chosen so that the generated set of IFCs
converges with respect to it.
Ideally, we should check the convergence of the calculated physical quantities by changing
the number of random configurations from which we extract the anharmonic IFCs.

It depends on the problems, but a rule of thumb tells us that 100~1000 configurations will do
for the calculation of cubic and quartic IFCs.
We can reduce the number of configurations if we calculate only the cubic IFCs.

.. _tutorial_BTO_IFC_step2:

2. Generate the displacement-force data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We calculate the atomic forces for each random configuration generated in the previous step.

The other VASP input files (:red:`INCAR` and :red:`KPOINTS`) are provided in **example/BaTiO3/anharm_IFCs/2_vasp_dfset**.
After running the VASP calculations, collect the resultant :red:`vasprun.xml` of
each calculation in **example/BaTiO3/anharm_IFCs/2_vasp_dfset**.

If you want to skip the VASP calculations, please copy or move the 80 :red:`vasprun.xml`
files provided in **2_vasp_dfset/reference** to **2_vasp_dfset**.

Generate the displacement-force data with the command

.. code-block:: bash

$ cd ${ALAMODE_ROOT}/example/BaTiO3/anharm_IFCs/2_vasp_dfset
$ cp ../1_configurations/POSCAR_ref_supercell ./
$ python3 ${ALAMODE_ROOT}/tools/extract.py --VASP=POSCAR_ref_supercell vasprun*.xml > DFSET_AIMD_random

The generated :red:`DFSET_AIMD_random` stores the atomic displacements and the atomic forces in each configuration,
from which we can calculate the anharmonic IFCs.

.. _tutorial_BTO_IFC_step3:

3. Cross validation (CV)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We assume that the harmonic force constants are already calculated.
Please use the method explained in :ref:`Tutorial 7.1 <label_tutorial_01>` for the calculation of harmonic IFCs.

In the cross validation, we determine the optimal amplitude of regularization (:math:`\alpha`) in the elastic-net or adaptive lasso.
Please see :ref:`the documentation <alm_thoery_enet>` for the notation and the theoretical background.

You can run the CV calculation with the following commands.

.. code-block:: bash

$ cd ${ALAMODE_ROOT}/example/BaTiO3/3_cv
$ ${ALAMODE_ROOT}/alm/alm BTO_alm_cv.in > BTO_alm_cv.log

In :red:`BTO_alm_cv.in`, ``FC2XML = ../cBTO222_harmonic.xml`` means that we fix the harmonic IFCs with the values in the given file.
This is because we would like to capture the stability or the curvature of the potential energy surface at the reference structure accurately.

.. note::
With ``NBODY = 2 3 3``, we restrict the quartic IFCs to up-to-three-body terms.
This treatment reduces the computational cost and makes the fitting more robust by reducing the number of degrees of freedom.
Although the best choice of ``NBODY``-tag will depend on the materials and on the number of your displacement-force data,
we recommend restricting the quartic IFCs to up-to-three-body terms and the higher order IFCs to up-to-two-body terms
since the higher-order IFCs will be more localized in space.

Plotting the generated :red:`cBTO222.cvscore` with

.. code-block:: bash

$ gnuplot cv_plot.plt

we get the following plot.
Note that you need to set ``STOP_CRITERION = 30`` in ``&optimize``-field to get exactly the same plot.
Otherwise, the calculation is stopped before calculations with small :math:`\alpha` are performed to save the computational cost.


.. figure:: ../../img/BTO_IFC_cv.png
:scale: 60%
:align: center

The result of the CV calculation for BaTiO\ :sub:`3`.

We can see that the CV score takes a minimum at the optimal :math:`\alpha`, which can be read from the last line of :red:`cBTO222.cvscore`.
::
# Minimum CVSCORE at alpha = 2.51189e-06

.. _tutorial_BTO_IFC_step4:

4. Calculation of IFCs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Finally, we calculate the IFCs of BaTiO\ :sub:`3` in **example/BaTiO3/anharm_IFCs/4_optimize**.

.. code-block:: bash

$ cd ${ALAMODE_ROOT}/example/BaTiO3/4_optimize

To prepare the input file, we copy the input of CV and set ``L1_ALPHA`` with the optimal value
by adding the new line in ``&optimize``-field.
::
L1_ALPHA = 2.51189e-06

Also, change ``CV=4`` in ``&optimize``-field to
::
CV = 0 # switch off CV

You can also use a smaller value for ``CONV_TOL`` to get a more accurate result.

With the input file prepared, run the calculation with

.. code-block:: bash

$ ${ALAMODE_ROOT}/alm/alm BTO_alm_opt.in > BTO_alm_opt.log

The calculated IFCs are written out in :red:`cBTO222.fcs` and :red:`cBTO222.xml`.

Checking :red:`BTO_alm_opt.log`, we can see that the fitting is successful with a small residual error.
::
RESIDUAL (%): 3.91121



Loading