# How to fix gauge in Quantum ESPRESSO?

I am trying to use Quantum ESPRESSO to manually calculate the Berry phase using the Berry connection, due to evolution along a closed loop in k-space. I want to do this manually instead of using existing methods such as the lberry tag, polarization, etc.

So far, I defined a custom circular path in K_POINTS (using the equation of a circle parameterized by a single variable, for example). Then, I run an SCF calculation and use the output .hdf5 files (one file per k-point sampled) to extract wavefunction data. I sum all the plane wave basis coefficients at each k-point, per band, to get a single wavefunction vector $$|\phi_n\rangle(k)$$ at the point $$k$$ for each band $$n$$.

However, when I try to use a difference method to numerically calculate the Berry phase of the loop using the gauge-dependent Berry connection $$\langle \phi_n | \frac{d}{dt} \phi_n \rangle$$, I end up with nonsense.

I learnt that this was because the gauge at each k-point is different, whereas the Berry phase can be calculated this way only if the gauge is consistent along the loop. To clarify, this gauge choice can come from the quantum adiabatic theorem and boils down to an arbitrary complex phase that multiplies the wavefunction: $$e^{i \theta(k)}|\phi_n\rangle(k)$$, where $$\theta(k)$$ is a smooth $$k$$-dependent function. Physical observables are gauge-independent and do not depend on this arbitrary phase (such as the Berry phase when calculated from the Berry curvature area integral, which is what I think is used by built-in polarization calculations). Note that calculating the Berry phase using the Berry connection comes with a $$2\pi n, n\in \mathbb{Z}$$ ambiguity. I want to calculate the phase this way because I want to calculate this ambiguity.

So, how do I fix the gauge? I have seen some works that say they "fix the gauge" to the so-called hydrogenic gauge (i.e. no gauge singularities at the band edge, etc). However, I do not know how to fix the gauge at all (whether to the hydrogenic gauge or not). Any advice?

• What do you mean by "calculate the ambiguity"? This is fairly fundamental to it being a phase, a change of 2\pi n is always allowed. Which interval you take your phase to lie in, e.g. [0,2\pi) or [-pi,pi), is equivalent to asking where your "origin" of coordinates is in real-space. Feb 19 at 1:26
• The formula you're using for the Berry connection is only correct in an orthonormal basis, so you will need to ensure you're using norm-conserving pseudopotentials for your calculations. Feb 19 at 1:27
• Thanks, that's helpful. I also read something about "Gauge invariant PAW", but am not sure whether that's the solution here. That said, I did use NC PPs. As for the ambiguity, my ultimate goal is to calculate the difference $A - B$, where $A$ is the Berry phase from integrating the Berry connection along the chosen loop, and $B$ is the Berry phase from integrating the Berry curvature in the region inside the loop. Usually, $A-B=0$ when there isn't a $2\pi$ ambiguity. However, certain gauge choices will make this nonzero and $=2\pi n$, where $n$ is an integer. Feb 19 at 1:40
• @PhilHasnip, you should make your comment into an answer! Feb 22 at 13:28
• I may have misunderstood, but there is still the issue of QE by default giving wavefunctions a random/arbitrary phase at each k-point, right? Feb 22 at 19:39