{
"cells": [
{
"cell_type": "markdown",
"id": "22d177dc-6cfb-4de2-9509-f1eb45e10cf2",
"metadata": {},
"source": [
"# Atomization \n",
"\n",
"For the source code, see [atomization_energy](https://workgraph-collections.readthedocs.io/en/latest/ase/espresso/module.html#workgraph_collections.ase.espresso.atomization_energy.atomization_energy).\n",
"\n",
"\n",
"## Introduction\n",
"The atomization energy, $\\Delta E$, of a molecule can be expressed as:\n",
"\n",
"$$\n",
"\\Delta E = n_{\\text{atom}} \\times E_{\\text{atom}} - E_{\\text{molecule}}\n",
"$$\n",
"\n",
"Where:\n",
"\n",
"- $\\Delta E$ is the atomization energy of the molecule.\n",
"- $n_{\\text{atom}}$ is the number of atoms.\n",
"- $E_{\\text{atom}}$ is the energy of an isolated atom.\n",
"- $E_{\\text{molecule}}$ is the energy of the molecule.\n",
"\n",
"## Example: Atomization energy of a molecule N2\n",
"\n",
"### Prepare the inputs and submit the workflow\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from ase.build import molecule\n",
"from ase import Atoms\n",
"from aiida import load_profile\n",
"from workgraph_collections.ase.espresso.atomization_energy import AtomizationEnergy\n",
"from aiida_pythonjob.config import config\n",
"# allow pickle\n",
"config[\"allow_pickle\"] = True\n",
"load_profile()\n",
"\n",
"# create input structure\n",
"n_atom = Atoms(\"N\", pbc=True)\n",
"n_atom.center(vacuum=5.0)\n",
"n2_molecule = molecule(\"N2\", pbc=True)\n",
"n2_molecule.center(vacuum=5.0)\n",
"\n",
"metadata = {\n",
" \"options\": {\n",
" 'prepend_text' : \"\"\"eval \"$(conda shell.posix hook)\"\n",
" conda activate aiida\n",
" export OMP_NUM_THREADS=1\n",
" \"\"\",\n",
" }\n",
"}\n",
"pseudopotentials = {\"N\": \"N.pbe-n-rrkjus_psl.1.0.0.UPF\"}\n",
"pseudo_dir = \"/home/xing/data/ase/espresso_pseudo\"\n",
"# pseudo_dir = \"/home/wang_x3/datas/pseudos/psl\"\n",
"input_data = {\n",
" \"system\": {\"ecutwfc\": 30, \"ecutrho\": 240,\n",
" \"occupations\": \"smearing\",\n",
" \"degauss\": 0.01,\n",
" \"smearing\": \"cold\",},\n",
"}\n",
"#------------------------- Set the inputs -------------------------\n",
"wg = AtomizationEnergy.build_graph(atom=n_atom,\n",
" molecule=n2_molecule,\n",
" pseudopotentials=pseudopotentials,\n",
" input_data=input_data,\n",
" pseudo_dir=pseudo_dir,\n",
" computer=\"localhost\",\n",
" metadata=metadata)\n",
"\n",
"wg.to_html()"
]
},
{
"cell_type": "markdown",
"id": "dd873a97",
"metadata": {},
"source": [
"Run the workflow"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "c48c10af",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"09/04/2025 07:22:58 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator,pw_calculator1\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: pw_calculator,pw_calculator1\n",
"09/04/2025 07:23:01 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 180062, 180075\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|on_wait]: Process status: Waiting for child processes: 180062, 180075\n",
"09/04/2025 07:23:04 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|update_task_state]: Task: pw_calculator, type: PYTHONJOB, finished.\n",
"09/04/2025 07:23:04 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|update_task_state]: Task: pw_calculator1, type: PYTHONJOB, finished.\n",
"09/04/2025 07:23:06 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: calc_atomization_energy\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: calc_atomization_energy\n",
"INFO:aiida_pythonjob.decorator:Executing process function, current stack status: 47 frames of 3000\n",
"09/04/2025 07:23:07 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|update_task_state]: Task: calc_atomization_energy, type: PYFUNCTION, finished.\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|update_task_state]: Task: calc_atomization_energy, type: PYFUNCTION, finished.\n",
"09/04/2025 07:23:07 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|continue_workgraph]: tasks ready to run: \n",
"09/04/2025 07:23:07 AM <581732> aiida.orm.nodes.process.workflow.workchain.WorkChainNode: [REPORT] [180058|WorkGraphEngine|finalize]: Finalize workgraph.\n",
"REPORT:aiida.orm.nodes.process.workflow.workchain.WorkChainNode:[180058|WorkGraphEngine|finalize]: Finalize workgraph.\n"
]
}
],
"source": [
"wg.run()\n"
]
},
{
"cell_type": "markdown",
"id": "2e7efd9d",
"metadata": {},
"source": [
"Print out the result"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "72481d10",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Atomization energy: 16.262 eV\n"
]
}
],
"source": [
"#------------------------- Print the output -------------------------\n",
"print('Atomization energy: {:0.3f} eV'.format(wg.outputs.atomization_energy.value.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
}