{ "cells": [ { "cell_type": "markdown", "id": "6a0f6d8f-ff7c-479b-893c-64a27bdfc59e", "metadata": {}, "source": [ "## Initialization" ] }, { "cell_type": "code", "execution_count": 1, "id": "40789f7b-9c05-4170-88b2-e3714a317260", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PLAMS working folder: /path/plams/ReorganizationEnergy/plams_workdir.002\n" ] } ], "source": [ "#!/usr/bin/env amspython\n", "from scm.plams import Molecule, Settings, ReorganizationEnergyJob, init, AMSJob\n", "\n", "# this line is not required in AMS2025+\n", "init()" ] }, { "cell_type": "markdown", "id": "28876aeb-a195-451e-be23-e5745174f6f7", "metadata": {}, "source": [ "## Define molecule\n", "\n", "Normally you would read it from an xyz file, but here is for convenience explicit code" ] }, { "cell_type": "code", "execution_count": 2, "id": "8bf306b3-5302-46ce-b391-efccd3e42171", "metadata": {}, "outputs": [], "source": [ "# molecule = Molecule(\"pyrrole.xyz\")\n", "\n", "\n", "def get_molecule(input_string):\n", " job = AMSJob.from_input(input_string)\n", " return job.molecule[\"\"]\n", "\n", "\n", "molecule = get_molecule(\n", " \"\"\"\n", "System\n", " Atoms\n", " C -1.12843000 0.00000000 -0.35463200\n", " C -0.71293000 0.00000000 0.96463800\n", " C 0.71293000 0.00000000 0.96463800\n", " C 1.12843000 0.00000000 -0.35463200\n", " N 0.00000000 0.00000000 -1.14563200\n", " H 0.00000000 0.00000000 -2.15713200\n", " H -2.12074000 0.00000000 -0.79100200\n", " H -1.36515000 0.00000000 1.83237800\n", " H 1.36515000 0.00000000 1.83237800\n", " H 2.12074000 0.00000000 -0.79100200\n", " End\n", "End\n", "\"\"\"\n", ")\n", "\n", "molecule.properties.name = \"pyrrole\" # normally the name of the xyz file" ] }, { "cell_type": "markdown", "id": "4993e4c1-5448-4b11-96b1-fcc9ae1b3f5d", "metadata": {}, "source": [ "## Setup and run job" ] }, { "cell_type": "code", "execution_count": 3, "id": "cee28e69-7b62-48be-a617-1422c2b68a67", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[05.03|13:59:19] JOB pyrrole STARTED\n", "[05.03|13:59:19] JOB pyrrole RUNNING\n", "[05.03|13:59:19] JOB pyrrole/go_A STARTED\n", "[05.03|13:59:19] JOB pyrrole/go_A RUNNING\n", "[05.03|13:59:23] JOB pyrrole/go_A FINISHED\n", "[05.03|13:59:23] JOB pyrrole/go_A SUCCESSFUL\n", "[05.03|13:59:23] JOB pyrrole/go_B STARTED\n", "[05.03|13:59:23] JOB pyrrole/go_B RUNNING\n", "[05.03|13:59:30] JOB pyrrole/go_B FINISHED\n", "[05.03|13:59:30] JOB pyrrole/go_B SUCCESSFUL\n", "[05.03|13:59:30] JOB pyrrole/sp_A_geo_B STARTED\n", "[05.03|13:59:30] JOB pyrrole/sp_A_geo_B RUNNING\n", "[05.03|13:59:33] JOB pyrrole/sp_A_geo_B FINISHED\n", "[05.03|13:59:33] JOB pyrrole/sp_A_geo_B SUCCESSFUL\n", "[05.03|13:59:33] JOB pyrrole/sp_B_geo_A STARTED\n", "[05.03|13:59:33] JOB pyrrole/sp_B_geo_A RUNNING\n", "[05.03|13:59:37] JOB pyrrole/sp_B_geo_A FINISHED\n", "[05.03|13:59:37] JOB pyrrole/sp_B_geo_A SUCCESSFUL\n", "[05.03|13:59:37] JOB pyrrole FINISHED\n", "[05.03|13:59:37] JOB pyrrole SUCCESSFUL\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Generic settings of the calculation\n", "# (for quantitatively better results, use better settings)\n", "common_settings = Settings()\n", "common_settings.input.adf.Basis.Type = \"DZ\"\n", "\n", "# Specific settings for the neutral calculation.\n", "# Nothing special needs to be done for the neutral calculation,\n", "# so we just use an empty settings.\n", "neutral_settings = Settings()\n", "\n", "# Specific settings for the anion calculation:\n", "anion_settings = Settings()\n", "anion_settings.input.ams.System.Charge = -1\n", "anion_settings.input.adf.Unrestricted = \"Yes\"\n", "anion_settings.input.adf.SpinPolarization = 1\n", "\n", "# Create and run the ReorganizationEnergyJob:\n", "job = ReorganizationEnergyJob(\n", " molecule, common_settings, neutral_settings, anion_settings, name=molecule.properties.name\n", ")\n", "job.run()" ] }, { "cell_type": "markdown", "id": "ae2e3890-cadf-4bf9-a735-1c8226a9c366", "metadata": {}, "source": [ "## Fetch and print the results:" ] }, { "cell_type": "code", "execution_count": 4, "id": "43b1bc35-ba6f-4c69-af03-b51508104386", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "== Results ==\n", "\n", "Molecule: pyrrole\n", "State A: neutral\n", "State B: anion\n", "\n", "Reorganization energy: 0.473683 [eV]\n", "\n", "| State | Optim Geo | Energy [eV]\n", "| A | A | -63.801633\n", "| A | B | -63.487503\n", "| B | A | -61.702138\n", "| B | B | -61.861691\n", "\n" ] } ], "source": [ "energy_unit = \"eV\"\n", "energies = job.results.get_all_energies(energy_unit)\n", "reorganization_energy = job.results.reorganization_energy(energy_unit)\n", "\n", "print(\"\")\n", "print(\"== Results ==\")\n", "print(\"\")\n", "print(f\"Molecule: {molecule.properties.name}\")\n", "print(\"State A: neutral\")\n", "print(\"State B: anion\")\n", "print(\"\")\n", "print(f\"Reorganization energy: {reorganization_energy:.6f} [{energy_unit}]\")\n", "print(\"\")\n", "print(f\"| State | Optim Geo | Energy [{energy_unit}]\")\n", "print(f'| A | A | {energies[\"state A geo A\"]:.6f}')\n", "print(f'| A | B | {energies[\"state A geo B\"]:.6f}')\n", "print(f'| B | A | {energies[\"state B geo A\"]:.6f}')\n", "print(f'| B | B | {energies[\"state B geo B\"]:.6f}')\n", "print(\"\")" ] }, { "cell_type": "code", "execution_count": null, "id": "ebd5620e-77cd-4cec-b27e-138ab94aa69c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }