ID Range¶
A particle group represents a subset of particles, which is defined by an instance of particle together with a sequence of indices.
Example:
-- construct particle instance for given simulation domain
local system = halmd.mdsim.particle({particles = 10000, species = 2})
-- select each species, assuming particles of a species have contiguous IDs
local group_A = halmd.mdsim.particle_groups.id_range({particle = system, range = {1, 5000}, label = "A"})
local group_B = halmd.mdsim.particle_groups.id_range({particle = system, range = {5001, 10000}, label = "B"})
-
class
halmd.mdsim.particle_groups.
id_range
(args)¶ Construct particle group from ID range.
Parameters: - args (table) – keyword arguments
- args.particle – instance of
halmd.mdsim.particle
- args.range (table) – particle ID range
{first, last}
- args.label (string) – group label
- args.global (boolean) – particle group can comprise the whole simulation
world (default:
false
) - args.fluctuating (boolean) – the number or identity of selected particles
can vary as the simulation progresses (default:
false
)
Note
Particle IDs are 1-based, i.e. the first particle has ID 1.
The flags
global
andfluctuating
are used, e.g., for the output of thermodynamic quantities viahalmd.observables.thermodynamics
.-
label
¶ Particle group label.
-
particle
¶ Instance of
halmd.mdsim.particle
.
-
size
¶ Number of particles in group.
-
global
¶ True if the particle group comprises the whole simulation world. This requires that
args.global
was set to true upon construction and thatsize
equals the number of particles inparticle
.
-
fluctuating
¶ The value of
args.fluctuating
passed upon construction.
-
to_particle
(args)¶ Parameters: - args (table) – keyword argruments
- args.particle – instance of
halmd.mdsim.particle
(optional) - args.label – label of the new particle instance (optional)
Returns: instance of
halmd.mdsim.particle
with data from the particle groupCopy the particle group to a new particle instance. If no parameters given, a suitable particle instance will be constructed.
Note
Only positions, mass, species and velocity are copied to the particle instance. Other data (e.g. ID, force) will not be copied.
If
args.particle
is present, the particle group will be copied into the given particle instance. Otherwise a new suitable particle instance with the label args.label will be created. Ifargs.label
is not given, it defaults to the group label.species
of the new particle instance will be initialized withparticle.species
.Note
args.particle
must reside in the same memory as the group and the number of particles must be equal tosize
.