2019-12-04 18:32:00 +01:00
|
|
|
|
2016-02-01 14:06:41 +01:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 by M. Ferrero, O. Parcollet
|
|
|
|
#
|
|
|
|
# DFT tools: Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola
|
|
|
|
#
|
|
|
|
# PLOVasp: Copyright (C) 2015 by O. E. Peil
|
|
|
|
#
|
|
|
|
# TRIQS is free software: you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
|
|
# Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
################################################################################
|
2015-11-20 18:54:51 +01:00
|
|
|
r"""
|
2019-12-04 18:32:00 +01:00
|
|
|
plovasp.converter
|
|
|
|
=================
|
2015-02-20 20:00:50 +01:00
|
|
|
|
2019-12-04 18:32:00 +01:00
|
|
|
PLOVASP is a tool to transform raw, non-normalized
|
|
|
|
projectors generated by VASP into normalized projectors
|
|
|
|
corresponding to user-defined projected localized orbitals (PLO).
|
2015-11-20 18:54:51 +01:00
|
|
|
|
|
|
|
Runs routines in proper order to generate and store PLOs.
|
|
|
|
|
2019-12-04 18:32:00 +01:00
|
|
|
Usage: python converter.py <conf-file> [<path-to-vasp-calculation>]
|
2015-11-20 18:54:51 +01:00
|
|
|
"""
|
2015-02-20 20:00:50 +01:00
|
|
|
import sys
|
2020-04-08 21:35:59 +02:00
|
|
|
from . import vaspio
|
|
|
|
from .inpconf import ConfigParameters
|
|
|
|
from .elstruct import ElectronicStructure
|
|
|
|
from .plotools import generate_plo, output_as_text
|
2023-03-24 17:36:35 +01:00
|
|
|
import logging
|
|
|
|
|
|
|
|
class PloFormatter(logging.Formatter):
|
2023-04-20 23:43:52 +02:00
|
|
|
"""
|
|
|
|
custom event logger for all output, warnings and debug info
|
|
|
|
"""
|
|
|
|
def __init__(self, default):
|
|
|
|
self._default_formatter = default
|
|
|
|
|
2023-03-24 17:36:35 +01:00
|
|
|
def format(self, record):
|
|
|
|
# Save the original format
|
|
|
|
_style = self._style
|
|
|
|
|
|
|
|
# Customized WARNING format
|
|
|
|
if record.levelno == logging.WARNING:
|
|
|
|
self._style = logging.PercentStyle("\n!!! WARNING !!!: %(msg)s\n")
|
|
|
|
|
|
|
|
result = super().format(record)
|
|
|
|
|
|
|
|
# Restore the original format
|
|
|
|
self._style = _style
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
# Uncomment this to get extra output
|
|
|
|
#logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
|
|
|
# Main logger from which all other loggers should be inherited
|
|
|
|
main_log = logging.getLogger('plovasp')
|
|
|
|
main_log.propagate = False
|
|
|
|
|
|
|
|
handler = logging.StreamHandler(sys.stdout)
|
|
|
|
formatter = PloFormatter("[%(levelname)s]:[%(name)s]: %(message)s")
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
main_log.addHandler(handler)
|
|
|
|
|
2015-02-20 20:00:50 +01:00
|
|
|
|
2015-12-16 15:58:14 +01:00
|
|
|
def generate_and_output_as_text(conf_filename, vasp_dir):
|
|
|
|
"""
|
|
|
|
Parse config file, process VASP data, and store as text.
|
|
|
|
"""
|
|
|
|
# Prepare input-file parameters
|
|
|
|
pars = ConfigParameters(conf_filename, verbosity=0)
|
|
|
|
pars.parse_input()
|
|
|
|
|
|
|
|
# Read VASP data
|
|
|
|
if 'efermi' in pars.general:
|
|
|
|
efermi_required = False
|
|
|
|
else:
|
|
|
|
efermi_required = True
|
|
|
|
vasp_data = vaspio.VaspData(vasp_dir, efermi_required=efermi_required)
|
|
|
|
el_struct = ElectronicStructure(vasp_data)
|
|
|
|
el_struct.debug_density_matrix()
|
|
|
|
if 'efermi' in pars.general:
|
|
|
|
el_struct.efermi = pars.general['efermi']
|
|
|
|
|
|
|
|
# Generate and store PLOs
|
|
|
|
pshells, pgroups = generate_plo(pars, el_struct)
|
|
|
|
output_as_text(pars, el_struct, pshells, pgroups)
|
|
|
|
|
2016-03-11 10:01:24 +01:00
|
|
|
def main():
|
2016-03-11 11:35:19 +01:00
|
|
|
"""
|
|
|
|
This function should not be called directly but via a bash script
|
|
|
|
'plovasp' invoking the main function as follows:
|
|
|
|
|
2018-07-03 01:16:50 +02:00
|
|
|
python -m applications.dft.converters.plovasp.converter $@
|
2016-03-11 11:35:19 +01:00
|
|
|
"""
|
2015-02-20 20:00:50 +01:00
|
|
|
narg = len(sys.argv)
|
|
|
|
if narg < 2:
|
2016-03-11 11:35:19 +01:00
|
|
|
raise SystemExit(" Usage: plovasp <conf-file> [<path-to-vasp-calcultaion>]")
|
2015-02-20 20:00:50 +01:00
|
|
|
else:
|
|
|
|
filename = sys.argv[1]
|
|
|
|
if narg > 2:
|
|
|
|
vasp_dir = sys.argv[2]
|
|
|
|
if vasp_dir[-1] != '/':
|
|
|
|
vasp_dir += '/'
|
|
|
|
else:
|
|
|
|
vasp_dir = './'
|
|
|
|
|
2016-01-22 15:59:12 +01:00
|
|
|
generate_and_output_as_text(filename, vasp_dir)
|
2015-11-20 18:54:51 +01:00
|
|
|
|
2016-03-11 10:01:24 +01:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|