{ "cells": [ { "cell_type": "markdown", "id": "8e2d6403", "metadata": {}, "source": [ "# openCOSMO-RS \n", "\n", "This tutorial demonstrates how to perform an OpenCOSMO-RS calculation using the ORCA python interface (OPI) and combining it with the [openCOSMO-RS_py](https://github.com/TUHH-TVT/openCOSMO-RS_py) project to calculate sigma profiles and solubilities.\n", "\n", "In this notebook we will:\n", "1. Import the required Python dependencies\n", "2. Define a working directory\n", "3. Prepare and visualize input structures\n", "4. Run ORCA calculations with COSMO solvation\n", "5. Parse .orcacosmo output files and extract sigma profiles\n", "6. Compute solubility using openCOSMO-RS (non-iterative and iterative methods)" ] }, { "cell_type": "markdown", "id": "070ef794", "metadata": {}, "source": [ "> **Note:** For this notebook to work you will have to install opencosmors_py from GitHub into your OPI `venv` by activating the `.venv` and using:\n", "\n", "```\n", "uv pip install git+https://github.com/TUHH-TVT/openCOSMO-RS_py\n", "```\n", "\n", "For more details visit the [openCOSMO-RS_py](https://github.com/TUHH-TVT/openCOSMO-RS_py) project on GitHub." ] }, { "cell_type": "markdown", "id": "9efa50ca", "metadata": {}, "source": [ "## Step 1: Import Dependencies\n", "\n", "We start by importing the modules needed for:\n", "- Interfacing with ORCA input/output\n", "- Plotting results\n", "- Numerical calculations and data handling\n", "- Handling for directory\n", "- Performing COSMO-RS calculations using the openCOSMO-RS library\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": 1, "id": "df4e7354", "metadata": {}, "outputs": [], "source": [ "# > Import pathlib for directory handling\n", "from pathlib import Path\n", "import shutil\n", "\n", "# > Import necessary libraries for numerical computations\n", "import numpy as np\n", "from scipy.optimize import fsolve\n", "\n", "# > Import the openCOSMO-RS library components\n", "from opencosmorspy.parameterization import openCOSMORS24a\n", "from opencosmorspy.cosmors import COSMORS\n", "from opencosmorspy.input_parsers import SigmaProfileParser\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.structures.structure import Structure\n", "from opi.input.simple_keywords import SolvationModel, Solvent\n", "\n", "# > Import libraries for visualization\n", "from matplotlib import pyplot as plt\n", "import py3Dmol" ] }, { "cell_type": "markdown", "id": "eb47b6f0", "metadata": {}, "source": [ "## Step 2: Define Working Directory\n", "\n", "All actual calculations will be performed in a subfolder **opencosmors**." ] }, { "cell_type": "code", "execution_count": null, "id": "dacfcb12", "metadata": {}, "outputs": [], "source": [ "# > Calculation is performed in `opencosmors`\n", "working_dir = Path(\"opencosmors\")\n", "# > The `working_dir`is automatically (re-)created\n", "shutil.rmtree(working_dir, ignore_errors=True)\n", "working_dir.mkdir()" ] }, { "cell_type": "markdown", "id": "f7cd84d3", "metadata": {}, "source": [ "## Step 3: Prepare and Visualize Input Structures\n", "\n", "We use **water** as our example molecule. The 3D structure in Cartesian coordinates is defined in XYZ format and visualized." ] }, { "cell_type": "code", "execution_count": 3, "id": "58f5cf3d", "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.