mirror of
https://github.com/triqs/dft_tools
synced 2024-06-29 08:24:54 +02:00
plovasp: implemented csc for hk format
This commit is contained in:
parent
8f5722a98e
commit
1fc15390d6
|
@ -350,7 +350,7 @@ class Poscar:
|
||||||
"""
|
"""
|
||||||
# Convenince local function
|
# Convenince local function
|
||||||
def readline_remove_comments():
|
def readline_remove_comments():
|
||||||
return f.next().split('!')[0].strip()
|
return f.next().split('!')[0].split('#')[0].strip()
|
||||||
|
|
||||||
# Add a slash to the path name if necessary
|
# Add a slash to the path name if necessary
|
||||||
if vasp_dir[-1] != '/':
|
if vasp_dir[-1] != '/':
|
||||||
|
|
|
@ -145,8 +145,7 @@ class VaspConverter(ConverterTools):
|
||||||
# TODO: think about multiple shell groups and how to map them on h5 structures
|
# TODO: think about multiple shell groups and how to map them on h5 structures
|
||||||
assert ng == 1, "Only one group is allowed at the moment"
|
assert ng == 1, "Only one group is allowed at the moment"
|
||||||
|
|
||||||
#try:
|
try:
|
||||||
if True:
|
|
||||||
for ig in xrange(ng):
|
for ig in xrange(ng):
|
||||||
gr_file = self.basename + '.pg%i'%(ig + 1)
|
gr_file = self.basename + '.pg%i'%(ig + 1)
|
||||||
jheader, rf = self.read_header_and_data(gr_file)
|
jheader, rf = self.read_header_and_data(gr_file)
|
||||||
|
@ -193,7 +192,7 @@ class VaspConverter(ConverterTools):
|
||||||
if sh['corr']:
|
if sh['corr']:
|
||||||
corr_shells.append(pars)
|
corr_shells.append(pars)
|
||||||
|
|
||||||
print shorbs_to_globalorbs
|
|
||||||
# TODO: generalize this to the case of multiple shell groups
|
# TODO: generalize this to the case of multiple shell groups
|
||||||
n_corr_shells = len(corr_shells)
|
n_corr_shells = len(corr_shells)
|
||||||
|
|
||||||
|
@ -261,7 +260,7 @@ class VaspConverter(ConverterTools):
|
||||||
rf_hk = self.read_data(f_hk)
|
rf_hk = self.read_data(f_hk)
|
||||||
for isp in xrange(n_spin_blocs):
|
for isp in xrange(n_spin_blocs):
|
||||||
for ik in xrange(n_k):
|
for ik in xrange(n_k):
|
||||||
print ik
|
|
||||||
for ib in xrange(n_orbs):
|
for ib in xrange(n_orbs):
|
||||||
for jb in xrange(n_orbs):
|
for jb in xrange(n_orbs):
|
||||||
hopping[ik, isp, ib, jb] = rf_hk.next()
|
hopping[ik, isp, ib, jb] = rf_hk.next()
|
||||||
|
@ -274,7 +273,7 @@ class VaspConverter(ConverterTools):
|
||||||
# print n_orbitals
|
# print n_orbitals
|
||||||
# print [crsh['dim'] for crsh in corr_shells]
|
# print [crsh['dim'] for crsh in corr_shells]
|
||||||
proj_mat_csc = numpy.zeros([n_k, n_spin_blocs, sum([sh['dim'] for sh in shells]), numpy.max(n_orbitals)], numpy.complex_)
|
proj_mat_csc = numpy.zeros([n_k, n_spin_blocs, sum([sh['dim'] for sh in shells]), numpy.max(n_orbitals)], numpy.complex_)
|
||||||
print 'proj_mat_csc', proj_mat_csc.shape
|
|
||||||
# TODO: implement reading from more than one projector group
|
# TODO: implement reading from more than one projector group
|
||||||
# In 'dmftproj' each ion represents a separate correlated shell.
|
# In 'dmftproj' each ion represents a separate correlated shell.
|
||||||
# In my interface a 'projected shell' includes sets of ions.
|
# In my interface a 'projected shell' includes sets of ions.
|
||||||
|
@ -301,7 +300,7 @@ class VaspConverter(ConverterTools):
|
||||||
|
|
||||||
# now save only projectors with flag 'corr' to proj_mat
|
# now save only projectors with flag 'corr' to proj_mat
|
||||||
proj_mat = numpy.zeros([n_k, n_spin_blocs, n_corr_shells, max([crsh['dim'] for crsh in corr_shells]), numpy.max(n_orbitals)], numpy.complex_)
|
proj_mat = numpy.zeros([n_k, n_spin_blocs, n_corr_shells, max([crsh['dim'] for crsh in corr_shells]), numpy.max(n_orbitals)], numpy.complex_)
|
||||||
print 'proj_mat', proj_mat.shape
|
|
||||||
if self.proj_or_hk == 'proj':
|
if self.proj_or_hk == 'proj':
|
||||||
for ish, sh in enumerate(p_shells):
|
for ish, sh in enumerate(p_shells):
|
||||||
if sh['corr']:
|
if sh['corr']:
|
||||||
|
@ -313,7 +312,7 @@ class VaspConverter(ConverterTools):
|
||||||
for ib in xrange(n_orbitals[ik, isp]):
|
for ib in xrange(n_orbitals[ik, isp]):
|
||||||
proj_mat[ik,isp,icsh,iclm,ib] = proj_mat_csc[ik,isp,ilm,ib]
|
proj_mat[ik,isp,icsh,iclm,ib] = proj_mat_csc[ik,isp,ilm,ib]
|
||||||
elif self.proj_or_hk == 'hk':
|
elif self.proj_or_hk == 'hk':
|
||||||
print crshorbs_to_globalorbs, proj_mat.shape, shorbs_to_globalorbs
|
|
||||||
for ish, sh in enumerate(p_shells):
|
for ish, sh in enumerate(p_shells):
|
||||||
if sh['corr']:
|
if sh['corr']:
|
||||||
for ion in xrange(len(sh['ion_list'])):
|
for ion in xrange(len(sh['ion_list'])):
|
||||||
|
@ -322,16 +321,15 @@ class VaspConverter(ConverterTools):
|
||||||
for ik in xrange(n_k):
|
for ik in xrange(n_k):
|
||||||
for iclm,ilm in enumerate(xrange(shorbs_to_globalorbs[ish][ion][0],shorbs_to_globalorbs[ish][ion][1])):
|
for iclm,ilm in enumerate(xrange(shorbs_to_globalorbs[ish][ion][0],shorbs_to_globalorbs[ish][ion][1])):
|
||||||
proj_mat[ik,isp,icsh,iclm,ilm] = 1.0
|
proj_mat[ik,isp,icsh,iclm,ilm] = 1.0
|
||||||
print proj_mat[0,0,0,:,:].real
|
|
||||||
print proj_mat[0,0,1,:,:].real
|
|
||||||
#corr_shell.pop('ion_list')
|
#corr_shell.pop('ion_list')
|
||||||
things_to_set = ['n_shells','shells','n_corr_shells','corr_shells','n_spin_blocs','n_orbitals','n_k','SO','SP','energy_unit']
|
things_to_set = ['n_shells','shells','n_corr_shells','corr_shells','n_spin_blocs','n_orbitals','n_k','SO','SP','energy_unit']
|
||||||
for it in things_to_set:
|
for it in things_to_set:
|
||||||
# print "%s:"%(it), locals()[it]
|
# print "%s:"%(it), locals()[it]
|
||||||
setattr(self,it,locals()[it])
|
setattr(self,it,locals()[it])
|
||||||
|
|
||||||
#except StopIteration:
|
except StopIteration:
|
||||||
# raise "VaspConverter: error reading %s"%self.gr_file
|
raise "VaspConverter: error reading %s"%self.gr_file
|
||||||
|
|
||||||
rf.close()
|
rf.close()
|
||||||
|
|
||||||
|
|
|
@ -98,9 +98,12 @@ class SumkDFT(object):
|
||||||
things_to_read = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required',
|
things_to_read = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required',
|
||||||
'symm_op', 'n_shells', 'shells', 'n_corr_shells', 'corr_shells', 'use_rotations', 'rot_mat',
|
'symm_op', 'n_shells', 'shells', 'n_corr_shells', 'corr_shells', 'use_rotations', 'rot_mat',
|
||||||
'rot_mat_time_inv', 'n_reps', 'dim_reps', 'T', 'n_orbitals', 'proj_mat', 'bz_weights', 'hopping',
|
'rot_mat_time_inv', 'n_reps', 'dim_reps', 'T', 'n_orbitals', 'proj_mat', 'bz_weights', 'hopping',
|
||||||
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr']
|
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr','proj_or_hk']
|
||||||
self.subgroup_present, self.value_read = self.read_input_from_hdf(
|
self.subgroup_present, self.value_read = self.read_input_from_hdf(
|
||||||
subgrp=self.dft_data, things_to_read=things_to_read)
|
subgrp=self.dft_data, things_to_read=things_to_read)
|
||||||
|
if self.proj_or_hk == 'hk':
|
||||||
|
self.subgroup_present, self.value_read = self.read_input_from_hdf(
|
||||||
|
subgrp=self.dft_data, things_to_read=['proj_mat_csc'])
|
||||||
if self.symm_op:
|
if self.symm_op:
|
||||||
self.symmcorr = Symmetry(hdf_file, subgroup=self.symmcorr_data)
|
self.symmcorr = Symmetry(hdf_file, subgroup=self.symmcorr_data)
|
||||||
|
|
||||||
|
@ -294,6 +297,7 @@ class SumkDFT(object):
|
||||||
|
|
||||||
- if shells='corr': orthonormalized projectors for correlated shells are used for the downfolding.
|
- if shells='corr': orthonormalized projectors for correlated shells are used for the downfolding.
|
||||||
- if shells='all': non-normalized projectors for all included shells are used for the downfolding.
|
- if shells='all': non-normalized projectors for all included shells are used for the downfolding.
|
||||||
|
- if shells='csc': orthonormalized projectors for all shells are used for the downfolding. Used for H(k).
|
||||||
|
|
||||||
ir : integer, optional
|
ir : integer, optional
|
||||||
Index of equivalent site in the non-correlated shell 'ish', only used if shells='all'.
|
Index of equivalent site in the non-correlated shell 'ish', only used if shells='all'.
|
||||||
|
@ -316,6 +320,8 @@ class SumkDFT(object):
|
||||||
raise ValueError, "downfold: provide ir if treating all shells."
|
raise ValueError, "downfold: provide ir if treating all shells."
|
||||||
dim = self.shells[ish]['dim']
|
dim = self.shells[ish]['dim']
|
||||||
projmat = self.proj_mat_all[ik, isp, ish, ir, 0:dim, 0:n_orb]
|
projmat = self.proj_mat_all[ik, isp, ish, ir, 0:dim, 0:n_orb]
|
||||||
|
elif shells == 'csc':
|
||||||
|
projmat = self.proj_mat_csc[ik, isp, 0:n_orb, 0:n_orb]
|
||||||
|
|
||||||
gf_downfolded.from_L_G_R(
|
gf_downfolded.from_L_G_R(
|
||||||
projmat, gf_to_downfold, projmat.conjugate().transpose())
|
projmat, gf_to_downfold, projmat.conjugate().transpose())
|
||||||
|
@ -346,6 +352,7 @@ class SumkDFT(object):
|
||||||
|
|
||||||
- if shells='corr': orthonormalized projectors for correlated shells are used for the upfolding.
|
- if shells='corr': orthonormalized projectors for correlated shells are used for the upfolding.
|
||||||
- if shells='all': non-normalized projectors for all included shells are used for the upfolding.
|
- if shells='all': non-normalized projectors for all included shells are used for the upfolding.
|
||||||
|
- if shells='csc': orthonormalized projectors for all shells are used for the upfolding. Used for H(k).
|
||||||
|
|
||||||
ir : integer, optional
|
ir : integer, optional
|
||||||
Index of equivalent site in the non-correlated shell 'ish', only used if shells='all'.
|
Index of equivalent site in the non-correlated shell 'ish', only used if shells='all'.
|
||||||
|
@ -368,6 +375,8 @@ class SumkDFT(object):
|
||||||
raise ValueError, "upfold: provide ir if treating all shells."
|
raise ValueError, "upfold: provide ir if treating all shells."
|
||||||
dim = self.shells[ish]['dim']
|
dim = self.shells[ish]['dim']
|
||||||
projmat = self.proj_mat_all[ik, isp, ish, ir, 0:dim, 0:n_orb]
|
projmat = self.proj_mat_all[ik, isp, ish, ir, 0:dim, 0:n_orb]
|
||||||
|
elif shells == 'csc':
|
||||||
|
projmat = self.proj_mat_csc[ik, isp, 0:n_orb, 0:n_orb]
|
||||||
|
|
||||||
gf_upfolded.from_L_G_R(
|
gf_upfolded.from_L_G_R(
|
||||||
projmat.conjugate().transpose(), gf_to_upfold, projmat)
|
projmat.conjugate().transpose(), gf_to_upfold, projmat)
|
||||||
|
@ -1840,6 +1849,15 @@ class SumkDFT(object):
|
||||||
for ik in mpi.slice_array(ikarray):
|
for ik in mpi.slice_array(ikarray):
|
||||||
G_latt_iw = self.lattice_gf(
|
G_latt_iw = self.lattice_gf(
|
||||||
ik=ik, mu=self.chemical_potential, iw_or_w="iw")
|
ik=ik, mu=self.chemical_potential, iw_or_w="iw")
|
||||||
|
if dm_type == 'vasp' and self.proj_or_hk == 'hk':
|
||||||
|
# rotate the Green function into the DFT band basis
|
||||||
|
for bname, gf in G_latt_iw:
|
||||||
|
G_latt_rot_iw = gf.copy()
|
||||||
|
G_latt_rot_iw << self.upfold(
|
||||||
|
ik, 0, bname, G_latt_iw[bname], gf,shells='csc')
|
||||||
|
|
||||||
|
G_latt_iw[bname] = G_latt_rot_iw.copy()
|
||||||
|
|
||||||
for bname, gf in G_latt_iw:
|
for bname, gf in G_latt_iw:
|
||||||
deltaN[bname][ik] = G_latt_iw[bname].density()
|
deltaN[bname][ik] = G_latt_iw[bname].density()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user