{ "cells": [ { "cell_type": "markdown", "id": "71a2f48b", "metadata": {}, "source": [ "# Calculation of Redox Potentials\n", "\n", "In this tutorial, we use ORCA together with the ORCA Python interface (OPI) to calculate the redox potentials of anisole and dimethoxybenzene in acetonitrile (MeCN) using density functional theory (DFT) with implicit solvation. The redox potentials are obtained from the Gibbs free energy difference between the neutral and oxidized species in solution, following a standard thermodynamic cycle. The calculations required to obtain these free energy differences include geometry optimizations and frequency calculations for both the oxidized and neutral species, as well as high-level single-point calculations using a hybrid DFT functional on the optimized structures. With this approach, four calculations are required for each redox couple: geometry optimization and single-point energy evaluation for both the oxidized and neutral states. Setting these calculations up, running them, and parsing the output can be simplified with OPI as shown below." ] }, { "cell_type": "markdown", "id": "d3da3e2e-870f-46e2-b1cc-eacfd4bc9f38", "metadata": {}, "source": [ "## Step 1: Installing 3rd-party Dependencies" ] }, { "cell_type": "code", "execution_count": null, "id": "9b2f99e1-beab-4ea4-8749-722c553b4329", "metadata": {}, "outputs": [], "source": [ "import sys\n", "!{sys.executable} -m pip install --upgrade py3Dmol" ] }, { "cell_type": "markdown", "id": "e86ab3fc", "metadata": {}, "source": [ "## Step 1: Import Dependencies\n", "\n", "We begin by importing all required Python modules for this tutorial. These include:\n", "\n", "- **OPI**: for setting up, running, and parsing ORCA quantum chemistry calculations.\n", "- **py3Dmol**: for interactive 3D visualization of molecular structures directly in the notebook.\n", "\n", "> **Note:** We additionally import modules for visualization/plotting like `py3Dmol`. For this, it might be necessary to install `py3Dmol` into your OPI `venv` (e.g., by activating the `.venv` and using `uv pip install py3Dmol`)." ] }, { "cell_type": "code", "execution_count": null, "id": "b4b88031", "metadata": {}, "outputs": [], "source": [ "# > Import pathlib for directory handling\n", "from pathlib import Path\n", "import shutil\n", "\n", "# > OPI imports for performing ORCA calculations and reading output\n", "from opi.core import Calculator\n", "from opi.input.structures.structure import Structure\n", "from opi.input.simple_keywords import Dft, Task, SolvationModel, Solvent, BasisSet\n", "from opi.input.simple_keywords import SimpleKeyword\n", "from opi.input.blocks import Block, BlockScf\n", "from opi.output.core import Output\n", "from opi.utils.units import AU_TO_EV\n", "\n", "# > Import py3Dmol for 3D molecular visualization\n", "import py3Dmol" ] }, { "cell_type": "markdown", "id": "62980249", "metadata": {}, "source": [ "## Step 2: Define Working Directory\n", "\n", "All actual calculations will be performed in a subfolder `redox`." ] }, { "cell_type": "code", "execution_count": null, "id": "8712d717", "metadata": {}, "outputs": [], "source": [ "# > Calculation is performed in `fock_matrix_diagonalization`\n", "working_dir = Path(\"redox\")\n", "# > The `working_dir`is automatically (re-)created\n", "shutil.rmtree(working_dir, ignore_errors=True)\n", "working_dir.mkdir()" ] }, { "cell_type": "markdown", "id": "986bd3db", "metadata": {}, "source": [ "## Step 3: Setting up the Structures\n", "\n", "We define the input structures as xyz-files:" ] }, { "cell_type": "code", "execution_count": 3, "id": "3613f8e7", "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.