Then how we can calculate their overlap of two ground states: \(\frac{\langle \textrm{psi_1} \mid \textrm{psi_2} \rangle}{\sqrt{\langle \textrm{psi_1} \mid \textrm{psi_1} \rangle} \sqrt{\langle \textrm{psi_2} \mid \textrm{psi_2} \rangle} }\) ?
It's simply psi_1.overlap(psi_2), or for the normalization as in your formula, psi_1.overlap(psi_2)/psi_1.norm / psi_2.norm .
See overlap for more details.
For infinite MPS, it's the largest eigenvalue of the transfermatrix, which is not just the overlap <psi_1|psi_2> - the latter is zero for any two states which are not exactly the same up to a prefactor, and hence not a usefull measure.
I don't think this works, even for finite MPS or with exact diagonalization.
The issue is that you need to pin the phase of the ground state, which is not well defined from the perspective of a variational algorithm: if \(|\Psi\rangle\) is a ground state, so is \(e^{i \phi} |\Psi\rangle\), so any variational, numerical algorithm like DMRG or ED returns the state with an arbitrary phase.
For that reason, \(\langle \phi_{gs}(\theta) |\phi_{gs}(\theta + \delta \theta) \rangle\) has an arbitrary phase, the only thing you can extract is the absolute value.
(Apart from that, as I said before, the overlap is not really well defined in the thermodynamic limit.)
The wilson loop \(\prod_{\theta \in \{0, 2\pi\}} \langle \phi_{gs}(\theta) \mid \phi_{gs}(\theta+\delta \theta) \rangle\) should be gauge free, although \( \langle \phi_{gs}(\theta) \mid \phi_{gs}(\theta+\delta \theta) \rangle\) is gauge dependent. Therefore, this formula can be used to numerically evaluate the berry phase. By the way, do you have any good idea to calculate the berry phase using DMRG ? Thanks.
You're right of course. Okay, let me just say that I never tried it...
You should probably still make sure that you follow the evolution with \(\theta\) adiabatically.
In other words, use the result from the DMRG run with \(\theta\) as an initial guess for the \(\theta + \delta \theta\) DMRG, similarly as is done e.g. in examples/chern_insulateors/chiral_pi_flux.py.