Bader Charge
For the source code, see bader.
Example: H2O molecule
Prepare the inputs and submit the workflow
[1]:
from aiida import load_profile
from aiida.orm import Dict, KpointsData, StructureData, load_code
from aiida_pseudo.data.pseudo import UpfData
from ase.build import molecule
from workgraph_collections.qe.bader import BaderWorkgraph
load_profile()
#===============================================================================
# load the codes
pw_code = load_code("pw-7.4@localhost")
pp_code = load_code("pp-7.4@localhost")
bader_code = load_code("bader@localhost")
# ===============================================================================
# create input structure
atoms = molecule("H2O")
atoms.center(vacuum=3.0)
atoms.pbc = True
structure = StructureData(ase=atoms)
# create input parameters node
scf_paras = Dict(
{
"CONTROL": {
"calculation": "scf",
},
"SYSTEM": {
"ecutwfc": 30,
"ecutrho": 240,
"occupations": "smearing",
"smearing": "gaussian",
"degauss": 0.1,
},
}
)
kpoints = KpointsData()
kpoints.set_kpoints_mesh([1, 1, 1])
# Load the pseudopotential kjpaw.
pseudos = {"H": UpfData("/home/xing/data/ase/espresso_pseudo/kjpaw/H.pbe-kjpaw_psl.1.0.0.UPF"),
"O": UpfData("/home/xing/data/ase/espresso_pseudo/kjpaw/O.pbe-n-kjpaw_psl.1.0.0.UPF")}
#
#
metadata = {
"options": {
"resources": {
"num_machines": 1,
"num_mpiprocs_per_machine": 1,
},
}
}
# ===============================================================================
inputs = {"scf":{
"pw": {
"parameters": scf_paras,
"pseudos": pseudos,
"metadata": metadata
},
"kpoints": kpoints,
},
"pp_valence": {
"parameters": Dict({
"INPUTPP": {"plot_num": 0},
"PLOT": {"iflag": 3},
}),
"metadata": metadata,
},
"pp_all": {
"parameters": Dict({
"INPUTPP": {"plot_num": 21},
"PLOT": {"iflag": 3},
}),
"metadata": metadata,
},
"bader": {
"metadata": metadata,
}
}
# prepare inputs and submit
wg = BaderWorkgraph.build_graph(structure=structure, pw_code=pw_code,
pp_code=pp_code, bader_code=bader_code,
inputs=inputs)
wg.to_html()
[1]:
Run the WorkGraph:
[2]:
wg.run()
#------------------------- Print the output -------------------------
charges = wg.outputs.bader_charge.value.get_array("charge")
print("Bader charges:")
print("Index Symbol Charge")
for i, charge in enumerate(charges):
print(f"{i:5d} {atoms.get_chemical_symbols()[i]:5s} {charge:5.3f}")
09/02/2025 01:54:31 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwBaseWorkChain
09/02/2025 01:54:32 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175332
09/02/2025 01:54:39 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175332|PwBaseWorkChain|run_process]: launching PwCalculation<175335> iteration #1
09/02/2025 01:54:52 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175332|PwBaseWorkChain|results]: work chain completed after 1 iterations
09/02/2025 01:54:52 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175332|PwBaseWorkChain|on_terminated]: remote folders will not be cleaned
09/02/2025 01:54:53 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|update_task_state]: Task: PwBaseWorkChain, type: WORKCHAIN, finished.
09/02/2025 01:54:58 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|continue_workgraph]: tasks ready to run: PpCalculation,PpCalculation1
09/02/2025 01:55:01 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175341, 175342
09/02/2025 01:55:16 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|update_task_state]: Task: PpCalculation1, type: CALCJOB, finished.
09/02/2025 01:55:17 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|update_task_state]: Task: PpCalculation, type: CALCJOB, finished.
09/02/2025 01:55:23 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|continue_workgraph]: tasks ready to run: BaderCalculation
09/02/2025 01:55:25 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175353
09/02/2025 01:55:35 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|update_task_state]: Task: BaderCalculation, type: CALCJOB, finished.
09/02/2025 01:55:40 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/02/2025 01:55:41 PM <1365991> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175329|WorkGraphEngine|finalize]: Finalize workgraph.
Bader charges:
Index Symbol Charge
0 O 7.147
1 H 0.427
2 H 0.427