Particle groups
A Group selects particles for a dynamical method, a restraint, a measurement, or trajectory output. Name each group once in Groups and reuse it throughout the simulation.
Select all particles or a subset
all = Group(:all, AllSelection())
cold = Group(:cold, TypeSelection(:C))
hot = Group(:hot, TypeSelection(:H))
tracers = Group(:tracers, IndexSelection([1, 5, 9]))
groups = Groups(all, cold, hot, tracers)Type names refer to the types supplied to ParticleSystem. Indices in IndexSelection identify particles in the input ordering (preserved even when spatial reordering is active). Pass groups=groups to Simulation.
Give each type its own bath or restraint
integrator = Integrator(
dt=0.0002,
scheme=VelocityVerlet(),
forces=[WCA(epsilon=10.0, sigma=1.0)],
methods=[
Langevin(cold; gamma=50.0, kT=5.0),
Langevin(hot; gamma=50.0, kT=100.0),
],
constraints=[FreezeGroup(tracers; mode=:spring, k=100.0)],
)The two-temperature example contains a complete configuration with separate baths and per-group diagnostics.
Measure a subset
cold_thermo = ThermodynamicObservable(cold; name=:cold)
hot_thermo = ThermodynamicObservable(hot; name=:hot)Pass these observables to a TableWriter or InMemoryWriter to compare groups. For charged systems, virial and pressure measurements require the whole system because the reciprocal-space virial has no per-particle decomposition; see Electrostatics.
Low-level ParticleGroups and Filters
On a low-level SimulationState, ParticleGroups provides reusable GPU-materialized selections (All, TypeIDs, Indices, materialize, apply_scalar!, apply_values!, gather, sum_values), while Filters layers selector-based helpers for freezing/tethering (Filters.freeze_particles!, Filters.unfreeze_particles!), bath assignment (Filters.assign_csvr_baths!, Filters.assign_nhc_baths!), and per-subset stochastic parameter updates (Filters.set_temperature!, Filters.set_friction!, Filters.set_friction_rate!, Filters.set_corr_time!, Filters.set_noise_scale!).
See the Workflow API reference and SimulationCore & Low-Level API for complete signatures.