Bands Structure

For the source code, see bands.

Example: Silicon band structure

Prepare the inputs and visualize the WorkGraph

[1]:
from copy import deepcopy
from aiida import load_profile
from aiida.orm import Dict, KpointsData, StructureData, load_code
from ase.build import bulk
from workgraph_collections.qe.bands import BandsWorkgraph

load_profile()

atoms = bulk('Si')
structure_si = StructureData(ase=atoms)

pw_code = load_code('pw-7.4@localhost')
scf_paras = {
    'CONTROL': {
        'calculation': 'scf',
    },
    'SYSTEM': {
        'ecutwfc': 30,
        'ecutrho': 240,
        'occupations': 'smearing',
        'smearing': 'gaussian',
        'degauss': 0.1,
    },
}
relax_paras = deepcopy(scf_paras)
relax_paras['CONTROL']['calculation'] = 'vc-relax'
bands_paras = deepcopy(scf_paras)
bands_paras['CONTROL']['calculation'] = 'bands'

kpoints = KpointsData()
kpoints.set_kpoints_mesh([3, 3, 3])
#
metadata = {
    'options': {
        'resources': {
            'num_machines': 1,
            'num_mpiprocs_per_machine': 4,
        },
    }
}

bands_inputs = {
    'relax': {
        'base': {
            'pw': {
                'parameters': Dict(relax_paras),
                'metadata': metadata,
            },
            'kpoints': kpoints,
        },
    },
    'scf': {
        'pw': {
            'parameters': Dict(scf_paras),
            'metadata': metadata,
        },
        'kpoints': kpoints,
    },
    'bands': {
        'pw': {
            'parameters': Dict(bands_paras),
            'metadata': metadata,
        },
        'kpoints': kpoints,
    },
}

wg = BandsWorkgraph.build_graph(
    structure=structure_si,
    code=pw_code,
    inputs=bands_inputs,
    pseudo_family='SSSP/1.3/PBEsol/efficiency',
    run_relax=True,
    bands_kpoints_distance=0.1,
)
wg.to_html()
[1]:

Run the WorkGraph

[2]:
wg.run()
09/02/2025 01:00:02 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwRelaxWorkChain
09/02/2025 01:00:03 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175117
09/02/2025 01:00:09 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<175120>
09/02/2025 01:00:09 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175120|PwBaseWorkChain|run_process]: launching PwCalculation<175123> iteration #1
09/02/2025 01:00:24 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175120|PwBaseWorkChain|results]: work chain completed after 1 iterations
09/02/2025 01:00:24 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175120|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:00:24 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|inspect_relax]: after iteration 1 cell volume of relaxed structure is 40.9225595043556
09/02/2025 01:00:25 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|run_relax]: launching PwBaseWorkChain<175132>
09/02/2025 01:00:25 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175132|PwBaseWorkChain|run_process]: launching PwCalculation<175135> iteration #1
09/02/2025 01:00:33 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175132|PwBaseWorkChain|results]: work chain completed after 1 iterations
09/02/2025 01:00:33 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175132|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:00:33 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|inspect_relax]: after iteration 2 cell volume of relaxed structure is 40.92255896569323
09/02/2025 01:00:33 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|inspect_relax]: relative cell volume difference 1.3162968698541411e-08 smaller than threshold 0.01
09/02/2025 01:00:33 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|results]: workchain completed after 2 iterations
09/02/2025 01:00:34 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175117|PwRelaxWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:00:34 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: PwRelaxWorkChain, type: WORKCHAIN, finished.
09/02/2025 01:00:42 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: inspect_relax,seekpath_structure_analysis
09/02/2025 01:00:43 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: inspect_relax, type: CALCFUNCTION, finished.
09/02/2025 01:00:44 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: seekpath_structure_analysis,update_scf_parameters
09/02/2025 01:00:45 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: seekpath_structure_analysis, type: CALCFUNCTION, finished.
09/02/2025 01:00:46 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: update_scf_parameters
09/02/2025 01:00:47 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: update_scf_parameters, type: CALCFUNCTION, finished.
09/02/2025 01:00:48 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwBaseWorkChain
09/02/2025 01:00:50 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175153
09/02/2025 01:00:55 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175153|PwBaseWorkChain|run_process]: launching PwCalculation<175156> iteration #1
09/02/2025 01:01:00 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175153|PwBaseWorkChain|results]: work chain completed after 1 iterations
09/02/2025 01:01:00 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175153|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:01:01 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: PwBaseWorkChain, type: WORKCHAIN, finished.
09/02/2025 01:01:07 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: update_bands_parameters
09/02/2025 01:01:08 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: update_bands_parameters, type: CALCFUNCTION, finished.
09/02/2025 01:01:08 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwBaseWorkChain1
09/02/2025 01:01:10 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175166
09/02/2025 01:01:15 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175166|PwBaseWorkChain|run_process]: launching PwCalculation<175169> iteration #1
09/02/2025 01:01:22 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175166|PwBaseWorkChain|results]: work chain completed after 1 iterations
09/02/2025 01:01:22 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175166|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:01:23 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|update_task_state]: Task: PwBaseWorkChain1, type: WORKCHAIN, finished.
09/02/2025 01:01:28 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/02/2025 01:01:30 PM <1272331> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175111|WorkGraphEngine|finalize]: Finalize workgraph.

Plot the band structure

[3]:
from workgraph_collections.qe.utils import plot_bandstructure

bands = wg.outputs.output_band.value
plot_bandstructure(bands)
[3]:
(<Figure size 640x480 with 1 Axes>, <Axes: ylabel='Dispersion (eV)'>)
../_images/qe_bands_6_1.png