3
0
mirror of https://github.com/triqs/dft_tools synced 2025-01-08 20:33:16 +01:00

Updated reference documentation for PLOVASP classes and functions.

This commit is contained in:
Alexander Hampel 2019-12-04 12:32:00 -05:00
parent 4d50e41135
commit e26444201a
9 changed files with 226 additions and 159 deletions

View File

@ -25,7 +25,6 @@ creates a h5 archive from the :ref:`PLOVASP<refPLOVASP>` output readable by
Here, we will present a guide how the interface `can` be used to create input for a DMFT calculation, using SrVO3 as an example. Full examples can be found in the :ref:`tutorial section of DFTTools<tutorials>`. Here, we will present a guide how the interface `can` be used to create input for a DMFT calculation, using SrVO3 as an example. Full examples can be found in the :ref:`tutorial section of DFTTools<tutorials>`.
|
Limitations of the interface Limitations of the interface
============================ ============================
@ -37,7 +36,6 @@ Limitations of the interface
(this implies no spin-orbit coupling) and spin-polarized projectors have not (this implies no spin-orbit coupling) and spin-polarized projectors have not
been tested. been tested.
|
VASP: generating raw projectors VASP: generating raw projectors
=============================== ===============================
@ -118,7 +116,6 @@ At the same time, **LOCPROJ** contains the total number of projectors (as well
as the number of `k`-points, bands, and spin channels) in the first line, which as the number of `k`-points, bands, and spin channels) in the first line, which
can be used to allocate the arrays before parsing. can be used to allocate the arrays before parsing.
|
Conversion for the DMFT self-consistency cycle Conversion for the DMFT self-consistency cycle
============================================== ==============================================
@ -165,7 +162,7 @@ for user convenience. Several parameters are required
The Option **TRANSFORM** is optional here, and it is specified to extract The Option **TRANSFORM** is optional here, and it is specified to extract
only the three :math:`t_{2g}` orbitals out of the five `d` orbitals given by only the three :math:`t_{2g}` orbitals out of the five `d` orbitals given by
:math:`l = 2`. A detailed explanation of all input parameters can be found :math:`l = 2`. A detailed explanation of all input parameters can be found
further below `PLOVASP guide`_. further below `PLOVASP detailed guide`_.
Next, the converter is executed. This can be done by calling :program:`PLOVASP` directly in the command line with the input file as an argument, e.g.: Next, the converter is executed. This can be done by calling :program:`PLOVASP` directly in the command line with the input file as an argument, e.g.:
| `plovasp plo.cfg` | `plovasp plo.cfg`
@ -198,7 +195,6 @@ in :class:`SumkDFT <dft.sumk_dft.SumkDFT>`, e.g.::
However, this should only be done after a careful study of the density matrix and the projected DOS in the localized basis. For the complete process for SrVO3 see the tutorial for the VASP interface `here <../tutorials/svo_vasp/svo_notebook.html>`_. However, this should only be done after a careful study of the density matrix and the projected DOS in the localized basis. For the complete process for SrVO3 see the tutorial for the VASP interface `here <../tutorials/svo_vasp/svo_notebook.html>`_.
|
PLOVASP detailed guide PLOVASP detailed guide
====================== ======================

View File

@ -22,12 +22,42 @@ Wannier90 Converter
:members: :members:
:special-members: :special-members:
PLOVASP
----------
.. _refPLOVASP:
PLOVASP reference, the classes / functions are sorted the way the converter uses them.
.. automodule:: triqs_dft_tools.converters.plovasp.converter
:members: generate_and_output_as_text
.. automodule:: triqs_dft_tools.converters.plovasp.inpconf
:members: ConfigParameters
.. automodule:: triqs_dft_tools.converters.plovasp.vaspio
:members: VaspData, Plocar, Poscar, Kpoints, Eigenval, Doscar, read_symmcar
.. automodule:: triqs_dft_tools.converters.plovasp.elstruct
:members: ElectronicStructure
.. automodule:: triqs_dft_tools.converters.plovasp.plotools
:members:
.. automodule:: triqs_dft_tools.converters.plovasp.proj_shell
:members:
.. automodule:: triqs_dft_tools.converters.plovasp.proj_group
:members:
VASP Converter VASP Converter
------------------- -------------------
.. _refVASPconverter:
.. autoclass:: triqs_dft_tools.converters.vasp_converter.VaspConverter .. autoclass:: triqs_dft_tools.converters.vasp_converter.VaspConverter
:members: :members:
:special-members: :special-members:
Converter Tools Converter Tools
--------------- ---------------
.. autoclass:: triqs_dft_tools.converters.converter_tools.ConverterTools .. autoclass:: triqs_dft_tools.converters.converter_tools.ConverterTools

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,14 +24,16 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.main plovasp.converter
========= =================
Main script of PLOVasp. PLOVASP is a tool to transform raw, non-normalized
projectors generated by VASP into normalized projectors
corresponding to user-defined projected localized orbitals (PLO).
Runs routines in proper order to generate and store PLOs. Runs routines in proper order to generate and store PLOs.
Usage: python main.py <conf-file> [<path-to-vasp-calcultaion>] Usage: python converter.py <conf-file> [<path-to-vasp-calculation>]
""" """
import sys import sys
import vaspio import vaspio
@ -85,4 +87,3 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.elstruct plovasp.elstruct
============= ================
Internal representation of VASP electronic structure data. Internal representation of VASP electronic structure data.
""" """
@ -51,7 +51,7 @@ class ElectronicStructure:
- *symmetry* (dict) : paramters of symmetry - *symmetry* (dict) : paramters of symmetry
When the object is created a simple consistency check When the object is created a simple consistency check
of the data coming from different VASP files is performed. of the data coming from different VASP files is performed.
""" """
def __init__(self, vasp_data): def __init__(self, vasp_data):
@ -123,7 +123,7 @@ class ElectronicStructure:
# Concatenate coordinates grouped by type into one array # Concatenate coordinates grouped by type into one array
self.structure['qcoords'] = np.vstack(vasp_data.poscar.q_types) self.structure['qcoords'] = np.vstack(vasp_data.poscar.q_types)
self.structure['type_of_ion'] = vasp_data.poscar.type_of_ion self.structure['type_of_ion'] = vasp_data.poscar.type_of_ion
a = [] a = []
for ia in range(3): for ia in range(3):
a.append( vasp_data.poscar.a_brav[:,ia]) a.append( vasp_data.poscar.a_brav[:,ia])
@ -133,11 +133,11 @@ class ElectronicStructure:
b3 = 2.0*np.pi*np.cross(a[0],a[1])/vol b3 = 2.0*np.pi*np.cross(a[0],a[1])/vol
b = [b1,b2,b3] b = [b1,b2,b3]
self.kmesh['kpoints_cart'] = 0.0 * self.kmesh['kpoints'] self.kmesh['kpoints_cart'] = 0.0 * self.kmesh['kpoints']
for ik in range(self.nktot): for ik in range(self.nktot):
for ii in range(3): for ii in range(3):
self.kmesh['kpoints_cart'][ik] += self.kmesh['kpoints'][ik,ii]*b[ii] self.kmesh['kpoints_cart'][ik] += self.kmesh['kpoints'][ik,ii]*b[ii]
# FIXME: This can be removed if ion coordinates are stored in a continuous array # FIXME: This can be removed if ion coordinates are stored in a continuous array
## Construct a map to access coordinates by index ## Construct a map to access coordinates by index
# self.structure['ion_index'] = [] # self.structure['ion_index'] = []

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.inpconfig plovasp.inpconfig
============== =================
Module for parsing and checking an input config-file. Module for parsing and checking an input config-file.
""" """
@ -195,8 +195,8 @@ class ConfigParameters:
first_char = par_str[0].lower() first_char = par_str[0].lower()
assert first_char in 'tf', "Logical parameters should be given by either 'True' or 'False'" assert first_char in 'tf', "Logical parameters should be given by either 'True' or 'False'"
return first_char == 't' return first_char == 't'
################################################################################ ################################################################################
# #
# parse_string_int() # parse_string_int()
@ -204,7 +204,7 @@ class ConfigParameters:
################################################################################ ################################################################################
def parse_string_int(self, par_str): def parse_string_int(self, par_str):
""" """
int parameters int parameters
""" """
return int(par_str) return int(par_str)
@ -494,12 +494,11 @@ class ConfigParameters:
################################################################################ ################################################################################
def groups_shells_consistency(self): def groups_shells_consistency(self):
""" """
Ensures consistency between groups and shells. Ensures consistency between groups and shells. In particular:
In particular: - if no groups are explicitly defined and only shell is defined create a group automatically
- if no groups are explicitly defined and only shell is defined create - check the existance of all shells referenced in the groups
a group automatically - check that all shells are referenced in the groups
- check the existance of all shells referenced in the groups
- check that all shells are referenced in the groups
""" """
# Special case: no groups is defined # Special case: no groups is defined
if self.ngroups == 0: if self.ngroups == 0:
@ -660,4 +659,3 @@ if __name__ == '__main__':
doscar = vaspio.Doscar() doscar = vaspio.Doscar()
doscar.from_file(vasp_dir) doscar.from_file(vasp_dir)
# pars = parse_input(filename) # pars = parse_input(filename)

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.plotools plovasp.plotools
============= ================
Set of routines for processing and outputting PLOs. Set of routines for processing and outputting PLOs.
@ -33,6 +33,25 @@ r"""
the consistency of the input data, generation of projected localized the consistency of the input data, generation of projected localized
orbitals (PLOs) out of raw VASP projectors, and outputting data orbitals (PLOs) out of raw VASP projectors, and outputting data
required by DFTTools. required by DFTTools.
The first step of PLO processing is to select subsets of projectors
corresponding to PLO groups. Each group contains a set of shells. Each
projector shell is represented by an object 'ProjectorShell' that contains
an array of projectors and information on the shell itself (orbital number,
ions, etc.). 'ProjectorShell's are contained in both a list of shells
(according to the original list as read from config-file) and in a
'ProjectorGroup' object, the latter also providing information about the
energy window.
Order of operations:
- transform projectors (all bands) in each shell
- select transformed shell projectors for a given group within the window
- orthogonalize if necessary projectors within a group by performing
the following operations for each k-point:
* combine all projector shells into a single array
* orthogonalize the array
* distribute back the arrays assuming that the order is preserved
""" """
import itertools as it import itertools as it
import numpy as np import numpy as np
@ -82,7 +101,7 @@ def check_data_consistency(pars, el_struct):
errmsg = "Projector for isite = %s, l = %s does not match PROJCAR"%(ion + 1, lshell) errmsg = "Projector for isite = %s, l = %s does not match PROJCAR"%(ion + 1, lshell)
raise Exception(errmsg) raise Exception(errmsg)
################################################################################ ################################################################################
# #
# generate_plo() # generate_plo()
@ -124,7 +143,7 @@ def generate_plo(conf_pars, el_struct):
print " Ion sort : %r"%(pshell.ion_sort) print " Ion sort : %r"%(pshell.ion_sort)
pshells.append(pshell) pshells.append(pshell)
pgroups = [] pgroups = []
for gr_par in conf_pars.groups: for gr_par in conf_pars.groups:
pgroup = ProjectorGroup(gr_par, pshells, eigvals) pgroup = ProjectorGroup(gr_par, pshells, eigvals)
@ -209,6 +228,7 @@ def generate_plo(conf_pars, el_struct):
def output_as_text(pars, el_struct, pshells, pgroups): def output_as_text(pars, el_struct, pshells, pgroups):
""" """
Output all information necessary for the converter as text files. Output all information necessary for the converter as text files.
""" """
ctrl_output(pars, el_struct, len(pgroups)) ctrl_output(pars, el_struct, len(pgroups))
plo_output(pars, el_struct, pshells, pgroups) plo_output(pars, el_struct, pshells, pgroups)
@ -260,6 +280,27 @@ def kpoints_output(basename, el_struct):
def ctrl_output(conf_pars, el_struct, ng): def ctrl_output(conf_pars, el_struct, ng):
""" """
Outputs a ctrl-file. Outputs a ctrl-file.
Control file format
""""""""""""""""""""""""""""""
Filename '<namebase>.ctrl'. Contains the data shared between all shells.
The JSON-header consists of the following elements:
* *nk*: number of `k`-points
* *ns*: number of spin channels
* *nc_flag*: collinear/noncollinear case (False/True)
* *ng*: number of projector groups
* Symmetry information (list of symmetry operations)
* *efermi*: Fermi level (optional)
* Lattice information
""" """
ctrl_fname = conf_pars.general['basename'] + '.ctrl' ctrl_fname = conf_pars.general['basename'] + '.ctrl'
head_dict = {} head_dict = {}
@ -311,31 +352,31 @@ def plo_output(conf_pars, el_struct, pshells, pgroups):
Each group is stored in a '<basename>.plog<Ng>' file. The format is the Each group is stored in a '<basename>.plog<Ng>' file. The format is the
following: following:
# Energy window: emin, emax | # Energy window: emin, emax
ib_min, ib_max | ib_min, ib_max
nelect | nelect
# Eigenvalues | # Eigenvalues
isp, ik1, kx, ky, kz, kweight | isp, ik1, kx, ky, kz, kweight
ib1, ib2 | ib1, ib2
eig1 | eig1
eig2 | eig2
... | ...
eigN | eigN
ik2, kx, ky, kz, kweight | ik2, kx, ky, kz, kweight
... | ...
# Projected shells | # Projected shells
Nshells | Nshells
# Shells: <shell indices> | # Shells: <shell indices>
# Shell <1> | # Shell <1>
Shell 1 | Shell 1
ndim | ndim
# complex arrays: plo(ns, nion, ndim, nb) | # complex arrays: plo(ns, nion, ndim, nb)
... | ...
# Shells: <shell indices> | # Shells: <shell indices>
# Shell <2> | # Shell <2>
Shell 2 | Shell 2
... | ...
""" """
for ig, pgroup in enumerate(pgroups): for ig, pgroup in enumerate(pgroups):
@ -343,9 +384,9 @@ def plo_output(conf_pars, el_struct, pshells, pgroups):
print " Storing PLO-group file '%s'..."%(plo_fname) print " Storing PLO-group file '%s'..."%(plo_fname)
head_dict = {} head_dict = {}
head_dict['nb_max'] = pgroup.nb_max head_dict['nb_max'] = pgroup.nb_max
if 'bands' in conf_pars.groups[ig]: if 'bands' in conf_pars.groups[ig]:
head_dict['bandwindow'] = (pgroup.ib_min, pgroup.ib_max) head_dict['bandwindow'] = (pgroup.ib_min, pgroup.ib_max)
else: else:
@ -381,13 +422,13 @@ def plo_output(conf_pars, el_struct, pshells, pgroups):
with open(plo_fname, 'wt') as f: with open(plo_fname, 'wt') as f:
f.write(header + "\n") f.write(header + "\n")
f.write("#END OF HEADER\n") f.write("#END OF HEADER\n")
# Eigenvalues within the window # Eigenvalues within the window
if 'bands' in conf_pars.groups[ig]: if 'bands' in conf_pars.groups[ig]:
f.write("# Eigenvalues within the band window: %s, %s\n"%(pgroup.ib_min+1, pgroup.ib_max+1)) f.write("# Eigenvalues within the band window: %s, %s\n"%(pgroup.ib_min+1, pgroup.ib_max+1))
else: else:
f.write("# Eigenvalues within the energy window: %s, %s\n"%(pgroup.emin, pgroup.emax)) f.write("# Eigenvalues within the energy window: %s, %s\n"%(pgroup.emin, pgroup.emax))
nk, nband, ns_band = el_struct.eigvals.shape nk, nband, ns_band = el_struct.eigvals.shape
for isp in xrange(ns_band): for isp in xrange(ns_band):
f.write("# is = %i\n"%(isp + 1)) f.write("# is = %i\n"%(isp + 1))
@ -441,17 +482,17 @@ def hk_output(conf_pars, el_struct, pgroups):
n_sh # number of total atomic shells n_sh # number of total atomic shells
at sort l dim # atom, sort, l, dim at sort l dim # atom, sort, l, dim
at sort l dim # atom, sort, l, dim at sort l dim # atom, sort, l, dim
After these header lines, the file has to contain the Hamiltonian matrix After these header lines, the file has to contain the Hamiltonian matrix
in orbital space. The standard convention is that you give for each k-point in orbital space. The standard convention is that you give for each k-point
first the matrix of the real part, then the matrix of the imaginary part, first the matrix of the real part, then the matrix of the imaginary part,
and then move on to the next k-point. and then move on to the next k-point.
""" """
for ig, pgroup in enumerate(pgroups): for ig, pgroup in enumerate(pgroups):
hk_fname = conf_pars.general['basename'] + '.hk%i'%(ig + 1) hk_fname = conf_pars.general['basename'] + '.hk%i'%(ig + 1)
print " Storing HK-group file '%s'..."%(hk_fname) print " Storing HK-group file '%s'..."%(hk_fname)
@ -459,7 +500,7 @@ def hk_output(conf_pars, el_struct, pgroups):
for ish in pgroup.ishells: for ish in pgroup.ishells:
shell = pgroup.shells[ish] shell = pgroup.shells[ish]
ion_output = [io + 1 for io in shell.ion_list] ion_output = [io + 1 for io in shell.ion_list]
for iion in ion_output: for iion in ion_output:
@ -469,11 +510,11 @@ def hk_output(conf_pars, el_struct, pgroups):
sh_dict['ndim'] = shell.ndim sh_dict['ndim'] = shell.ndim
# Convert ion indices from the internal representation (starting from 0) # Convert ion indices from the internal representation (starting from 0)
# to conventional VASP representation (starting from 1) # to conventional VASP representation (starting from 1)
# Derive sorts from equivalence classes # Derive sorts from equivalence classes
sh_dict['ion_list'] = ion_output sh_dict['ion_list'] = ion_output
sh_dict['ion_sort'] = shell.ion_sort sh_dict['ion_sort'] = shell.ion_sort
head_shells.append(sh_dict) head_shells.append(sh_dict)

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.proj_group plovasp.proj_group
=============== ==================
Storage and manipulation of projector groups. Storage and manipulation of projector groups.
""" """
@ -48,10 +48,9 @@ class ProjectorGroup:
the parameters from the config-file (passed in `pars`). the parameters from the config-file (passed in `pars`).
Parameters: Parameters:
- gr_pars (dict) : group parameters from the config-file
- gr_pars (dict) : group parameters from the config-file - shells ([ProjectorShell]) : array of ProjectorShell objects
- shells ([ProjectorShell]) : array of ProjectorShell objects - eigvals (numpy.array) : array of KS eigenvalues
- eigvals (numpy.array) : array of KS eigenvalues
""" """
def __init__(self, gr_pars, shells, eigvals): def __init__(self, gr_pars, shells, eigvals):
@ -74,16 +73,16 @@ class ProjectorGroup:
ib_win[:,:,1] = gr_pars['bands'][1]-1 ib_win[:,:,1] = gr_pars['bands'][1]-1
ib_min = gr_pars['bands'][0] - 1 ib_min = gr_pars['bands'][0] - 1
ib_max = gr_pars['bands'][1] - 1 ib_max = gr_pars['bands'][1] - 1
else: else:
ib_win, ib_min, ib_max = self.select_bands(eigvals) ib_win, ib_min, ib_max = self.select_bands(eigvals)
self.ib_win = ib_win self.ib_win = ib_win
self.ib_min = ib_min self.ib_min = ib_min
self.ib_max = ib_max self.ib_max = ib_max
self.nb_max = ib_max - ib_min + 1 self.nb_max = ib_max - ib_min + 1
if self.complement: if self.complement:
n_bands = self.ib_win[:,:,1] - self.ib_win[:,:,0]+1 n_bands = self.ib_win[:,:,1] - self.ib_win[:,:,0]+1
n_orbs = sum([x.ndim for x in self.shells]) n_orbs = sum([x.ndim for x in self.shells])
@ -92,14 +91,14 @@ class ProjectorGroup:
self.complement = False self.complement = False
print "\nWARNING: The total number of orbitals in this group is " print "\nWARNING: The total number of orbitals in this group is "
print "equal to the number of bands. Setting COMPLEMENT to FALSE!\n" print "equal to the number of bands. Setting COMPLEMENT to FALSE!\n"
# Select projectors within the energy window # Select projectors within the energy window
for ish in self.ishells: for ish in self.ishells:
shell = self.shells[ish] shell = self.shells[ish]
shell.select_projectors(ib_win, ib_min, ib_max) shell.select_projectors(ib_win, ib_min, ib_max)
################################################################################ ################################################################################
# #
@ -177,8 +176,8 @@ class ProjectorGroup:
nlm = i2 - i1 + 1 nlm = i2 - i1 + 1
shell = self.shells[ish] shell = self.shells[ish]
shell.proj_win[ion, isp, ik, :nlm, :nb] = p_orth[i1:i2, :nb] shell.proj_win[ion, isp, ik, :nlm, :nb] = p_orth[i1:i2, :nb]
################################################################################ ################################################################################
# #
# calc_hk # calc_hk
@ -188,11 +187,11 @@ class ProjectorGroup:
""" """
Calculate H(k) for a group by applying the projectors P Calculate H(k) for a group by applying the projectors P
to the eigenvalues eps. to the eigenvalues eps.
H_ij(k) = sum_l P*_il eps_l P_lj H_ij(k) = sum_l P*_il eps_l P_lj
""" """
# here we abuse the get_block_matrix_map(), however, it only works # here we abuse the get_block_matrix_map(), however, it only works
# if self.normion is false # if self.normion is false
temp = self.normion temp = self.normion
@ -201,15 +200,15 @@ class ProjectorGroup:
self.normion = temp self.normion = temp
_, ns, nk, _, _ = self.shells[0].proj_win.shape _, ns, nk, _, _ = self.shells[0].proj_win.shape
self.hk = np.zeros((ns,nk,ndim,ndim), dtype=np.complex128) self.hk = np.zeros((ns,nk,ndim,ndim), dtype=np.complex128)
# Note that 'ns' and 'nk' are the same for all shells # Note that 'ns' and 'nk' are the same for all shells
for isp in xrange(ns): for isp in xrange(ns):
for ik in xrange(nk): for ik in xrange(nk):
bmin = self.ib_win[ik, isp, 0] bmin = self.ib_win[ik, isp, 0]
bmax = self.ib_win[ik, isp, 1]+1 bmax = self.ib_win[ik, isp, 1]+1
nb = bmax - bmin nb = bmax - bmin
p_mat = np.zeros((ndim, nb), dtype=np.complex128) p_mat = np.zeros((ndim, nb), dtype=np.complex128)
#print(bmin,bmax,nb) #print(bmin,bmax,nb)
# Combine all projectors of the group to one block projector # Combine all projectors of the group to one block projector
@ -221,7 +220,7 @@ class ProjectorGroup:
nlm = i2 - i1 + 1 nlm = i2 - i1 + 1
shell = self.shells[ish] shell = self.shells[ish]
p_mat[i1:i2, :nb] = shell.proj_win[ion, isp, ik, :nlm, :nb] p_mat[i1:i2, :nb] = shell.proj_win[ion, isp, ik, :nlm, :nb]
self.hk[isp,ik,:,:] = np.dot(p_mat*eigvals[ik,bmin:bmax,isp], self.hk[isp,ik,:,:] = np.dot(p_mat*eigvals[ik,bmin:bmax,isp],
p_mat.transpose().conjugate()) p_mat.transpose().conjugate())
@ -234,36 +233,36 @@ class ProjectorGroup:
def calc_complement(self,eigvals): def calc_complement(self,eigvals):
""" """
Calculate the complement for a group of projectors. Calculate the complement for a group of projectors.
This leads to quadtratic projectors P = <l|n> by using a Gram-Schmidt. This leads to quadtratic projectors P = <l|n> by using a Gram-Schmidt.
The projector on the orthogonal complement of the existing projectors The projector on the orthogonal complement of the existing projectors
{|l>} is P^u = 1 - sum_l |l><l| |l> is P^u = 1 - sum_l |l><l|
We get candidates for complement projectors by applying P^u to a Bloch We get candidates for complement projectors by applying P^u to a Bloch
state |n>: |l*> = P^u |n>. For numerical stability we select that Bloch state |n>: |l*> = P^u |n>. For numerical stability we select that Bloch
state which leads to the |l*> with the largest norm (that corresponds to state which leads to the |l*> with the largest norm (that corresponds to
that Bloch state with the smallest overlap with the space spanned by {|l>}) that Bloch state with the smallest overlap with the space spanned by |l>)
We normalize |l*> and add it to {|l>}. We do so untill we have as many We normalize |l*> and add it to |l>. We do so untill we have as many
|l> states as we have {|n>} states. |l> states as we have |n> states.
""" """
print '\nCalculating complement\n' print '\nCalculating complement\n'
block_maps, ndim = self.get_block_matrix_map() block_maps, ndim = self.get_block_matrix_map()
_, ns, nk, _, _ = self.shells[0].proj_win.shape _, ns, nk, _, _ = self.shells[0].proj_win.shape
p_mat = np.zeros((ndim, self.nb_max), dtype=np.complex128) p_mat = np.zeros((ndim, self.nb_max), dtype=np.complex128)
p_full = np.zeros((1,ns,nk,self.nb_max, self.nb_max), dtype=np.complex128) p_full = np.zeros((1,ns,nk,self.nb_max, self.nb_max), dtype=np.complex128)
# Note that 'ns' and 'nk' are the same for all shells # Note that 'ns' and 'nk' are the same for all shells
for isp in xrange(ns): for isp in xrange(ns):
for ik in xrange(nk): for ik in xrange(nk):
bmin = self.ib_win[ik, isp, 0] bmin = self.ib_win[ik, isp, 0]
bmax = self.ib_win[ik, isp, 1]+1 bmax = self.ib_win[ik, isp, 1]+1
nb = bmax - bmin nb = bmax - bmin
# Combine all projectors of the group to one block projector # Combine all projectors of the group to one block projector
for bl_map in block_maps: for bl_map in block_maps:
p_mat[:, :] = 0.0j # !!! Clean-up from the last k-point and block! p_mat[:, :] = 0.0j # !!! Clean-up from the last k-point and block!
@ -297,11 +296,11 @@ class ProjectorGroup:
sh_pars['ib_min'] = bmin sh_pars['ib_min'] = bmin
sh_pars['ib_max'] = bmax sh_pars['ib_max'] = bmax
sh_pars['ib_win'] = self.ib_win sh_pars['ib_win'] = self.ib_win
self.shells.append(ComplementShell(sh_pars,p_full[:,:,:,ndim:,:],False)) self.shells.append(ComplementShell(sh_pars,p_full[:,:,:,ndim:,:],False))
self.ishells.append(self.ishells[-1]+1) self.ishells.append(self.ishells[-1]+1)
################################################################################ ################################################################################
# #
# gen_block_matrix_map # gen_block_matrix_map
@ -321,13 +320,13 @@ class ProjectorGroup:
of projectors to be orthogonalized. Each subset corresponds to a subset of sites of projectors to be orthogonalized. Each subset corresponds to a subset of sites
and spans all orbital indices. defined by 'bl_map' as and spans all orbital indices. defined by 'bl_map' as
bl_map = [((i1_start, i1_end), (i1_shell, i1_ion)), bl_map = [((i1_start, i1_end), (i1_shell, i1_ion)),
((i2_start, i2_end), (i2_shell, i2_ion)), ((i2_start, i2_end), (i2_shell, i2_ion)),
...], ...],
where `iX_start`, `iX_end` is the range of indices of the block matrix where `iX_start`, `iX_end` is the range of indices of the block matrix
(in Python convention `iX_end = iX_last + 1`, with `iX_last` being the last index (in Python convention `iX_end = iX_last + 1`, with `iX_last` being the last index
of the range), of the range),
`iX_shell` and `iX_ion` the shell and site indices. The length of the range `iX_shell` and `iX_ion` the shell and site indices. The length of the range
should be consistent with 'nlm' dimensions of a corresponding shell, i.e., should be consistent with 'nlm' dimensions of a corresponding shell, i.e.,
`iX_end - iX_start = nlm[iX_shell]`. `iX_end - iX_start = nlm[iX_shell]`.
@ -336,7 +335,7 @@ class ProjectorGroup:
1. Orthogonality is ensured on each site (NORMION = True). 1. Orthogonality is ensured on each site (NORMION = True).
For each site 'ion' we have the following mapping: For each site 'ion' we have the following mapping:
block_maps = [bl_map[ion] for ion in xrange(shell.nion) block_maps = [bl_map[ion] for ion in xrange(shell.nion)
for shell in shells] for shell in shells]
bl_map = [((i1_start, i1_end), (i1_shell, ion)), bl_map = [((i1_start, i1_end), (i1_shell, ion)),
@ -438,14 +437,15 @@ class ProjectorGroup:
Parameters Parameters
---------- ----------
eigvals (numpy.array) : all eigenvalues eigvals (numpy.array) : all eigenvalues
emin, emax (float) : energy window emin, emax (float) : energy window
Returns Returns
------- -------
ib_win, nb_min, nb_max : ib_win, nb_min, nb_max : lowest and highest indices of the selected bands
""" """
# Sanity check # Sanity check
if self.emin > eigvals.max() or self.emax < eigvals.min(): if self.emin > eigvals.max() or self.emax < eigvals.min():
@ -481,5 +481,3 @@ class ProjectorGroup:
ib_max = max(ib_max, ib2) ib_max = max(ib_max, ib2)
return ib_win, ib_min, ib_max return ib_win, ib_min, ib_max

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.proj_shell plovasp.proj_shell
=============== ==================
Storage and manipulation on projector shells. Storage and manipulation on projector shells.
""" """
@ -74,7 +74,7 @@ class ProjectorShell:
self.user_index = sh_pars['user_index'] self.user_index = sh_pars['user_index']
self.corr = sh_pars['corr'] self.corr = sh_pars['corr']
self.ion_sort = [sh_pars['ion_sort']] self.ion_sort = [sh_pars['ion_sort']]
self.nc_flag = nc_flag self.nc_flag = nc_flag
# try: # try:
# self.tmatrix = sh_pars['tmatrix'] # self.tmatrix = sh_pars['tmatrix']
# except KeyError: # except KeyError:
@ -86,7 +86,7 @@ class ProjectorShell:
self.nion = self.ions['nion'] self.nion = self.ions['nion']
# Extract ion list and equivalence classes (ion sorts) # Extract ion list and equivalence classes (ion sorts)
self.ion_list = sorted(it.chain(*self.ions['ion_list'])) self.ion_list = sorted(it.chain(*self.ions['ion_list']))
if self.ion_sort[0] is None: if self.ion_sort[0] is None:
self.ion_sort = [] self.ion_sort = []
for ion in self.ion_list: for ion in self.ion_list:
@ -219,7 +219,7 @@ class ProjectorShell:
def extract_projectors(self, proj_raw, proj_params, kmesh, structure): def extract_projectors(self, proj_raw, proj_params, kmesh, structure):
""" """
Extracts projectors for the given shell. Extracts projectors for the given shell.
Projectors are selected from the raw-projector array 'proj_raw' Projectors are selected from the raw-projector array 'proj_raw'
according to the shell parameters. according to the shell parameters.
If necessary the projectors are transformed usin 'self.tmatrices'. If necessary the projectors are transformed usin 'self.tmatrices'.
@ -476,8 +476,8 @@ class ComplementShell(ProjectorShell):
self.ions = sh_pars['ions'] self.ions = sh_pars['ions']
self.user_index = sh_pars['user_index'] self.user_index = sh_pars['user_index']
self.corr = sh_pars['corr'] self.corr = sh_pars['corr']
self.nc_flag = nc_flag self.nc_flag = nc_flag
self.ib_min = sh_pars['ib_min'] self.ib_min = sh_pars['ib_min']
self.ib_max = sh_pars['ib_max'] self.ib_max = sh_pars['ib_max']
self.ib_win = sh_pars['ib_win'] self.ib_win = sh_pars['ib_win']
@ -498,16 +498,15 @@ class ComplementShell(ProjectorShell):
self.ndim = proj_compl.shape[3] self.ndim = proj_compl.shape[3]
self.proj_win = proj_compl self.proj_win = proj_compl
def extract_tmatrices(self, sh_pars): def extract_tmatrices(self, sh_pars):
raise Exception('not implemented') raise Exception('not implemented')
def local_hamiltonian(self, el_struct, site_diag=True, spin_diag=True): def local_hamiltonian(self, el_struct, site_diag=True, spin_diag=True):
raise Exception('not implemented') raise Exception('not implemented')
def density_matrix(self, el_struct, site_diag=True, spin_diag=True): def density_matrix(self, el_struct, site_diag=True, spin_diag=True):
raise Exception('not implemented') raise Exception('not implemented')
#def density_of_states(self, el_struct, emesh): #def density_of_states(self, el_struct, emesh):
# raise Exception('not implemented') # raise Exception('not implemented')

View File

@ -1,4 +1,4 @@
################################################################################ ################################################################################
# #
# TRIQS: a Toolbox for Research in Interacting Quantum Systems # TRIQS: a Toolbox for Research in Interacting Quantum Systems
@ -24,8 +24,8 @@
# #
################################################################################ ################################################################################
r""" r"""
vasp.vaspio plovasp.vaspio
=========== ==============
Input of required VASP data. Input of required VASP data.
@ -107,16 +107,18 @@ class VaspData:
################################################################################ ################################################################################
################################################################################ ################################################################################
class Plocar: class Plocar:
r""" """
Class containing raw PLO data from VASP. Class containing raw PLO data from VASP.
Properties Properties:
---------- - *plo* (numpy.array((nion, ns, nk, nb, nlmmax))) : raw projectors
- *params* (dict) : parameters read from PLOCAR
- *ferw* (array(nion, ns, nk, nb)) : Fermi weights from VASP
- *plo* (numpy.array((nion, ns, nk, nb, nlmmax))) : raw projectors
- *params* (dict) : parameters read from PLOCAR
- *ferw* (array(nion, ns, nk, nb)) : Fermi weights from VASP
""" """
def __init__(self):
self.plo = None
self.proj_params = None
def from_file(self, vasp_dir='./', plocar_filename='PLOCAR'): def from_file(self, vasp_dir='./', plocar_filename='PLOCAR'):
r""" r"""
@ -330,14 +332,12 @@ class Poscar:
""" """
Class containing POSCAR data from VASP. Class containing POSCAR data from VASP.
Properties Properties:
---------- - nq (int) : total number of ions
- ntypes ([int]) : number of ion types
nq (int) : total number of ions - nions (int) : a list of number of ions of each type
ntypes ([int]) : number of ion types - a_brav (numpy.array((3, 3), dtype=float)) : lattice vectors
nions (int) : a list of number of ions of each type - q_types ([numpy.array((nions, 3), dtype=float)]) : a list of
a_brav (numpy.array((3, 3), dtype=float)) : lattice vectors
q_types ([numpy.array((nions, 3), dtype=float)]) : a list of
arrays each containing fractional coordinates of ions of a given type arrays each containing fractional coordinates of ions of a given type
""" """
def __init__(self): def __init__(self):
@ -450,16 +450,18 @@ class Kpoints:
""" """
Class describing k-points and optionally tetrahedra. Class describing k-points and optionally tetrahedra.
Properties Properties:
---------- - nktot (int) : total number of k-points in the IBZ
- kpts (numpy.array((nktot, 3), dtype=float)) : k-point vectors (fractional coordinates)
- nktot (int) : total number of k-points in the IBZ - ntet (int) : total number of k-point tetrahedra
- kpts (numpy.array((nktot, 3), dtype=float)) : k-point vectors (fractional coordinates) - itet (numpy.array((ntet, 5), dtype=float) : array of tetrahedra
- ntet (int) : total number of k-point tetrahedra - volt (float) : volume of a tetrahedron (the k-grid is assumed to
- itet (numpy.array((ntet, 5), dtype=float) : array of tetrahedra be uniform)
- volt (float) : volume of a tetrahedron (the k-grid is assumed to
be uniform)
""" """
def __init__(self):
self.kpts = None
self.nktot = None
self.kwghts = None
# #
# Reads IBZKPT file # Reads IBZKPT file
# #
@ -503,7 +505,7 @@ class Kpoints:
self.kwghts[ik] = float(sline[3]) self.kwghts[ik] = float(sline[3])
self.kwghts /= self.nktot self.kwghts /= self.nktot
# Attempt to read tetrahedra # Attempt to read tetrahedra
# Skip comment line ("Tetrahedra") # Skip comment line ("Tetrahedra")
try: try:
@ -604,7 +606,7 @@ class Eigenval:
assert len(tmp) == 2 * self.ispin + 1, "EIGENVAL file is incorrect (probably from old versions of VASP)" assert len(tmp) == 2 * self.ispin + 1, "EIGENVAL file is incorrect (probably from old versions of VASP)"
self.eigs[ik, ib, :] = tmp[1:self.ispin+1] self.eigs[ik, ib, :] = tmp[1:self.ispin+1]
self.ferw[ik, ib, :] = tmp[self.ispin+1:] self.ferw[ik, ib, :] = tmp[self.ispin+1:]
################################################################################ ################################################################################
################################################################################ ################################################################################
@ -617,6 +619,10 @@ class Doscar:
""" """
Class containing some data from DOSCAR Class containing some data from DOSCAR
""" """
def __init__(self):
self.ncdij = None
self.efermi = None
def from_file(self, vasp_dir='./', dos_filename='DOSCAR'): def from_file(self, vasp_dir='./', dos_filename='DOSCAR'):
""" """
Reads only E_Fermi from DOSCAR. Reads only E_Fermi from DOSCAR.
@ -712,5 +718,3 @@ def read_symmcar(vasp_dir, symm_filename='SYMMCAR'):
data.update({ 'nrot': nrot, 'ntrans': ntrans, data.update({ 'nrot': nrot, 'ntrans': ntrans,
'lmax': lmax, 'nion': nion, 'lmax': lmax, 'nion': nion,
'sym_rots': rot_mats, 'perm_map': rot_map }) 'sym_rots': rot_mats, 'perm_map': rot_map })