Keep the full complex generalized group velocity in kappa_offdiag - #185
Conversation
get_kappa_offdiag discarded the imaginary part of the off-diagonal group
velocity before squaring it:
buf_vel(:, i, j) = real(cv0, r8)
justified by "I can take the real part since at the end we sum over both
modes and the imaginary components disappear". The premise holds --
sum_ij Im v_ij is zero because v_ij = conj(v_ji) -- but the quantity
accumulated afterwards is quadratic:
buf_velsq(:, :, i, j) += lo_outerproduct(v1, v1)
and sum_ij Im v^a Im v^b does not vanish. Dropping it leaves
Re v^a Re v^b alone, which is not invariant under the arbitrary per-mode
phases zheev returns, so kappa_offdiag depends on the eigenvector basis.
Measured on three materials, a random phase gauge moved it by 27-59 %
while leaving kappa_sma bit-identical.
Keeping cv0 complex and taking the real part of the outer product gives
Re v^a Re v^b + Im v^a Im v^b, the gauge invariant bilinear
(lo_complex_outerproduct conjugates its first argument). kappa_offdiag is
then bit-identical across gauges; kappa_sma, frequencies, linewidths,
lifetimes, heat capacities and group velocities are unchanged.
kappa_offdiag itself moves: 0.00481941 -> 0.00830067 (KI, Pm-3m),
0.05503408 -> 0.06626228 (Rb2O, Fm-3m), 0.07273678/0.14298927 ->
0.16748196/0.37433862 (KPTe2, R-3m) W/mK at 300 K on a 6^3 mesh.
|
Hi Shao, thanks for the fix. I am running the CLI. Your text is not clear about the merge though: "The branch is for diagnostics only and is not proposed for merging" yet you are making a merge request... Please elaborate, and clean up the final branch for the MR if that is what you want |
|
Hi Matthieu, thanks for testing. Sorry for the ambiguous wording. There are two separate branches: The fix: Surefire618:fix/coherence-gauge-invariance. The only change is to keep the generalized group velocity complex. This is the branch this MR points at, and the one to merge. The test: Surefire618:random_phase_injection. It adds a toy experiment that demonstrates the gauge dependence of the original result and the gauge invariance after the fix. This branch is for diagnostics only and is not part of this MR. The sentence you quoted refers to the second branch only. I will make that explicit in the PR description. Best wishes, Shuo |
mjv500
left a comment
There was a problem hiding this comment.
looks clean to me and passes automatic tests
|
Thanks @Surefire618 ! |
|
Good catch! |
Keep the full complex generalized group velocity in
kappa_offdiagThe bug
get_kappa_offdiagdrops the imaginary part of the off-diagonal group velocity:The premise is true —
v_ij = conj(v_ji), sosum_ij Im v_ij = 0— butbuf_velis not summed linearly. It is accumulated quadratically,and
sum_ij Im v^a Im v^bdoes not vanish. What is left,Re v^a Re v^b, is not invariant underv_ss' -> exp(i(th_s' - th_s)) v_ss', sokappa_offdiagdepends on the arbitrary phases thatzheevreturns for the eigenvectors.The fix
Keep
cv0complex and take the real part of the outer product instead:lo_complex_outerproduct(a, b)ism(i,j) = conj(a(j)) * b(i), so this givesRe v^a Re v^b + Im v^a Im v^b, the gauge-invariant combination.buf_veland the localv0,v1inget_kappa_offdiagbecome complex; the variables of the same name inget_kappaare untouched.The fix in this branch
fix/coherence-gauge-invarianceis prepared for a merge.Evidence
MgO from
tdep-tutorials/04_thermal_conductivity/Examples/MgO, 300 K, third order, isotope scattering on, adaptive Gaussian integration, one MPI rank.Gauge-invariance test (test only branch, do no merge)
To test gauge invariance I prepared a random-phase-injection patch, available as the branch
Surefire618:random_phase_injection. It multiplies every eigenvector by a random phase,e_s -> exp(i th_s) e_s, before the off-diagonal velocity is built.The patch is enabled by setting the environment variable
TDEP_GAUGE_SEED:export TDEP_GAUGE_SEED=1 thermal_conductivity -qg 8 8 8 --temperature 300The original behaviour is recovered by taking the real part of the velocities:
A sanity check confirms that the phased vectors are still orthonormal and are still eigenvectors with the same eigenvalues. The patch also writes
v_ss'tooutfile.velocity_offdiagonal. This test branchSurefire618:random_phase_injectionis for diagnostics only and is not proposed for merging.The coherence channel at 8³ reads:
TDEP_GAUGE_SEED=1TDEP_GAUGE_SEED=2TDEP_GAUGE_SEED=3The input files and the
thermal_conductivitylog files are attached for reference:mgo_gauge.tar.gz