Snapshot¶
- class hoomd.Snapshot(communicator=None)¶
Self-contained copy of the simulation
State
.- Parameters:
communicator (Communicator) – MPI communicator to be used when accessing the snapshot.
See
State
andgsd.hoomd.Frame
for detailed documentation on the components ofSnapshot
.Note
Snapshot
is duck-type compatible withgsd.hoomd.Frame
except that arrays inSnapshot
are not assignable. You can edit their contents: e.g.snapshot.particles.typeid[:] == 0
.Warning
Data is only present on the root rank:
if snapshot.communicator.rank == 0: pos = snapshot.particles.position[0]
Example:
snapshot = hoomd.Snapshot()
- communicator¶
MPI communicator.
- Type:
- property angles¶
Angles.
- angles.typeid¶
Angle type id.
- Type:
(N,)
numpy.ndarray
ofuint32
- angles.group¶
Tags of the particles in the angle.
- Type:
(N, 3)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.angles.N = 1 snapshot.angles.group[:] = [[0, 1, 2]] snapshot.angles.types = ["A-B-B"] snapshot.angles.typeid[:] = [0]
- property bonds¶
Bonds.
- bonds.typeid¶
Bond type id.
- Type:
(N,)
numpy.ndarray
ofuint32
- bonds.group¶
Tags of the particles in the bond.
- Type:
(N, 2)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.bonds.N = 2 snapshot.bonds.group[:] = [[0, 1], [2, 3]] snapshot.bonds.types = ["A-B"] snapshot.bonds.typeid[:] = [0, 0]
- property configuration¶
Snapshot box configuration.
- box¶
Simulation box parameters
[Lx, Ly, Lz, xy, xz, yz]
.
Note
box
accepts any values thatBox.from_box
allows when setting.See also
Example:
snapshot.configuration.box = [10, 20, 30, 0.1, 0.2, 0.3]
- property constraints¶
Constraints.
- constraints.value¶
Constraint length.
- Type:
(N, )
numpy.ndarray
offloat
- constraints.group¶
Tags of the particles in the constraint.
- Type:
(N, 2)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.constraints.N = 2 snapshot.constraints.group[:] = [[0, 1], [2, 3]] snapshot.constraints.value[:] = [1, 1]
- property dihedrals¶
Dihedrals.
- dihedrals.typeid¶
Dihedral type id.
- Type:
(N,)
numpy.ndarray
ofuint32
- dihedrals.group¶
Tags of the particles in the dihedral.
- Type:
(N, 4)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.dihedrals.N = 1 snapshot.dihedrals.group[:] = [[0, 1, 2, 3]] snapshot.dihedrals.types = ["A-B-B-A"] snapshot.dihedrals.typeid[:] = [0]
- classmethod from_gsd_frame(gsd_snap, communicator)¶
Constructs a
hoomd.Snapshot
from agsd.hoomd.Frame
object.- Parameters:
gsd_snap (gsd.hoomd.Frame) – The gsd frame to convert to a
hoomd.Snapshot
.communicator (hoomd.communicator.Communicator) – The MPI communicator to use for the snapshot. This prevents the snapshot from being stored on every rank.
Tip
Use
Simulation.create_state_from_gsd
to efficiently initialize the system state from a GSD file.Note
from_gsd_frame
only accesses thegsd_snap
argument on rank 0. In MPI simulations, avoid duplicating memory and file reads by reading GSD files only on rank 0 and passinggsd_snap=None
on other ranks.
- property impropers¶
Impropers.
- impropers.typeid¶
Improper type id.
- Type:
(N,)
numpy.ndarray
ofuint32
- impropers.group¶
Tags of the particles in the improper.
- Type:
(N, 4)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.if snapshot.communicator.rank == 0: snapshot.impropers.N = 1 snapshot.impropers.group[:] = [[0, 1, 2, 3]] snapshot.impropers.types = ["A-B-B-A"] snapshot.impropers.typeid[:] = [0]
- property mpcd¶
MPCD data.
- mpcd.position¶
Particle position \([\mathrm{length}]\).
- Type:
(N, 3)
numpy.ndarray
offloat
- mpcd.velocity¶
Particle velocity \([\mathrm{velocity}]\).
- Type:
(N, 3)
numpy.ndarray
offloat
- mpcd.typeid¶
Particle type id.
- Type:
(N, )
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Note
This attribute is only available when HOOMD-blue is built with the MPCD component.
- property pairs¶
Special pairs.
- pairs.typeid¶
Special pair type id.
- Type:
(N,)
numpy.ndarray
ofuint32
- pairs.group¶
Tags of the particles in the special pair.
- Type:
(N, 2)
numpy.ndarray
ofuint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.pairs.N = 2 snapshot.pairs.group[:] = [[0, 1], [2, 3]] snapshot.pairs.types = ["A-B"] snapshot.pairs.typeid[:] = [0, 0]
- property particles¶
Particles.
- particles.position¶
Particle position \([\mathrm{length}]\).
- Type:
(N, 3)
numpy.ndarray
offloat
- particles.orientation¶
Particle orientation.
- Type:
(N, 4)
numpy.ndarray
offloat
- particles.typeid¶
Particle type id.
- Type:
(N, )
numpy.ndarray
ofuint32
- particles.mass¶
Particle mass \([\mathrm{mass}]\).
- Type:
(N, )
numpy.ndarray
offloat
- particles.charge¶
Particle charge \([\mathrm{charge}]\).
- Type:
(N, )
numpy.ndarray
offloat
- particles.diameter¶
Particle diameter \([\mathrm{length}]\).
- Type:
(N, )
numpy.ndarray
offloat
- particles.body¶
Particle body.
- Type:
(N, )
numpy.ndarray
ofint32
- particles.moment_inertia¶
Particle moment of inertia \([\mathrm{mass} \cdot \mathrm{length}^2]\).
- Type:
(N, 3)
numpy.ndarray
offloat
- particles.velocity¶
Particle velocity \([\mathrm{velocity}]\).
- Type:
(N, 3)
numpy.ndarray
offloat
- particles.angmom¶
Particle angular momentum \([\mathrm{mass} \cdot \mathrm{velocity} \cdot \mathrm{length}]\).
- Type:
(N, 4)
numpy.ndarray
offloat
- particles.image¶
Particle image.
- Type:
(N, 3)
numpy.ndarray
ofint32
Note
Set
N
to change the size of the arrays.Example:
if snapshot.communicator.rank == 0: snapshot.particles.N = 4 snapshot.particles.position[:] = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]] snapshot.particles.types = ['A', 'B'] snapshot.particles.typeid[:] = [0, 1, 1, 0]
- replicate(nx, ny, nz=1)¶
Replicate the snapshot along the periodic box directions.
- Parameters:
Performs the same operation as
State.replicate
on aSnapshot
.- Returns:
self
Example:
snapshot.replicate(nx=2, ny=2, nz=2)
- wrap()¶
Wrap particles into the snapshot box.
- Returns:
self
Example:
snapshot.wrap()