Total Linear Momentum¶
For every velocity frame, PQAnalysis evaluates the total linear momentum of the selected atoms,
and writes its scaled norm
one value per frame. Here \(m_i\) is the atomic mass in amu taken from the
topology, \(\mathbf{v}_i\) is the atomic velocity read from the trajectory,
and \(\sigma\) is the scale factor. This is a diagnostic for
center-of-mass drift and momentum conservation [Allen2017], not a substitute
for inspecting the thermostat, constraints or integration scheme.
Run the diagnostic¶
$ pqanalysis check_momentum examples/water/trajectory.vel \
--selection all \
--output momentum.dat
The output contains a one-based frame index and the scaled momentum norm. Use
--scale when the input convention differs from Å·s⁻¹, and --selection
to restrict the sum to a subset of atoms.
Output and API¶
See Total linear momentum for the output schema. Python workflows
can call PQAnalysis.analysis.momentum.api.check_momentum() or use
PQAnalysis.analysis.momentum.momentum.Momentum directly:
from PQAnalysis.analysis import Momentum
from PQAnalysis.io import TrajectoryReader
norms = Momentum(
TrajectoryReader("examples/water/trajectory.vel"),
selection="all",
).run()
print(norms[:5])
Units¶
PQ velocity trajectories store velocities in Å·s⁻¹, so \(\mathbf{P}\) is in
amu·Å·s⁻¹. The default \(\sigma = 10^{-15}\) converts that to
amu·Å·fs⁻¹, the unit of the second output column. Any other value of
--scale multiplies the norm, and it is then the user’s
responsibility to make \(\sigma\) match the velocity convention of the
input trajectory.
Precision and the noise floor¶
\(\mathbf{P}\) is a heavily cancelling sum. In a well-behaved simulation the individual terms \(m_i\mathbf{v}_i\) are large and nearly cancel, so the surviving norm is smaller than any single term by many orders of magnitude. The smallest norm that still carries information is therefore set by the relative precision \(\varepsilon\) of the velocity values, not by the accumulator, which is always float64:
Three code paths set \(\varepsilon\) differently:
File-backed PQ and QMCFC velocity trajectories (
.velor.velocsfiles read throughcheck_momentum) are parsed directly as float64. Here \(\varepsilon\) is the precision of the text itself, that is, the number of significant digits the MD engine wrote.Other xyz-family trajectory formats read from file keep the single-precision arrays produced by the general frame reader, giving \(\varepsilon\approx 1.2\times10^{-7}\) before the values are widened to float64 for the sum.
Trajectory objects built in memory keep the precision of the velocity arrays they were given, so a float64 array is summed without any loss.
As a rule of thumb, a scaled norm below roughly \(10^{-7}\) of \(\sum_i m_i\lVert\mathbf{v}_i\rVert\) is parsing and round-off noise rather than physical drift. Compare against that scale before reading anything into an absolute value.
The compatibility path multiplies and sums atoms in the same order as the
legacy equipartition.jl calculation [thhTools], so residuals near the
float64 noise floor are reproduced bit for bit. Native output uses 17
significant digits, so reloading it as float64 preserves each calculated value
exactly.
Validity and interpretation¶
A trustworthy result is a flat trace: \(p(t)\) fluctuating around the noise floor with no trend over the whole trajectory. Read the shape of the series rather than any single value.
- Systematic increase
Center-of-mass drift: an integration time step that is too large, accumulated round-off, or a thermostat that adds momentum without removing it.
- Step at one frame
Usually a restart, a velocity reassignment or a change of ensemble.
- Flat trace at a large value
The simulation started with non-zero total momentum. It is conserved, but the center of mass is translating, and MSD or diffusion coefficients from that trajectory are biased unless the drift is removed.
The diagnostic must be read differently in these cases:
- Partial selections
Momentum conservation is a statement about the whole system. A subset of atoms obeys no conservation law, so
--selectionlocates which species carries a drift; it cannot test conservation.- External forces
Walls, position restraints, frozen atoms, external fields and momentum-removing thermostats break translational invariance on purpose. A non-conserved momentum is then the expected result.
- Unknown masses
Every selected atom must have a known mass; the analysis refuses to run otherwise, because a missing mass would silently change the sum.
- Equipartition and temperature
This is a single vector sum over the system. It says nothing about how kinetic energy is distributed over degrees of freedom, and a conserved total momentum is no evidence of a correct temperature or of proper thermostatting.
References¶
[Allen2017] describes conserved quantities in a molecular-dynamics run and the removal of center-of-mass motion.