|
| 1 | +import numpy as np |
| 2 | +from h5 import HDFArchive |
| 3 | + |
| 4 | +from triqs.gf import make_gf_imtime |
| 5 | +from triqs.operators import util |
| 6 | + |
| 7 | +from triqs_ctseg import SolverCore as Solver |
| 8 | + |
| 9 | +# load input data from h5 |
| 10 | +# the input data is generated from the github.com/TRIQS/solid_dmft/tree/3.3.x/test/python/svo_gw_emb_dyn test |
| 11 | +with HDFArchive('dynamic_int_multiorb_input.h5', 'r') as ar: |
| 12 | + delta_tau = ar['delta_tau'] |
| 13 | + chemical_potential = ar['chemical_potential'] |
| 14 | + Uloc_dlr_2idx = ar['Uloc_dlr_2idx'] |
| 15 | + Uloc_dlr_2idx_prime = ar['Uloc_dlr_2idx_prime'] |
| 16 | + Vloc = ar['Vloc'] |
| 17 | + |
| 18 | +# Number of orbitals and time mesh for interaction |
| 19 | +n_orb = Vloc.shape[0] |
| 20 | +n_tau_k = 10001 |
| 21 | + |
| 22 | +# Solver construction parameters |
| 23 | +constr_params = { |
| 24 | + 'gf_struct': [(block, 1) for block in delta_tau.indices], |
| 25 | + 'beta': delta_tau.mesh.beta, |
| 26 | + 'n_tau': len(delta_tau.mesh), |
| 27 | + 'n_tau_k': n_tau_k, |
| 28 | +} |
| 29 | + |
| 30 | +# Construct solver |
| 31 | +S = Solver(**constr_params) |
| 32 | + |
| 33 | +# Hybridization Delta(tau) |
| 34 | +for name, block in S.Delta_tau: |
| 35 | + block << delta_tau[name] |
| 36 | + |
| 37 | +# Interaction Hamiltonian |
| 38 | +Umat, Upmat = util.reduce_4index_to_2index(Vloc) |
| 39 | + |
| 40 | +h_int = util.h_int_density(['down', 'up'], n_orb, off_diag=False, U=Umat, Uprime=Upmat) |
| 41 | + |
| 42 | +# create full frequency interaction on full time mesh |
| 43 | +Uloc_tau_2idx = make_gf_imtime(Uloc_dlr_2idx, n_tau=n_tau_k) |
| 44 | +Uloc_tau_2idx_prime = make_gf_imtime(Uloc_dlr_2idx_prime, n_tau=n_tau_k) |
| 45 | + |
| 46 | +# fill D0_tau from Uloc_tau_2idx and Uloc_tau_2idx_prime |
| 47 | +# same spin interaction |
| 48 | +S.D0_tau[0:n_orb, 0:n_orb] << Uloc_tau_2idx.real |
| 49 | +S.D0_tau[n_orb:2*n_orb, n_orb:2*n_orb] << Uloc_tau_2idx.real |
| 50 | +# opposite spin interaction |
| 51 | +S.D0_tau[0:n_orb, n_orb:2*n_orb] << Uloc_tau_2idx_prime.real |
| 52 | +S.D0_tau[n_orb:2*n_orb, 0:n_orb] << Uloc_tau_2idx_prime.real |
| 53 | + |
| 54 | +# Solve parameters |
| 55 | +solve_params = { |
| 56 | + 'h_int': h_int, |
| 57 | + 'chemical_potential': chemical_potential, |
| 58 | + 'length_cycle': 600, |
| 59 | + 'n_warmup_cycles': 2000, |
| 60 | + 'n_cycles': 40000, |
| 61 | + 'measure_perturbation_order_histograms': True, |
| 62 | + 'measure_statehist': True, |
| 63 | + 'measure_n': True |
| 64 | +} |
| 65 | + |
| 66 | +# Solve |
| 67 | +S.solve(**solve_params) |
| 68 | + |
| 69 | +# very basic check of the results |
| 70 | +ref_occ = np.array([0.1673 for occ in range(2*n_orb)]) |
| 71 | +assert(np.allclose(S.results.densities, ref_occ, atol=1e-2)) |
| 72 | + |
0 commit comments