{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Geometry Optimization\n", "This tutorial will demonstrate the use of PyBigDFT for performing geometry optimization. We will start with a simple example of a molecular system. Then we will move to an advanced example involving a slab of NaCl.\n", "\n", "## Molecule Example\n", "Let's begin with a simple example of an Aflatoxin B1 molecule." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "cano = \"CN1C=NC2=C1C(=O)N(C(=O)N2C)C\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can use openbabel to create a system from its cannonical smiles representation." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from openbabel.openbabel import OBMol, OBConversion, OBBuilder\n", "conv = OBConversion()\n", "conv.SetInFormat(\"can\")\n", "\n", "mol = OBMol()\n", "conv.ReadString(mol, cano)\n", "mol.AddHydrogens()\n", "\n", "builder = OBBuilder()\n", "builder.Build(mol)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we convert from babel to PyBigDFT. An openbabel structure after calling build is usually not a good starting point. Normally you would do some combination of optimization and conformer search. For our case, we will do geometry optimization followed by a short molecular dynamics run. This will give us a decent geometry, but one that is not the actual minimum." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/wddawson/Documents/CEA/binaries/bds/install/lib/python3.7/site-packages/BigDFT/IO.py:371: UserWarning: Unsupported bond type had to be set to 1 (i.e. aromatic)\n", " UserWarning)\n", "/Users/wddawson/Documents/CEA/binaries/bds/install/lib/python3.7/site-packages/BigDFT/IO.py:371: UserWarning: Unsupported bond type had to be set to 1 (i.e. aromatic)\n", " UserWarning)\n" ] } ], "source": [ "from BigDFT.Interop.BabelInterop import convert_babel_to_system, molecular_dynamics, optimize_system\n", "sys_start = convert_babel_to_system(mol)\n", "sys_opt = optimize_system(sys_start)\n", "sys = molecular_dynamics(sys_opt, 10000, 300)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n",
" jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n",
" jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n",
" jupyter labextension install jupyterlab_3dmol