Compare commits

...

2 Commits

2 changed files with 55 additions and 10 deletions

View File

@ -620,6 +620,23 @@ def read_wannier90_blochbasis_data(wannier_seed, n_wannier_spin):
assert ks_eigenvals_spin.shape[1] == num_ks_bands, '.eig and u_dis.mat data inconsistent'
if disentangle:
# In case the disentanglement window is not set by the user, change manually both limits to
# larger window to avoid possible counting error in next line
dis_tol = 1e-5
shift_dis_down = np.any(np.isclose(np.min(ks_eigenvals_spin, axis=1), dis_window_min, atol=dis_tol, rtol=0.) == True)
shift_dis_up = np.any(np.isclose(np.max(ks_eigenvals_spin, axis=1), dis_window_max, atol=dis_tol, rtol=0.) == True)
if shift_dis_down or shift_dis_up:
if shift_dis_down:
mpi.report('WARNING: dis_win_min too close to value in .eig, manually shifting it down by '
+ '{} to avoid counting error'.format(2*dis_tol))
dis_window_min -= 2*dis_tol
if shift_dis_up:
mpi.report('WARNING: dis_win_max too close to value in .eig, manually shifting it up by '
+ '{} to avoid counting error'.format(2*dis_tol))
dis_window_max += 2*dis_tol
mpi.report('This can happen when the user did not specify disentanglement windows in .win. '
+ 'Check if this is the case here.')
# Determine which bands are inside the band window
inside_window = np.logical_and(ks_eigenvals_spin >= dis_window_min,
ks_eigenvals_spin <= dis_window_max)
@ -1168,7 +1185,8 @@ def check_bloch_basis_hk(n_corr_shells, corr_shells, n_k, n_spin_blocks, n_bands
hks_are_equal = np.isclose(downfolded_ham, wannier_ham_corr, atol=1e-4, rtol=0)
if not np.all(hks_are_equal):
index_difference = np.nonzero(np.logical_not(np.all(hks_are_equal, axis=2)))
isp, ik = np.transpose(index_difference)[0]
isp = index_difference[0][0]
ik = index_difference[1][0]
mpi.report('WARNING: mismatch between downfolded Hamiltonian and Fourier transformed '
+ 'H(R). First occurred at kpt {} and spin {}:'.format(ik, isp))

View File

@ -1824,7 +1824,7 @@ class SumkDFT(object):
def symm_deg_gf(self, gf_to_symm, ish=0):
r"""
Averages a GF over degenerate shells.
Averages a GF or a dict of np.ndarrays over degenerate shells.
Degenerate shells of an inequivalent correlated shell are defined by
`self.deg_shells`. This function enforces corresponding degeneracies
@ -1834,6 +1834,7 @@ class SumkDFT(object):
----------
gf_to_symm : gf_struct_solver like
Input and output GF (i.e., it gets overwritten)
or dict of np.ndarrays.
ish : int
Index of an inequivalent shell. (default value 0)
@ -1843,6 +1844,13 @@ class SumkDFT(object):
# an h5 file, self.deg_shells might be None
if self.deg_shells is None: return
if not isinstance(gf_to_symm, BlockGf) and isinstance(gf_to_symm[list(gf_to_symm.keys())[0]], np.ndarray):
blockgf = False
elif isinstance(gf_to_symm, BlockGf):
blockgf = True
else:
raise ValueError("gf_to_symm should be either a BlockGf or a dict of numpy arrays")
for degsh in self.deg_shells[ish]:
# ss will hold the averaged orbitals in the basis where the
# blocks are all equal
@ -1851,18 +1859,30 @@ class SumkDFT(object):
n_deg = len(degsh)
for key in degsh:
if ss is None:
ss = gf_to_symm[key].copy()
ss.zero()
helper = ss.copy()
if blockgf:
ss = gf_to_symm[key].copy()
ss.zero()
helper = ss.copy()
else:
ss = np.zeros_like(gf_to_symm[key])
helper = np.zeros_like(gf_to_symm[key])
# get the transformation matrix
if isinstance(degsh, dict):
v, C = degsh[key]
else:
# for backward compatibility, allow degsh to be a list
v = np.eye(*ss.target_shape)
if blockgf:
v = np.eye(*ss.target_shape)
else:
v = np.eye(*ss.shape)
C = False
# the helper is in the basis where the blocks are all equal
helper.from_L_G_R(v.conjugate().transpose(), gf_to_symm[key], v)
if blockgf:
helper.from_L_G_R(v.conjugate().transpose(), gf_to_symm[key], v)
else:
helper = np.dot(v.conjugate().transpose(), np.dot(gf_to_symm[key], v))
if C:
helper << helper.transpose()
# average over all shells
@ -1873,12 +1893,19 @@ class SumkDFT(object):
v, C = degsh[key]
else:
# for backward compatibility, allow degsh to be a list
v = np.eye(*ss.target_shape)
if blockgf:
v = np.eye(*ss.target_shape)
else:
v = np.eye(*ss.shape)
C = False
if C:
if blockgf and C:
gf_to_symm[key].from_L_G_R(v, ss.transpose().copy(), v.conjugate().transpose())
else:
elif blockgf and not C:
gf_to_symm[key].from_L_G_R(v, ss, v.conjugate().transpose())
elif not blockgf and C:
gf_to_symm[key] = np.dot(v, np.dot(ss.transpose().copy(), v.conjugate().transpose()))
elif not blockgf and not C:
gf_to_symm[key] = np.dot(v, np.dot(ss, v.conjugate().transpose()))
def total_density(self, mu=None, with_Sigma=True, with_dc=True, broadening=None, beta=None):
r"""