Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge dev GW embedding (includes other fixes as well) #78

Merged
merged 37 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b2827e8
[fix] small FTPS problems and introduce a different eta for FTPS
the-hampel Jul 17, 2023
b5be67a
[feat] add direct G_iw cthyb measurement
the-hampel Jul 17, 2023
add2108
[fix] tests
the-hampel Jul 17, 2023
ce588fd
[doc] small fix in read_config documentation
the-hampel Jul 18, 2023
f814aeb
[feat] read bdft interaction from h5
the-hampel Sep 29, 2023
5ead372
[feat] add DC from bdft
the-hampel Oct 3, 2023
1062ace
[fix] remove not yet merged cthyb feature
the-hampel Oct 3, 2023
fc0ca41
add test data
the-hampel Oct 7, 2023
69c469c
add rotations of U/V and add par n_w_b_nn
the-hampel Oct 13, 2023
2d90f4f
[feat] calc Wloc from Gloc for DC pot
the-hampel Jan 17, 2024
352c121
[test] fix old tests after changes
the-hampel Jan 18, 2024
936fe8c
version in eV
the-hampel Jan 30, 2024
35db7ce
updates
the-hampel Jan 31, 2024
8b387d8
add missing test
the-hampel Jan 31, 2024
2ec53dd
[feat] new gw_flow embedding driver module
the-hampel Feb 8, 2024
88dd3da
enable hubbardi
the-hampel Feb 9, 2024
703dd21
allow qp embedding from aimbes
the-hampel Feb 9, 2024
d5efd8b
fix dim of return Sigma_ir depending on spin
the-hampel Feb 12, 2024
2d59359
fix for last commit
the-hampel Feb 12, 2024
8f7fffa
allow to specify aimbes iteration to load
the-hampel Feb 14, 2024
57b43cb
minor fixes
cnyeh Feb 14, 2024
a0765b8
[feat] use it_1e to determine iteration
the-hampel Feb 16, 2024
38616bb
small fixes to example
the-hampel Feb 28, 2024
7958652
Merge remote-tracking branch 'origin/unstable' into dev_gw_embedding
the-hampel Mar 9, 2024
e87385c
Merge remote-tracking branch 'origin/unstable' into dev_gw_embedding
the-hampel Mar 9, 2024
6a33da6
clean up imports
the-hampel Mar 10, 2024
e8a34f9
[feat] allow diagonal approximation of imp problem via enforce_off_di…
the-hampel Apr 2, 2024
add583a
Merge remote-tracking branch 'origin/unstable' into dev_gw_embedding
the-hampel Apr 5, 2024
f69632e
[feat] add triqs CRM Dyson solver for cthyb
the-hampel Apr 9, 2024
f56c189
[fix] use DLR CRM in gw embedding and use GW params for DLR -> IR
the-hampel Apr 10, 2024
2192a22
Merge remote-tracking branch 'origin/unstable' into dev_gw_embedding
the-hampel May 15, 2024
ec673e2
[feat] new ctseg solver, cRPA reader, new DC
the-hampel May 17, 2024
e8c5f7a
remove comments
the-hampel May 20, 2024
8af80d1
Merge remote-tracking branch 'origin/unstable' into dev_gw_embedding
the-hampel May 20, 2024
13fb7ea
move imports closer to gw_converter functions
the-hampel May 20, 2024
d7732fa
move imports closer to gw_converter functions
the-hampel May 20, 2024
412e80c
[feat] allow PCB to read from TRIQS TB object
the-hampel May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[feat] add triqs CRM Dyson solver for cthyb
* use dyson CRM solver from triqs (triqs 3.3.x) to obtain Sigma imp:
  "crm_dyson_solver=true" and dlr_wmax and dlr_eps in sec general
* modify basic SVO test to do crm test instead of gl
the-hampel committed Apr 9, 2024
commit f69632e9a369b21ffcb688da216f4e38ce420bef
4 changes: 4 additions & 0 deletions python/solid_dmft/dmft_tools/results_to_archive.py
Original file line number Diff line number Diff line change
@@ -79,6 +79,10 @@ def _compile_information(sum_k, general_params, solver_params, solvers, map_imp_
write_to_h5['G_time_orig_{}'.format(icrsh)] = solvers[icrsh].G_time_orig
write_to_h5['Gimp_l_{}'.format(icrsh)] = solvers[icrsh].G_l

if solver_params[isolvsec]['crm_dyson_solver']:
write_to_h5['G_time_orig_{}'.format(icrsh)] = solvers[icrsh].G_time_orig
write_to_h5['Sigma_dlr_{}'.format(icrsh)] = solvers[icrsh].Sigma_dlr

# if solver_params['measure_G_iw']:
# write_to_h5['Gimp_freq_direct_{}'.format(icrsh)] = solvers[icrsh].G_iw_direct

76 changes: 74 additions & 2 deletions python/solid_dmft/dmft_tools/solver.py
Original file line number Diff line number Diff line change
@@ -25,9 +25,8 @@
import numpy as np
from itertools import product

from triqs.gf import MeshImTime, MeshReTime, MeshReFreq, MeshLegendre, Gf, BlockGf, make_gf_imfreq, make_hermitian, Omega, iOmega_n, make_gf_from_fourier, fit_hermitian_tail, make_gf_imtime, make_gf_dlr, make_gf_dlr_imfreq
from triqs.gf import MeshImTime, MeshReTime, MeshDLRImFreq, MeshReFreq, MeshLegendre, Gf, BlockGf, make_gf_imfreq, make_hermitian, Omega, iOmega_n, make_gf_from_fourier, make_gf_dlr, fit_gf_dlr, make_gf_dlr_imtime
from triqs.gf.tools import inverse, make_zero_tail
from triqs.gf import make_gf_imfreq
from triqs.gf.descriptors import Fourier
from triqs.operators import c_dag, c, Operator, util
from triqs.operators.util.U_matrix import reduce_4index_to_2index
@@ -281,6 +280,10 @@ def _init_ImFreq_objects(self):
# move original G_freq to G_freq_orig
self.G_time_orig = self.G_time.copy()

if self.solver_params['type'] in ['cthyb'] and self.solver_params['crm_dyson_solver']:
self.G_time_orig = self.G_time.copy()
self.Sigma_dlr = None

if self.solver_params['type'] in ['cthyb', 'hubbardI'] and self.solver_params['measure_density_matrix']:
self.density_matrix = None
self.h_loc_diagonalization = None
@@ -1019,6 +1022,75 @@ def set_Gs_from_G_l():
elif self.solver_params['perform_tail_fit'] and not self.solver_params['legendre_fit']:
# if tailfit has been used replace Sigma with the tail fitted Sigma from cthyb
self.Sigma_freq << self.triqs_solver.Sigma_iw
elif self.solver_params['crm_dyson_solver']:
from triqs.gf.dlr_crm_dyson_solver import minimize_dyson

mpi.report('\nCRM Dyson solver to extract Σ impurity\n')
# fit QMC G_tau to DLR
if mpi.is_master_node():
self.G_time_orig << self.triqs_solver.G_tau
G_dlr = fit_gf_dlr(self.triqs_solver.G_tau,
w_max=self.general_params['dlr_wmax'], eps=self.general_params['dlr_eps'])
self.G_time = make_gf_dlr_imtime(G_dlr)

# assume little error on G0_iw and use to get G0_dlr
mesh_dlr_iw = MeshDLRImFreq(G_dlr.mesh)
G0_dlr_iw = self.sum_k.block_structure.create_gf(ish=self.icrsh, gf_function=Gf, mesh=mesh_dlr_iw, space='solver')
for block, gf in G0_dlr_iw:
for iwn in mesh_dlr_iw:
gf[iwn] = self.G0_freq[block](iwn)
self.sum_k.symm_deg_gf(G0_dlr_iw, ish=self.icrsh)
G0_dlr = make_gf_dlr(G0_dlr_iw)

# average moments
self.sum_k.symm_deg_gf(self.triqs_solver.Sigma_Hartree, ish=self.icrsh)
first_mom = {}
for block, mom in self.triqs_solver.Sigma_moments.items():
first_mom[block] = mom[1]
self.sum_k.symm_deg_gf(first_mom, ish=self.icrsh)

for block, mom in self.triqs_solver.Sigma_moments.items():
mom[0] = self.triqs_solver.Sigma_Hartree[block]
mom[1] = first_mom[block]

# minimize dyson for the first entry of each deg shell
Sigma_dlr = self.sum_k.block_structure.create_gf(ish=self.icrsh, gf_function=Gf, mesh=G_dlr.mesh, space='solver')
# without any degenerate shells we run the minimization for all blocks
if self.sum_k.deg_shells[self.icrsh] == []:
for block, gf in Sigma_dlr:
print('Minimizing Dyson via CRM for Σ[block]:', block)
gf, min_res = minimize_dyson(G0_tau=G0_dlr[block],
G_tau=G_dlr[block],
Sigma_moments=self.triqs_solver.Sigma_moments[block],
verbose=True
)
else:
for deg_shell in self.sum_k.deg_shells[self.icrsh]:
for i, block in enumerate(deg_shell):
if i == 0:
print('Minimizing Dyson via CRM for Σ[block]:', block)
Sigma_dlr[block], min_res = minimize_dyson(G0_tau=G0_dlr[block],
G_tau=G_dlr[block],
Sigma_moments=self.triqs_solver.Sigma_moments[block],
verbose=True
)
sol_block = block
else:
Sigma_dlr[block] << Sigma_dlr[sol_block]

print(f'Copying result from first block of deg list to {block}')
print('\n')

self.Sigma_freq = make_gf_imfreq(Sigma_dlr, n_iw=self.general_params['n_iw'])
for block, gf in self.Sigma_freq:
gf += self.triqs_solver.Sigma_moments[block][0]
self.Sigma_dlr = Sigma_dlr

mpi.barrier()
self.Sigma_freq = mpi.bcast(self.Sigma_freq)
self.Sigma_dlr = mpi.bcast(self.Sigma_dlr)
self.G_time = mpi.bcast(self.G_time)
self.G_time_orig = mpi.bcast(self.G_time_orig)
else:
# obtain Sigma via dyson from symmetrized G_freq
self.Sigma_freq << inverse(self.G0_freq) - inverse(self.G_freq)
17 changes: 10 additions & 7 deletions python/solid_dmft/gw_embedding/bdft_converter.py
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ def calc_W_from_Gloc(Gloc_dlr: Gf | BlockGf, U: np.ndarray | dict) -> Gf | Block
return W_dlr


def convert_gw_output(job_h5: str, gw_h5: str, wmax_dlr: float, it_1e: int = 0, it_2e: int = 0) -> tuple[dict, IAFT]:
def convert_gw_output(job_h5: str, gw_h5: str, dlr_wmax: float, dlr_eps: float, it_1e: int = 0, it_2e: int = 0) -> tuple[dict, IAFT]:
"""
read bdft output and convert to triqs Gf DLR objects

@@ -250,8 +250,10 @@ def convert_gw_output(job_h5: str, gw_h5: str, wmax_dlr: float, it_1e: int = 0,
path to solid_dmft job file
gw_h5: string
path to GW checkpoint file for AIMBES code
wmax_dlr: float
dlr_wmax: float
DLR energy cutoff, same as Lambda / beta for the impurity problem
dlr_eps: float
precision for DLR basis set
it_1e: int, optional
iteration to read from gw_h5 calculation for 1e downfolding, defaults to last iteration
it_2e: int, optional
@@ -269,7 +271,8 @@ def convert_gw_output(job_h5: str, gw_h5: str, wmax_dlr: float, it_1e: int = 0,

mpi.report('reading output from bdft code')

gw_data = {'wmax_dlr': wmax_dlr}
gw_data = {'dlr_wmax': dlr_wmax,
'dlr_eps': dlr_eps}

with HDFArchive(gw_h5, 'r') as ar:
if not it_1e or not it_2e:
@@ -340,14 +343,14 @@ def convert_gw_output(job_h5: str, gw_h5: str, wmax_dlr: float, it_1e: int = 0,
gw_data['mesh_dlr_iw_b'] = MeshDLRImFreq(
beta=gw_data['beta'],
statistic='Boson',
w_max=gw_data['wmax_dlr'],
eps=gw_data['prec'],
w_max=gw_data['dlr_wmax'],
eps=gw_data['dlr_eps'],
)
gw_data['mesh_dlr_iw_f'] = MeshDLRImFreq(
beta=gw_data['beta'],
statistic='Fermion',
w_max=gw_data['wmax_dlr'],
eps=gw_data['prec'],
w_max=gw_data['dlr_wmax'],
eps=gw_data['dlr_eps'],
)

(
3 changes: 2 additions & 1 deletion python/solid_dmft/gw_embedding/gw_flow.py
Original file line number Diff line number Diff line change
@@ -227,7 +227,8 @@ def embedding_driver(general_params, solver_params, gw_params, advanced_params):
gw_data, ir_kernel = convert_gw_output(
general_params['jobname'] + '/' + general_params['seedname'] + '.h5',
gw_params['h5_file'],
wmax_dlr=general_params['w_max'],
dlr_wmax=general_params['dlr_wmax'],
dlr_eps=general_params['dlr_eps'],
it_1e = gw_params['it_1e'],
it_2e = gw_params['it_2e'],
)
6 changes: 4 additions & 2 deletions python/solid_dmft/io_tools/default.toml
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ csc = false
dc = true
dc_dmft = "<none>"
dc_type = "<none>"
dlr_eps = "<none>"
dlr_wmax = "<none>"
enforce_off_diag = true
eta = "<none>"
fixed_mu_value = "<none>"
@@ -54,22 +56,22 @@ sigma_mix = 1.0
store_solver = false
U = "<none>"
U_prime = "<none>"
w_max = "<none>"
w_range = [-10, 10]

# Keys in this section that should be passed to the triqs solver
# explicitly need to be added to the triqs_solver_params
# when initializing the solver.py class from solid_dmft
[[solver]]
type = "cthyb"
idx_impurities = "<none>"
crm_dyson_solver = false
delta_interface = false
diag_delta = false
fit_max_moment = "<none>"
fit_max_n = "<none>"
fit_max_w = "<none>"
fit_min_n = "<none>"
fit_min_w = "<none>"
idx_impurities = "<none>"
imag_threshold = 1.0e-14
legendre_fit = false
length_cycle = "<no default>"
4 changes: 4 additions & 0 deletions python/solid_dmft/io_tools/verify_input_params.py
Original file line number Diff line number Diff line change
@@ -81,6 +81,10 @@ def _verify_input_params_solver(params: FullConfig) -> None:
if entry['type'] not in supported_grids['real']:
raise ValueError(f'Solver {entry["type"]} does not support imaginary-frequency grid.')

for entry in solver_params:
if entry['type'] == 'cthyb' and entry['crm_dyson_solver'] and not entry['measure_density_matrix']:
raise ValueError('Solver "cthyb" when using "crm_dyson_solver" must also measure the density matrix: "measure_density_matrix" = True')

def _verify_input_params_gw(params: FullConfig) -> None:
pass

2 changes: 1 addition & 1 deletion test/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ set (integration_tests
svo_hubbardI_basic
svo_hartree
lno_hubbardI_mag
svo_cthyb_basic_gl
svo_cthyb_basic_crm
svo_cthyb_basic_tf
svo_cthyb_crpa
svo_ctseg_dyn
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ mu_initial_guess = -0.027041
prec_mu = 0.001
n_iw = 501
n_tau = 10001
dlr_wmax = 4
dlr_eps = 1e-8

h_int_type = "kanamori"
U = 8.0
@@ -31,10 +33,9 @@ load_sigma = false

[solver]
type = "cthyb"
n_l = 35
length_cycle = 120
length_cycle = 250
n_warmup_cycles = 8000
n_cycles_tot = 1e+4
imag_threshold = 1e-5
measure_G_l = true
measure_density_matrix = true
crm_dyson_solver = true
File renamed without changes.
File renamed without changes.
File renamed without changes.