Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
38 changes: 27 additions & 11 deletions python/w2dyn_cthyb/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def solve(self, **params_kw):
n_cycles = params_kw.pop("n_cycles") ### what does the True or False mean?
n_warmup_cycles = params_kw.pop("n_warmup_cycles", 5000) ### default
max_time = params_kw.pop("max_time", -1)
worm = params_kw.pop("worm", False)
selfenergy = params_kw.pop("selfenergy", "dyson")
worm = params_kw.pop("worm", selfenergy in ["improved_worm", "symmetric_improved_worm"]) # Improved estimators imply worm sampling
percentageworminsert = params_kw.pop("PercentageWormInsert", 0.20)
percentagewormreplace = params_kw.pop("PercentageWormReplace", 0.20)
wormcomponents = params_kw.pop("worm_components", None)
Expand All @@ -124,7 +125,7 @@ def solve(self, **params_kw):

random_seed = params_kw.pop("random_seed", 1)
move_double = params_kw.pop("move_double", True)
measure_G_l = params_kw.pop("measure_G_l", False)
measure_G_l = params_kw.pop("measure_G_l", True)
measure_G_tau = params_kw.pop("measure_G_tau", True)
measure_pert_order = params_kw.pop("measure_pert_order", False)
statesampling = params_kw.pop("statesampling", False)
Expand Down Expand Up @@ -247,6 +248,8 @@ def solve(self, **params_kw):
### in a more sophisticated way

cfg["General"]["beta"] = self.beta
cfg["General"]["siw_moments"] = "estimate"
cfg["General"]["SelfEnergy"] = selfenergy
cfg["QMC"]["Niw"] = self.n_iw
cfg["QMC"]["Ntau"] = self.n_tau * 2 # use double resolution bins & down sample to Triqs l8r

Expand All @@ -262,6 +265,13 @@ def solve(self, **params_kw):
cfg["QMC"]["measurement_time"] = max_time
cfg["QMC"]["Ncorr"] = length_cycle

if selfenergy == "improved_worm":
cfg["QMC"]["WormMeasGSigmaiw"] = 1
cfg["General"]["FTType"] = "none_worm"
elif selfenergy == "symmetric_improved_worm":
cfg["QMC"]["WormMeasQQ"] = 1
cfg["General"]["FTType"] = "none_worm"

if statesampling:
cfg["QMC"]["statesampling"] = 1
else:
Expand Down Expand Up @@ -356,21 +366,29 @@ def solve(self, **params_kw):

### solve impurity problem
mccfgcontainer = []
siw_method = cfg["General"]["SelfEnergy"]
smom_method = cfg["General"]["siw_moments"]
iter_no = 1
if measure_G_tau or measure_G_l or measure_pert_order:

if self.complex:
solver.set_problem(imp_problem)
solver.umatrix = U_ijkl
result = solver.solve(mccfgcontainer)
result.postprocessing(siw_method, smom_method)
gtau = result.other["gtau-full"]
giw = result.giw
siw = result.siw

elif not worm:

solver.set_problem(imp_problem)
solver.umatrix = U_ijkl
result = solver.solve(iter_no, mccfgcontainer)
result.postprocessing(siw_method, smom_method)
gtau = result.other["gtau-full"]
giw = result.giw
siw = result.siw

elif worm_get_sector_index(cfg['QMC']) == 2:

Expand Down Expand Up @@ -413,6 +431,7 @@ def solve(self, **params_kw):
solver.set_problem(imp_problem)
solver.umatrix = U_ijkl
result_aux, result = solver.solve_component(1, 2, comp_ind, mccfgcontainer)
result.postprocessing(siw_method, smom_method)

for i in list(result.other.keys()):

Expand All @@ -437,6 +456,8 @@ def solve(self, **params_kw):
gtau[0, b1, s1, b2, s2, :] = result.other[gtau_name]

gtau = stat.DistributedSample(gtau, mpi_comm, ntotal=mpi.size)
giw = result.giw
siw = result.siw

elif cfg["QMC"]["FourPnt"] == 8: # Know that: worm == True and worm_get_sector_index(cfg['QMC']) != 2

Expand Down Expand Up @@ -687,16 +708,11 @@ def bs_diagflat(bs_array):
self.G_tau, self.G_tau_error = w2dyn_ndarray_to_triqs_BlockGF_tau_beta_ntau(
gtau, self.beta, self.gf_struct)

self.G_iw = BlockGf(mesh=self.iw_mesh, gf_struct=self.gf_struct)

### I will use the FFT from triqs here...
for name, g in self.G_tau:
bl_size = g.target_shape[0]
known_moments = np.zeros((4, bl_size, bl_size), dtype=complex)
for i in range(bl_size):
known_moments[1,i,i] = 1
self.G_iw, self.G_iw_error = w2dyn_ndarray_to_triqs_BlockGF_iw_beta_niw(
giw, self.n_iw, self.beta, self.gf_struct)

self.G_iw[name].set_from_fourier(g, known_moments)
Comment on lines -690 to -699
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahausoel Was there any particular reason why you used a Fourier transform instead of using the impurity Green's function from w2dynamics? Do the Legendre tails from w2dynamics pose a problem anywhere?

@HugoStrand What is your opinion on that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Legendre tail are undesirable we could set config["General"]["FTType"] = "plain".

self.Sigma_iw, self.Sigma_iw_error = w2dyn_ndarray_to_triqs_BlockGF_iw_beta_niw(
siw, self.n_iw, self.beta, self.gf_struct)

### add perturbation order as observable
#print 'measure_pert_order ', measure_pert_order
Expand Down
2 changes: 2 additions & 0 deletions test/python/2orb_Discrete_Bath.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
with HDFArchive("2orb_Discrete_Bath.out.h5",'w') as results:
results["G_iw"] = S.G_iw
results["G_tau"] = S.G_tau
results["Sigma_iw"] = S.Sigma_iw

from triqs.utility.h5diff import h5diff
if args.libcxx:
Expand Down Expand Up @@ -151,6 +152,7 @@
with HDFArchive("2orb_Discrete_Bath.delta_interface.out.h5",'w') as results:
results["G_iw"] = S.G_iw
results["G_tau"] = S.G_tau
results["Sigma_iw"] = S.Sigma_iw

if args.libcxx:
h5diff("2orb_Discrete_Bath.libcxx.ref.h5", "2orb_Discrete_Bath.delta_interface.out.h5",
Expand Down
Binary file modified test/python/2orb_Discrete_Bath.ref.h5
Binary file not shown.
2 changes: 2 additions & 0 deletions test/python/SIAM_Discrete_Bath.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
with HDFArchive("SIAM_Discrete_Bath.out.h5",'w') as results:
results["G_iw"] = S.G_iw
results["G_tau"] = S.G_tau
results["Sigma_iw"] = S.Sigma_iw

from triqs.utility.h5diff import h5diff
if args.libcxx:
Expand Down Expand Up @@ -117,6 +118,7 @@
with HDFArchive("SIAM_Discrete_Bath.delta_interface.out.h5",'w') as results:
results["G_iw"] = S.G_iw
results["G_tau"] = S.G_tau
results["Sigma_iw"] = S.Sigma_iw

if args.libcxx:
h5diff("SIAM_Discrete_Bath.libcxx.ref.h5","SIAM_Discrete_Bath.delta_interface.out.h5")
Expand Down
Binary file modified test/python/SIAM_Discrete_Bath.ref.h5
Binary file not shown.
Loading