{
"cells": [
{
"cell_type": "markdown",
"id": "22d177dc-6cfb-4de2-9509-f1eb45e10cf2",
"metadata": {},
"source": [
"# X-ray photoelectron spectroscopy (XPS)\n",
"For the source code, see [xps](https://workgraph-collections.readthedocs.io/en/latest/qe/module.html#workgraph_collections.ase.espresso.xps.xps_workgraph).\n",
"\n",
"\n",
"## Visualizing the WorkGraph Builder\n"
]
},
{
"cell_type": "markdown",
"id": "efa095d0",
"metadata": {},
"source": [
"## Example: ETFA molecule\n",
"\n",
"### Prepare the inputs and submit the workflow\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from ase.io import read\n",
"from aiida import load_profile\n",
"from aiida.orm import (\n",
" Dict,\n",
" KpointsData,\n",
" StructureData,\n",
" load_code,\n",
" load_group,\n",
" QueryBuilder,\n",
" Group,\n",
")\n",
"from workgraph_collections.qe.xps import XpsWorkgraph\n",
"\n",
"load_profile()\n",
"\n",
"def load_core_hole_pseudos(pseudo_group=\"pseudo_demo_pbe\"):\n",
" \"\"\"Load the core hole pseudos.\"\"\"\n",
" pseudo_group = (\n",
" QueryBuilder().append(Group, filters={\"label\": pseudo_group}).one()[0]\n",
" )\n",
" pseudos = {\"core_hole\": {\n",
" pseudo.label.split(\"_\")[0]: pseudo for pseudo in pseudo_group.nodes if \"gs\" not in pseudo.label\n",
" },\n",
" \"gipaw\": {\n",
" pseudo.label.split(\"_\")[0]: pseudo for pseudo in pseudo_group.nodes if \"gs\" in pseudo.label\n",
" }}\n",
" return pseudos, pseudo_group.base.extras.get(\"correction\", {})\n",
"\n",
"\n",
"# create input structure\n",
"etfa = read(\"datas/ETFA.xyz\")\n",
"structure = StructureData(ase=etfa)\n",
"# create the PW node\n",
"code = load_code(\"pw-7.4@localhost\")\n",
"# code = load_code(\"pw-7.4@eiger\")\n",
"parameters = Dict(\n",
" {\n",
" \"CONTROL\": {\n",
" \"calculation\": \"scf\",\n",
" },\n",
" \"SYSTEM\": {\n",
" \"ecutwfc\": 40,\n",
" \"ecutrho\": 300,\n",
" \"occupations\": \"fixed\",\n",
" },\n",
" }\n",
")\n",
"kpoints = KpointsData()\n",
"kpoints.set_kpoints_mesh([1, 1, 1])\n",
"# Load the pseudopotential family.\n",
"core_hole_pseudos, correction_energies = load_core_hole_pseudos(\"pseudo_demo_pbe\")\n",
"correction_energies = {\n",
" key.split(\"_\")[0]: value[\"core\"] for key, value in correction_energies.items()\n",
"}\n",
"pseudo_family = load_group(\"SSSP/1.3/PBE/efficiency\")\n",
"pseudos = pseudo_family.get_pseudos(structure=structure)\n",
"#\n",
"metadata = {\n",
" \"options\": {\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" \"num_mpiprocs_per_machine\": 4,\n",
" },\n",
" }\n",
"}\n",
"metadata_eiger = {\n",
" \"options\": {\n",
" \"custom_scheduler_commands\": \"#SBATCH --account=mr32\",\n",
" \"resources\": {\n",
" \"num_machines\": 1,\n",
" \"num_mpiprocs_per_machine\": 36,\n",
" },\n",
" }\n",
"}\n",
"# ===============================================================================\n",
"wg = XpsWorkgraph.build_graph(\n",
" structure=structure,\n",
" code=code,\n",
" # atoms_list=[0, 1, 2, 3],\n",
" element_list=[\"C\"],\n",
" parameters=parameters,\n",
" kpoints=kpoints,\n",
" pseudos=pseudos,\n",
" is_molecule=True,\n",
" core_hole_pseudos=core_hole_pseudos,\n",
" correction_energies=correction_energies,\n",
" metadata=metadata,\n",
")\n",
"wg.to_html()"
]
},
{
"cell_type": "markdown",
"id": "b12df8ef",
"metadata": {},
"source": [
"Run the workgraph"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7fcfdafe",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"09/02/2025 03:12:25 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|continue_workgraph]: tasks ready to run: get_xspectra_structures\n",
"09/02/2025 03:12:26 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|update_task_state]: Task: get_xspectra_structures, type: CALCFUNCTION, finished.\n",
"09/02/2025 03:12:26 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|continue_workgraph]: tasks ready to run: run_scf\n",
"09/02/2025 03:12:31 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175849\n",
"09/02/2025 03:12:36 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|continue_workgraph]: tasks ready to run: PwCalculation,PwCalculation1,PwCalculation2,PwCalculation3,PwCalculation4\n",
"09/02/2025 03:12:40 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175850, 175851, 175852, 175853, 175854\n",
"09/02/2025 03:13:24 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|update_task_state]: Task: PwCalculation1, type: CALCJOB, finished.\n",
"09/02/2025 03:13:32 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 03:13:32 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 175850, 175852, 175853, 175854\n",
"09/02/2025 03:13:42 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|update_task_state]: Task: PwCalculation, type: CALCJOB, finished.\n",
"09/02/2025 03:13:43 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|update_task_state]: Task: PwCalculation2, type: CALCJOB, finished.\n",
"09/02/2025 03:13:43 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|update_task_state]: Task: PwCalculation3, type: CALCJOB, finished.\n",
"09/02/2025 03:13:44 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|update_task_state]: Task: PwCalculation4, type: CALCJOB, finished.\n",
"09/02/2025 03:13:47 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 03:13:47 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175849|WorkGraphEngine|finalize]: Finalize workgraph.\n",
"09/02/2025 03:13:49 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|update_task_state]: Task: run_scf, type: GRAPH, finished.\n",
"09/02/2025 03:13:50 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|continue_workgraph]: tasks ready to run: binding_energy\n",
"09/02/2025 03:13:51 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|update_task_state]: Task: binding_energy, type: CALCFUNCTION, finished.\n",
"09/02/2025 03:13:51 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/02/2025 03:13:51 PM <1488790> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [175827|WorkGraphEngine|finalize]: Finalize workgraph.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"result: \n",
" site_0: 305.1129763777\n",
" site_1: 302.0445550643\n",
" site_2: 299.7042622079\n",
" site_3: 297.9095340518\n"
]
}
],
"source": [
"wg.run()"
]
},
{
"cell_type": "markdown",
"id": "1a6fe286",
"metadata": {},
"source": [
"Print the results:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "3aaf0dc5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"result: \n",
" site_0: 305.1129763777\n",
" site_1: 302.0445550643\n",
" site_2: 299.7042622079\n",
" site_3: 297.9095340518\n"
]
}
],
"source": [
"print(\"result: \")\n",
"\n",
"for key, value in wg.outputs.result.value.value.items():\n",
" print(f\" {key}: {value}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "aiida",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}