def test_k_space_path(self): units = np.array([[1.0, 1.0, 0.0], [0.5, 0.0, 0.5], [0., 1.5, 1.5]]) bl = BravaisLattice(units=units) bz = BrillouinZone(bl) Gamma = np.array([0.0, 0.0, 0.0]) M = np.array([0.5, 0.5, 0.0]) R = np.array([0.5, 0.5, 0.5]) X = np.array([0.5, 0.0, 0.0]) Z = np.array([0.0, 0.0, 0.5]) # ---- num = 101 paths = [(Gamma, M), (M, R), (X, Z)] kvecs, dist = k_space_path(paths, num=num, bz=bz) dist_cmp_exact = [0.] for n, (ki, kf) in enumerate(paths): dk = kf - ki kvec = kvecs[n * num:(n + 1) * num] kvec_exact = ki[None, :] + np.linspace(0, 1, num)[:, None] * dk[None, :] self.assertTrue(np.array_equal(kvec, kvec_exact)) dd = np.linalg.norm(np.dot(dk, bz.units)) dist_cmp_exact.append(dd + dist_cmp_exact[-1]) dist_cmp = np.concatenate((dist[0:1], dist[num - 1::num])) self.assertTrue(np.array_equal(dist_cmp, dist_cmp_exact))
def test_TBLattice(self): tbl = TBLattice(units=self.units, hoppings=self.hoppings, orbital_positions=self.orbital_positions, orbital_names=self.orbital_names) print(tbl) self.assertEqual(list(self.hoppings.keys()), list(tbl.hoppings.keys())) self.assertTrue( all( map(np.array_equal, self.hoppings.values(), tbl.hoppings.values()))) # Make sure manual BravaisLattice / TightBinding / BrillouinZone # construction yields same objects bl = BravaisLattice(self.units, self.orbital_positions, self.orbital_names) bz = BrillouinZone(bl) tb = TightBinding(bl, self.hoppings) self.assertEqual(bl, tbl.bl) self.assertEqual(bz, tbl.bz) self.assertEqual(tb, tbl.tb) # Test H5 Read / Write with HDFArchive("tbl.h5", 'w') as arch: arch['tbl'] = tbl with HDFArchive("tbl.h5", 'r') as arch: tbl_read = arch['tbl'] self.assertEqual(tbl, tbl_read)
def solve_lattice_bse(parm, momsus=False): print('--> solve_lattice_bse') print('nw =', parm.nw) print('nwf =', parm.nwf) # ------------------------------------------------------------------ # -- Setup lattice bl = BravaisLattice([(1,0,0), (0,1,0)]) bz = BrillouinZone(bl) bzmesh = MeshBrZone(bz, n_k=1) # only one k-point e_k = Gf(mesh=bzmesh, target_shape=[1, 1]) e_k *= 0. # ------------------------------------------------------------------ # -- Lattice single-particle Green's function mesh = MeshImFreq(beta=parm.beta, S='Fermion', n_max=parm.nwf_gf) parm.Sigma_iw = parm.G_iw.copy() G0_iw = parm.G_iw.copy() G0_iw << inverse(iOmega_n + 0.5*parm.U) parm.Sigma_iw << inverse(G0_iw) - inverse(parm.G_iw) parm.mu = 0.5*parm.U g_wk = lattice_dyson_g_wk(mu=parm.mu, e_k=e_k, sigma_w=parm.Sigma_iw) g_wr = fourier_wk_to_wr(g_wk) # ------------------------------------------------------------------ # -- Non-interacting generalized lattice susceptibility chi0_wr = chi0r_from_gr_PH(nw=parm.nw, nnu=parm.nwf, gr=g_wr) chi0_wk = chi0q_from_chi0r(chi0_wr) # ------------------------------------------------------------------ # -- Solve lattice BSE parm.chi_wk = chiq_from_chi0q_and_gamma_PH(chi0_wk, parm.gamma_m) # ------------------------------------------------------------------ # -- Store results and static results num = np.squeeze(parm.chi_wk.data.real) ref = np.squeeze(parm.chi_m.data.real) diff = np.max(np.abs(num - ref)) print('diff =', diff) parm.chi_w = chiq_sum_nu_q(parm.chi_wk) # static suscept return parm
def bubble_setup(beta, mu, tb_lattice, nk, nw, sigma_w=None): print((tprf_banner(), "\n")) print(('beta =', beta)) print(('mu =', mu)) print(('sigma =', (not (sigma == None)))) norb = tb_lattice.NOrbitalsInUnitCell print(('nk =', nk)) print(('nw =', nw)) print(('norb =', norb)) print() ntau = 4 * nw ntot = np.prod(nk) * norb**4 + np.prod(nk) * (nw + ntau) * norb**2 nbytes = ntot * np.complex128().nbytes ngb = nbytes / 1024.**3 print(('Approx. Memory Utilization: %2.2f GB\n' % ngb)) periodization_matrix = np.diag(np.array(list(nk), dtype=int)) #print 'periodization_matrix =\n', periodization_matrix bz = BrillouinZone(tb_lattice.bl) bzmesh = MeshBrZone(bz, periodization_matrix) print('--> ek') e_k = ek_tb_dispersion_on_bzmesh(tb_lattice, bzmesh, bz) if sigma is None: print('--> g0k') wmesh = MeshImFreq(beta=beta, S='Fermion', n_max=nw) g_wk = lattice_dyson_g0_wk(mu=mu, e_k=e_k, mesh=wmesh) else: print('--> gk') sigma_w = strip_sigma(nw, beta, sigma) g_wk = lattice_dyson_g_wk(mu=mu, e_k=e_k, sigma_w=sigma_w) print('--> gr_from_gk (k->r)') g_wr = fourier_wk_to_wr(g_wk) del g_wk print('--> grt_from_grw (w->tau)') g_tr = fourier_wr_to_tr(g_wr) del g_wr if sigma is None: return g_tr else: return g_tr, sigma_w
# 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 may obtain a copy of the License at # https:#www.gnu.org/licenses/gpl-3.0.txt # # Authors: Nils Wentzell import numpy as np from triqs.gf import * from h5 import HDFArchive from triqs.lattice import BrillouinZone, BravaisLattice bz = BrillouinZone(BravaisLattice([[1, 0], [0, 1]])) bzmesh = MeshBrZone(bz, n_k=4) beta = 1.2345 fmesh = MeshImFreq(beta=beta, S='Fermion', n_max=8) bmesh = MeshImFreq(beta=beta, S='Boson', n_max=6) prodmesh = MeshProduct(bzmesh, bmesh, fmesh, fmesh) ek = Gf(mesh=bzmesh, target_shape=[1, 1]) ek.data[:] = np.random.random(ek.data.shape) chi = Gf(mesh=prodmesh, target_shape=[1, 1, 1, 1]) chi.data[:] = np.random.random(chi.data.shape) filename = 'test_bz_h5.h5'
import triqs_dualfermion.plothelper as plothelper import numpy as np import itertools from triqs.lattice import BravaisLattice, BrillouinZone from triqs.gf import Gf, MeshProduct, MeshBrillouinZone, MeshImFreq n_k = 32 n_w = 20 t=1 beta = 10. BL = BravaisLattice([(1, 0, 0), (0, 1, 0)]) # Two unit vectors in R3 BZ = BrillouinZone(BL) kmesh = MeshBrillouinZone(BZ, n_k=n_k) wmesh = MeshImFreq(beta=beta, S='Fermion', n_max=n_w) g0 = Gf(mesh=MeshProduct(wmesh, kmesh), target_shape=[]) # g0(k,omega), scalar valued def eps(k): return -2 * t* (np.cos(k.value[0]) + np.cos(k.value[1])) # NB : loop is a bit slow in python ... for k in g0.mesh[1]: for w in g0.mesh[0]: g0[w,k] = 1/(w - eps(k)) #name = "gd_k"
# 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 may obtain a copy of the License at # https:#www.gnu.org/licenses/gpl-3.0.txt # # Authors: Olivier Parcollet, Nils Wentzell import copy import numpy as np from triqs.gf import MeshBrZone from triqs.lattice import BrillouinZone, BravaisLattice cell = [[1., 0., 2.], [0.5, 2.5, 1.], [1., 2., 0.]] bl = BravaisLattice(cell) bz = BrillouinZone(bl) periodization_matrix = 32 * np.eye(3, dtype=int) bzmesh = MeshBrZone(bz, periodization_matrix) bzmesh_ref = copy.deepcopy(bzmesh) # BREAKS units = bzmesh.domain.units units_ref = bzmesh_ref.domain.units np.testing.assert_array_almost_equal(units, units_ref)
# ==== System Parameters ==== beta = 25. # Inverse temperature mu = 5.3938 # Chemical potential U = 2.3 # Density-density interaction J = 0.4 # Hunds coupling n_iw = int(10 * beta) # The number of positive Matsubara frequencies n_k = 16 # The number of k-points per dimension spin_names = ['up', 'dn'] # The spins orb_names = [0, 1, 2] # The orbitals TBL = tight_binding_model(lambda_soc=0.) # The Tight-Binding Lattice TBL.bz = BrillouinZone(TBL.bl) n_orb = len(orb_names) # ==== Local Hamiltonian ==== c_dag_vec = { s: matrix([[c_dag(s,o) for o in orb_names]]) for s in spin_names } c_vec = { s: matrix([[c(s,o)] for o in orb_names]) for s in spin_names } h_0_mat = TBL._hop[(0,0,0)][0:n_orb,0:n_orb] h_0 = sum(c_dag_vec[s] * h_0_mat * c_vec[s] for s in spin_names)[0,0] Umat, Upmat = U_matrix_kanamori(n_orb, U_int=U, J_hund=J) h_int = h_int_kanamori(spin_names, orb_names, Umat, Upmat, J, off_diag=True) h_imp = h_0 + h_int