{
"cells": [
{
"cell_type": "markdown",
"source": [
"### Simulation with an All-Atom Structure-Based Model using OpenSMOG\n",
"\n",
"This tutorial should take between 5 to 15 minutes of reading and performing simulations.\n",
"\n",
"Input files for this tutorial can be found [here](https://github.com/junioreif/OpenSMOG/tree/main/Tutorials/SMOG2_AA_CI2)"
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"The first step is to import the **OpenSMOG** module"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"from OpenSMOG import SBM"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"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.002 ` (**reduced time unit**) Sets the time step used in integration.
\n",
"`collision_rate=1.0` (**reduced inverse-time unit**) Sets the collision rate in the Langevin integrator.
\n",
"`r_cutoff=0.65` (**nanometers**) Sets the non-bonded cutoff.
\n",
"`temperature=0.5` (**reduced temperature unit**) Sets the temperature for the simulation.
\n",
"\n",
"sbm_AA is an arbitrarily chosen variable name for the SBM object"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA = SBM(name='2ci2', time_step=0.002, collision_rate=1.0, r_cutoff=0.65, temperature=0.5)"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"There are three hardware platform options to run the simulations: \r\n",
"\r\n",
"`platform=\"cuda\"`
\r\n",
"`platform=\"HIP\"`
\r\n",
"`platform=\"opencl\"`
\r\n",
"`platform=\"cpu\"`
\r\n",
"\r\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\" \r\n"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA.setup_openmm(platform='cuda',GPUindex='default')"
],
"outputs": [],
"metadata": {
"tags": []
}
},
{
"cell_type": "markdown",
"source": [
"Sets the directory name where the output files are saved"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA.saveFolder('output_2ci2_AA')"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"Load the **gro**, **top** and **xml** files into the sbm_AA object"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA_grofile = 'SMOG2_AA_CI2/2ci2.AA.gro'\r\n",
"sbm_AA_topfile = 'SMOG2_AA_CI2/2ci2.AA.top'\r\n",
"sbm_AA_xmlfile = 'SMOG2_AA_CI2/2ci2.AA.xml'\r\n",
"\r\n",
"sbm_AA.loadSystem(Grofile=sbm_AA_grofile, Topfile=sbm_AA_topfile, Xmlfile=sbm_AA_xmlfile)"
],
"outputs": [],
"metadata": {}
},
{
"cell_type": "markdown",
"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 6-12 potential is being applied."
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"The simulation **context** is created with all information given in the previous steps."
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA.createSimulation()"
],
"outputs": [],
"metadata": {
"tags": []
}
},
{
"cell_type": "markdown",
"source": [
"Create the **reporters** that will save the simulation data in an output folder.\r\n",
"\r\n",
"`trajectory=True` Save the trajectory in .dcd format.
\r\n",
"`energies=True` Save the energy in text format separated by a comma.
\r\n",
"`interval=10**3` The interval (in steps) at which the trajectory and energies are saved."
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA.createReporters(trajectory=True, energies=True, energy_components=True, interval=10**3)"
],
"outputs": [],
"metadata": {
"tags": []
}
},
{
"cell_type": "markdown",
"source": [
"The `run` function receives the following parameters:\n",
"\n",
"`nsteps=10**6` Number of steps to perform in the simulation.
\n",
"`report=True` Shows the simulation details (Progress (%), Step and Time Remaining)
\n",
"`interval=10**3` The step interval to show the details"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"source": [
"sbm_AA.run(nsteps=10**6, report=True, interval=10**3)"
],
"outputs": [],
"metadata": {
"scrolled": true,
"tags": []
}
},
{
"cell_type": "markdown",
"source": [
"The output files are located in the output folder"
],
"metadata": {}
}
],
"metadata": {
"interpreter": {
"hash": "6c1e1dc993528b01ea0560a49e19c0e55ea625de972d398fe3046f8c57ef6008"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3.8.8 64-bit ('base': conda)"
},
"language_info": {
"name": "python",
"version": "3.8.8",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
}
},
"nbformat": 4,
"nbformat_minor": 5
}