Writers¶
mBuild utilizes ParmEd to write Compound
information to a variety of file
formats (e.g. PDB, MOL2, GRO. The full list of formats supported by ParmEd
can be found at http://parmed.github.io/ParmEd/html/readwrite.html).
Additionally, mBuild features several internal writers for file formats not yet
supported by ParmEd. Information on these internal writers can be found below.
By default, mBuild will only write coordinate and bond information to these files,
i.e. no angles or dihedrals, and no atom typing is performed (atom names are used
as atom types). However, force fields can be applied to Compounds by passing force
field XML files (used by the Foyer package - https://github.com/mosdef-hub/foyer)
to the save
function if Foyer is installed. If a force field is applied to a
Compound, the mBuild internal writers will also write angle and dihedral information
to the file in addition to labelling atoms by the atom types specified by the force
field.
GSD (General Simulation Data)¶
Default data file format for HOOMD v2¶
-
mbuild.formats.gsdwriter.
write_gsd
(structure, filename, ref_distance=1.0, ref_mass=1.0, ref_energy=1.0, rigid_bodies=None, shift_coords=True, write_special_pairs=True, **kwargs)[source]¶ Output a GSD file (HOOMD v2 default data format).
Parameters: - structure : parmed.Structure
ParmEd Structure object
- filename : str
Path of the output file.
- ref_distance : float, optional, default=1.0
Reference distance for conversion to reduced units
- ref_mass : float, optional, default=1.0
Reference mass for conversion to reduced units
- ref_energy : float, optional, default=1.0
Reference energy for conversion to reduced units
- rigid_bodies : list of int, optional, default=None
List of rigid body information. An integer value is required for each atom corresponding to the index of the rigid body the particle is to be associated with. A value of None indicates the atom is not part of a rigid body.
- shift_coords : bool, optional, default=True
Shift coordinates from (0, L) to (-L/2, L/2) if necessary.
- write_special_pairs : bool, optional, default=True
Writes out special pair information necessary to correctly use the OPLS fudged 1,4 interactions in HOOMD.
Notes
Force field parameters are not written to the GSD file and must be included manually into a HOOMD input script.
LAMMPS data¶
Default data file format for LAMMPS¶
-
mbuild.formats.lammpsdata.
write_lammpsdata
(structure, filename, atom_style='full', unit_style='real', detect_forcefield_style=True, nbfix_in_data_file=True, use_urey_bradleys=False, use_rb_torsions=True, use_dihedrals=False)[source]¶ Output a LAMMPS data file.
Outputs a LAMMPS data file in the ‘full’ atom style format. Default units are ‘real’ units. See http://lammps.sandia.gov/doc/atom_style.html for more information on atom styles.
Parameters: - structure : parmed.Structure
ParmEd structure object
- filename : str
Path of the output file
- atom_style: str
Defines the style of atoms to be saved in a LAMMPS data file. The following atom styles are currently supported: ‘full’, ‘atomic’, ‘charge’, ‘molecular’ see http://lammps.sandia.gov/doc/atom_style.html for more information on atom styles.
- unit_style: str
Defines to unit style to be save in a LAMMPS data file. Defaults to ‘real’ units. Current styles are supported: ‘real’, ‘lj’ see https://lammps.sandia.gov/doc/99/units.html for more information on unit styles
- detect_forcefield_style: boolean
If True, format lammpsdata parameters based on the contents of the parmed Structure
- use_urey_bradleys: boolean
If True, will treat angles as CHARMM-style angles with urey bradley terms while looking for structure.urey_bradleys
- use_rb_torsions:
If True, will treat dihedrals OPLS-style torsions while looking for structure.rb_torsions
- use_dihedrals:
If True, will treat dihedrals as CHARMM-style dihedrals while looking for structure.dihedrals
Notes
See http://lammps.sandia.gov/doc/2001/data_format.html for a full description of the LAMMPS data format. Currently the following sections are supported (in addition to the header): Masses, Nonbond Coeffs, Bond Coeffs, Angle Coeffs, Dihedral Coeffs, Atoms, Bonds, Angles, Dihedrals, Impropers OPLS and CHARMM forcefield styles are supported, AMBER forcefield styles are NOT
Some of this function has beed adopted from mdtraj’s support of the LAMMPSTRJ trajectory format. See https://github.com/mdtraj/mdtraj/blob/master/mdtraj/formats/lammpstrj.py for details.