Skip to content

Instantly share code, notes, and snippets.

@rmatsum836
Created November 17, 2020 01:04
Show Gist options
  • Save rmatsum836/7c85abdad5f44bc0a26ffa7ee7e9b9d9 to your computer and use it in GitHub Desktop.
Save rmatsum836/7c85abdad5f44bc0a26ffa7ee7e9b9d9 to your computer and use it in GitHub Desktop.
import mbuild
import foyer
import mosdef_cassandra as mc
import unyt as u
from mosdef_cassandra.utils.get_files import (
get_example_ff_path,
get_example_mol2_path,
)
def run_nvt_spce(**custom_args):
# Load water with SPC/E geometry from mol2 file
molecule = mbuild.load("O", smiles=True)
# Create an empty mbuild.Box
box = mbuild.Box(lengths=[3.0, 3.0, 3.0])
# fill box
water_box = mbuild.fill_box(molecule, n_compounds=1, box=box)
# Load forcefields
spce = foyer.Forcefield(get_example_ff_path("spce"))
# Use foyer to apply forcefields
molecule_ff = spce.apply(water_box)
# Create box and species list
box_list = [water_box]
species_list = [molecule_ff]
# Use Cassandra to insert some initial number of species
mols_in_boxes = [[1]]
# Define the system object
system = mc.System(box_list, species_list, mols_in_boxes=mols_in_boxes,
fix_bonds=True)
# Get the move probabilities
moveset = mc.MoveSet("nvt", species_list)
default_args = {
"angle_style": ["fixed"],
}
# Combine default/custom args and override default
custom_args = {**default_args, **custom_args}
# Run a simulation with at 300 K with 10000 MC moveset
mc.run(
system=system,
moveset=moveset,
run_type="equilibration",
run_length=10000,
temperature=300.0 * u.K,
**custom_args,
)
if __name__ == "__main__":
run_nvt_spce()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment