From 1fc15390d6e5a143d588213fe19fb13a31d47d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Sch=C3=BCler?= Date: Tue, 2 Jul 2019 14:06:12 +0200 Subject: [PATCH] plovasp: implemented csc for hk format --- python/converters/plovasp/vaspio.py | 2 +- python/converters/vasp_converter.py | 20 +++++++++----------- python/sumk_dft.py | 20 +++++++++++++++++++- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/python/converters/plovasp/vaspio.py b/python/converters/plovasp/vaspio.py index 3c0faa64..f13e59e0 100644 --- a/python/converters/plovasp/vaspio.py +++ b/python/converters/plovasp/vaspio.py @@ -350,7 +350,7 @@ class Poscar: """ # Convenince local function 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 if vasp_dir[-1] != '/': diff --git a/python/converters/vasp_converter.py b/python/converters/vasp_converter.py index e2c4d61d..1cc1b821 100644 --- a/python/converters/vasp_converter.py +++ b/python/converters/vasp_converter.py @@ -145,8 +145,7 @@ class VaspConverter(ConverterTools): # 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" - #try: - if True: + try: for ig in xrange(ng): gr_file = self.basename + '.pg%i'%(ig + 1) jheader, rf = self.read_header_and_data(gr_file) @@ -193,7 +192,7 @@ class VaspConverter(ConverterTools): if sh['corr']: corr_shells.append(pars) - print shorbs_to_globalorbs + # TODO: generalize this to the case of multiple shell groups n_corr_shells = len(corr_shells) @@ -261,7 +260,7 @@ class VaspConverter(ConverterTools): rf_hk = self.read_data(f_hk) for isp in xrange(n_spin_blocs): for ik in xrange(n_k): - print ik + for ib in xrange(n_orbs): for jb in xrange(n_orbs): hopping[ik, isp, ib, jb] = rf_hk.next() @@ -274,7 +273,7 @@ class VaspConverter(ConverterTools): # print n_orbitals # 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_) - print 'proj_mat_csc', proj_mat_csc.shape + # TODO: implement reading from more than one projector group # In 'dmftproj' each ion represents a separate correlated shell. # 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 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': for ish, sh in enumerate(p_shells): if sh['corr']: @@ -313,7 +312,7 @@ class VaspConverter(ConverterTools): for ib in xrange(n_orbitals[ik, isp]): proj_mat[ik,isp,icsh,iclm,ib] = proj_mat_csc[ik,isp,ilm,ib] elif self.proj_or_hk == 'hk': - print crshorbs_to_globalorbs, proj_mat.shape, shorbs_to_globalorbs + for ish, sh in enumerate(p_shells): if sh['corr']: for ion in xrange(len(sh['ion_list'])): @@ -322,16 +321,15 @@ class VaspConverter(ConverterTools): for ik in xrange(n_k): 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 - print proj_mat[0,0,0,:,:].real - print proj_mat[0,0,1,:,:].real + #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'] for it in things_to_set: # print "%s:"%(it), locals()[it] setattr(self,it,locals()[it]) - #except StopIteration: - # raise "VaspConverter: error reading %s"%self.gr_file + except StopIteration: + raise "VaspConverter: error reading %s"%self.gr_file rf.close() diff --git a/python/sumk_dft.py b/python/sumk_dft.py index e358be3e..0a8f3af0 100644 --- a/python/sumk_dft.py +++ b/python/sumk_dft.py @@ -98,9 +98,12 @@ class SumkDFT(object): 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', '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( 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: 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='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 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." dim = self.shells[ish]['dim'] 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( 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='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 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." dim = self.shells[ish]['dim'] 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( projmat.conjugate().transpose(), gf_to_upfold, projmat) @@ -1840,6 +1849,15 @@ class SumkDFT(object): for ik in mpi.slice_array(ikarray): G_latt_iw = self.lattice_gf( 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: deltaN[bname][ik] = G_latt_iw[bname].density()