From 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 tags
local group_A = halmd.mdsim.particle_groups.from_range({particle = system, range = {1, 5000}, label = "A"})
local group_B = halmd.mdsim.particle_groups.from_range({particle = system, range = {5001, 10000}, label = "B"})
class halmd.mdsim.particle_groups.from_range(args)

Construct particle group from tag range.

  • args (table) – keyword arguments
  • args.particle – instance of halmd.mdsim.particle
  • args.range (table) – particle tag range {first, last}
  • args.label (string) – group label
  • (boolean) – particle group can comprise the whole simulation world (default: false)


Particle tags are 1-based, i.e. the first particle has tag 1.


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.

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