{ "cells": [ { "cell_type": "markdown", "id": "348db862", "metadata": {}, "source": [ "# External Methods \n", "\n", "This tutorial demonstrates how to perform an ORCA calculation via OPI with external wrapper scripts to allow the use of methods not natively implemented in ORCA. As an example, we will run an optimization of the phenylalanine–serine dipeptide with PM7. Therefore, the respective wrapper must be downloaded (available via [GitHub](https://github.com/faccts/orca-external-tools)) and MOPAC has to be installed (also available via [GitHub](https://github.com/openmopac/mopac)). Besides geometry optimization, also other ORCA functionalities like GOAT or a NEB-TS are available in combination with wrapper scripts.\n", "\n", ":::{note}\n", "Besides MOPAC and PM7, you can use any program and method of your liking as long as you have the respective program installed and the wrapper available. If you create or use a custom wrapper script, please consider contributing on [GitHub](https://github.com/faccts/orca-external-tools) to make it accessible for everyone.\n", ":::\n", "\n", "In this notebook we will:\n", "1. Import the required python dependencies.\n", "2. Define a working directory.\n", "3. Set up the input structure.\n", "4. Define the calculation settings.\n", "5. Perform the ORCA calculation.\n", "6. Check for proper termination.\n", "7. Process the results." ] }, { "cell_type": "markdown", "id": "8cc75855", "metadata": {}, "source": [ "## Step 1: Import Dependencies\n", "\n", "The first thing to do for using OPI is to import the modules needed. We additionally import also the modules for visualization like `py3Dmol`. For this, it might be necessary to install `py3Dmol` into your OPI `venv` (e.g., by activating the `.venv` and using `pip install py3Dmol`)." ] }, { "cell_type": "code", "execution_count": 1, "id": "20705d64", "metadata": {}, "outputs": [], "source": [ "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.output.core import Output\n", "from opi.input.simple_keywords import Opt\n", "from opi.input.structures.structure import Structure\n", "from opi.input.blocks import BlockMethod\n", "from opi.input.simple_keywords import ExternalTools\n", "\n", "# > for visualization of molecules\n", "import py3Dmol" ] }, { "cell_type": "markdown", "id": "48122235", "metadata": {}, "source": [ "## Step 2: Working Directory\n", "\n", "When working with OPI, it is always a good idea to define a subdirectory in which the actual ORCA calculations will take place. In this case, we set up a `RUN` directory:" ] }, { "cell_type": "code", "execution_count": 2, "id": "d2a07d41", "metadata": {}, "outputs": [], "source": [ "# > Calculation is performed in `RUN`\n", "working_dir = Path(\"RUN\")\n", "# > The `working_dir`is automatically (re-)created\n", "shutil.rmtree(working_dir, ignore_errors=True)\n", "working_dir.mkdir()" ] }, { "cell_type": "markdown", "id": "cd363d23", "metadata": {}, "source": [ "## Step 3: Setup the Input Structure\n", "\n", "We define the structure with Cartesian coordinates in angstrom and visualize it:\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "11f3f621", "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.