{ "cells": [ { "cell_type": "markdown", "id": "a559242a", "metadata": {}, "source": [ "# Atomization energy\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", "## Visualizing the WorkGraph Builder\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "138f6157", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from workgraph_collections.ase.emt.atomization_energy import atomization_energy\n", "\n", "task = atomization_energy.TaskCls()\n", "task.to_html()" ] }, { "cell_type": "markdown", "id": "9e6360d8", "metadata": {}, "source": [ "## Visualizing the WorkGraph" ] }, { "cell_type": "code", "execution_count": 2, "id": "01bedd69", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from workgraph_collections.ase.emt.atomization_energy import atomization_energy\n", "\n", "wg = atomization_energy()\n", "wg.to_html()" ] }, { "cell_type": "markdown", "id": "efa095d0", "metadata": {}, "source": [ "## Example: Atomization energy of a molecule N2\n", "\n", "### Prepare the inputs and submit the workflow\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "8ee799d2-0b5b-4609-957f-6b3f2cd451f0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WorkGraph process created, PK: 16423\n", "Atomization energy: 9.651 eV\n" ] } ], "source": [ "from ase.build import molecule\n", "from ase import Atoms\n", "from workgraph_collections.ase.emt.atomization_energy import atomization_energy\n", "from aiida import load_profile\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\": \"\"\"\n", "eval \"$(conda shell.posix hook)\"\n", "conda activate aiida\n", "export OMP_NUM_THREADS=1\n", " \"\"\",\n", " }\n", "}\n", "# ------------------------- Set the inputs -------------------------\n", "wg = atomization_energy()\n", "wg.tasks[\"scf_atom\"].set(\n", " {\"atoms\": n_atom, \"computer\": \"localhost\", \"metadata\": metadata}\n", ")\n", "wg.tasks[\"scf_mol\"].set(\n", " {\"atoms\": n2_molecule, \"computer\": \"localhost\", \"metadata\": metadata}\n", ")\n", "wg.tasks[\"calc_atomization_energy\"].set({\"molecule\": n2_molecule, \"computer\": \"localhost\"})\n", "# ------------------------- Submit the calculation -------------------\n", "wg.submit(wait=True, timeout=200)\n", "# ------------------------- Print the output -------------------------\n", "print(\n", " \"Atomization energy: {:0.3f} eV\".format(\n", " wg.tasks[\"calc_atomization_energy\"].outputs[\"result\"].value.value\n", " )\n", ")\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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" }, "vscode": { "interpreter": { "hash": "2f450c1ff08798c4974437dd057310afef0de414c25d1fd960ad375311c3f6ff" } } }, "nbformat": 4, "nbformat_minor": 5 }