kups.observables.stress
¶
Stress tensor calculations via the virial theorem.
Stress is the symmetric (3, 3) tensor
σ = -1/V sym[Σ_i r_i ⊗ ∂U/∂r_i + h^T · ∂U/∂h]
Only the lower-triangular entries of ∂U/∂h are stored -- the parameter
degrees of freedom of a lower-triangular cell h -- so the full 3×3 cell
virial is never materialized; the upper triangle of σ is filled by symmetry.
Per-axis periodicity is honoured: components touching a non-periodic
(vacuum/bounding-box) axis are zeroed, so an isolated cluster has zero stress
and a slab keeps only its in-plane block. The volume divisor is the full cell
volume |det h| (LAMMPS convention: a slab's stress is diluted by its vacuum
extent).
IsMolecularVirialParticles
¶
Bases: HasPositions, HasGroupIndex, HasSystemIndex, Protocol
Particles with position gradients, group and system assignment.
Source code in src/kups/observables/stress.py
IsVirialParticles
¶
Bases: HasPositions, HasSystemIndex, Protocol
Particles with position gradients ∂U/∂r.
Source code in src/kups/observables/stress.py
IsVirialSystems
¶
Bases: HasCell[AnyPeriodicity], Protocol
Systems with a cell (any periodicity) and cell gradients ∂U/∂h (stored lower-triangular).
Source code in src/kups/observables/stress.py
molecular_stress_via_virial_theorem(particles, groups, systems)
¶
Compute molecular virial stress tensor (RASPA convention).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, IsMolecularVirialParticles]
|
Per-particle positions, group/system index, and gradients. |
required |
groups
|
Table[GroupId, HasSystemIndex]
|
Per-group system assignment. |
required |
systems
|
Table[SystemId, IsVirialSystems]
|
Per-system cell and cell gradients (lower-triangular). |
required |
Returns:
| Type | Description |
|---|---|
Table[SystemId, Array]
|
Symmetric stress tensor per system, shape |
Source code in src/kups/observables/stress.py
stress_via_virial_theorem(particles, systems)
¶
Compute atomic-level virial stress tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
particles
|
Table[ParticleId, IsVirialParticles]
|
Per-particle positions, system index, and position gradients. |
required |
systems
|
Table[SystemId, IsVirialSystems]
|
Per-system cell and cell gradients (lower-triangular). |
required |
Returns:
| Type | Description |
|---|---|
Table[SystemId, Array]
|
Symmetric stress tensor per system, shape |
Source code in src/kups/observables/stress.py
total_lattice_gradient(positions, position_gradients, cell, partial_lattice_gradient, system)
¶
Total lattice gradient ∂E/∂h|_r + h⁻ᵀ·Σ_i r_i ⊗ ∂E/∂r_i, in frame parameters.
A potential reports the partial gradient ∂E/∂h|_r, taken at fixed
Cartesian positions. Variable-cell relaxation needs the total derivative,
with atoms riding the cell at fixed fractional coordinates; this adds the
position-virial term h⁻ᵀ·Σ_i r_i ⊗ ∂E/∂r_i. Stress is unchanged either way.
Non-periodic axes carry no atoms -- a slab/vacuum basis vector is a
bounding-box edge, not a translation -- so their coupling rows are dropped via
the cell's periodic mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
Array
|
Real-space positions |
required |
position_gradients
|
Array
|
|
required |
cell
|
Table[SystemId, C]
|
Per-system cells |
required |
partial_lattice_gradient
|
Table[SystemId, C]
|
|
required |
system
|
Index[SystemId]
|
Per-particle system index, replicating |
required |
Returns:
| Type | Description |
|---|---|
Table[SystemId, C]
|
Total lattice gradient as |