3
0
mirror of https://github.com/triqs/dft_tools synced 2024-07-11 05:43:48 +02:00

fix spaghettis function and update test

This commit is contained in:
Alexander Hampel 2021-12-15 09:01:10 -05:00
parent bb4682fafa
commit a36f2fdc61
3 changed files with 20 additions and 23 deletions

View File

@ -59,9 +59,9 @@ class SumkDFT(object):
It cannot be used with the spin-orbit coupling on; namely h_field is set to 0 if self.SO=True. It cannot be used with the spin-orbit coupling on; namely h_field is set to 0 if self.SO=True.
mesh: MeshImFreq or MeshImFreq, optional. Frequency mesh of Sigma. mesh: MeshImFreq or MeshImFreq, optional. Frequency mesh of Sigma.
beta : real, optional beta : real, optional
Inverse temperature. Used to construct imaginary frequency if mesh is not given. Inverse temperature. Used to construct imaginary frequency if mesh is not given.
n_iw : integer, optional n_iw : integer, optional
Number of Matsubara frequencies. Used to construct imaginary frequency if mesh is not given. Number of Matsubara frequencies. Used to construct imaginary frequency if mesh is not given.
use_dft_blocks : boolean, optional use_dft_blocks : boolean, optional
If True, the local Green's function matrix for each spin is divided into smaller blocks If True, the local Green's function matrix for each spin is divided into smaller blocks
with the block structure determined from the DFT density matrix of the corresponding correlated shell. with the block structure determined from the DFT density matrix of the corresponding correlated shell.
@ -110,7 +110,7 @@ class SumkDFT(object):
self.mesh = mesh self.mesh = mesh
else: else:
raise ValueError('mesh must be a triqs mesh of type MeshImFreq or MeshReFreq') raise ValueError('mesh must be a triqs mesh of type MeshImFreq or MeshReFreq')
self.block_structure = BlockStructure() self.block_structure = BlockStructure()
@ -621,12 +621,12 @@ class SumkDFT(object):
assert len(Sigma_imp) == self.n_corr_shells,\ assert len(Sigma_imp) == self.n_corr_shells,\
"put_Sigma: give exactly one Sigma for each corr. shell!" "put_Sigma: give exactly one Sigma for each corr. shell!"
if isinstance(self.mesh, MeshImFreq) and all(isinstance(gf, Gf) and gf.mesh == self.mesh for bname, gf in Sigma_imp[0]): if isinstance(self.mesh, MeshImFreq) and all(isinstance(gf.mesh, MeshImFreq) and isinstance(gf, Gf) and gf.mesh == self.mesh for bname, gf in Sigma_imp[0]):
# Imaginary frequency Sigma: # Imaginary frequency Sigma:
self.Sigma_imp = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, space='sumk') self.Sigma_imp = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, space='sumk')
for icrsh in range(self.n_corr_shells)] for icrsh in range(self.n_corr_shells)]
SK_Sigma_imp = self.Sigma_imp SK_Sigma_imp = self.Sigma_imp
elif isinstance(self.mesh, MeshReFreq) and all(isinstance(gf, Gf) and gf.mesh == self.mesh for bname, gf in Sigma_imp[0]): elif isinstance(self.mesh, MeshReFreq) and all(isinstance(gf, Gf) and isinstance(gf.mesh, MeshReFreq) and gf.mesh == self.mesh for bname, gf in Sigma_imp[0]):
# Real frequency Sigma: # Real frequency Sigma:
self.Sigma_imp = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, gf_function=GfReFreq, space='sumk') self.Sigma_imp = [self.block_structure.create_gf(ish=icrsh, mesh=Sigma_imp[icrsh].mesh, gf_function=GfReFreq, space='sumk')
for icrsh in range(self.n_corr_shells)] for icrsh in range(self.n_corr_shells)]

View File

@ -822,8 +822,9 @@ class SumkDFTTools(SumkDFT):
Data as it is also written to the files. Data as it is also written to the files.
""" """
assert hasattr( # check if ReFreqMesh is given
self, "Sigma_imp_w"), "spaghettis: Set Sigma_imp_w first." assert isinstance(self.mesh, MeshReFreq)
things_to_read = ['n_k', 'n_orbitals', 'proj_mat', things_to_read = ['n_k', 'n_orbitals', 'proj_mat',
'hopping', 'n_parproj', 'proj_mat_all'] 'hopping', 'n_parproj', 'proj_mat_all']
value_read = self.read_input_from_hdf( value_read = self.read_input_from_hdf(
@ -840,7 +841,7 @@ class SumkDFTTools(SumkDFT):
if mu is None: if mu is None:
mu = self.chemical_potential mu = self.chemical_potential
spn = self.spin_block_names[self.SO] spn = self.spin_block_names[self.SO]
mesh = [x.real for x in self.mesh] mesh = numpy.array([x.value for x in self.mesh])
n_om = len(mesh) n_om = len(mesh)
if plot_range is None: if plot_range is None:
@ -858,7 +859,7 @@ class SumkDFTTools(SumkDFT):
Akw = {sp: numpy.zeros( Akw = {sp: numpy.zeros(
[self.shells[ishell]['dim'], self.n_k, n_om], numpy.float_) for sp in spn} [self.shells[ishell]['dim'], self.n_k, n_om], numpy.float_) for sp in spn}
if not ishell is None: if ishell is not None:
gf_struct_parproj = [ gf_struct_parproj = [
(sp, self.shells[ishell]['dim']) for sp in spn] (sp, self.shells[ishell]['dim']) for sp in spn]
G_loc = BlockGf(name_block_generator=[(block, GfReFreq(target_shape=(block_dim, block_dim), mesh=self.Sigma_imp_w[0].mesh)) G_loc = BlockGf(name_block_generator=[(block, GfReFreq(target_shape=(block_dim, block_dim), mesh=self.Sigma_imp_w[0].mesh))

View File

@ -1,20 +1,16 @@
from triqs_dft_tools.sumk_dft_tools import * from triqs_dft_tools.sumk_dft_tools import *
from triqs.utility.h5diff import h5diff from triqs.utility.h5diff import h5diff
from h5 import HDFArchive from h5 import HDFArchive
beta = 40 with HDFArchive('SrVO3_Sigma.h5', 'r') as ar:
SK = SumkDFTTools(hdf_file='SrVO3_spectral.h5', use_dft_blocks=True)
if mpi.is_master_node():
with HDFArchive('SrVO3_Sigma.h5', 'a') as ar:
Sigma = ar['dmft_transp_input']['Sigma_w'] Sigma = ar['dmft_transp_input']['Sigma_w']
SK.chemical_potential = ar['dmft_transp_input']['chemical_potential'] chemical_potential = ar['dmft_transp_input']['chemical_potential']
SK.dc_imp = ar['dmft_transp_input']['dc_imp'] dc_imp = ar['dmft_transp_input']['dc_imp']
Sigma = mpi.bcast(Sigma) SK = SumkDFTTools(hdf_file='SrVO3_spectral.h5', use_dft_blocks=True, mesh = Sigma.mesh)
SK.chemical_potential = mpi.bcast(SK.chemical_potential)
SK.dc_imp = mpi.bcast(SK.dc_imp) SK.chemical_potential = chemical_potential
SK.dc_imp = dc_imp
SK.set_Sigma([Sigma]) SK.set_Sigma([Sigma])
dos_wannier = SK.dos_wannier_basis(broadening=0.01, with_Sigma=True, with_dc=True, save_to_file=False) dos_wannier = SK.dos_wannier_basis(broadening=0.01, with_Sigma=True, with_dc=True, save_to_file=False)
@ -24,12 +20,12 @@ spaghetti = SK.spaghettis(broadening=0.01, plot_shift=0.0, plot_range=(-1,1), is
if mpi.is_master_node(): if mpi.is_master_node():
# with HDFArchive('srvo3_spectral.ref.h5', 'a') as ar: # with HDFArchive('srvo3_spectral.ref.h5', 'a') as ar:
# ar['dos_wannier'] = dos_wannier # ar['dos_wannier'] = dos_wannier
# ar['dos_parproj'] = dos_parproj # ar['dos_parproj'] = dos_parproj
# ar['spaghetti'] = spaghetti # ar['spaghetti'] = spaghetti
with HDFArchive('srvo3_spectral.out.h5', 'a') as ar: with HDFArchive('srvo3_spectral.out.h5', 'a') as ar:
ar['dos_wannier'] = dos_wannier ar['dos_wannier'] = dos_wannier
ar['dos_parproj'] = dos_parproj ar['dos_parproj'] = dos_parproj
ar['spaghetti'] = spaghetti ar['spaghetti'] = spaghetti