Flow for QHA calculations with two DOFs

Warning: This code is still under development. This example shows to run calculations with the ZSISA quasi-harmonic approximation and two degrees of freedom.

run qha 2d
Downloading repository from: https://github.com/PseudoDojo/ONCVPSP-PBEsol-PDv0.4/archive/refs/heads/master.zip ...
Installing ONCVPSP-PBEsol-SR-PDv0.4 in: /home/runner/.abinit/pseudos/ONCVPSP-PBEsol-SR-PDv0.4

0.00iB [00:00, ?iB/s]
754kiB [00:00, 6.02MiB/s]
1.49MiB [00:00, 5.81MiB/s]
2.25MiB [00:00, 5.50MiB/s]
2.87MiB [00:00, 5.66MiB/s]
3.44MiB [00:00, 5.66MiB/s]
4.19MiB [00:00, 6.17MiB/s]
4.85MiB [00:00, 5.88MiB/s]
5.47MiB [00:00, 5.69MiB/s]
6.06MiB [00:01, 5.62MiB/s]
6.71MiB [00:01, 5.85MiB/s]
7.32MiB [00:01, 5.72MiB/s]
7.94MiB [00:01, 5.37MiB/s]
8.49MiB [00:01, 5.31MiB/s]
9.08MiB [00:01, 5.45MiB/s]
9.69MiB [00:01, 5.43MiB/s]
10.3MiB [00:01, 5.27MiB/s]
10.8MiB [00:01, 5.23MiB/s]
11.6MiB [00:02, 5.35MiB/s]
12.3MiB [00:02, 5.77MiB/s]
12.9MiB [00:02, 5.72MiB/s]
13.5MiB [00:02, 5.69MiB/s]
14.1MiB [00:02, 5.55MiB/s]
14.9MiB [00:02, 5.59MiB/s]
15.7MiB [00:02, 6.09MiB/s]
16.3MiB [00:02, 5.84MiB/s]
17.1MiB [00:03, 5.92MiB/s]
18.0MiB [00:03, 5.93MiB/s]
18.7MiB [00:03, 6.08MiB/s]
19.3MiB [00:03, 5.69MiB/s]
20.1MiB [00:03, 6.19MiB/s]
20.8MiB [00:03, 6.25MiB/s]
21.4MiB [00:03, 6.01MiB/s]
22.1MiB [00:03, 5.71MiB/s]
22.7MiB [00:03, 5.78MiB/s]
23.4MiB [00:04, 5.75MiB/s]
24.0MiB [00:04, 5.66MiB/s]
24.7MiB [00:04, 6.02MiB/s]
25.3MiB [00:04, 5.63MiB/s]
25.9MiB [00:04, 5.54MiB/s]
26.8MiB [00:04, 5.85MiB/s]
27.6MiB [00:04, 6.28MiB/s]
28.2MiB [00:04, 6.11MiB/s]
28.9MiB [00:04, 6.29MiB/s]
29.6MiB [00:05, 6.12MiB/s]
30.3MiB [00:05, 6.38MiB/s]
31.0MiB [00:05, 6.15MiB/s]
31.6MiB [00:05, 5.89MiB/s]
32.3MiB [00:05, 6.01MiB/s]
33.0MiB [00:05, 5.78MiB/s]
33.8MiB [00:05, 5.70MiB/s]
34.6MiB [00:05, 6.14MiB/s]
35.2MiB [00:06, 6.06MiB/s]
35.8MiB [00:06, 6.00MiB/s]
36.4MiB [00:06, 5.80MiB/s]
37.1MiB [00:06, 5.94MiB/s]
37.7MiB [00:06, 5.84MiB/s]
38.3MiB [00:06, 5.29MiB/s]
38.9MiB [00:06, 5.17MiB/s]
39.8MiB [00:06, 5.51MiB/s]
40.4MiB [00:07, 5.44MiB/s]
41.2MiB [00:07, 5.52MiB/s]
41.6MiB [00:07, 5.80MiB/s]

Validating md5 checksums of ONCVPSP-PBEsol-SR-PDv0.4...
Checksum test: OK
Installation completed successfully in 8.21 [s]

import os
import sys

import numpy as np

from abipy import abilab, flowtk
from abipy.flowtk.qha_2d import Qha2dFlow


def build_flow(options):
    """
    Create a `Qha2dFlow` for quasi-harmonic calculations with two DOFs
    """
    # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
    if not options.workdir:
        __file__ = os.path.join(os.getcwd(), "run_qha_2d.py")
        options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")

    # Initialize structure and pseudos for ZnO.
    structure = abilab.Structure.from_abistring("""
natom 4
ntypat 2
typat
1 1 2
2
znucl 30 8
xred
   0.0000000000    0.0000000000   -0.0025137620
   0.3333333333    0.6666666667    0.4974862380
   0.0000000000    0.0000000000    0.3835201241
   0.3333333333    0.6666666667    0.8835201241
acell    1.0    1.0    1.0
rprim
   6.3016720624    0.0000000000    0.0000000000
  -3.1508360312    5.4574080923    0.0000000000
   0.0000000000    0.0000000000    9.7234377918
""")

    # Use NC PBEsol pseudos from pseudodojo v0.4
    from abipy.flowtk.psrepos import get_oncvpsp_pseudos

    pseudos = get_oncvpsp_pseudos(xc_name="PBEsol", version="0.4")

    scf_input = abilab.AbinitInput(structure, pseudos)

    # Set other important variables
    scf_input.set_vars(
        nband=scf_input.num_valence_electrons // 2,
        # nline=10,
        nbdbuf=0,
        nstep=100,
        ecutsm=1.0,
        # tolvrs=1.0e-18,    # SCF stopping criterion.
        tolvrs=1.0e-6,  # SCF stopping criterion.
        paral_kgb=0,
    )

    # Select k-mesh for electrons and q-mesh for phonons.
    # ngkpt = [6, 6, 4]; ngqpt = [1, 1, 1]
    ngkpt = [2, 2, 2]
    ngqpt = [1, 1, 1]

    # scf_input.set_scf_nband_semicond()
    scf_input.set_kmesh(ngkpt=ngkpt, shiftk=[0, 0, 0])

    bo_strains_a = [-5, 0, 5, 10, 15]
    bo_strains_c = [-5, 0, 5, 10, 15]
    # bo_strains_a = [0, 5, 10, 15, 20]
    # bo_strains_c = [0, 5, 10, 15, 20]
    # This is just for testing purposes
    # bo_strains_a = [0, 5]
    # bo_strains_c = [0, 5]
    bo_strains_a = [
        0,
    ]
    bo_strains_c = [0, 5]
    bo_strains_a = np.array(bo_strains_a) / 100
    bo_strains_c = np.array(bo_strains_c) / 100

    bo_strains_ac = [bo_strains_a, bo_strains_c]
    phdos_strains_ac = bo_strains_ac

    with_becs = True
    with_quad = False
    # with_quad = not structure.has_zero_dynamical_quadrupoles

    return Qha2dFlow.from_scf_input(
        options.workdir, scf_input, bo_strains_ac, phdos_strains_ac, ngqpt, with_becs, with_quad, edos_ngkpt=None
    )


# This block generates the thumbnails in the Abipy gallery.
# You can safely REMOVE this part if you are using this script for production runs.
if os.getenv("READTHEDOCS", False):
    __name__ = None
    import tempfile

    options = flowtk.build_flow_main_parser().parse_args(["-w", tempfile.mkdtemp()])
    build_flow(options).graphviz_imshow()


@flowtk.flow_main
def main(options):
    """
    This is our main function that will be invoked by the script.
    flow_main is a decorator implementing the command line interface.
    Command line args are stored in `options`.
    """
    return build_flow(options)


if __name__ == "__main__":
    sys.exit(main())

Total running time of the script: (0 minutes 8.416 seconds)

Gallery generated by Sphinx-Gallery