Dynamical magnetic charges

Crystalline Cr2O3 with magnetic field (zeemanfield) Flow to compute dynamical magnetic charges with finite differences.

Z_jv^m=Ω_0 (∂M_v)/(∂u_j ) = (∂F_j)/(∂H_v ) = Ω_0 (∂^2 E)/(∂H_β ∂u_i ).

run fd hfield
Downloading repository from: https://github.com/PseudoDojo/ONCVPSP-PBEsol-FR-PDv0.4/archive/refs/heads/master.zip ...
Installing ONCVPSP-PBEsol-FR-PDv0.4 in: /home/runner/.abinit/pseudos/ONCVPSP-PBEsol-FR-PDv0.4

0.00iB [00:00, ?iB/s]
701kiB [00:00, 5.87MiB/s]
1.39MiB [00:00, 5.67MiB/s]
2.09MiB [00:00, 5.58MiB/s]
2.91MiB [00:00, 5.82MiB/s]
3.68MiB [00:00, 5.64MiB/s]
4.49MiB [00:00, 6.00MiB/s]
5.19MiB [00:00, 6.08MiB/s]
5.85MiB [00:00, 6.00MiB/s]
6.52MiB [00:01, 6.16MiB/s]
7.33MiB [00:01, 6.69MiB/s]
8.09MiB [00:01, 6.29MiB/s]
8.94MiB [00:01, 6.88MiB/s]
9.79MiB [00:01, 7.14MiB/s]
10.5MiB [00:01, 7.11MiB/s]
11.3MiB [00:01, 7.20MiB/s]
12.0MiB [00:01, 7.14MiB/s]
12.8MiB [00:01, 6.88MiB/s]
13.5MiB [00:02, 6.65MiB/s]
14.2MiB [00:02, 6.64MiB/s]
15.1MiB [00:02, 7.00MiB/s]
15.8MiB [00:02, 7.04MiB/s]
16.6MiB [00:02, 6.98MiB/s]
17.3MiB [00:02, 6.45MiB/s]
18.1MiB [00:02, 6.60MiB/s]
18.9MiB [00:02, 6.48MiB/s]
19.7MiB [00:03, 6.62MiB/s]
20.4MiB [00:03, 6.57MiB/s]
21.3MiB [00:03, 6.48MiB/s]
22.0MiB [00:03, 6.25MiB/s]
22.8MiB [00:03, 6.18MiB/s]
23.5MiB [00:03, 6.12MiB/s]
24.2MiB [00:03, 5.86MiB/s]
25.0MiB [00:03, 6.36MiB/s]
25.8MiB [00:03, 6.55MiB/s]
26.6MiB [00:04, 6.77MiB/s]
27.3MiB [00:04, 6.68MiB/s]
28.0MiB [00:04, 6.59MiB/s]
28.7MiB [00:04, 6.60MiB/s]
29.4MiB [00:04, 6.51MiB/s]
30.0MiB [00:04, 6.49MiB/s]
30.8MiB [00:04, 6.53MiB/s]
31.5MiB [00:04, 6.56MiB/s]
32.3MiB [00:04, 6.39MiB/s]
33.2MiB [00:05, 6.13MiB/s]
33.9MiB [00:05, 6.14MiB/s]
34.7MiB [00:05, 6.49MiB/s]
35.3MiB [00:05, 6.37MiB/s]
36.1MiB [00:05, 6.50MiB/s]
36.8MiB [00:05, 6.70MiB/s]
37.6MiB [00:05, 6.63MiB/s]
38.4MiB [00:05, 6.34MiB/s]
39.1MiB [00:06, 6.49MiB/s]
40.0MiB [00:06, 6.77MiB/s]
40.9MiB [00:06, 6.54MiB/s]
41.7MiB [00:06, 6.30MiB/s]
42.7MiB [00:06, 7.18MiB/s]
43.5MiB [00:06, 7.27MiB/s]
44.3MiB [00:06, 7.25MiB/s]
45.0MiB [00:06, 6.45MiB/s]
45.8MiB [00:07, 6.62MiB/s]
46.6MiB [00:07, 6.80MiB/s]
47.4MiB [00:07, 6.81MiB/s]
48.1MiB [00:07, 6.82MiB/s]
48.2MiB [00:07, 6.56MiB/s]

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

import sys
import os
import abipy.flowtk as flowtk

from abipy.core.structure import Structure
from abipy.abio.inputs import AbinitInput
from abipy.flowtk.finitediff import FiniteHfieldWork


def build_flow(options):
    # Set working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
    if not options.workdir:
        options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_", "flow_")

    structure = Structure.from_abistring("""
natom 10
ntypat 2
typat
1 1 1
1 2 2
2 2 2
2
znucl 24 8
xred      3.4574472807E-01  3.4574472807E-01  3.4574472807E-01
          1.5425527193E-01  1.5425527193E-01  1.5425527193E-01
          6.5425527193E-01  6.5425527193E-01  6.5425527193E-01
          8.4574472807E-01  8.4574472807E-01  8.4574472807E-01
          5.5995881675E-01  2.5000000000E-01  9.4004118325E-01
          2.5000000000E-01  9.4004118325E-01  5.5995881675E-01
          9.4004118325E-01  5.5995881675E-01  2.5000000000E-01
          4.4004118325E-01  7.5000000000E-01  5.9958816751E-02
          5.9958816751E-02  4.4004118325E-01  7.5000000000E-01
          7.5000000000E-01  5.9958816751E-02  4.4004118325E-01

acell    3*1.0223825450E+01
rprim     5.2802747870E-01  0.0000000000E+00  8.4922728509E-01
         -2.6401373935E-01  4.5728521045E-01  8.4922728509E-01
         -2.6401373935E-01 -4.5728521045E-01  8.4922728509E-01
""")

    # Get NC pseudos from pseudodojo.
    from abipy.flowtk.psrepos import get_oncvpsp_pseudos
    pseudos = get_oncvpsp_pseudos(xc_name="PBEsol", version="0.4",
                                  relativity_type="FR", accuracy="standard")
                                  #relativity_type="SR", accuracy="standard")
    #nspinor = 1
    #nsppol, nspden = 1, 4
    #if nspinor == 1:
    #    nsppol, nspden  = 2, 2

    scf_input = AbinitInput(structure, pseudos)
    num_ele = scf_input.num_valence_electrons
    #scf_input.set_spin_mode(self, spin_mode)
    # AFM
    #nspinor, nsppol, nspden  = 1, 1, 2
    nspinor, nsppol, nspden  = 2, 1, 4
    metallic = True

    nband = int(1.1 * num_ele) if metallic else num_ele
    nband += nband % 2

    scf_input.set_vars(
        #ecut=43,
        ecut=12,
        #nband=60,          # Cr.psp8:14; O.psp8:6; (14*6+6*4)/2=54;54(occupied)+6(unoccupied)=60
        nband=nband,
        tolvrs=1e-3,       # SCF stopping criterion
        #tolvrs=1e-8,       # SCF stopping criterion
        nspinor=nspinor,
        nsppol=nsppol,
        nspden=nspden,
        nstep=800,         # Maximal number of SCF cycles
        #nstep=0,         # Maximal number of SCF cycles
        diemac=12.0,
        occopt=7,
        tsmear=0.01,
        ixc=7,
        paral_kgb=0,       # The system is too small to use paral_kgb = 1
    )

    # kptopt=4,          # NO TR.
    scf_input.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0, 0, 0], kptopt=4)
    #scf_input.set_kmesh(ngkpt=[4, 4, 4], shiftk=[0, 0, 0], kptopt=4)

    scf_input["spinat"] = """
        0.0 0.0  -4.0
        0.0 0.0   4.0
        0.0 0.0   4.0
        0.0 0.0  -4.0
        18*0
    """

    # Initialize the flow
    flow = flowtk.Flow(workdir=options.workdir, manager=options.manager)

    fd_accuracy = 2
    relax_ions = True
    relax_ions_opts = None

    work = FiniteHfieldWork.from_scf_input(
        scf_input,
        fd_accuracy=fd_accuracy,
        step_au=0.01,
        relax_ions=relax_ions,
        relax_ions_opts=relax_ions_opts,
        #extra_abivars=dict(berryopt=-1),  # This to compute the polarization at E = 0
    )

    # Add the work to the flow.
    flow.register_work(work)

    return flow


# 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.890 seconds)

Gallery generated by Sphinx-Gallery