Bands Structure

For the source code, see bands.

Visualizing the WorkGraph Builder

[1]:
from workgraph_collections.ase.espresso.bands import bands_workgraph
from aiida import load_profile
load_profile()

task = bands_workgraph.task()
task.to_html()
[1]:

Visualizing the WorkGraph

[2]:
from workgraph_collections.ase.espresso.bands import bands_workgraph

wg = bands_workgraph(run_relax=True, run_scf=True)
wg.to_html()
[2]:

Example: Silicon

Prepare the inputs and submit the workflow

[3]:
from ase.build import bulk
from aiida import load_profile
from copy import deepcopy

from workgraph_collections.ase.espresso.bands import bands_workgraph

load_profile()

atoms = bulk('Si')


metadata = {
    "options": {
        'prepend_text' : """eval "$(conda shell.posix hook)"
        conda activate aiida
        export OMP_NUM_THREADS=1
        """,
    }
}
pseudopotentials = {"Si": "Si.pbe-nl-rrkjus_psl.1.0.0.UPF"}
# pseudo_dir = "/home/xing/data/ase/espresso_pseudo"
pseudo_dir = "/home/wang_x3/datas/pseudos/psl"
scf_input_data = {
    "control": {"calculation": "scf",
                },
    "system": {"ecutwfc": 30, "ecutrho": 240,
               "occupations": "smearing",
                "degauss": 0.01,
                "smearing": "cold"
                },
}
bands_input_data = deepcopy(scf_input_data)
bands_input_data["control"].update({"calculation": "bands"})

inputs = {
    "scf": {
        "input_data": scf_input_data,
        "kpts": (4, 4, 4),
        "computer": "localhost",
        "metadata": metadata
    },
    "find_kponits_path": {
        "computer": "localhost",
        "metadata": metadata
    },
    "bands": {
        "input_data": bands_input_data,
        "computer": "localhost",
        "metadata": metadata
    },
}
#------------------------- Set the inputs -------------------------
wg = bands_workgraph(atoms=atoms,
                    pw_command="mpirun -np 1 pw.x",
                    pseudopotentials=pseudopotentials,
                    pseudo_dir=pseudo_dir,
                    inputs=inputs,
                    density=10,
                    run_relax=True,
                    run_scf=True,
                    )
#------------------------- Submit the calculation -------------------
wg.submit(wait=True, timeout=200)


WorkGraph process created, PK: 21550
[3]:
<WorkChainNode: uuid: 3a643249-7320-4624-9b2d-4f44f85c23dc (pk: 21550) (aiida_workgraph.engine.workgraph.WorkGraphEngine)>

Plot the band structure

[4]:
from ase.spectrum.band_structure import BandStructure
import numpy as np

data = wg.tasks["bands"].outputs["results"].value.value
eigenvalues = np.array([np.array(data['eigenvalues'][0])])
kpts = wg.tasks["find_kponits_path"].outputs["result"].value.value
bs = BandStructure(path=kpts, energies=eigenvalues)
bs.plot()
[4]:
<AxesSubplot:ylabel='energies [eV]'>
../../_images/ase_espresso_bands_7_1.png