From 8c4e4f9e9224ff095155c855715faec83e34fbe3 Mon Sep 17 00:00:00 2001 From: Jiacheng Wang <63186896+jcwang587@users.noreply.github.com> Date: Mon, 6 Jul 2026 12:28:17 -0400 Subject: [PATCH] Fix imaginary-mode count in hr_factors np.sum(np.where(freqs[3:] < 0.0)) sums the indices of the imaginary modes instead of counting them, inflating nom_imag_freq whenever more than one imaginary mode exists past the first three entries. The inflated count made the Huang-Rhys projection silently drop that many extra low-frequency real modes (underestimating dQ and the total S when the displacement has weight there), and the emitted warning reported a wrong number of imaginary modes. Co-Authored-By: Claude Fable 5 --- pypl/hr_factors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypl/hr_factors.py b/pypl/hr_factors.py index f0e0406..378ca91 100644 --- a/pypl/hr_factors.py +++ b/pypl/hr_factors.py @@ -31,7 +31,7 @@ def __init__(self, freqs, modes, atomic_symbols, mass_list=None): self.nom = freqs.shape[0] self.nom_translational = 3 - self.nom_imag_freq = np.sum(np.where(self.freqs[3:] < 0.0)) + self.nom_imag_freq = int(np.sum(self.freqs[3:] < 0.0)) if self.nom_imag_freq > 0: warnings.warn( f"{self.nom_imag_freq} imaginary mode(s) detected in the phonon spectrum. "