vibeqc.compute_stress_tensor

vibeqc.compute_stress_tensor(system, gradient)[source]

Force virial — NOT the true periodic stress.

Warning

This is only the atomic-force virial σ_{ij} = -(1/V)·Σ_A R_{A,i}·F_{A,j}. It is not the periodic stress (1/V)·∂E/∂ε: it omits the explicit lattice/Ewald strain dependence and the Gaussian-basis Pulay stress, and it assumes the atoms scale with the strain. On H₂/STO-3G it comes out opposite in sign to the true ∂E/∂ε. Do not use it to relax the cell or report a stress. For cell relaxation use vibeqc.bipole_optimize.relax_cell() (energy-only Nelder-Mead) or relax_cell_gradient() (L-BFGS-B on the exact FD strain gradient); both are correct by construction. This helper is retained only for the force-virial diagnostic.

Computes the 3×3 force virial in Ha/bohr³:

σ_{ij} = -(1/V) · Σ_A R_{A,i} · F_{A,j}

where R_A are atomic positions and F_A = -dE/dR_A.

Parameters:
  • system (PeriodicSystem) – The periodic system (provides lattice + atomic positions).

  • gradient ((n_atoms, 3) ndarray) – Atomic gradient in Ha/bohr (negative of forces).

Returns:

Stress tensor in Ha/bohr³.

Return type:

ndarray shape (3, 3)