Fixed calculation of norm for per-atom rank-2 tensors in get_parity_data

This MR fixes the norm selection for atomic_v of the get_parity_data function when it represents a per-atom polarizability (6-component reduced Voigt tensor) rather than a per-atom dipole (3-component vector). The norm was previously computed as a naive Euclidean norm over the raw 6 Voigt components, instead of expanding to the full symmetric 3x3 tensor and taking the Frobenius norm (as already done for virial/stress). This under-weighted the off-diagonal (xy, xz, yz) contributions, since they each appear twice in the full tensor.

The 3-component dipole-like case is unaffected.

Testing

Fixed test_get_parity_data_norm, which previously mirrored the same bug in its expected-value calculation and so could not catch it. Added two new tests covering the 3-component and 6-component atomic_v norm cases separately, the latter asserting the corrected result differs from the old, incorrect one.

Merge request reports

Loading