ID Range

A particle group represents a subset of particles, which is defined by an instance of particle together with a sequence of indices.


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

  • args (table) – keyword arguments
  • args.particle – instance of halmd.mdsim.particle
  • args.range (table) – particle ID range {first, last}
  • args.label (string) – group label
  • (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)


Particle IDs are 1-based, i.e. the first particle has ID 1.

The flags global and fluctuating are used, e.g., for the output of thermodynamic quantities via halmd.observables.thermodynamics.


Particle group label.


Instance of halmd.mdsim.particle.


Number of particles in group.


True if the particle group comprises the whole simulation world. This requires that was set to true upon construction and that size equals the number of particles in particle.


The value of args.fluctuating passed upon construction.

  • args (table) – keyword argruments
  • args.particle – instance of halmd.mdsim.particle (optional)
  • args.label – label of the new particle instance (optional)

instance of halmd.mdsim.particle with data from the particle group

Copy the particle group to a new particle instance. If no parameters given, a suitable particle instance will be constructed.


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. If args.label is not given, it defaults to the group label. species of the new particle instance will be initialized with particle.species.


args.particle must reside in the same memory as the group and the number of particles must be equal to size.