Skip to content

Commit

Permalink
Merge branch 'main' into gf_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
thenoursehorse authored May 16, 2024
2 parents d6345d1 + d6a1e8c commit a44feb7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion examples/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def force_paramagnetic(A):

if np.abs(U - 3.5) < 1e-10:
# Some different ways to construct some Green's functions
mu = kweight.mu

# The k-space and frequency mesh of the problem
iw_mesh = MeshImFreq(beta=beta, S='Fermion', n_max=64)
Expand Down
38 changes: 38 additions & 0 deletions src/risb/helpers_triqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,44 @@ def get_g_k_w(g0_k_w : BlockGf | None = None,
for k, w in gf.mesh:
gf[k,w] = inverse(inverse(g0_k_w[bl][k,w]) - sigma_w[bl][w])
elif (g_qp_k_w is not None) and (R is not None):
=======
def get_sigma_w(gf_struct, mesh, Lambda, R, mu=0, h_loc=None):
sigma_w = BlockGf(mesh=mesh, gf_struct=gf_struct)
for bl, gf in sigma_w:
id = np.eye(*gf.data.shape[-2::]) # Last two indices are the orbital structure
Z = R[bl] @ R[bl].conj().T
id_Z = (id - np.linalg.inv(Z))
id_Z_mu = id_Z * mu
hf = np.linalg.inv(R[bl]) @ Lambda[bl] @ np.linalg.inv(R[bl].conj().T)
if h_loc is not None:
for w in gf.mesh:
gf[w] = id_Z * w + hf + id_Z_mu - h_loc[bl]
else:
for w in gf.mesh:
gf[w] = id_Z * w + hf + id_Z_mu
return sigma_w

# FIXME have to check h0_kin_k shares the same mesh
def get_g_qp_k_w(gf_struct, mesh, h0_kin_k, Lambda, R, mu=0):
g_qp_k_w = BlockGf(mesh=mesh, gf_struct=gf_struct)
for bl, gf in g_qp_k_w:
h_qp = get_h_qp(R=R[bl], Lambda=Lambda[bl], h0_kin_k=h0_kin_k[bl], mu=mu)
for k, w in g_qp_k_w.mesh:
gf[k,w] = inverse(w - h_qp[k.data_index])
return g_qp_k_w

def get_g_k_w(**kwargs):
if ('g0_k_w' in kwargs) and ('sigma_w' in kwargs):
g0_k_w = kwargs['g0_k_w']
sigma_w = kwargs['sigma_w']
g_k_w = g0_k_w.copy()
g_k_w.zero()
for bl, gf in g_k_w:
for k, w in gf.mesh:
gf[k,w] = inverse(inverse(g0_k_w[bl][k,w]) - sigma_w[bl][w])
elif ('g_qp_k_w' in kwargs) and ('R' in kwargs):
g_qp_k_w = kwargs['g_qp_k_w']
R = kwargs['R']
g_k_w = g_qp_k_w.copy()
g_k_w.zero()
for bl, gf in g_qp_k_w:
Expand Down

0 comments on commit a44feb7

Please sign in to comment.