{ "cells": [ { "cell_type": "markdown", "id": "e676a8e1-8c9d-4e06-975b-bdca2e8647fd", "metadata": {}, "source": [ "## Initial imports" ] }, { "cell_type": "code", "execution_count": 1, "id": "e7d55482-7a63-4d9f-a720-2dbd198d6521", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "PLAMS working folder: /path/plams/examples/COSMORSConformers/plams_workdir\n" ] } ], "source": [ "from scm.plams.recipes.adfcosmorsconformers import ADFCOSMORSConfJob, ADFCOSMORSConfFilter\n", "from scm.plams import Molecule, from_smiles, Settings, init, config, JobRunner\n", "from scm.conformers import ConformersJob\n", "\n", "# this line is not required in AMS2025+\n", "init();" ] }, { "cell_type": "code", "execution_count": 2, "id": "24541907-e64a-40ba-bcde-077b3484bf5c", "metadata": {}, "outputs": [], "source": [ "config.default_jobrunner = JobRunner(parallel=True, maxjobs=8) # Set the default jobrunner to be parallel\n", "config.default_jobmanager.settings.hashing = None # Disable rerun prevention\n", "config.job.runscript.nproc = 1 # Number of cores for each job\n", "config.log.stdout = 1 # Suppress plams output" ] }, { "cell_type": "markdown", "id": "ae03f386-2f8f-4fb5-9dcb-4e5529de98d0", "metadata": {}, "source": [ "## Set up conformer generator" ] }, { "cell_type": "markdown", "id": "47bc1ee7-def3-43f2-8cf9-9a89f99988d6", "metadata": {}, "source": [ "First, we input the acetic acid molecule with the `from_smiles` function" ] }, { "cell_type": "code", "execution_count": 3, "id": "1c873e27-0231-42c6-8253-ca0236b78c88", "metadata": {}, "outputs": [], "source": [ "mol = from_smiles(\"CC(=O)O\")" ] }, { "cell_type": "markdown", "id": "db87c8f7-7e0f-47ca-a372-64417d35b7bf", "metadata": {}, "source": [ "Now, we'll specify a conformer generator (identical to the default) that generates only 50 initial structures:" ] }, { "cell_type": "code", "execution_count": 4, "id": "213cfc46-e2ee-4544-b8f8-6cf132e7f91e", "metadata": {}, "outputs": [], "source": [ "conf_sett = Settings()\n", "conf_sett.input.AMS.Generator.RDKit\n", "conf_sett.input.AMS.Generator.RDKit.InitialNConformers = 50\n", "conf_job = ConformersJob(name=\"conformers_uff\", molecule=mol, settings=conf_sett)" ] }, { "cell_type": "markdown", "id": "5bb08dec-a93e-472b-a8ce-37816c01e1c9", "metadata": {}, "source": [ "Let's also specify an additional step to add to the default workflow. Here, we'll add a DFTB geometry optimization." ] }, { "cell_type": "code", "execution_count": 5, "id": "7c358881-cc56-4851-ab4d-a357105128cf", "metadata": {}, "outputs": [], "source": [ "dftb_sett = Settings()\n", "dftb_sett.input.DFTB\n", "dftb_sett.input.AMS.Task = \"Optimize\"" ] }, { "cell_type": "markdown", "id": "5ebc8c6d-e951-4c1a-a9c8-c7b5b3e7d51a", "metadata": {}, "source": [ "The final thing we need to specify are filters. Let's make three filters, the first to take a maximum of 20 conformers with a maximum energy range of 22 kcal/mol, the second with 10 conformers and 12 kcal/mol and the third with 5 conformers and 7 kcal/mol." ] }, { "cell_type": "code", "execution_count": 6, "id": "ab44876a-9ee6-4009-b51f-bdb8073bf2e8", "metadata": {}, "outputs": [], "source": [ "# ADFCOSMORSConfFilter(max number of conformers, max energy range)\n", "fil1 = ADFCOSMORSConfFilter(20, 22) # applied to UFF\n", "fil2 = ADFCOSMORSConfFilter(10, 12) # applied to DFTB\n", "fil3 = ADFCOSMORSConfFilter(5, 7) # applied to ADF gas phase" ] }, { "cell_type": "markdown", "id": "09e070fc-be09-4cff-a09a-bd6ff5f4a000", "metadata": {}, "source": [ "## Run COSMO-RS conformers job" ] }, { "cell_type": "markdown", "id": "e3f91ae0-1518-4185-80c4-2779703a2df5", "metadata": {}, "source": [ "Finally, we give this information to the `ADFCOSMORSConfJob` class. We also specify the name of the coskf files as well as the directory in which we'll find them after the calculations complete." ] }, { "cell_type": "code", "execution_count": 7, "id": "a778760d-0d80-44a8-9068-0183c5b6fd51", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[19.03|15:33:37] JOB plamsjob STARTED\n", "[19.03|15:33:37] Waiting for job plamsjob to finish\n", "[19.03|15:33:37] JOB plamsjob/conformers_uff STARTED\n", "[19.03|15:33:37] JOB plamsjob/additional_1 STARTED\n", "[19.03|15:33:37] JOB plamsjob/adf_conformers STARTED\n", "[19.03|15:33:37] JOB plamsjob/adf_filter STARTED\n", "[19.03|15:33:37] Waiting for job conformers_uff to finish\n", "[19.03|15:33:37] Waiting for job adf_filter to finish\n", "[19.03|15:33:37] Waiting for job additional_1 to finish\n", "[19.03|15:33:37] Waiting for job adf_conformers to finish\n", "[19.03|15:33:44] JOB plamsjob/conformers_uff SUCCESSFUL\n", "[19.03|15:33:45] JOB plamsjob/additional_1 SUCCESSFUL\n", "[19.03|15:43:18] JOB plamsjob/adf_conformers SUCCESSFUL\n", "[19.03|15:43:19] JOB plamsjob/adf_filter SUCCESSFUL\n", "[19.03|15:43:19] JOB plamsjob/replay STARTED\n", "[19.03|15:44:08] JOB plamsjob/replay SUCCESSFUL\n", "[19.03|15:44:10] JOB plamsjob SUCCESSFUL\n" ] } ], "source": [ "job = ADFCOSMORSConfJob(\n", " mol,\n", " conf_gen=conf_job,\n", " first_filter=fil1,\n", " additional=[(dftb_sett, fil2)],\n", " final_filter=fil3,\n", " coskf_name=\"acetic_acid\",\n", " coskf_dir=\"test_coskfs\",\n", ")\n", "job.run()\n", "job.results.wait()" ] }, { "cell_type": "code", "execution_count": 12, "id": "fa86e6a5-4098-4d31-96a4-5a338d62ccfc", "metadata": {}, "outputs": [], "source": [ "!amsview test_coskfs/acetic_acid_0.coskf" ] }, { "cell_type": "code", "execution_count": 13, "id": "96fae9f9-5465-494c-accf-23bcb3783843", "metadata": {}, "outputs": [], "source": [ "!amsview test_coskfs/acetic_acid_1.coskf" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.16" } }, "nbformat": 4, "nbformat_minor": 5 }