Created
March 8, 2024 19:39
-
-
Save chrisjonesBSU/3d5c251890712df7346a25dd5285dc4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "92a238cd-4b48-49f6-8c6c-4d9167392656", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import warnings\n", | |
"warnings.filterwarnings(\"ignore\")\n", | |
"\n", | |
"import mbuild as mb\n", | |
"import unyt as u\n", | |
"\n", | |
"import gmso\n", | |
"from gmso.external import from_mbuild, to_hoomd_forcefield, to_hoomd_snapshot\n", | |
"from gmso.core.forcefield import ForceField\n", | |
"from gmso.parameterization import apply\n", | |
"from gmso.utils.io import get_fn" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"id": "923b6d94-7f67-4d3b-8a05-4e164c83b9b7", | |
"metadata": {}, | |
"source": [ | |
"## Using GAFF with Periodic Impropers:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "560bd0c0-e894-4cbe-9a3b-12202e0b4cf0", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"No charged group detected, skipping electrostatics.\n" | |
] | |
} | |
], | |
"source": [ | |
"benzene = mb.load(\"c1ccccc1\", smiles=True)\n", | |
"benzene.box = mb.Box([5, 5, 5,])\n", | |
"top = from_mbuild(benzene)\n", | |
"\n", | |
"base_units = dict(mass=u.g/u.mol, length=u.nm, energy=u.kJ/u.mol)\n", | |
"gaff = ForceField(get_fn(\"gmso_xmls/test_ffstyles/gaff.xml\"))\n", | |
"paramaterized_top = apply(top=top, forcefields=gaff, identify_connections=True)\n", | |
"snap, _ = to_hoomd_snapshot(top, base_units=base_units)\n", | |
"forces, _ = to_hoomd_forcefield(top, r_cut=1.4, base_units=base_units)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "7257f456-671a-4813-b2ce-34c6d02de440", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Dihedrals\n", | |
"ca-ca-ca-ha\n", | |
"_HOOMDDict{'k': 15.167, 'd': 1.0, 'n': 2, 'phi0': 3.141592653589793}\n", | |
"ha-ca-ca-ha\n", | |
"_HOOMDDict{'k': 15.167, 'd': 1.0, 'n': 2, 'phi0': 3.141592653589793}\n", | |
"ca-ca-ca-ca\n", | |
"_HOOMDDict{'k': 15.167, 'd': 1.0, 'n': 2, 'phi0': 3.141592653589793}\n", | |
"\n", | |
"Impropers\n", | |
"<hoomd.md.improper.Periodic object at 0x7834ae23be10>\n", | |
"ca-*-*-ha\n", | |
"_HOOMDDict{'k': 4.6024, 'n': 2, 'd': 1, 'chi0': 3.141592653589793}\n" | |
] | |
} | |
], | |
"source": [ | |
"improper_force = forces[\"impropers\"][0]\n", | |
"dihedral_force = forces[\"dihedrals\"][0]\n", | |
"\n", | |
"print(\"Dihedrals\")\n", | |
"for param in dihedral_force.params:\n", | |
" print(param)\n", | |
" print(dihedral_force.params[param])\n", | |
" \n", | |
"print()\n", | |
"\n", | |
"print(\"Impropers\")\n", | |
"print(improper_force)\n", | |
"for param in improper_force.params:\n", | |
" print(param)\n", | |
" print(improper_force.params[param])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "3ae98108-5796-46d1-9c69-00ee07391856", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"['ca-ca-ca-ha']\n" | |
] | |
} | |
], | |
"source": [ | |
"print(snap.impropers.types)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "e9efdf93-c634-4a70-9be4-c1b0b612cf34", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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.11.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment