Fill Box
All-Atom (AA) Hexane and Ethanol System
Note
foyer is used in conjunction with mBuild
in
the following example to demonstrate how the MoSDeF
libraries can be used together to generate a simulation box.
Import the required mbuild package.
import mbuild as mb
Construct an all-atom (AA) hexane and ethanol using the OPLS-AA force field (FF), which is shipped as a standard foyer FF. The hexane and ethanol molecules will be created using smiles strings. The hexane and ethanol residues will be named “HEX” and “ETO”, respectively. Lastly, the hexane and ethanol molecule’s configuration will be energy minimized, properly reorienting the molecule to the specified FF, which is sometimes needed for some simulation engines to ensure the initial configuration energy is not too high.
Note
The energy minimize step requires the foyer package.
hexane = mb.load('CCCCCC', smiles=True)
hexane.name = 'HEX'
hexane.energy_minimize(forcefield='oplsaa', steps=10**4)
ethanol = mb.load('CCO', smiles=True)
ethanol.name = 'ETO'
ethanol.energy_minimize(forcefield='oplsaa', steps=10**4)
The liquid box is built to a density of 680 kg/m3, with a 50/50 mol ratio of hexane and ethanol, and will be in an orthogonal box measuring 5.0 nm in the x, y, and z-dimensions.
box_liq = mb.fill_box(compound= [hexane, ethanol],
density=680,
compound_ratio=[0.5, 0.5],
box=[5.0, 5.0, 5.0])
United Atom (UA) Methane System
Note
foyer is used in conjunction with mBuild
in
the following example to demonstrate how the MoSDeF libraries
integrate to generate a simulation box. A subset of the TraPPE-United Atom
force field (FF) comes standard with the foyer software package.
Import the required mbuild package.
import mbuild as mb
Construct a pseudo-monatomic molecule (united atom (UA) methane), for use with the
TraPPE FF. The UA methane, bead type “_CH4”, will be built as a child (mbuild.Compound.children
), so the parent (mbuild.Compound
) will
allow a user-selected residue name (mbuild.Compound.name
). If the methane is built using methane = mb.Compound(name="_CH4")
, then the user must keep the residue name “_CH4” or foyer will not recognize the bead type when using the standard TraPPE force field XML file.
methane = mb.Compound(name="MET")
methane_child_bead = mb.Compound(name="_CH4")
methane.add(methane_child_bead, inherit_periodicity=False)
Note
The inherit_periodicity
flag is an optional boolean (default=True), which replaces
the periodicity of self with the periodicity of the Compound being added.
The orthogonal liquid box contains 1230 methane molecules and measures 4.5 nm in all the x, y, and z-dimensions.
box_liq = mb.fill_box(compound=methane,
n_compounds=1230,
box=[4.5, 4.5, 4.5]
)