HOOMD-blue File Writers

Write GSD (General Simulation Data)

Default data file format for HOOMD-blue

GSD format.

https://gsd.readthedocs.io/en/stable/

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:
structureparmed.Structure

ParmEd Structure object

filenamestr

Path of the output file.

ref_distancefloat, optional, default=1.0

Reference distance for conversion to reduced units

ref_massfloat, optional, default=1.0

Reference mass for conversion to reduced units

ref_energyfloat, optional, default=1.0

Reference energy for conversion to reduced units

rigid_bodieslist 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_coordsbool, optional, default=True

Shift coordinates from (0, L) to (-L/2, L/2) if necessary.

write_special_pairsbool, 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.

Create HOOMD-blue force field (>= 3.0)

HOOMD v3 forcefield format.

mbuild.formats.hoomd_forcefield.create_hoomd_forcefield(structure, r_cut, ref_distance=1.0, ref_mass=1.0, ref_energy=1.0, auto_scale=False, nlist_buffer=0.4, snapshot_kwargs={}, pppm_kwargs={'Nx': 8, 'Ny': 8, 'Nz': 8, 'order': 4}, init_snap=None)[source]

Convert a parametrized pmd.Structure to a HOOMD snapshot and forces.

Parameters:
structureparmed.Structure

ParmEd Structure object

r_cutfloat

Cutoff radius in simulation units

ref_distancefloat, optional, default=1.0

Reference distance for unit conversion ((Angstrom) / (desired units))

ref_massfloat, optional, default=1.0

Reference mass for unit conversion ((Dalton) / (desired units))

ref_energyfloat, optional, default=1.0

Reference energy for unit conversion ((kcal/mol) / (desired units))

auto_scalebool, optional, default=False

Scale to reduced units by automatically using the largest sigma value as ref_distance, largest mass value as ref_mass, and largest epsilon value as ref_energy

nlist_bufferfloat, optional, default=True

buffer argument to pass to hoomd.md.nlist.Cell

snapshot_kwargsdict

Keyword arguments to pass to to_hoomdsnapshot

pppm_kwargsdict

Keyword arguments to pass to hoomd.md.long_range.pppm.make_pppm_coulomb_forces

init_snaphoomd.Snapshot, optional, default=None

Initial snapshot to which to add the ParmEd structure object (useful for rigid bodies)

Returns:
hoomd_snapshothoomd.Snapshot

HOOMD snapshot object to initialize the simulation

hoomd_forcefieldlist[hoomd.md.force.Force]

List of hoomd force computes created during conversion

ReferenceValuesnamedtuple

Values used in scaling

Notes

If you pass a non-parametrized pmd.Structure, you will not have angle, dihedral, or force field information. You may be better off creating a hoomd.Snapshot. See mbuild.formats.hoomd_snapshot.to_hoomdsnapshot()

About units: This method operates on a Parmed.Structure object where the units used differ from those used in mBuild and Foyer which may have been used when creating the typed Parmed.Structure.

The default units used when writing out the HOOMD Snapshot are: Distance (Angstrom) Mass (Dalton) Energy (kcal/mol)

If you wish to convert this unit system to another, you can use the reference parameters (ref_distance, ref_mass, ref_energy). The values used here should be expected to convert from the Parmed Structure units (above) to your desired units. The Parmed.Structure values are divided by the reference values.

If you wish to used a reduced unit system, set auto_scale = True. When auto_scale is True, the reference parameters won’t be used.

Examples

To convert the energy units from kcal/mol to kj/mol:

use ref_energy = 0.2390057 (kcal/kj)

To convert the distance units from Angstrom to nm:

use ref_distance = 10 (angstroms/nm)

To use a reduced unit system, where mass, sigma, and epsilon are scaled by the largest value of each:

use auto_scale = True, ref_distance = ref_energy = ref_mass = 1

Create HOOMD-blue Simulation (v2.x)

HOOMD simulation format.

mbuild.formats.hoomd_simulation.create_hoomd_simulation(structure, r_cut, ref_distance=1.0, ref_mass=1.0, ref_energy=1.0, auto_scale=False, snapshot_kwargs={}, pppm_kwargs={'Nx': 8, 'Ny': 8, 'Nz': 8, 'order': 4}, init_snap=None, restart=None, nlist=<Mock name='mock.md.nlist.cell' id='140164864987792'>)[source]

Convert a parametrized pmd.Structure to hoomd.SimulationContext.

Parameters:
structureparmed.Structure

ParmEd Structure object

r_cutfloat

Cutoff radius in simulation units

ref_distancefloat, optional, default=1.0

Reference distance for unit conversion (from Angstrom)

ref_massfloat, optional, default=1.0

Reference mass for unit conversion (from Dalton)

ref_energyfloat, optional, default=1.0

Reference energy for unit conversion (from kcal/mol)

auto_scalebool, optional, default=False

Scale to reduced units by automatically using the largest sigma value as ref_distance, largest mass value as ref_mass, and largest epsilon value as ref_energy

snapshot_kwargsdict

Kwargs to pass to to_hoomdsnapshot

pppm_kwargsdict

Kwargs to pass to hoomd’s pppm function

init_snaphoomd.data.SnapshotParticleData, optional, default=None

Initial snapshot to which to add the ParmEd structure object (useful for rigid bodies)

restartstr, optional, default=None

Path to the gsd file from which to restart the simulation. https://hoomd-blue.readthedocs.io/en/v2.9.4/restartable-jobs.html Note: It is assumed that the ParmEd structure and the system in restart.gsd contain the same types. The ParmEd structure is still used to initialize the forces, but restart.gsd is used to initialize the system state (e.g., particle positions, momenta, etc).

nlisthoomd.md.nlist, default=hoomd.md.nlist.cell

Type of neighborlist to use, see https://hoomd-blue.readthedocs.io/en/stable/module-md-nlist.html for more information.

Returns:
hoomd_objectslist

List of hoomd objects created during conversion

ReferenceValuesnamedtuple

Values used in scaling

HOOMD-blue Snapshot

HOOMD snapshot format.

mbuild.formats.hoomd_snapshot.from_snapshot(snapshot, scale=1.0)[source]

Convert a Snapshot to a Compound.

Snapshot can be a hoomd.Snapshot or a gsd.hoomd.Frame.

Parameters:
snapshothoomd.Snapshot or gsd.hoomd.Frame

Snapshot from which to build the mbuild Compound.

scalefloat, optional, default 1.0

Value by which to scale the length values

Returns:
compCompound
mbuild.formats.hoomd_snapshot.to_hoomdsnapshot(structure, ref_distance=1.0, ref_mass=1.0, ref_energy=1.0, rigid_bodies=None, shift_coords=True, write_special_pairs=True, auto_scale=False, parmed_kwargs={}, hoomd_snapshot=None)[source]

Convert a Compound or parmed.Structure to hoomd.Snapshot.

Parameters:
structureparmed.Structure

ParmEd Structure object Reference distance for unit conversion ((Angstrom) / (desired units))

ref_massfloat, optional, default=1.0

Reference mass for unit conversion ((Dalton) / (desired units))

ref_energyfloat, optional, default=1.0

Reference energy for unit conversion ((kcal/mol) / (desired units))

rigid_bodieslist 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_coordsbool, optional, default=True

Shift coordinates from (0, L) to (-L/2, L/2) if necessary.

auto_scalebool, optional, default=False

Automatically use largest sigma value as ref_distance, largest mass value as ref_mass and largest epsilon value as ref_energy

write_special_pairsbool, optional, default=True

Writes out special pair information necessary to correctly use the OPLS fudged 1,4 interactions in HOOMD.

hoomd_snapshothoomd.Snapshot, optional, default=None

Initial snapshot to which to add the ParmEd structure object. The box information of the initial snapshot will be overwritten. (useful for rigid bodies)

Returns:
hoomd_snapshothoomd.Snapshot
ReferenceValuesnamedtuple

Values used in scaling

Notes

This method does not create hoomd forcefield objects and the snapshot returned does not store the forcefield parameters. See mbuild.formats.hoomd_forcefield.create_hoomd_forcefield()

About units: This method operates on a Parmed.Structure object

where the units used differ from those used in mBuild and Foyer which may have been used when creating the typed Parmed.Structure.

The default units used when writing out the HOOMD Snapshot are: Distance (Angstrom) Mass (Dalton) Energy (kcal/mol)

If you wish to convert this unit system to another, you can use the reference parameters (ref_distance, ref_mass, ref_energy). The values used here should be expected to convert from the Parmed Structure units (above) to your desired units. The Parmed.Structure values are divided by the reference values.

If you wish to used a reduced unit system, set auto_scale = True. When auto_scale is True, the reference parameters won’t be used.

Examples

To convert the energy units from kcal/mol to kj/mol:

use ref_energy = 0.2390057 (kcal/kj)

To convert the distance units from Angstrom to nm:

use ref_distance = 10 (angstroms/nm)

To use a reduced unit system, where mass, sigma, and epsilon are scaled by the largest value of each:

use auto_scale = True, ref_distance = ref_energy = ref_mass = 1