Projected density of states (PDOS)
For the source code, see pdos.
Example: Silicon
Prepare the inputs and submit the workflow
[7]:
from ase.build import bulk
from aiida import load_profile
from copy import deepcopy
from workgraph_collections.ase.espresso.pdos import PdosWorkgraph
from aiida_pythonjob.config import config
# allow pickle
config["allow_pickle"] = True
load_profile()
atoms = bulk('Al')
metadata = {
"options": {
'prepend_text' : """eval "$(conda shell.posix hook)"
conda activate aiida
export OMP_NUM_THREADS=1
""",
}
}
pseudopotentials = {"Al": "Al.pbe-n-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 = {
"system": {"ecutwfc": 30, "ecutrho": 240,
"occupations": "smearing",
"degauss": 0.01,
"smearing": "gaussian",
},
}
nscf_input_data = deepcopy(scf_input_data)
nscf_input_data["system"].update({"occupations": "tetrahedra"})
inputs = {
"scf": {
"input_data": scf_input_data,
"kpts": [10, 10, 10],
"computer": "localhost",
"metadata": metadata
},
"nscf": {
"input_data": nscf_input_data,
"kpts": [20, 20, 20],
"computer": "localhost",
"metadata": metadata
},
"dos": {
"input_data": {},
"computer": "localhost",
"metadata": metadata
}
}
#------------------------- Set the inputs -------------------------
wg = PdosWorkgraph.build_graph(atoms=atoms,
pw_command="mpirun -np 4 pw.x",
dos_command="mpirun -np 4 dos.x",
projwfc_command="mpirun -np 4 projwfc.x",
pseudopotentials=pseudopotentials,
pseudo_dir=pseudo_dir,
inputs=inputs)
wg.to_html()
[7]:
Run the calculation
[2]:
wg.run()
09/03/2025 09:14:50 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator
09/03/2025 09:14:51 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178742
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178742
09/03/2025 09:14:58 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.
09/03/2025 09:15:00 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator1
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator1
09/03/2025 09:15:01 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178758
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178758
09/03/2025 09:15:16 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.
09/03/2025 09:15:18 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: dos_calculator,projwfc_calculator
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|continue_workgraph]: tasks ready to run: dos_calculator,projwfc_calculator
09/03/2025 09:15:20 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178774, 178780
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178774, 178780
09/03/2025 09:15:44 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|update_task_state]: Task: projwfc_calculator, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|update_task_state]: Task: projwfc_calculator, type: PYTHONJOB, finished.
09/03/2025 09:15:48 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|continue_workgraph]: tasks ready to run:
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/03/2025 09:15:49 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178774
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 178774
09/03/2025 09:16:44 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|update_task_state]: Task: dos_calculator, type: PYTHONJOB, finished.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|update_task_state]: Task: dos_calculator, type: PYTHONJOB, finished.
09/03/2025 09:16:47 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|continue_workgraph]: tasks ready to run:
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|continue_workgraph]: tasks ready to run:
09/03/2025 09:16:47 PM <328043> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [178738|WorkGraphEngine|finalize]: Finalize workgraph.
REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[178738|WorkGraphEngine|finalize]: Finalize workgraph.
Print the results
[6]:
import matplotlib.pyplot as plt
import numpy as np
#------------------------- Print the output -------------------------
dos_data = wg.outputs.dos.dos.value.value
pdos_data = wg.outputs.projwfc.projections.value.value
# make plots
plt.figure(figsize = (8, 4))
plt.plot(dos_data['x']['array'], dos_data['y']['arrays'][1], label='total')
# plt.plot(pdos_data['totol']['energy'], pdos_data['totol']['dos'], label='total')
# for file_name, data in pdos_data['atom'].items():
# value = np.array(data)
# plt.plot(value[:, 0], np.sum(value[:, 2:], axis=1), label=file_name[-4:])
plt.yticks([])
plt.xlabel('Energy (eV)')
plt.ylabel('DOS')
plt.legend(frameon=False)
[6]:
<matplotlib.legend.Legend at 0x70deea144790>