kups.md.observables
¶
Molecular dynamics observable utilities.
Pure utility functions for computing MD-specific observables from momenta, forces, and other MD quantities. These are used internally by integrators and are distinct from the StateProperty-based observables in kups.observables.
instantaneous_pressure(kinetic_energy, cauchy_stress, volume)
¶
Compute instantaneous pressure from kinetic energy and Cauchy stress.
where \(K\) is the total kinetic energy, \(d\) is the spatial dimensionality, \(V\) is the volume, and \(\boldsymbol{\sigma}\) is the Cauchy stress tensor (units: energy/length³).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kinetic_energy
|
Array
|
Total kinetic energy \(K\) (units: energy), scalar or array. |
required |
cauchy_stress
|
Array
|
Cauchy stress tensor \(\boldsymbol{\sigma}\)
(units: energy/length³), shape |
required |
volume
|
Array
|
System volume \(V\) (units: length³), scalar or array. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Instantaneous pressure \(P\) (units: energy/length³), scalar or array. |
Source code in src/kups/md/observables.py
instantaneous_pressure_tensor(particles, systems)
¶
Compute the symmetric instantaneous pressure tensor.
where the second term is the symmetric Cauchy stress from the virial
theorem (stress_via_virial_theorem), which includes both the
pair-force contribution sym(Σ Fᵢ ⊗ rᵢ)/V and the lattice-gradient
contribution h^T·∂U/∂h / V needed for periodic potentials such as
Ewald and PME. This is the tensorial generalisation of
instantaneous_pressure used
by extended-variable NPT integrators (e.g. Gao–Fang–Wang BAOAB NPT
Langevin, Eq. 9).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, _PressureTensorParticles]
|
Per-particle table providing |
required |
systems
|
Table[SystemId, IsVirialSystems]
|
Per-system table providing |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Symmetric pressure tensor per system, shape |
Array
|
units of energy/length³. |
Source code in src/kups/md/observables.py
particle_kinetic_energy(momentum, mass)
¶
Compute the per-particle kinetic energy from momentum and mass.
Calculates the kinetic energy for each particle using:
where \(\mathbf{p}_i\) is the momentum vector and \(m_i\) is the particle mass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
momentum
|
Array
|
Momentum vector \(\mathbf{p}\) (units: mass·length/time), shape |
required |
mass
|
Array
|
Particle mass \(m\) (units: mass), shape |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Per-particle kinetic energy \(K\) (units: energy), shape |
Source code in src/kups/md/observables.py
remove_center_of_mass_momentum(momenta, masses, system)
¶
Project momenta onto the zero-total-momentum subspace per system.
The projection subtracts the center-of-mass velocity from each particle,
p_i <- p_i - m_i * sum_j(p_j) / sum_j(m_j), independently for each
system index. This is the mass-metric projection for the canonical ensemble
conditioned on zero total momentum.
Source code in src/kups/md/observables.py
system_kinetic_energy(momenta, masses, system, *, remove_com=False)
¶
Total kinetic energy per system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
momenta
|
Array
|
Particle momenta, shape |
required |
masses
|
Array
|
Particle masses, shape |
required |
system
|
Index[SystemId]
|
Per-atom system index. |
required |
remove_com
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
Kinetic energy per system, shape |