if use_qn: QN = [sum([n(*mkind("up",o)) for o in orb_names],Operator()), sum([n(*mkind("dn",o)) for o in orb_names],Operator())] for o in orb_names: dn = n(*mkind("up",o)) - n(*mkind("dn",o)) QN.append(dn*dn) p["partition_method"] = "quantum_numbers" p["quantum_numbers"] = QN mpi.report("Constructing the solver...") # Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw) mpi.report("Preparing the hybridization function...") # Set hybridization function delta_w = GfImFreq(indices = [0], beta=beta, n_points=n_iw) delta_w << (V**2) * inverse(iOmega_n - epsilon) + (V**2) * inverse(iOmega_n + epsilon) S.G0_iw << inverse(iOmega_n + mu - delta_w) mpi.report("Running the simulation...") # Solve the problem S.solve(h_int=H, **p) # Save the results if mpi.is_master_node(): with HDFArchive(results_file_name,'w') as Results: Results['G_tau'] = S.G_tau
def anderson(use_qn=True, use_blocks=True): spin_names = ("up","dn") mkind = lambda spin: (spin,0) if use_blocks else ("tot",spin) # Input parameters beta = 10.0 U = 2.0 mu = 1.0 h = 0.1 V = 0.5 epsilon = 2.3 n_iw = 1025 n_tau = 10001 p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 50000 p["n_cycles"] = 5000000 p["measure_density_matrix"] = True p["use_norm_as_weight"] = True results_file_name = "anderson" if use_blocks: results_file_name += ".block" if use_qn: results_file_name += ".qn" results_file_name += ".h5" mpi.report("Welcome to Anderson (1 correlated site + symmetric bath) test.") H = U*n(*mkind("up"))*n(*mkind("dn")) QN = [] if use_qn: for spin in spin_names: QN.append(n(*mkind(spin))) p["quantum_numbers"] = QN p["partition_method"] = "quantum_numbers" gf_struct = {} for spin in spin_names: bn, i = mkind(spin) gf_struct.setdefault(bn,[]).append(i) gf_struct = [ [key, value] for key, value in gf_struct.items() ] # convert from dict to list of lists mpi.report("Constructing the solver...") # Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw) mpi.report("Preparing the hybridization function...") # Set hybridization function delta_w = GfImFreq(indices = [0], beta=beta) delta_w << (V**2) * inverse(iOmega_n - epsilon) + (V**2) * inverse(iOmega_n + epsilon) for spin in spin_names: bn, i = mkind(spin) S.G0_iw[bn][i,i] << inverse(iOmega_n + mu - {'up':h,'dn':-h}[spin] - delta_w) mpi.report("Running the simulation...") # Solve the problem S.solve(h_int=H, **p) # Save the results if mpi.is_master_node(): static_observables = {'Nup' : n(*mkind("up")), 'Ndn' : n(*mkind("dn")), 'unity' : Operator(1.0)} dm = S.density_matrix for oname in static_observables.keys(): print oname, trace_rho_op(dm,static_observables[oname],S.h_loc_diagonalization) with HDFArchive(results_file_name,'w') as Results: Results['G_tau'] = S.G_tau
Delta_iw << inverse( iOmega_n - Ek ) + inverse( iOmega_n + Ek ) Delta_iw.from_L_G_R(V, Delta_iw, V) Delta_tau = Gf(mesh=tmesh, target_shape=target_shape) Delta_tail, Delta_tail_err = Delta_iw.fit_hermitian_tail() Delta_tau << InverseFourier(Delta_iw, Delta_tail) G0_iw = Gf(mesh=wmesh, target_shape=target_shape) G0_iw << inverse( iOmega_n - Delta_iw - E_loc ) S.G0_iw << G0_iw S.solve( h_int = h_int, length_cycle = 10, n_warmup_cycles = 1, n_cycles = 1, ) h_loc_ref = S.h_loc - h_int print 'h_loc =\n', h_loc print 'h_loc_ref =\n', h_loc_ref Delta_tau_ref = S.Delta_tau['0'] Delta_iw_ref = Delta_iw.copy() Delta_tail_ref, Delta_tail_err_ref = Delta_iw_ref.fit_hermitian_tail() Delta_iw_ref << Fourier(Delta_tau_ref, Delta_tail_ref) diff = h_loc - h_loc_ref print 'h_loc diff =', diff
def five_plus_five(use_interaction=True): results_file_name = "5_plus_5." + ("int." if use_interaction else "") + "h5" # Block structure of GF L = 2 # d-orbital spin_names = ("up", "dn") orb_names = cubic_names(L) # Input parameters beta = 40. mu = 26 U = 4.0 J = 0.7 F0 = U F2 = J * (14.0 / (1.0 + 0.63)) F4 = F2 * 0.63 # Dump the local Hamiltonian to a text file (set to None to disable dumping) H_dump = "H.txt" # Dump Delta parameters to a text file (set to None to disable dumping) Delta_dump = "Delta_params.txt" # Hybridization function parameters # Delta(\tau) is diagonal in the basis of cubic harmonics # Each component of Delta(\tau) is represented as a list of single-particle # terms parametrized by pairs (V_k,\epsilon_k). delta_params = { "xy": { 'V': 0.2, 'e': -0.2 }, "yz": { 'V': 0.2, 'e': -0.15 }, "z^2": { 'V': 0.2, 'e': -0.1 }, "xz": { 'V': 0.2, 'e': 0.05 }, "x^2-y^2": { 'V': 0.2, 'e': 0.4 } } atomic_levels = { ('up_xy', 0): -0.2, ('dn_xy', 0): -0.2, ('up_yz', 0): -0.15, ('dn_yz', 0): -0.15, ('up_z^2', 0): -0.1, ('dn_z^2', 0): -0.1, ('up_xz', 0): 0.05, ('dn_xz', 0): 0.05, ('up_x^2-y^2', 0): 0.4, ('dn_x^2-y^2', 0): 0.4 } n_iw = 1025 n_tau = 10001 p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 #p["n_warmup_cycles"] = 5000 p["n_warmup_cycles"] = 500 p["n_cycles"] = int(1.e1 / mpi.size) #p["n_cycles"] = int(5.e5 / mpi.size) #p["n_cycles"] = int(5.e6 / mpi.size) p["partition_method"] = "autopartition" p["measure_G_tau"] = True p["move_shift"] = True p["move_double"] = True p["measure_pert_order"] = False p["performance_analysis"] = False p["use_trace_estimator"] = False mpi.report("Welcome to 5+5 (5 orbitals + 5 bath sites) test.") gf_struct = set_operator_structure(spin_names, orb_names, False) mkind = get_mkind(False, None) H = Operator() if use_interaction: # Local Hamiltonian U_mat = U_matrix(L, [F0, F2, F4], basis='cubic') H += h_int_slater(spin_names, orb_names, U_mat, False, H_dump=H_dump) else: mu = 0. p["h_int"] = H # Quantum numbers (N_up and N_down) QN = [Operator(), Operator()] for cn in orb_names: for i, sn in enumerate(spin_names): QN[i] += n(*mkind(sn, cn)) if p["partition_method"] == "quantum_numbers": p["quantum_numbers"] = QN mpi.report("Constructing the solver...") # Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_tau=n_tau, n_iw=n_iw) mpi.report("Preparing the hybridization function...") H_hyb = Operator() # Set hybridization function if Delta_dump: Delta_dump_file = open(Delta_dump, 'w') for sn, cn in product(spin_names, orb_names): bn, i = mkind(sn, cn) V = delta_params[cn]['V'] e = delta_params[cn]['e'] delta_w = Gf(mesh=MeshImFreq(beta, 'Fermion', n_iw), target_shape=[]) delta_w << (V**2) * inverse(iOmega_n - e) S.G0_iw[bn][i, i] << inverse(iOmega_n + mu - atomic_levels[(bn, i)] - delta_w) cnb = cn + '_b' # bath level a = sn + '_' + cn b = sn + '_' + cn + '_b' H_hyb += ( atomic_levels[(bn,i)] - mu ) * n(a, 0) + \ n(b,0) * e + V * ( c(a,0) * c_dag(b,0) + c(b,0) * c_dag(a,0) ) # Dump Delta parameters if Delta_dump: Delta_dump_file.write(bn + '\t') Delta_dump_file.write(str(V) + '\t') Delta_dump_file.write(str(e) + '\n') if mpi.is_master_node(): filename_ham = 'data_Ham%s.h5' % ('_int' if use_interaction else '') with HDFArchive(filename_ham, 'w') as arch: arch['H'] = H_hyb + H arch['gf_struct'] = gf_struct arch['beta'] = beta mpi.report("Running the simulation...") # Solve the problem S.solve(**p) # Save the results if mpi.is_master_node(): Results = HDFArchive(results_file_name, 'w') Results['G_tau'] = S.G_tau Results['G0_iw'] = S.G0_iw Results['use_interaction'] = use_interaction Results['delta_params'] = delta_params Results['spin_names'] = spin_names Results['orb_names'] = orb_names import __main__ Results.create_group("log") log = Results["log"] log["version"] = version.version log["triqs_hash"] = version.triqs_hash log["cthyb_hash"] = version.cthyb_hash log["script"] = inspect.getsource(__main__)
delta_w = GfImFreq(indices=[0], beta=cp['beta']) delta_w << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in solver.G0_iw: g0 << inverse(iOmega_n + mu - delta_w) sp = dict( h_int=n('up', 0) * n('do', 0) + c_dag('up', 0) * c('do', 0) + c_dag('do', 0) * c('up', 0), max_time=-1, length_cycle=50, n_warmup_cycles=50, n_cycles=500, move_double=False, ) solver.solve(**sp) filename = 'h5_read_write.h5' with HDFArchive(filename, 'w') as A: A['solver'] = solver with HDFArchive(filename, 'r') as A: solver_ref = A['solver'] assert (solver.last_constr_parameters == solver_ref.last_constr_parameters) assert (solver.last_solve_parameters == solver.last_solve_parameters) #assert( solver.last_container_set == solver_ref.last_container_set ) # want to write this # -- Poor mans version of comparison of the container sets for key in dir(solver_ref):
def run_calculation(use_qn=True): # Input parameters beta = 10.0 U = 2.0 mu = 1.0 epsilon = 2.3 t = 0.1 n_iw = 1025 n_tau = 10001 p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 20000 p["n_cycles"] = 1000000 results_file_name = "spinless" if use_qn: results_file_name += ".qn" results_file_name += ".h5" mpi.report( "Welcome to spinless (spinless electrons on a correlated dimer) test.") H = U * n("tot", "A") * n("tot", "B") QN = [] if use_qn: QN.append(n("tot", "A") + n("tot", "B")) p["partition_method"] = "quantum_numbers" p["quantum_numbers"] = QN gf_struct = [["tot", ["A", "B"]]] mpi.report("Constructing the solver...") ## Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_iw=n_iw, n_tau=n_tau) mpi.report("Preparing the hybridization function...") ## Set hybridization function delta_w = GfImFreq(indices=["A", "B"], beta=beta) delta_w << inverse(iOmega_n - np.array([[epsilon, -t], [-t, epsilon]]) ) + inverse(iOmega_n - np.array([[-epsilon, -t], [-t, -epsilon]])) S.G0_iw["tot"] << inverse(iOmega_n - np.array([[-mu, -t], [-t, -mu]]) - delta_w) mpi.report("Running the simulation...") ## Solve the problem S.solve(h_int=H, **p) ## Save the results if mpi.is_master_node(): with HDFArchive(results_file_name, 'w') as Results: Results["tot"] = S.G_tau["tot"]
mpi.report("Preparing the hybridization function...") # Set hybridization function delta_w = GfImFreq(indices=orb_names, beta=beta, n_points=n_iw) delta_w_part = delta_w.copy() for e, v in zip(epsilon, V): delta_w_part << inverse(iOmega_n - e) delta_w_part.from_L_G_R(np.transpose(v), delta_w_part, v) delta_w += delta_w_part S.G0_iw << inverse(iOmega_n + mu - delta_w) # Accumulate histograms and G_tau mpi.report("Preliminary run...") S.solve(h_int=H, **p_pre) if mpi.is_master_node(): with HDFArchive("data_measure_g2.h5", 'w') as ar: ar['beta'] = beta ar['U'] = U ar['mu'] = mu ar['J'] = J ar['epsilon'] = epsilon ar['V'] = V ar['G_tau'] = S.G_tau ar['pre_solve_params'] = p_pre if preliminary_only: exit() # Accumulate G2
p = None p = mpi.bcast(p) S = SolverCore(beta=p.beta, gf_struct=p.gf_struct, n_tau=p.ntau, n_iw=p.nw) S.G0_iw['0'] << p.g0t_iw solve_parameters = dict( h_int=p.Ht_int, max_time=-1, random_name="", random_seed=123 * mpi.rank + 567, length_cycle=100, n_warmup_cycles=int(1e4), #n_cycles = int(1e9) / mpi.size, n_cycles=int(1e7) / mpi.size, move_double=True, measure_G2_iw_ph=True, measure_G2_n_fermionic=10, measure_G2_n_bosonic=1, ) S.solve(**solve_parameters) if mpi.is_master_node(): p.g_tau = S.G_tau p.g0_iw = S.G0_iw p.g4_ph = S.G2_iw_ph[('0', '0')] with HDFArchive('data_cthyb.h5', 'w') as A: A['p'] = p