Observables
Choose the physical quantities you want to measure with Observable descriptors, then attach them to a TableWriter, GSDWriter, or InMemoryWriter on any sampling schedule.
Temperature, energy, pressure and box geometry
all = Group(:all, AllSelection())
thermo = ThermodynamicObservable(all; name=:thermo)
press = PressureObservable(name=:press)
boxobs = BoxObservable(name=:box)
writer = TableWriter("npt_obs.csv";
every=100,
observables=[
thermo => [:temperature, :kinetic_energy, :potential_energy, :total_energy],
press => [:pressure, :surface_tension],
boxobs => [:volume, :density, :Lx, :Ly, :Lz],
],
mode=:replace,
)Pass observables=[thermo, press, boxobs] and writers=[writer] to Simulation. Because BoxObservable reads only the periodic cell geometry, sampling it alone incurs zero energy or virial evaluation overhead.
Available observables
| Observable | Supported fields | Use it for |
|---|---|---|
ThermodynamicObservable(group) | :temperature, :kinetic_energy, :potential_energy, :total_energy, :virial, *_accumulated | Equilibration, group temperatures, and energy conservation |
PressureObservable() | :pressure, :volume, :density, :box, :Lx, :Ly, :Lz, :pressure_tensor, :virial_tensor, :surface_tension | NPT mechanical pressure, full symmetric P_{αβ}/W_{αβ} tensors, and 3D slab surface tension γ = ½ Lz (Pzz − ½(Pxx + Pyy)) |
BoxObservable() | :volume, :density, :box, :Lx, :Ly, :Lz | Lightweight cell-geometry tracking without energy/virial evaluation |
VirialObservable(group) | :virial, :virial_accumulated | Scalar virial diagnostics |
MSDObservable(group) | :msd, :elapsed_time | Mean-squared displacement and diffusion |
VACFObservable(group) | :vacf, :elapsed_time | Velocity autocorrelation function |
CollisionObservable() | :counts, :rate, :pair_counts, :pair_rates | Encounters between particle types |
BathExchangeObservable() | :heat, :entropy, :entropy_production_rate, :temperature_error, :extended_hamiltonian | Heat/entropy exchange with stochastic baths and conserved NHC/CSVR extended Hamiltonian |
Notes on specific measurements:
Pressure and tensor fields:
:pressure_tensorreturns(Pxx, Pyy, Pxy)in 2D or(Pxx, Pyy, Pzz, Pxy, Pxz, Pyz)in 3D withP_{αβ} = (K_{αβ} + W_{αβ}) / V;:virial_tensorreturns the corresponding configurational virial componentsW_{αβ}. When capturing tensor or:boxNamedTuplefields in memory for direct Julia analysis, attach them to anInMemoryWriter(; observables=[press => [:pressure, :pressure_tensor, :virial_tensor, :surface_tension]]).Constrained & charged systems: when electrostatics, lattice dispersion, or holonomic constraints are active, request virial and pressure observables on the full system (reciprocal-space and constraint virials are global quantities).
Collisions: follow the cutoff setup in the two-temperature example or configure pair cutoffs via
set_collision_pair_cutoffs!.
Start a production interval
run!(sim, Stage(:equilibrate, steps=1_000))
reset_observables!(sim)
run!(sim, Stage(:production, steps=10_000))reset_observables! clears accumulated measurements and sets a fresh reference configuration for MSD and VACF without erasing output already written to disk. Use writers to control how and when data is saved.
For low-level step diagnostics on a SimulationState, see collect_step_observables, virial_tensor, virial_components, mechanical_pressure, and the Workflow API and SimulationCore references.