{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Geometry optimization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`Auto3D` is mainly designed for generating low-energy 3D structures from the SMILES. It aslo provides a wrapper function `opt_geometry` to do geometry optimization for existing 3D structures, using `ANI2x`, `AIMNET` or `ANI2xt` as the optimizing engine. \n", "\n", "You can use it to opimize 3D structures from other sources, or try tight optimization convergence threshold from the output of Auto3D.\n", "\n", "The source jupyter notebook can be downloaded [here](https://github.com/isayevlab/Auto3D_pkg/blob/main/example/geometry_optimization.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "import os, sys\nroot = os.path.dirname(os.path.dirname(os.path.abspath(\"__file__\")))\nsys.path.append(root)\n\nimport Auto3D\nfrom Auto3D import Auto3DOptions, main, opt_geometry" }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2.2.10\n" ] } ], "source": [ "#Always ensure that you have the latest version\n", "print(Auto3D.__version__)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Preparing for parallel optimizing... (Max optimization steps: 5000)\n", "Total 3D conformers: 4\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ " 9%|▊ | 432/5000 [00:23<04:08, 18.38it/s]" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Optimization finished at step 433: Total 3D structures: 4 Converged: 4 Dropped(Oscillating): 0 Active: 0\n", "/home/jack/Auto3D_pkg/example/files/RDKIT_AIMNET_smiles/smiles_out_AIMNET_opt.sdf\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n" ] } ], "source": [ "path = os.path.join(root, \"example/files/RDKIT_AIMNET_smiles/smiles_out.sdf\")\n", "optimized = opt_geometry(path, model_name=\"AIMNET\", opt_tol=0.002)\n", "print(optimized)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function opt_geometry in module Auto3D.ASE.geometry:\n", "\n", "opt_geometry(path: str, model_name: str, gpu_idx=0, opt_tol=0.003, opt_steps=5000)\n", " Geometry optimization interface with FIRE optimizer.\n", " \n", " :param path: Input sdf file\n", " :type path: str\n", " :param model_name: ANI2x, ANI2xt or AIMNET\n", " :type model_name: str\n", " :param gpu_idx: GPU cuda index, defaults to 0\n", " :type gpu_idx: int, optional\n", " :param opt_tol: Convergence_threshold for geometry optimization (eV/A), defaults to 0.003\n", " :type opt_tol: float, optional\n", " :param opt_steps: Maximum geometry optimization steps, defaults to 5000\n", " :type opt_steps: int, optional\n", "\n" ] } ], "source": [ "help(opt_geometry) #please note that model_name can be \"ANI2x\", \"ANI2xt\" and \"AIMNET\"." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3.9.7 ('py39')", "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.9.17" }, "vscode": { "interpreter": { "hash": "61b4062b24dfb1010f420dad5aa3bd73a4d2af47d0ec44eafec465a35a9d7239" } } }, "nbformat": 4, "nbformat_minor": 2 }