Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


.vscode/
184 changes: 81 additions & 103 deletions docs/source/ase/espresso/atomization_energy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
"- $E_{\\text{atom}}$ is the energy of an isolated atom.\n",
"- $E_{\\text{molecule}}$ is the energy of the molecule.\n",
"\n",
"## Visualizing the WorkGraph Builder\n"
"## Example: Atomization energy of a molecule N2\n",
"\n",
"### Prepare the inputs and submit the workflow\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1a8ebc0d",
"execution_count": 4,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"metadata": {},
"outputs": [
{
Expand All @@ -40,160 +43,140 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"html/atomization_energy0.html\"\n",
" src=\"html/AtomizationEnergy.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7890d71b9810>"
"<IPython.lib.display.IFrame at 0x71c0483c9c10>"
]
},
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from workgraph_collections.ase.espresso.atomization_energy import atomization_energy\n",
"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",
"task = atomization_energy.TaskCls()\n",
"task.to_html()"
"wg.to_html()"
]
},
{
"cell_type": "markdown",
"id": "9e6360d8",
"id": "dd873a97",
"metadata": {},
"source": [
"## Visualizing the WorkGraph"
"Run the workflow"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "01bedd69",
"id": "c48c10af",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"html/Atomization energy.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7890d70670d0>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
"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": [
"from workgraph_collections.ase.espresso.atomization_energy import atomization_energy\n",
"\n",
"wg = atomization_energy()\n",
"wg.to_html()"
"wg.run()\n"
]
},
{
"cell_type": "markdown",
"id": "efa095d0",
"id": "2e7efd9d",
"metadata": {},
"source": [
"## Example: Atomization energy of a molecule N2\n",
"\n",
"### Prepare the inputs and submit the workflow\n"
"Print out the result"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0",
"id": "72481d10",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"WorkGraph process created, PK: 16469\n",
"Energy of a N atom: -269.881\n",
"Energy of an un-relaxed N2 molecule: -556.008\n",
"Atomization energy: 16.246 eV\n"
"Atomization energy: 16.262 eV\n"
]
}
],
"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 atomization_energy\n",
"\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 = atomization_energy()\n",
"wg.tasks[\"scf_atom\"].set({\"atoms\": n_atom,\n",
" \"pseudopotentials\": pseudopotentials,\n",
" \"pseudo_dir\": pseudo_dir,\n",
" \"input_data\": input_data,\n",
" \"computer\": \"localhost\",\n",
" \"metadata\": metadata})\n",
"wg.tasks[\"scf_mol\"].set({\"atoms\": n2_molecule,\n",
" \"pseudopotentials\": pseudopotentials,\n",
" \"pseudo_dir\": pseudo_dir,\n",
" \"input_data\": input_data,\n",
" \"computer\": \"localhost\",\n",
" \"metadata\": metadata})\n",
"wg.tasks[\"calc_atomization_energy\"].set({\"molecule\": n2_molecule, \"computer\": \"localhost\"})\n",
"#------------------------- Submit the calculation -------------------\n",
"# wg.run()\n",
"wg.submit(wait=True, timeout=200)\n",
"#------------------------- Print the output -------------------------\n",
"print('Energy of a N atom: {:0.3f}'.format(wg.tasks['scf_atom'].outputs[\"results\"].value.value['energy']))\n",
"print('Energy of an un-relaxed N2 molecule: {:0.3f}'.format(wg.tasks['scf_mol'].outputs[\"results\"].value.value['energy']))\n",
"print('Atomization energy: {:0.3f} eV'.format(wg.tasks['calc_atomization_energy'].outputs[\"result\"].value.value))\n",
"\n"
"print('Atomization energy: {:0.3f} eV'.format(wg.outputs.atomization_energy.value.value))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "aiida",
"language": "python",
"name": "python3"
},
Expand All @@ -208,11 +191,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
},
"vscode": {
"interpreter": {
"hash": "2f450c1ff08798c4974437dd057310afef0de414c25d1fd960ad375311c3f6ff"
}
}
},
"nbformat": 4,
Expand Down
Loading
Loading