mirror of
https://github.com/triqs/dft_tools
synced 2024-08-16 01:08:29 +02:00
[style] format and doc strings
This commit is contained in:
parent
6df646ea0b
commit
5ae4949313
@ -53,12 +53,11 @@ class SumkDFTTools(SumkDFT):
|
|||||||
parproj_data=parproj_data, symmpar_data=symmpar_data, bands_data=bands_data,
|
parproj_data=parproj_data, symmpar_data=symmpar_data, bands_data=bands_data,
|
||||||
transp_data=transp_data, misc_data=misc_data, cont_data=cont_data)
|
transp_data=transp_data, misc_data=misc_data, cont_data=cont_data)
|
||||||
|
|
||||||
# Uses .data of only GfReFreq objects.
|
|
||||||
# Uses .data of only GfReFreq objects.
|
|
||||||
def density_of_states(self, mu=None, broadening=None, mesh=None, with_Sigma=True, with_dc=True, proj_type=None, dosocc=False, save_to_file=True):
|
def density_of_states(self, mu=None, broadening=None, mesh=None, with_Sigma=True, with_dc=True, proj_type=None, dosocc=False, save_to_file=True):
|
||||||
"""
|
"""
|
||||||
Calculates the density of states. The basis of the projected density of states is
|
Calculates the density of states and the projected density of states.
|
||||||
specified by proj_type.
|
The basis of the projected density of states is specified by proj_type.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
mu : double, optional
|
mu : double, optional
|
||||||
@ -98,12 +97,14 @@ class SumkDFTTools(SumkDFT):
|
|||||||
"""
|
"""
|
||||||
if (proj_type != None):
|
if (proj_type != None):
|
||||||
# assert proj_type in ('wann', 'vasp','wien2k','elk'), "'proj_type' must be either 'wann', 'vasp', 'wien2k', or 'elk'"
|
# assert proj_type in ('wann', 'vasp','wien2k','elk'), "'proj_type' must be either 'wann', 'vasp', 'wien2k', or 'elk'"
|
||||||
assert proj_type in ('wann', 'vasp','wien2k',), "'proj_type' must be either 'wann', 'vasp', 'wien2k'"
|
assert proj_type in ('wann', 'vasp', 'wien2k',
|
||||||
|
), "'proj_type' must be either 'wann', 'vasp', 'wien2k'"
|
||||||
if (proj_type != 'wann'):
|
if (proj_type != 'wann'):
|
||||||
assert proj_type == self.dft_code, "proj_type must be from the corresponding dft inputs."
|
assert proj_type == self.dft_code, "proj_type must be from the corresponding dft inputs."
|
||||||
|
|
||||||
if (with_Sigma):
|
if (with_Sigma):
|
||||||
assert isinstance(self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
assert isinstance(
|
||||||
|
self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
||||||
mesh = self.Sigma_imp[0].mesh
|
mesh = self.Sigma_imp[0].mesh
|
||||||
elif mesh is not None:
|
elif mesh is not None:
|
||||||
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
||||||
@ -260,7 +261,6 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
return DOS, DOSproj, DOSproj_orb
|
return DOS, DOSproj, DOSproj_orb
|
||||||
|
|
||||||
|
|
||||||
def proj_type_G_loc(self, G_latt, G_inp, ik, ish, proj_type=None):
|
def proj_type_G_loc(self, G_latt, G_inp, ik, ish, proj_type=None):
|
||||||
"""
|
"""
|
||||||
Internal routine which calculates the project Green's function subject to the
|
Internal routine which calculates the project Green's function subject to the
|
||||||
@ -364,6 +364,7 @@ class SumkDFTTools(SumkDFT):
|
|||||||
"""
|
"""
|
||||||
Calculates the band resolved density matrices (occupations) from the Matsubara
|
Calculates the band resolved density matrices (occupations) from the Matsubara
|
||||||
frequency self-energy.
|
frequency self-energy.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
mu : double, optional
|
mu : double, optional
|
||||||
@ -376,7 +377,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
save_occ : boolean, optional
|
save_occ : boolean, optional
|
||||||
If True, saves the band resolved density matrix in misc_data.
|
If True, saves the band resolved density matrix in misc_data.
|
||||||
save_to_file : boolean, optional
|
save_to_file : boolean, optional
|
||||||
If True, text files with the calculated data will be created.
|
If True, text files with the calculated data will be created.\
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
occik : Dict of numpy arrays
|
occik : Dict of numpy arrays
|
||||||
@ -387,7 +389,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
mesh = self.Sigma_imp[0].mesh
|
mesh = self.Sigma_imp[0].mesh
|
||||||
else:
|
else:
|
||||||
mesh = self.mesh
|
mesh = self.mesh
|
||||||
assert isinstance(mesh, MeshImFreq), "SumkDFT.mesh must be real if with_Sigma is True or mesh is not given"
|
assert isinstance(
|
||||||
|
mesh, MeshImFreq), "SumkDFT.mesh must be real if with_Sigma is True or mesh is not given"
|
||||||
|
|
||||||
if mu is None:
|
if mu is None:
|
||||||
mu = self.chemical_potential
|
mu = self.chemical_potential
|
||||||
@ -396,7 +399,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
occik = {}
|
occik = {}
|
||||||
for sp in spn:
|
for sp in spn:
|
||||||
# same format as gf.data ndarray
|
# same format as gf.data ndarray
|
||||||
occik[sp] = [numpy.zeros([1, self.n_orbitals[ik, ntoi[sp]], self.n_orbitals[ik, ntoi[sp]]], numpy.double) for ik in range(self.n_k)]
|
occik[sp] = [numpy.zeros([1, self.n_orbitals[ik, ntoi[sp]],
|
||||||
|
self.n_orbitals[ik, ntoi[sp]]], numpy.double) for ik in range(self.n_k)]
|
||||||
# calculate the occupations
|
# calculate the occupations
|
||||||
ikarray = numpy.array(range(self.n_k))
|
ikarray = numpy.array(range(self.n_k))
|
||||||
for ik in range(self.n_k):
|
for ik in range(self.n_k):
|
||||||
@ -420,7 +424,6 @@ class SumkDFTTools(SumkDFT):
|
|||||||
del ar
|
del ar
|
||||||
return occik
|
return occik
|
||||||
|
|
||||||
# Uses .data of only GfReFreq objects.
|
|
||||||
def spectral_contours(self, mu=None, broadening=None, mesh=None, plot_range=None, FS=True, with_Sigma=True, with_dc=True, proj_type=None, save_to_file=True):
|
def spectral_contours(self, mu=None, broadening=None, mesh=None, plot_range=None, FS=True, with_Sigma=True, with_dc=True, proj_type=None, save_to_file=True):
|
||||||
"""
|
"""
|
||||||
Calculates the correlated spectral function at the Fermi level (relating to the Fermi
|
Calculates the correlated spectral function at the Fermi level (relating to the Fermi
|
||||||
@ -479,7 +482,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
if mu is None:
|
if mu is None:
|
||||||
mu = self.chemical_potential
|
mu = self.chemical_potential
|
||||||
if (with_Sigma):
|
if (with_Sigma):
|
||||||
assert isinstance(self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
assert isinstance(
|
||||||
|
self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
||||||
mesh = self.Sigma_imp[0].mesh
|
mesh = self.Sigma_imp[0].mesh
|
||||||
elif mesh is not None:
|
elif mesh is not None:
|
||||||
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
||||||
@ -512,12 +516,13 @@ class SumkDFTTools(SumkDFT):
|
|||||||
mesh_val2 = mesh_val[(mesh_val > om_minplot) & (mesh_val < om_maxplot)]
|
mesh_val2 = mesh_val[(mesh_val > om_minplot) & (mesh_val < om_maxplot)]
|
||||||
# \omega ~= 0.0 index for FS file
|
# \omega ~= 0.0 index for FS file
|
||||||
abs_mesh_val = [abs(i) for i in mesh_val2]
|
abs_mesh_val = [abs(i) for i in mesh_val2]
|
||||||
jw=[i for i in range(len(abs_mesh_val)) if abs_mesh_val[i] == numpy.min(abs_mesh_val[:])]
|
jw = [i for i in range(len(abs_mesh_val)) if abs_mesh_val[i]
|
||||||
|
== numpy.min(abs_mesh_val[:])]
|
||||||
|
|
||||||
# calculate the spectral functions for the irreducible set of k-points
|
# calculate the spectral functions for the irreducible set of k-points
|
||||||
[Akw, pAkw, pAkw_orb] = self.gen_Akw(mu=mu, broadening=broadening, mesh=mesh, \
|
[Akw, pAkw, pAkw_orb] = self.gen_Akw(mu=mu, broadening=broadening, mesh=mesh,
|
||||||
plot_shift=0.0, plot_range=plot_range, \
|
plot_shift=0.0, plot_range=plot_range,
|
||||||
shell_list=None, with_Sigma=with_Sigma, with_dc=with_dc, \
|
shell_list=None, with_Sigma=with_Sigma, with_dc=with_dc,
|
||||||
proj_type=proj_type)
|
proj_type=proj_type)
|
||||||
|
|
||||||
if save_to_file and mpi.is_master_node():
|
if save_to_file and mpi.is_master_node():
|
||||||
@ -552,7 +557,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
strng = 'Akw_FS' + '_' + proj_type + '_' + sp + '_proj' + str(ish)
|
strng = 'Akw_FS' + '_' + proj_type + '_' + sp + '_proj' + str(ish)
|
||||||
jom = jw[0]
|
jom = jw[0]
|
||||||
else:
|
else:
|
||||||
strng = 'Akw_omega_' + str(iom) + '_' + proj_type + '_' + sp + '_proj' + str(ish)
|
strng = 'Akw_omega_' + str(iom) + '_' + proj_type + \
|
||||||
|
'_' + sp + '_proj' + str(ish)
|
||||||
jom = iom
|
jom = iom
|
||||||
f = open(strng + '.dat', 'w')
|
f = open(strng + '.dat', 'w')
|
||||||
f.write("#Spectral function evaluated at frequency = %s\n" % mesh_val2[jom])
|
f.write("#Spectral function evaluated at frequency = %s\n" % mesh_val2[jom])
|
||||||
@ -566,7 +572,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
for i in range(dim):
|
for i in range(dim):
|
||||||
for j in range(dim):
|
for j in range(dim):
|
||||||
# For Elk with parproj - skip off-diagonal elements
|
# For Elk with parproj - skip off-diagonal elements
|
||||||
if(proj_type=='elk') and (i!=j): continue
|
if (proj_type == 'elk') and (i != j):
|
||||||
|
continue
|
||||||
strng2 = strng + '_' + str(i) + '_' + str(j)
|
strng2 = strng + '_' + str(i) + '_' + str(j)
|
||||||
# Open file for storage:
|
# Open file for storage:
|
||||||
f = open(strng2 + '.dat', 'w')
|
f = open(strng2 + '.dat', 'w')
|
||||||
@ -579,7 +586,6 @@ class SumkDFTTools(SumkDFT):
|
|||||||
|
|
||||||
return Akw, pAkw, pAkw_orb
|
return Akw, pAkw, pAkw_orb
|
||||||
|
|
||||||
# Uses .data of only GfReFreq objects.
|
|
||||||
def spaghettis(self, mu=None, broadening=None, mesh=None, plot_shift=0.0, plot_range=None, shell_list=None, with_Sigma=True, with_dc=True, proj_type=None, save_to_file=True):
|
def spaghettis(self, mu=None, broadening=None, mesh=None, plot_shift=0.0, plot_range=None, shell_list=None, with_Sigma=True, with_dc=True, proj_type=None, save_to_file=True):
|
||||||
"""
|
"""
|
||||||
Calculates the k-resolved spectral function A(k,w) (band structure)
|
Calculates the k-resolved spectral function A(k,w) (band structure)
|
||||||
@ -644,7 +650,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
if mu is None:
|
if mu is None:
|
||||||
mu = self.chemical_potential
|
mu = self.chemical_potential
|
||||||
if (with_Sigma):
|
if (with_Sigma):
|
||||||
assert isinstance(self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
assert isinstance(
|
||||||
|
self.Sigma_imp[0].mesh, MeshReFreq), "SumkDFT.mesh must be real if with_Sigma is True"
|
||||||
mesh = self.Sigma_imp[0].mesh
|
mesh = self.Sigma_imp[0].mesh
|
||||||
elif mesh is not None:
|
elif mesh is not None:
|
||||||
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
assert isinstance(mesh, MeshReFreq), "mesh must be of form MeshReFreq"
|
||||||
@ -669,9 +676,9 @@ class SumkDFTTools(SumkDFT):
|
|||||||
om_maxplot = plot_range[1]
|
om_maxplot = plot_range[1]
|
||||||
n_om = len(mesh_val[(mesh_val > om_minplot) & (mesh_val < om_maxplot)])
|
n_om = len(mesh_val[(mesh_val > om_minplot) & (mesh_val < om_maxplot)])
|
||||||
|
|
||||||
[Akw, pAkw, pAkw_orb] = self.gen_Akw(mu=mu, broadening=broadening, mesh=mesh, \
|
[Akw, pAkw, pAkw_orb] = self.gen_Akw(mu=mu, broadening=broadening, mesh=mesh,
|
||||||
plot_shift=plot_shift, plot_range=plot_range, \
|
plot_shift=plot_shift, plot_range=plot_range,
|
||||||
shell_list=shell_list, with_Sigma=with_Sigma, with_dc=with_dc, \
|
shell_list=shell_list, with_Sigma=with_Sigma, with_dc=with_dc,
|
||||||
proj_type=proj_type)
|
proj_type=proj_type)
|
||||||
|
|
||||||
if save_to_file and mpi.is_master_node():
|
if save_to_file and mpi.is_master_node():
|
||||||
@ -705,7 +712,8 @@ class SumkDFTTools(SumkDFT):
|
|||||||
for i in range(dim):
|
for i in range(dim):
|
||||||
for j in range(dim):
|
for j in range(dim):
|
||||||
# For Elk with parproj - skip off-diagonal elements
|
# For Elk with parproj - skip off-diagonal elements
|
||||||
if(proj_type=='elk') and (i!=j): continue
|
if(proj_type =='elk') and (i!=j):
|
||||||
|
continue
|
||||||
# Open file for storage:
|
# Open file for storage:
|
||||||
f = open('Akw_' + proj_type + '_' + sp + '_proj' + str(jsh)
|
f = open('Akw_' + proj_type + '_' + sp + '_proj' + str(jsh)
|
||||||
+ '_' + str(i) + '_' + str(j) + '.dat', 'w')
|
+ '_' + str(i) + '_' + str(j) + '.dat', 'w')
|
||||||
|
Loading…
Reference in New Issue
Block a user