{ "cells": [ { "cell_type": "markdown", "id": "1fb5ff37", "metadata": {}, "source": [ "### Simulation with a C-alpha Structure-Based Model using OpenSMOG\n", "\n", "This tutorial should take between 5 to 15 minutes to complete.\n", "\n", "Input files for this tutorial can be found [here](https://github.com/junioreif/OpenSMOG/tree/main/Tutorials/SMOG2_CA_CI2)" ] }, { "cell_type": "markdown", "id": "5c2a85be", "metadata": {}, "source": [ "The first step is to import the **OpenSMOG** module" ] }, { "cell_type": "code", "execution_count": null, "id": "d1f2a709", "metadata": {}, "outputs": [], "source": [ "from OpenSMOG import SBM" ] }, { "cell_type": "markdown", "id": "1c54846b", "metadata": {}, "source": [ "SBM class sets the parameters for the simulation:\n", "\n", "`name=\"2ci2\"` Sets the name of each simulation *(this name is used as prefix for the outputs)*.
\n", "`time_step=0.0005 ` (**reduced time unit**) Sets the time step used in integration.
\n", "`collision_rate=1.0` (**reduced inverse-time unit**) Sets the collision rate for the Langevin integrator.
\n", "`r_cutoff=1.1` (**nanometers**) Sets the non-bonded cutoff.
\n", "`temperature=0.5` (**reduced temperature unit**) Sets the temperature in the simulation.
\n", "\n", "sbm_CA is an arbitrarily chosen variable name for the SBM object" ] }, { "cell_type": "code", "execution_count": null, "id": "abc57547", "metadata": {}, "outputs": [], "source": [ "sbm_CA = SBM(name='2ci2', time_step=0.0005, collision_rate=1.0, r_cutoff=1.1, temperature=0.5)" ] }, { "cell_type": "markdown", "id": "b350d122", "metadata": {}, "source": [ "There are three hardware platform options to run the simulations: \n", "\n", "`platform=\"cuda\"`
\n", "`platform=\"HIP\"`
\n", "`platform=\"opencl\"`
\n", "`platform=\"cpu\"`
\n", "\n", "if **cuda**, **opencl** or **HIP** is choosen the GPUindex can be define as \"0\". If two GPUs are used, one may give \"0,1\" \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "sbm_CA.setup_openmm(platform='cuda',GPUindex='default')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sets the directory name where to save the simulation outputs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sbm_CA.saveFolder('output_2ci2_CA')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the **gro**, **top** and **xml** files into the sbm_CA object" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sbm_CA_grofile = 'SMOG2_CA_CI2/2ci2.CA.gro'\n", "sbm_CA_topfile = 'SMOG2_CA_CI2/2ci2.CA.top'\n", "sbm_CA_xmlfile = 'SMOG2_CA_CI2/2ci2.CA.xml'\n", "\n", "sbm_CA.loadSystem(Grofile=sbm_CA_grofile, Topfile=sbm_CA_topfile, Xmlfile=sbm_CA_xmlfile)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This function returns the name of each contact potential that is being used in the current model.\n", "In this example, only a Lennard-Jones-style 10-12 potential is being applied." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The simulation **context** is created with all information given in the previous steps." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "sbm_CA.createSimulation()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create the **reporters** that will save the simulation data in an output folder.\n", "\n", "`trajectory=True` Save the trajectory in .dcd format.
\n", "`energies=True` Save the energy in text format separated by a comma.
\n", "`interval=10**3` The interval (in steps) at which the trajectory and energies are saved." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "sbm_CA.createReporters(trajectory=True, energies=True, energy_components=True, interval=10**3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `run` function receives the following parameters:\n", "\n", "`nsteps=10**6` Number of steps to be performed in the simulation.
\n", "`report=True` Show the simulation details (Progress (%), Step and Time Remaining)
\n", "`interval=10**3` The step interval to show the details" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true, "tags": [] }, "outputs": [], "source": [ "sbm_CA.run(nsteps=10**6, report=True, interval=10**3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The output files are located in the output folder" ] } ], "metadata": { "interpreter": { "hash": "6c1e1dc993528b01ea0560a49e19c0e55ea625de972d398fe3046f8c57ef6008" }, "kernelspec": { "display_name": "Python 3.8.8 64-bit ('base': conda)", "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.8" } }, "nbformat": 4, "nbformat_minor": 5 }