def assertH5FileEqual(self, file1, file2): """ Compares two files using difflib. Empty lines are ignored. Files are assumed to be relatively small; the data is truncated for files larger than MAX_SIZE bytes. """ try: h5diff(file1, file2, precision=1e-6) except RuntimeError as err: if "FAILED" in err: return self.fail("Files '%s' and '%s' differ"%(file1, file2))
p["move_double"] = False p["use_norm_as_weight"] = True p["measure_density_matrix"] = True H = U*n("up",1)*n("dn",1) + U*n("up",2)*n("dn",2) H = H + 0.5*h*(n("up",1) - n("dn",1)) + 0.5*h*(n("up",2) - n("dn",2)) # Construct the solver S = Solver(beta=beta, gf_struct={"up":[1,2], "dn":[1,2]}, n_tau=n_tau, n_iw=n_iw) # Set hybridization function delta_w = GfImFreq(indices = [1,2], beta=beta) delta_w << (V**2)*(inverse(iOmega_n - epsilon) + inverse(iOmega_n + epsilon)) for bn, g in S.G0_iw: g << inverse(iOmega_n - np.matrix([[-mu,t],[t,-mu]]) - delta_w) # Solve! S.solve(h_int=H, **p) if mpi.is_master_node(): # Measure expectation values dm = S.density_matrix static_observables = {"N1_up" : n("up",1), "N1_dn" : n("dn",1), "N2_up" : n("up",2), "N2_dn" : n("dn",2)} with HDFArchive('measure_static.out.h5','w') as ar: for name,op in static_observables.iteritems(): ave = trace_rho_op(dm,op,S.h_loc_diagonalization) ar[name] = ave from pytriqs.utility.h5diff import h5diff h5diff("measure_static.out.h5","measure_static.ref.h5")
# Global moves gm = {} gm['flip_spins'] = { ("up", 0): ("dn", 0), ("dn", 0): ("up", 0), ("up", 1): ("dn", 1), ("dn", 1): ("up", 1) } gm['swap_orbs'] = { ("up", 0): ("up", 1), ("up", 1): ("up", 0), ("dn", 0): ("dn", 1), ("dn", 1): ("dn", 0) } p["move_global"] = gm p["move_global_prob"] = 0.06 S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("move_global.out.h5", 'w') as Results: Results["G_tau"] = S.G_tau if mpi.is_master_node(): with HDFArchive("move_global.ref.h5", 'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) from pytriqs.utility.h5diff import h5diff h5diff("move_global.out.h5", "move_global.ref.h5")
from pytriqs.applications.dft.converters.wien2k_converter import * from pytriqs.operators.util import set_operator_structure from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff # Basic input parameters beta = 40 # Init the SumK class SK=SumkDFT(hdf_file='SrVO3.h5',use_dft_blocks=True) num_orbitals = SK.corr_shells[0]['dim'] l = SK.corr_shells[0]['l'] spin_names = ['up','down'] orb_names = ['%s'%i for i in range(num_orbitals)] orb_hybridized = False gf_struct = set_operator_structure(spin_names,orb_names,orb_hybridized) glist = [ GfImFreq(indices=inner,beta=beta) for block,inner in gf_struct.iteritems()] Sigma_iw = BlockGf(name_list = gf_struct.keys(), block_list = glist, make_copies = False) SK.set_Sigma([Sigma_iw]) Gloc = SK.extract_G_loc() if mpi.is_master_node(): with HDFArchive('srvo3_Gloc.out.h5','w') as ar: ar['Gloc'] = Gloc[0] if mpi.is_master_node(): h5diff("srvo3_Gloc.out.h5","srvo3_Gloc.ref.h5")
# Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.archive import * from triqs_dft_tools.sumk_dft_tools import SumkDFTTools import pytriqs.utility.mpi as mpi from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff SK = SumkDFTTools(hdf_file = 'SrVO3.h5') dm = SK.density_matrix(method = 'using_gf', beta = 40) dm_pc = SK.partial_charges(beta=40,with_Sigma=False,with_dc=False) with HDFArchive('sumkdft_basic.out.h5','w') as ar: ar['dm'] = dm ar['dm_pc'] = dm_pc if mpi.is_master_node(): h5diff('sumkdft_basic.out.h5','sumkdft_basic.ref.h5')
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # from __future__ import print_function from pytriqs.utility.h5diff import h5diff from dcore.dcore_pre import dcore_pre # # Execute dcore_pre.py to generate test.h5 # Then Check the Diff of test.h5 and the reference output (stan_ref.h5)) # with open("nis.ini", 'w') as f: print("[model]", file=f) print("lattice = wannier90", file=f) print("seedname = nis", file=f) print("nelec = 24.0", file=f) print("ncor = 2", file=f) print("norb = [5, 5]", file=f) print("interaction = slater_uj", file=f) print("slater_uj = [(2, 1.0, 0.0), (2, 1.0, 0.0)]", file=f) print("", file=f) print("[system]", file=f) print("nk0 = 4", file=f) print("nk1 = 4", file=f) print("nk2 = 3", file=f) dcore_pre("nis.ini") h5diff("nis.h5", "nis_ref.h5")
p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 500 p["n_warmup_cycles"] = 5000 p["n_cycles"] = 5000 p["measure_g_l"] = True p["move_double"] = False p["perform_tail_fit"] = True p["fit_max_moment"] = 2 S.solve(h_int=H, **p) # Calculation is done. Now save a few things if mpi.is_master_node(): with HDFArchive("single_site_bethe.out.h5", 'w') as Results: Results["Sigma_iw"] = S.Sigma_iw Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l # Check against reference if mpi.is_master_node(): with HDFArchive("single_site_bethe.ref.h5", 'r') as Results: assert_block_gfs_are_close(Results["Sigma_iw"], S.Sigma_iw) assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_iw"], S.G_iw) assert_block_gfs_are_close(Results["G_l"], S.G_l) # Redondant with previous check from pytriqs.utility.h5diff import h5diff h5diff("single_site_bethe.out.h5", "single_site_bethe.ref.h5")
p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 1000 p["n_cycles"] = 5000 p["measure_g_tau"] = True p["measure_g_l"] = False p["move_double"] = False # Global moves gm = {} gm['flip_spins'] = {("up",0) : ("dn",0), ("dn",0) : ("up",0), ("up",1) : ("dn",1), ("dn",1) : ("up",1)} gm['swap_orbs'] = {("up",0) : ("up",1), ("up",1) : ("up",0), ("dn",0) : ("dn",1), ("dn",1) : ("dn",0)} p["move_global"] = gm p["move_global_prob"] = 0.06 S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("move_global.out.h5",'w') as Results: Results["G_tau"] = S.G_tau if mpi.is_master_node(): with HDFArchive("move_global.ref.h5",'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) from pytriqs.utility.h5diff import h5diff h5diff("move_global.out.h5","move_global.ref.h5")
delta_w = GfImFreq(indices=orb_names, beta=beta) delta_w << inverse(iOmega_n - epsilon) + inverse(iOmega_n + epsilon) delta_w.from_L_G_R(V, delta_w, V) S.G0_iw << inverse(iOmega_n + mu - delta_w) # Parameters p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 50 p["n_cycles"] = 5000 p["measure_g_l"] = True p["move_double"] = False S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("kanamori.out.h5", 'w') as Results: Results["G_tau"] = S.G_tau Results["G_leg"] = S.G_l if mpi.is_master_node(): with HDFArchive("kanamori.ref.h5", 'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_leg"], S.G_l) from pytriqs.utility.h5diff import h5diff h5diff("kanamori.out.h5", "kanamori.ref.h5")
delta_w = GfImFreq(indices = orb_names, beta=beta) delta_w << inverse(iOmega_n - epsilon) + inverse(iOmega_n + epsilon) delta_w.from_L_G_R(V, delta_w, V) S.G0_iw << inverse(iOmega_n + mu - delta_w) # Parameters p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 50 p["n_cycles"] = 5000 p["measure_g_l"] = True p["move_double"] = False S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("kanamori.out.h5",'w') as Results: Results["G_tau"] = S.G_tau Results["G_leg"] = S.G_l if mpi.is_master_node(): with HDFArchive("kanamori.ref.h5",'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_leg"], S.G_l) from pytriqs.utility.h5diff import h5diff h5diff("kanamori.out.h5","kanamori.ref.h5")
# Block structure of GF gf_struct = set_operator_structure(spin_names,cubic_names,False) # Local Hamiltonian H = h_int_slater(spin_names,cubic_names,U_mat,False) # Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_iw=1025, n_tau=100000) # Set hybridization function delta_w = GfImFreq(indices = [0], beta=beta) delta_w << (half_bandwidth/2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - delta_w) S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("slater.out.h5",'w') as Results: Results["G_tau"] = S.G_tau Results["G_leg"] = S.G_l if mpi.is_master_node(): with HDFArchive("slater.ref.h5",'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_leg"], S.G_l) from pytriqs.utility.h5diff import h5diff h5diff("slater.out.h5","slater.ref.h5")
#!/usr/bin/env python from triqs_hubbardi import * from pytriqs.archive import * from pytriqs.gf import * from pytriqs.operators import * from pytriqs.utility.h5diff import h5diff D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U / 2.0, 50 S = Solver(beta=beta, gf_struct=[('up', [0]), ('down', [0])], n_iw=5, n_tau=2, n_w=2, n_l=5) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) S.solve(h_int=U * n('up', 0) * n('down', 0), calc_gl=True) with HDFArchive("aim_l.h5", 'w') as A: A["G_l"] = S.G_l h5diff('aim_l.h5', 'aim_l.ref.h5')
from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff # Basic input parameters beta = 40 # Init the SumK class SK = SumkDFT(hdf_file='SrVO3.h5', use_dft_blocks=True) num_orbitals = SK.corr_shells[0]['dim'] l = SK.corr_shells[0]['l'] spin_names = ['up', 'down'] orb_names = ['%s' % i for i in range(num_orbitals)] orb_hybridized = False gf_struct = set_operator_structure(spin_names, orb_names, orb_hybridized) glist = [GfImFreq(indices=inner, beta=beta) for block, inner in gf_struct] Sigma_iw = BlockGf(name_list=[block for block, inner in gf_struct], block_list=glist, make_copies=False) SK.set_Sigma([Sigma_iw]) Gloc = SK.extract_G_loc() if mpi.is_master_node(): with HDFArchive('srvo3_Gloc.out.h5', 'w') as ar: ar['Gloc'] = Gloc[0] if mpi.is_master_node(): h5diff("srvo3_Gloc.out.h5", "srvo3_Gloc.ref.h5")
# Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola # # TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.archive import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi from triqs_dft_tools.converters import * Converter = HkConverter(filename='hk_convert_hamiltonian.hk',hdf_filename='hk_convert.out.h5') Converter.convert_dft_input() if mpi.is_master_node(): h5diff("hk_convert.out.h5","hk_convert.ref.h5")
[ 0.0-0.1j ,-0.2+0.j , 0.1+0.j , 0.5+0.j ], [ 0.5+0.j , 0.1+0.j , 0.0+0.j , 0.0+0.j ], [ 0.1+0.j , 0.5+0.j , 0.0+0.j , 0.0+0.j ]] H_matrix = np.array(H_matrix) # fops for the AtomDiag solver fops = [] for i in range(H_matrix.shape[0]): fops.append(('ud',i)) H = Operator() for i in range(H_matrix.shape[0]): for j in range(H_matrix.shape[1]): H += H_matrix[i,j] * c_dag('ud',i)*c('ud',j) # interaction term between the 1st and 2nd orbital H+=3*n('ud',0)*n('ud',1) S = AtomDiag(H,fops) G_tau = atomic_gf(S,beta=10,indices_list={'ud':range(4)},n_tau=41) with HDFArchive('atomdiag_ed.out.h5','w') as ar: ar['G_tau']=G_tau from pytriqs.utility.h5diff import h5diff # the reference solution was checked against an external ED result h5diff('atomdiag_ed.ref.h5','atomdiag_ed.out.h5')
[0.1 + 0.j, 0.5 + 0.j, 0.0 + 0.j, 0.0 + 0.j]] H_matrix = np.array(H_matrix) # fops for the AtomDiag solver fops = [] for i in range(H_matrix.shape[0]): fops.append(('ud', i)) H = Operator() for i in range(H_matrix.shape[0]): for j in range(H_matrix.shape[1]): H += H_matrix[i, j] * c_dag('ud', i) * c('ud', j) # interaction term between the 1st and 2nd orbital H += 3 * n('ud', 0) * n('ud', 1) S = AtomDiag(H, fops) G_tau = atomic_g_tau(S, beta=10, gf_struct={'ud': range(4)}, n_tau=41) # -- The reference data only have first order tail info G_tau['ud'].singularity *= 0. G_tau['ud'].singularity[1] = np.eye(4) with HDFArchive('atomdiag_ed.out.h5', 'w') as ar: ar['G_tau'] = G_tau from pytriqs.utility.h5diff import h5diff # the reference solution was checked against an external ED result h5diff('atomdiag_ed.ref.h5', 'atomdiag_ed.out.h5')
#!/usr/bin/env python from triqs_hubbardi import * from pytriqs.archive import * from pytriqs.gf import * from pytriqs.operators import * from pytriqs.utility.h5diff import h5diff D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U / 2.0, 50 S = Solver(beta=beta, gf_struct=[('up', [0]), ('down', [0])], n_iw=20, n_tau=2, n_w=2) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) S.solve(h_int=U * n('up', 0) * n('down', 0), n_iw=20, n_tau=2, n_w=2) with HDFArchive("aim_matsubara.h5", 'w') as A: A["G_iw"] = S.G_iw with HDFArchive("aim_matsubara.ref.h5", 'r') as A: Giw_read = A["G_iw"] h5diff('aim_matsubara.h5', 'aim_matsubara.ref.h5')
Results["Delta_tau"] = S.Delta_tau Results["G0_iw"] = S.G0_iw Results["G_tau"] = S.G_tau Results["G_l"] = S.G_l Results["G_iw"] = S.G_iw Results["G_iw_raw"] = S.G_iw_raw Results["Sigma_iw"] = S.Sigma_iw Results["Sigma_iw_raw"] = S.Sigma_iw_raw # Check against reference if mpi.is_master_node(): with HDFArchive("single_site_bethe.ref.h5",'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_l"], S.G_l) assert_block_gfs_are_close(Results["G_iw_raw"], S.G_iw_raw) assert_block_gfs_are_close(Results["Sigma_iw_raw"], S.Sigma_iw_raw, precision=5e-5) assert_block_gfs_are_close(Results["Sigma_iw"], S.Sigma_iw) assert_block_gfs_are_close(Results["G_iw"], S.G_iw) # Redundant with previous check from pytriqs.utility.h5diff import h5diff h5diff("single_site_bethe.out.h5","single_site_bethe.ref.h5", precision=5e-5)
epsilon2 = 4.0 mu = 2.0 for name, g0 in solv.G0_iw: g0 << inverse(iOmega_n + mu - V1**2*inverse(iOmega_n - epsilon1) - V2**2*inverse(iOmega_n - epsilon2) ) # -- Solve the impurity model solv.solve( h_int = 5.0*n('up',0)*n('do',0), measure_G_tau = True, move_double = True, # -- measurements length_cycle = 20, n_warmup_cycles = int(1e4), n_cycles = int(1e4), # -- measure density-density correlator measure_O_tau = (n('up',0), n('do',0)), ) # -- Store results filename = 'O_tau_ins.out.h5' with HDFArchive(filename, 'w') as res: res['O_tau'] = solv.O_tau h5diff(filename, 'O_tau_ins.ref.h5')
# # DCore -- Integrated DMFT software for correlated electrons # Copyright (C) 2017 The University of Tokyo # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # from __future__ import print_function from pytriqs.utility.h5diff import h5diff from pytriqs.applications.dcore.dcore import dcore dcore('dmft.ini') h5diff("test.out.h5", "test_ref.out.h5")
from pytriqs.utility.h5diff import h5diff import pytriqs.operators.util as op # General parameters beta = 200.0 # Inverse temperature l = 2 # Angular momentum n_orbs = 2*l + 1 # Number of orbitals U = 6.0 # Screened Coulomb interaction J = 0.6 # Hund's coupling half_bandwidth = 1.0 # Half bandwidth mu = 1.0 # Chemical potential spin_names = ['up','down'] # Outer (non-hybridizing) blocks orb_names = ['%s'%i for i in range(n_orbs)] # Orbital indices off_diag=True gf_struct = op.set_operator_structure(spin_names,orb_names,off_diag=off_diag) U_mat = op.U_matrix(l=l, U_int=U, J_hund=J, basis='spherical') H = op.h_int_slater(spin_names,orb_names,U_mat,off_diag=off_diag) S = Solver(beta=beta, gf_struct=gf_struct, n_iw = 1025) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu) S.solve(h_int=H) with HDFArchive("hubbard.h5",'w') as A: A["G"] = S.G_iw A["Sigma"] = S.Sigma_iw print h5diff("hubbard.h5", "hubbard.ref.h5")
from numpy import * from triqs_dft_tools.converters.wien2k_converter import * from triqs_dft_tools.sumk_dft import * from triqs_dft_tools.sumk_dft_tools import * from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff beta = 40 Converter = Wien2kConverter(filename='SrVO3', repacking=True) Converter.convert_dft_input() Converter.convert_transport_input() SK = SumkDFTTools(hdf_file='SrVO3.h5', use_dft_blocks=True) with HDFArchive('SrVO3_Sigma.h5', 'a') as ar: Sigma = ar['dmft_transp_input']['Sigma_w'] SK.set_Sigma([Sigma]) SK.chemical_potential = ar['dmft_transp_input']['chemical_potential'] SK.dc_imp = ar['dmft_transp_input']['dc_imp'] SK.transport_distribution(directions=['xx'], broadening=0.0, energy_window=[-0.3,0.3], Om_mesh=[0.00, 0.02] , beta=beta, with_Sigma=True) #SK.save(['Gamma_w','Om_meshr','omega','directions']) #SK.load(['Gamma_w','Om_meshr','omega','directions']) SK.conductivity_and_seebeck(beta=beta) SK.hdf_file = 'srvo3_transp.out.h5' SK.save(['seebeck','optic_cond','kappa']) if mpi.is_master_node(): h5diff("srvo3_transp.out.h5","srvo3_transp.ref.h5")
#!/usr/bin/env python from triqs_hubbardi import * from pytriqs.archive import * from pytriqs.gf import * from pytriqs.operators import * from pytriqs.utility.h5diff import h5diff D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U / 2.0, 50 S = Solver(beta=beta, gf_struct=[('up', [0]), ('down', [0])], n_iw=5, n_tau=30, n_w=2) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) S.solve(h_int=U * n('up', 0) * n('down', 0), calc_gtau=True) with HDFArchive("aim_tau.h5", 'w') as A: A["G_tau"] = S.G_tau h5diff('aim_tau.h5', 'aim_tau.ref.h5')
# # Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola # # TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from triqs_dft_tools.converters import * from pytriqs.archive import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi Converter = Wannier90Converter(seedname='LaVO3-Pnma',hdf_filename='w90_convert.out.h5') Converter.convert_dft_input() if mpi.is_master_node(): h5diff("w90_convert.out.h5","w90_convert.ref.h5")
# # Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola # # TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.applications.dft.converters import * from pytriqs.archive import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi Converter = Wannier90Converter(seedname='LaVO3-Pnma', hdf_filename='w90_convert.out.h5') Converter.convert_dft_input() if mpi.is_master_node(): h5diff("w90_convert.out.h5", "w90_convert.ref.h5")
# TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.archive import * from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi from triqs_dft_tools.converters import Wien2kConverter Converter = Wien2kConverter(filename='SrVO3') Converter.hdf_file = 'wien2k_convert.out.h5' Converter.convert_dft_input() Converter.convert_parproj_input() if mpi.is_master_node(): h5diff('wien2k_convert.out.h5', 'wien2k_convert.ref.h5')
p["length_cycle"] = 500 p["n_warmup_cycles"] = 5000 p["n_cycles"] = 5000 p["measure_g_l"] = True p["move_double"] = False p["perform_tail_fit"] = True p["fit_max_moment"] = 2 S.solve(h_int=H, **p) # Calculation is done. Now save a few things if mpi.is_master_node(): with HDFArchive("single_site_bethe.out.h5",'w') as Results: Results["Sigma_iw"] = S.Sigma_iw Results["G_tau"] = S.G_tau Results["G_iw"] = S.G_iw Results["G_l"] = S.G_l # Check against reference if mpi.is_master_node(): with HDFArchive("single_site_bethe.ref.h5",'r') as Results: assert_block_gfs_are_close(Results["Sigma_iw"], S.Sigma_iw) assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_iw"], S.G_iw) assert_block_gfs_are_close(Results["G_l"], S.G_l) # Redondant with previous check from pytriqs.utility.h5diff import h5diff h5diff("single_site_bethe.out.h5","single_site_bethe.ref.h5")
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # from __future__ import print_function from pytriqs.utility.h5diff import h5diff from dcore.dcore_pre import dcore_pre # # Execute dcore_pre.py to generate test.h5 # Then Check the Diff of test.h5 and the reference output (stan_ref.h5)) # with open("dmft.ini", 'w') as f: print("[model]", file=f) print("lattice = wannier90", file=f) print("seedname = chain", file=f) print("nelec = 5.0", file=f) print("ncor = 2", file=f) print("norb = 6, 8", file=f) print("kanamori = [(3.0, 2.0, 0.5), (5.0, 3.0, 1.0)]", file=f) print("spin_orbit = True", file=f) print("", file=f) print("[system]", file=f) print("nk0 = 40", file=f) print("nk1 = 1", file=f) print("nk2 = 1", file=f) dcore_pre("dmft.ini") h5diff("chain.h5", "chain_ref.h5")
delta_w = GfImFreq(indices=orb_names, beta=beta) delta_w << inverse(iOmega_n - epsilon) + inverse(iOmega_n + epsilon) delta_w.from_L_G_R(V, delta_w, V) S.G0_iw << inverse(iOmega_n + mu - delta_w) # Parameters p = {} p["max_time"] = -1 p["random_name"] = "" p["random_seed"] = 123 * mpi.rank + 567 p["length_cycle"] = 50 p["n_warmup_cycles"] = 50 p["n_cycles"] = 5000 p["measure_G_l"] = True p["move_double"] = False S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("kanamori_py.out.h5", 'w') as Results: Results["G_tau"] = S.G_tau Results["G_leg"] = S.G_l if mpi.is_master_node(): with HDFArchive("kanamori_py.ref.h5", 'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_leg"], S.G_l) from pytriqs.utility.h5diff import h5diff h5diff("kanamori_py.out.h5", "kanamori_py.ref.h5")
#!/usr/bin/env python from triqs_hubbardi import * from pytriqs.archive import * from pytriqs.gf import * from pytriqs.operators import * from pytriqs.utility.h5diff import h5diff D, V, U = 1.0, 0.2, 4.0 e_f, beta = -U/2.0, 50 S = Solver(beta = beta, gf_struct = [ ('up',[0]), ('down',[0]) ],n_iw=5,n_tau=2,n_w=20) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n - e_f - V**2 * Wilson(D)) S.solve(h_int = U * n('up',0) * n('down',0),calc_gw=True ) with HDFArchive("aim_w.h5",'w') as A: A["G_w"] = S.G_w h5diff('aim_w.h5', 'aim_w.ref.h5')
the test was created, which were checked against the ED result. The data from the ED solver can be found in the file complex_Gtau_ED.bench.h5 for future reference. """ # the Hamiltonian of the system # the first two orbitals are the impurity, the other two are the bath H_mat = np.array([[-0.2, 0.1j, 0.5, 0.1], [-0.1j, -0.3, 0.1, 0.5], [0.5, 0.1, 0.1, 0.0], [0.1, 0.5, 0.0, 0.0]]) corr_dim = 2 G0_iw = GfImFreq(beta=10, indices=range(len(H_mat)), n_points=101) G0_iw << inverse(iOmega_n - H_mat) H_int = 3 * n("ud", 0) * n("ud", 1) p = {} p["random_seed"] = 123 p["length_cycle"] = 100 p["n_warmup_cycles"] = 1000 p["n_cycles"] = 5000 S = Solver(beta=10, gf_struct={"ud": range(corr_dim)}, n_tau=203, n_iw=101) S.G0_iw << G0_iw[:corr_dim, :corr_dim] S.solve(h_int=H_int, **p) with HDFArchive("complex_Gtau_ED.out.h5", "w") as ar: ar["G_tau"] = S.G_tau h5diff("complex_Gtau_ED.ref.h5", "complex_Gtau_ED.out.h5")
# Block structure of GF gf_struct = set_operator_structure(spin_names, cubic_names, False) # Local Hamiltonian H = h_int_slater(spin_names, cubic_names, U_mat, False) # Construct the solver S = SolverCore(beta=beta, gf_struct=gf_struct, n_iw=1025, n_tau=100000) # Set hybridization function delta_w = GfImFreq(indices=[0], beta=beta) delta_w << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - delta_w) S.solve(h_int=H, **p) if mpi.is_master_node(): with HDFArchive("slater.out.h5", 'w') as Results: Results["G_tau"] = S.G_tau Results["G_leg"] = S.G_l if mpi.is_master_node(): with HDFArchive("slater.ref.h5", 'r') as Results: assert_block_gfs_are_close(Results["G_tau"], S.G_tau) assert_block_gfs_are_close(Results["G_leg"], S.G_l) from pytriqs.utility.h5diff import h5diff h5diff("slater.out.h5", "slater.ref.h5")
# TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.archive import * from pytriqs.utility.comparison_tests import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi from triqs_dft_tools.converters import Wien2kConverter Converter = Wien2kConverter(filename='SrVO3') Converter.hdf_file = 'wien2k_convert.out.h5' Converter.convert_dft_input() Converter.convert_parproj_input() if mpi.is_master_node(): h5diff('wien2k_convert.out.h5','wien2k_convert.ref.h5')
# # Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola # # TRIQS is free software: you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation, either version 3 of the License, or (at your option) any later # version. # # TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # TRIQS. If not, see <http://www.gnu.org/licenses/>. # ################################################################################ from pytriqs.applications.dft.converters import * from pytriqs.archive import * from pytriqs.utility.h5diff import h5diff import pytriqs.utility.mpi as mpi Converter = HkConverter(filename='hk_convert_hamiltonian.hk',hdf_filename='hk_convert.out.h5') Converter.convert_dft_input() if mpi.is_master_node(): h5diff("hk_convert.out.h5","hk_convert.ref.h5")
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. # from __future__ import print_function from dcore.dcore_pre import dcore_pre from pytriqs.utility.h5diff import h5diff # # Execute dcore_pre.py to generate test.h5 # Then Check the Diff of test.h5 and the reference output (stan_ref.h5)) # for lattice in ['bethe', 'chain', 'square', 'cubic']: input_fname = 'stan_' + lattice + '.in' seedname = 'stan_test_' + lattice seedname_ref = 'stan_ref_' + lattice with open(input_fname, 'w') as f: print("[model]", file=f) print("t = 1.0", file=f) print("kanamori = [(4.0,0.0,0.0)]", file=f) print("lattice = ", lattice, file=f) print("seedname = " + seedname, file=f) dcore_pre(input_fname) h5diff(seedname + ".h5", seedname_ref + ".h5")
""" # the Hamiltonian of the system # the first two orbitals are the impurity, the other two are the bath H_mat = np.array([[-0.2 , 0.1j , 0.5 , 0.1 ], [-0.1j ,-0.3 , 0.1 , 0.5 ], [ 0.5 , 0.1 , 0.1 , 0.0 ], [ 0.1 , 0.5 , 0.0 , 0.0 ]]) corr_dim = 2 G0_iw = GfImFreq(beta=10,indices=range(len(H_mat)),n_points=101) G0_iw << inverse(iOmega_n - H_mat) H_int = 3*n("ud",0)*n("ud",1) p = {} p["random_seed"] = 123 p["length_cycle"] = 100 p["n_warmup_cycles"] = 1000 p["n_cycles"] = 5000 S = Solver(beta=10,gf_struct={"ud":range(corr_dim)},n_tau=203,n_iw=101) S.G0_iw << G0_iw[:corr_dim,:corr_dim] S.solve(h_int=H_int,**p) with HDFArchive("complex_Gtau_ED.out.h5","w") as ar: ar["G_tau"]=S.G_tau h5diff("complex_Gtau_ED.ref.h5","complex_Gtau_ED.out.h5")
delta_iw = GfImFreq(indices=[0], beta=beta, mesh=S.G_iw.mesh) delta_iw << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - delta_iw) g_iw = GfImFreq(indices=[0], beta=beta, mesh=S.G_iw.mesh) for name, g0 in S.G0_iw: g0 << inverse(iOmega_n + mu - (half_bandwidth / 2.0)**2 * g_iw) S.solve(h_int=H) with HDFArchive("bethe5.h5", 'w') as A: A["G_iw"] = S.G_iw with HDFArchive("bethe5.ref.h5", 'r') as A: Giw_read = A["G_iw"] h5diff('bethe5.h5', 'bethe5.ref.h5') # this can be reproduced with the triqs 1.4 Hubbard-I solver with the following script: #from pytriqs.applications.impurity_solvers.hubbard_I import Solver #import numpy #S = Solver(beta = 40, l=2) #eal={} #eal['up'] = -25.0*numpy.identity(5) #eal['down'] = -25.0*numpy.identity(5) #S.set_atomic_levels(eal=eal) #S.solve(U_int = 4.0, J_hund=1.0) # # S.G then contains the greens function on matsubara, such that