2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
##########################################################################
|
2013-07-23 19:49:42 +02:00
|
|
|
#
|
|
|
|
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 by M. Aichhorn, L. Pourovskii, V. Vildosola
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
2016-05-09 10:19:56 +02:00
|
|
|
##########################################################################
|
2022-03-01 23:51:39 +01:00
|
|
|
"""
|
|
|
|
Wien2k converter
|
|
|
|
"""
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
from types import *
|
2014-12-09 16:47:40 +01:00
|
|
|
import numpy
|
2020-04-08 21:47:15 +02:00
|
|
|
from h5 import *
|
2020-04-08 21:35:59 +02:00
|
|
|
from .converter_tools import *
|
2014-11-20 13:17:46 +01:00
|
|
|
import os.path
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2014-11-08 23:51:24 +01:00
|
|
|
class Wien2kConverter(ConverterTools):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2014-11-18 11:30:26 +01:00
|
|
|
Conversion from Wien2k output to an hdf5 file that can be used as input for the SumkDFT class.
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
def __init__(self, filename, hdf_filename=None,
|
|
|
|
dft_subgrp='dft_input', symmcorr_subgrp='dft_symmcorr_input',
|
|
|
|
parproj_subgrp='dft_parproj_input', symmpar_subgrp='dft_symmpar_input',
|
|
|
|
bands_subgrp='dft_bands_input', misc_subgrp='dft_misc_input',
|
|
|
|
transp_subgrp='dft_transp_input', repacking=False):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2015-03-12 00:01:12 +01:00
|
|
|
Initialise the class.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
filename : string
|
|
|
|
Base name of DFT files.
|
|
|
|
hdf_filename : string, optional
|
|
|
|
Name of hdf5 archive to be created.
|
|
|
|
dft_subgrp : string, optional
|
|
|
|
Name of subgroup storing necessary DFT data.
|
|
|
|
symmcorr_subgrp : string, optional
|
|
|
|
Name of subgroup storing correlated-shell symmetry data.
|
|
|
|
parproj_subgrp : string, optional
|
|
|
|
Name of subgroup storing partial projector data.
|
|
|
|
symmpar_subgrp : string, optional
|
|
|
|
Name of subgroup storing partial-projector symmetry data.
|
|
|
|
bands_subgrp : string, optional
|
|
|
|
Name of subgroup storing band data.
|
|
|
|
misc_subgrp : string, optional
|
|
|
|
Name of subgroup storing miscellaneous DFT data.
|
|
|
|
transp_subgrp : string, optional
|
|
|
|
Name of subgroup storing transport data.
|
|
|
|
repacking : boolean, optional
|
|
|
|
Does the hdf5 archive need to be repacked to save space?
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2020-04-08 21:55:39 +02:00
|
|
|
assert isinstance(filename, str), "Wien2kConverter: Please provide the DFT files' base name as a string."
|
2016-05-09 10:19:56 +02:00
|
|
|
if hdf_filename is None:
|
|
|
|
hdf_filename = filename + '.h5'
|
2015-02-10 16:35:12 +01:00
|
|
|
self.hdf_file = hdf_filename
|
2016-05-09 10:19:56 +02:00
|
|
|
self.dft_file = filename + '.ctqmcout'
|
|
|
|
self.symmcorr_file = filename + '.symqmc'
|
|
|
|
self.parproj_file = filename + '.parproj'
|
|
|
|
self.symmpar_file = filename + '.sympar'
|
|
|
|
self.band_file = filename + '.outband'
|
|
|
|
self.bandwin_file = filename + '.oubwin'
|
|
|
|
self.struct_file = filename + '.struct'
|
|
|
|
self.outputs_file = filename + '.outputs'
|
|
|
|
self.pmat_file = filename + '.pmat'
|
2014-11-18 11:30:26 +01:00
|
|
|
self.dft_subgrp = dft_subgrp
|
2014-11-03 14:47:55 +01:00
|
|
|
self.symmcorr_subgrp = symmcorr_subgrp
|
|
|
|
self.parproj_subgrp = parproj_subgrp
|
|
|
|
self.symmpar_subgrp = symmpar_subgrp
|
|
|
|
self.bands_subgrp = bands_subgrp
|
2015-02-10 11:55:44 +01:00
|
|
|
self.misc_subgrp = misc_subgrp
|
2014-11-03 11:16:32 +01:00
|
|
|
self.transp_subgrp = transp_subgrp
|
2016-05-09 10:19:56 +02:00
|
|
|
self.fortran_to_replace = {'D': 'E'}
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Checks if h5 file is there and repacks it if wanted:
|
|
|
|
if (os.path.exists(self.hdf_file) and repacking):
|
2014-11-19 18:50:53 +01:00
|
|
|
ConverterTools.repack(self)
|
2014-11-20 13:17:46 +01:00
|
|
|
|
2014-12-09 12:26:00 +01:00
|
|
|
def convert_dft_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2015-03-12 00:01:12 +01:00
|
|
|
Reads the appropriate files and stores the data for the
|
|
|
|
|
|
|
|
- dft_subgrp
|
|
|
|
- symmcorr_subgrp
|
|
|
|
- misc_subgrp
|
|
|
|
|
2022-03-01 23:51:39 +01:00
|
|
|
in the hdf5 archive.
|
2015-03-12 00:01:12 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
# Read and write only on the master node
|
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
|
|
|
mpi.report("Reading input from %s..." % self.dft_file)
|
|
|
|
|
|
|
|
# R is a generator : each R.Next() will return the next number in the
|
|
|
|
# file
|
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, self.dft_file, self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
try:
|
2020-04-08 21:35:59 +02:00
|
|
|
energy_unit = next(R) # read the energy convertion factor
|
2016-05-09 10:19:56 +02:00
|
|
|
# read the number of k points
|
2020-04-08 21:35:59 +02:00
|
|
|
n_k = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
k_dep_projection = 1
|
|
|
|
# flag for spin-polarised calculation
|
2020-04-08 21:35:59 +02:00
|
|
|
SP = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
# flag for spin-orbit calculation
|
2020-04-08 21:35:59 +02:00
|
|
|
SO = int(next(R))
|
|
|
|
charge_below = next(R) # total charge below energy window
|
2016-05-09 10:19:56 +02:00
|
|
|
# total density required, for setting the chemical potential
|
2020-04-08 21:35:59 +02:00
|
|
|
density_required = next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
symm_op = 1 # Use symmetry groups for the k-sum
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
# the information on the non-correlated shells is not important
|
|
|
|
# here, maybe skip:
|
|
|
|
# number of shells (e.g. Fe d, As p, O p) in the unit cell,
|
2020-04-08 21:35:59 +02:00
|
|
|
n_shells = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
# corresponds to index R in formulas
|
2014-11-26 16:24:02 +01:00
|
|
|
# now read the information about the shells (atom, sort, l, dim):
|
|
|
|
shell_entries = ['atom', 'sort', 'l', 'dim']
|
2016-05-09 10:19:56 +02:00
|
|
|
shells = [{name: int(val) for name, val in zip(
|
|
|
|
shell_entries, R)} for ish in range(n_shells)]
|
|
|
|
|
|
|
|
# number of corr. shells (e.g. Fe d, Ce f) in the unit cell,
|
2020-04-08 21:35:59 +02:00
|
|
|
n_corr_shells = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
# corresponds to index R in formulas
|
|
|
|
# now read the information about the shells (atom, sort, l, dim, SO
|
|
|
|
# flag, irep):
|
2014-11-26 16:24:02 +01:00
|
|
|
corr_shell_entries = ['atom', 'sort', 'l', 'dim', 'SO', 'irep']
|
2016-05-09 10:19:56 +02:00
|
|
|
corr_shells = [{name: int(val) for name, val in zip(
|
|
|
|
corr_shell_entries, R)} for icrsh in range(n_corr_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
# determine the number of inequivalent correlated shells and maps,
|
|
|
|
# needed for further reading
|
|
|
|
n_inequiv_shells, corr_to_inequiv, inequiv_to_corr = ConverterTools.det_shell_equivalence(
|
|
|
|
self, corr_shells)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
use_rotations = 1
|
2016-05-09 10:19:56 +02:00
|
|
|
rot_mat = [numpy.identity(
|
2023-01-23 21:40:57 +01:00
|
|
|
corr_shells[icrsh]['dim'], complex) for icrsh in range(n_corr_shells)]
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# read the matrices
|
|
|
|
rot_mat_time_inv = [0 for i in range(n_corr_shells)]
|
|
|
|
|
2014-11-26 16:24:02 +01:00
|
|
|
for icrsh in range(n_corr_shells):
|
|
|
|
for i in range(corr_shells[icrsh]['dim']): # read real part:
|
|
|
|
for j in range(corr_shells[icrsh]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat[icrsh][i, j] = next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
# read imaginary part:
|
|
|
|
for i in range(corr_shells[icrsh]['dim']):
|
2014-11-26 16:24:02 +01:00
|
|
|
for j in range(corr_shells[icrsh]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat[icrsh][i, j] += 1j * next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if (SP == 1): # read time inversion flag:
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat_time_inv[icrsh] = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# Read here the info for the transformation of the basis:
|
2014-11-15 18:15:45 +01:00
|
|
|
n_reps = [1 for i in range(n_inequiv_shells)]
|
|
|
|
dim_reps = [0 for i in range(n_inequiv_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
T = []
|
2014-11-26 16:24:02 +01:00
|
|
|
for ish in range(n_inequiv_shells):
|
2016-05-09 10:19:56 +02:00
|
|
|
# number of representatives ("subsets"), e.g. t2g and eg
|
2020-04-08 21:35:59 +02:00
|
|
|
n_reps[ish] = int(next(R))
|
|
|
|
dim_reps[ish] = [int(next(R)) for i in range(
|
2016-05-09 10:19:56 +02:00
|
|
|
n_reps[ish])] # dimensions of the subsets
|
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# The transformation matrix:
|
|
|
|
# is of dimension 2l+1 without SO, and 2*(2l+1) with SO!
|
2016-05-09 10:19:56 +02:00
|
|
|
ll = 2 * corr_shells[inequiv_to_corr[ish]]['l'] + 1
|
2014-11-26 16:24:02 +01:00
|
|
|
lmax = ll * (corr_shells[inequiv_to_corr[ish]]['SO'] + 1)
|
2023-01-23 21:40:57 +01:00
|
|
|
T.append(numpy.zeros([lmax, lmax], complex))
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# now read it from file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(lmax):
|
|
|
|
for j in range(lmax):
|
2020-04-08 21:35:59 +02:00
|
|
|
T[ish][i, j] = next(R)
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(lmax):
|
|
|
|
for j in range(lmax):
|
2020-04-08 21:35:59 +02:00
|
|
|
T[ish][i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Spin blocks to be read:
|
2016-05-09 10:19:56 +02:00
|
|
|
n_spin_blocs = SP + 1 - SO
|
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# read the list of n_orbitals for all k points
|
2023-01-23 21:40:57 +01:00
|
|
|
n_orbitals = numpy.zeros([n_k, n_spin_blocs], int)
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2020-04-08 21:35:59 +02:00
|
|
|
n_orbitals[ik, isp] = int(next(R))
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Initialise the projectors:
|
2016-05-09 10:19:56 +02:00
|
|
|
proj_mat = numpy.zeros([n_k, n_spin_blocs, n_corr_shells, max(
|
2023-01-23 21:40:57 +01:00
|
|
|
[crsh['dim'] for crsh in corr_shells]), numpy.max(n_orbitals)], complex)
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Read the projectors from the file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for icrsh in range(n_corr_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
n_orb = corr_shells[icrsh]['dim']
|
2016-05-09 10:19:56 +02:00
|
|
|
# first Real part for BOTH spins, due to conventions in
|
|
|
|
# dmftproj:
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik][isp]):
|
2020-04-08 21:35:59 +02:00
|
|
|
proj_mat[ik, isp, icrsh, i, j] = next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
# now Imag part:
|
|
|
|
for isp in range(n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
|
|
|
for j in range(n_orbitals[ik][isp]):
|
2020-04-08 21:35:59 +02:00
|
|
|
proj_mat[ik, isp, icrsh, i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# now define the arrays for weights and hopping ...
|
2016-05-09 10:19:56 +02:00
|
|
|
# w(k_index), default normalisation
|
2023-01-23 21:40:57 +01:00
|
|
|
bz_weights = numpy.ones([n_k], float) / float(n_k)
|
2016-05-09 10:19:56 +02:00
|
|
|
hopping = numpy.zeros([n_k, n_spin_blocs, numpy.max(
|
2023-01-23 21:40:57 +01:00
|
|
|
n_orbitals), numpy.max(n_orbitals)], complex)
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# weights in the file
|
2016-05-09 10:19:56 +02:00
|
|
|
for ik in range(n_k):
|
2020-04-08 21:35:59 +02:00
|
|
|
bz_weights[ik] = next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# if the sum over spins is in the weights, take it out again!!
|
|
|
|
sm = sum(bz_weights)
|
2016-05-09 10:19:56 +02:00
|
|
|
bz_weights[:] /= sm
|
2014-09-22 19:24:33 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Grab the H
|
2016-05-09 10:19:56 +02:00
|
|
|
# we use now the convention of a DIAGONAL Hamiltonian -- convention
|
|
|
|
# for Wien2K.
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
for ik in range(n_k):
|
|
|
|
n_orb = n_orbitals[ik, isp]
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
2020-04-08 21:35:59 +02:00
|
|
|
hopping[ik, isp, i, i] = next(R) * energy_unit
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2014-09-22 19:24:33 +02:00
|
|
|
# keep some things that we need for reading parproj:
|
2016-05-09 10:19:56 +02:00
|
|
|
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:
|
|
|
|
setattr(self, it, locals()[it])
|
|
|
|
except StopIteration: # a more explicit error if the file is corrupted.
|
2020-06-23 11:13:00 +02:00
|
|
|
raise IOError("wien2k : reading file %s failed!" % self.dft_file)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2023-01-04 23:16:57 +01:00
|
|
|
#new variable: dft_code - this determines which DFT code the inputs come from.
|
|
|
|
#used for certain routines within dft_tools if treating the inputs differently is required.
|
|
|
|
dft_code = 'wien2k'
|
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (self.dft_subgrp in ar):
|
|
|
|
ar.create_group(self.dft_subgrp)
|
|
|
|
# The subgroup containing the data. If it does not exist, it is
|
|
|
|
# created. If it exists, the data is overwritten!
|
|
|
|
things_to_save = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required',
|
2016-05-09 10:19:56 +02:00
|
|
|
'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',
|
2023-01-04 23:16:57 +01:00
|
|
|
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr', 'dft_code']
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_save:
|
|
|
|
ar[self.dft_subgrp][it] = locals()[it]
|
2014-10-31 18:52:32 +01:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
# Symmetries are used, so now convert symmetry information for
|
|
|
|
# *correlated* orbitals:
|
|
|
|
self.convert_symmetry_input(orbits=self.corr_shells, symm_file=self.symmcorr_file,
|
|
|
|
symm_subgrp=self.symmcorr_subgrp, SO=self.SO, SP=self.SP)
|
2015-03-12 00:01:12 +01:00
|
|
|
self.convert_misc_input()
|
2014-10-31 18:52:32 +01:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
def convert_parproj_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2022-03-01 23:51:39 +01:00
|
|
|
Reads the appropriate files and stores the data for the
|
2015-03-12 00:01:12 +01:00
|
|
|
|
|
|
|
- parproj_subgrp
|
|
|
|
- symmpar_subgrp
|
|
|
|
|
2022-03-01 23:51:39 +01:00
|
|
|
in the hdf5 archive.
|
2015-03-12 00:01:12 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
2015-07-07 15:08:53 +02:00
|
|
|
|
|
|
|
# get needed data from hdf file
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
things_to_read = ['SP', 'SO', 'n_shells',
|
2016-05-09 10:19:56 +02:00
|
|
|
'n_k', 'n_orbitals', 'shells']
|
2015-07-07 15:08:53 +02:00
|
|
|
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_read:
|
|
|
|
if not hasattr(self, it):
|
|
|
|
setattr(self, it, ar[self.dft_subgrp][it])
|
|
|
|
self.n_spin_blocs = self.SP + 1 - self.SO
|
2015-07-07 15:08:53 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % self.parproj_file)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2023-01-23 21:40:57 +01:00
|
|
|
dens_mat_below = [[numpy.zeros([self.shells[ish]['dim'], self.shells[ish]['dim']], complex) for ish in range(self.n_shells)]
|
2016-05-09 10:19:56 +02:00
|
|
|
for isp in range(self.n_spin_blocs)]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, self.parproj_file, self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2020-04-08 21:35:59 +02:00
|
|
|
n_parproj = [int(next(R)) for i in range(self.n_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
n_parproj = numpy.array(n_parproj)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Initialise P, here a double list of matrices:
|
2016-05-09 10:19:56 +02:00
|
|
|
proj_mat_all = numpy.zeros([self.n_k, self.n_spin_blocs, self.n_shells, max(
|
2023-01-23 21:40:57 +01:00
|
|
|
n_parproj), max([sh['dim'] for sh in self.shells]), numpy.max(self.n_orbitals)], complex)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
rot_mat_all = [numpy.identity(
|
2023-01-23 21:40:57 +01:00
|
|
|
self.shells[ish]['dim'], complex) for ish in range(self.n_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
rot_mat_all_time_inv = [0 for i in range(self.n_shells)]
|
|
|
|
|
|
|
|
for ish in range(self.n_shells):
|
|
|
|
# read first the projectors for this orbital:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(self.n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for ir in range(n_parproj[ish]):
|
2014-11-03 14:47:55 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
# read real part:
|
|
|
|
for i in range(self.shells[ish]['dim']):
|
2014-11-26 16:24:02 +01:00
|
|
|
for j in range(self.n_orbitals[ik][isp]):
|
2020-04-08 21:35:59 +02:00
|
|
|
proj_mat_all[ik, isp, ish, ir, i, j] = next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
# read imaginary part:
|
|
|
|
for i in range(self.shells[ish]['dim']):
|
2014-11-26 16:24:02 +01:00
|
|
|
for j in range(self.n_orbitals[ik][isp]):
|
2016-05-09 10:19:56 +02:00
|
|
|
proj_mat_all[ik, isp, ish,
|
2020-04-08 21:35:59 +02:00
|
|
|
ir, i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
# now read the Density Matrix for this orbital below the energy
|
|
|
|
# window:
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
dens_mat_below[isp][ish][i, j] = next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
# read imaginary part:
|
|
|
|
for i in range(self.shells[ish]['dim']):
|
2014-11-26 16:24:02 +01:00
|
|
|
for j in range(self.shells[ish]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
dens_mat_below[isp][ish][i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
if (self.SP == 0):
|
|
|
|
dens_mat_below[isp][ish] /= 2.0
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Global -> local rotation matrix for this shell:
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read real part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat_all[ish][i, j] = next(R)
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(self.shells[ish]['dim']): # read imaginary part:
|
|
|
|
for j in range(self.shells[ish]['dim']):
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat_all[ish][i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
if (self.SP):
|
2020-04-08 21:35:59 +02:00
|
|
|
rot_mat_all_time_inv[ish] = int(next(R))
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (self.parproj_subgrp in ar):
|
|
|
|
ar.create_group(self.parproj_subgrp)
|
|
|
|
# The subgroup containing the data. If it does not exist, it is
|
|
|
|
# created. If it exists, the data is overwritten!
|
|
|
|
things_to_save = ['dens_mat_below', 'n_parproj',
|
2016-05-09 10:19:56 +02:00
|
|
|
'proj_mat_all', 'rot_mat_all', 'rot_mat_all_time_inv']
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_save:
|
|
|
|
ar[self.parproj_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
# Symmetries are used, so now convert symmetry information for *all*
|
|
|
|
# orbitals:
|
|
|
|
self.convert_symmetry_input(orbits=self.shells, symm_file=self.symmpar_file,
|
|
|
|
symm_subgrp=self.symmpar_subgrp, SO=self.SO, SP=self.SP)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
def convert_bands_input(self):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2022-03-01 23:51:39 +01:00
|
|
|
Reads the appropriate files and stores the data for the bands_subgrp in the hdf5 archive.
|
2015-03-12 00:01:12 +01:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
try:
|
2015-07-07 15:08:53 +02:00
|
|
|
# get needed data from hdf file
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
things_to_read = ['SP', 'SO', 'n_corr_shells',
|
2016-05-09 10:19:56 +02:00
|
|
|
'n_shells', 'corr_shells', 'shells', 'energy_unit']
|
2015-07-07 15:08:53 +02:00
|
|
|
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_read:
|
|
|
|
if not hasattr(self, it):
|
|
|
|
setattr(self, it, ar[self.dft_subgrp][it])
|
|
|
|
self.n_spin_blocs = self.SP + 1 - self.SO
|
2015-07-07 15:08:53 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % self.band_file)
|
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, self.band_file, self.fortran_to_replace)
|
2020-04-08 21:35:59 +02:00
|
|
|
n_k = int(next(R))
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# read the list of n_orbitals for all k points
|
2023-01-23 21:40:57 +01:00
|
|
|
n_orbitals = numpy.zeros([n_k, self.n_spin_blocs], int)
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2020-04-08 21:35:59 +02:00
|
|
|
n_orbitals[ik, isp] = int(next(R))
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Initialise the projectors:
|
2016-05-09 10:19:56 +02:00
|
|
|
proj_mat = numpy.zeros([n_k, self.n_spin_blocs, self.n_corr_shells, max(
|
2023-01-23 21:40:57 +01:00
|
|
|
[crsh['dim'] for crsh in self.corr_shells]), numpy.max(n_orbitals)], complex)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Read the projectors from the file:
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for icrsh in range(self.n_corr_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
n_orb = self.corr_shells[icrsh]['dim']
|
2016-05-09 10:19:56 +02:00
|
|
|
# first Real part for BOTH spins, due to conventions in
|
|
|
|
# dmftproj:
|
2013-07-23 19:49:42 +02:00
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
2016-05-09 10:19:56 +02:00
|
|
|
for j in range(n_orbitals[ik, isp]):
|
2020-04-08 21:35:59 +02:00
|
|
|
proj_mat[ik, isp, icrsh, i, j] = next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
# now Imag part:
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
2016-05-09 10:19:56 +02:00
|
|
|
for j in range(n_orbitals[ik, isp]):
|
2020-04-08 21:35:59 +02:00
|
|
|
proj_mat[ik, isp, icrsh, i, j] += 1j * next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
hopping = numpy.zeros([n_k, self.n_spin_blocs, numpy.max(
|
2023-01-23 21:40:57 +01:00
|
|
|
n_orbitals), numpy.max(n_orbitals)], complex)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Grab the H
|
|
|
|
# we use now the convention of a DIAGONAL Hamiltonian!!!!
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
for ik in range(n_k):
|
|
|
|
n_orb = n_orbitals[ik, isp]
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(n_orb):
|
2020-04-08 21:35:59 +02:00
|
|
|
hopping[ik, isp, i, i] = next(R) * self.energy_unit
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# now read the partial projectors:
|
2020-04-08 21:35:59 +02:00
|
|
|
n_parproj = [int(next(R)) for i in range(self.n_shells)]
|
2013-07-23 19:49:42 +02:00
|
|
|
n_parproj = numpy.array(n_parproj)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
# Initialise P, here a double list of matrices:
|
2016-05-09 10:19:56 +02:00
|
|
|
proj_mat_all = numpy.zeros([n_k, self.n_spin_blocs, self.n_shells, max(n_parproj), max(
|
2023-01-23 21:40:57 +01:00
|
|
|
[sh['dim'] for sh in self.shells]), numpy.max(n_orbitals)], complex)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
for ish in range(self.n_shells):
|
2014-11-26 16:24:02 +01:00
|
|
|
for ik in range(n_k):
|
2013-07-23 19:49:42 +02:00
|
|
|
for ir in range(n_parproj[ish]):
|
|
|
|
for isp in range(self.n_spin_blocs):
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
# read real part:
|
|
|
|
for i in range(self.shells[ish]['dim']):
|
|
|
|
for j in range(n_orbitals[ik, isp]):
|
|
|
|
proj_mat_all[ik, isp, ish,
|
2020-04-08 21:35:59 +02:00
|
|
|
ir, i, j] = next(R)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
# read imaginary part:
|
|
|
|
for i in range(self.shells[ish]['dim']):
|
|
|
|
for j in range(n_orbitals[ik, isp]):
|
|
|
|
proj_mat_all[ik, isp, ish,
|
2020-04-08 21:35:59 +02:00
|
|
|
ir, i, j] += 1j * next(R)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2015-07-07 15:08:53 +02:00
|
|
|
R.close()
|
|
|
|
|
|
|
|
except KeyError:
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_bands_input : Needed data not found in hdf file. Consider calling convert_dft_input first!")
|
2016-05-09 10:19:56 +02:00
|
|
|
except StopIteration: # a more explicit error if the file is corrupted.
|
2020-06-23 11:13:00 +02:00
|
|
|
raise IOError("wien2k : reading file %s failed!" % self.band_file)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2014-11-03 14:47:55 +01:00
|
|
|
# Save it to the HDF:
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (self.bands_subgrp in ar):
|
|
|
|
ar.create_group(self.bands_subgrp)
|
|
|
|
# The subgroup containing the data. If it does not exist, it is
|
|
|
|
# created. If it exists, the data is overwritten!
|
|
|
|
things_to_save = ['n_k', 'n_orbitals', 'proj_mat',
|
2016-05-09 10:19:56 +02:00
|
|
|
'hopping', 'n_parproj', 'proj_mat_all']
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_save:
|
|
|
|
ar[self.bands_subgrp][it] = locals()[it]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2015-03-12 00:01:12 +01:00
|
|
|
def convert_misc_input(self):
|
2014-11-03 11:16:32 +01:00
|
|
|
"""
|
2015-03-12 00:01:12 +01:00
|
|
|
Reads additional information on:
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2015-03-12 00:01:12 +01:00
|
|
|
- the band window from :file:`case.oubwin`,
|
|
|
|
- lattice parameters from :file:`case.struct`,
|
|
|
|
- symmetries from :file:`case.outputs`,
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2015-03-12 00:01:12 +01:00
|
|
|
if those Wien2k files are present and stores the data in the hdf5 archive.
|
2022-03-01 23:51:39 +01:00
|
|
|
This function is automatically called by :meth:`convert_dft_input <triqs_dft_tools.converters.wien2k.Wien2kConverter.convert_dft_input>`.
|
2015-03-12 00:01:12 +01:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
|
|
|
|
2015-03-12 00:01:12 +01:00
|
|
|
# Check if SP, SO and n_k are already in h5
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'r') as ar:
|
|
|
|
if not (self.dft_subgrp in ar):
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_misc_input: No %s subgroup in hdf file found! Call convert_dft_input first." % self.dft_subgrp)
|
2018-12-06 23:28:49 +01:00
|
|
|
SP = ar[self.dft_subgrp]['SP']
|
|
|
|
SO = ar[self.dft_subgrp]['SO']
|
|
|
|
n_k = ar[self.dft_subgrp]['n_k']
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2015-02-24 18:14:05 +01:00
|
|
|
things_to_save = []
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
# Read relevant data from .oubwin/up/dn files
|
|
|
|
#############################################
|
|
|
|
# band_window: Contains the index of the lowest and highest band within the
|
|
|
|
# projected subspace (used by dmftproj) for each k-point.
|
2014-12-19 11:53:06 +01:00
|
|
|
|
2019-06-26 20:19:18 +02:00
|
|
|
if (SP == 0 and SO == 0): # read .oubwin file
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.bandwin_file]
|
2019-06-26 20:19:18 +02:00
|
|
|
elif (SP == 1 and SO == 0): # read .oubwinup and .oubwindn
|
2016-05-09 10:19:56 +02:00
|
|
|
files = [self.bandwin_file + 'up', self.bandwin_file + 'dn']
|
2019-06-26 20:19:18 +02:00
|
|
|
elif (SP == 1 and SO == 1): # read either .oubwinup or .oubwindn
|
|
|
|
if os.path.exists(self.bandwin_file + 'up'):
|
|
|
|
files = [self.bandwin_file + 'up']
|
|
|
|
elif os.path.exists(self.bandwin_file + 'dn'):
|
|
|
|
files = [self.bandwin_file + 'dn']
|
|
|
|
else:
|
|
|
|
assert 0, "convert_misc_input: If SO and SP are 1 provide either .oubwinup or .oubwindn file"
|
2019-06-14 17:18:58 +02:00
|
|
|
else:
|
2019-06-14 17:08:12 +02:00
|
|
|
assert 0, "convert_misc_input: Reading oubwin error! Check SP and SO, if SO=1 SP must be 1."
|
2015-07-07 15:26:04 +02:00
|
|
|
|
|
|
|
band_window = [None for isp in range(SP + 1 - SO)]
|
2014-12-11 12:11:48 +01:00
|
|
|
for isp, f in enumerate(files):
|
2015-02-20 15:15:17 +01:00
|
|
|
if os.path.exists(f):
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % f)
|
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, f, self.fortran_to_replace)
|
2020-04-08 21:35:59 +02:00
|
|
|
n_k_oubwin = int(next(R))
|
2015-07-07 15:26:04 +02:00
|
|
|
if (n_k_oubwin != n_k):
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report(
|
|
|
|
"convert_misc_input : WARNING : n_k in case.oubwin is different from n_k in case.klist")
|
|
|
|
assert int(
|
2020-04-08 21:35:59 +02:00
|
|
|
next(R)) == SO, "convert_misc_input: SO is inconsistent in oubwin file!"
|
2015-07-07 15:26:04 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
band_window[isp] = numpy.zeros((n_k_oubwin, 2), dtype=int)
|
2020-04-08 21:35:59 +02:00
|
|
|
for ik in range(n_k_oubwin):
|
|
|
|
next(R)
|
|
|
|
band_window[isp][ik, 0] = next(R) # lowest band
|
|
|
|
band_window[isp][ik, 1] = next(R) # highest band
|
|
|
|
next(R)
|
2015-02-24 18:14:05 +01:00
|
|
|
things_to_save.append('band_window')
|
2015-02-10 11:55:44 +01:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
R.close() # Reading done!
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Read relevant data from .struct file
|
2014-12-19 11:53:06 +01:00
|
|
|
######################################
|
|
|
|
# lattice_type: bravais lattice type as defined by Wien2k
|
|
|
|
# lattice_constants: unit cell parameters in a. u.
|
|
|
|
# lattice_angles: unit cell angles in rad
|
|
|
|
|
2015-02-20 15:15:17 +01:00
|
|
|
if (os.path.exists(self.struct_file)):
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % self.struct_file)
|
|
|
|
|
2015-02-20 15:15:17 +01:00
|
|
|
with open(self.struct_file) as R:
|
|
|
|
try:
|
|
|
|
R.readline()
|
|
|
|
lattice_type = R.readline().split()[0]
|
|
|
|
R.readline()
|
2015-03-03 18:43:50 +01:00
|
|
|
temp = R.readline()
|
2016-05-09 10:19:56 +02:00
|
|
|
lattice_constants = numpy.array(
|
|
|
|
[float(temp[0 + 10 * i:10 + 10 * i].strip()) for i in range(3)])
|
|
|
|
lattice_angles = numpy.array(
|
|
|
|
[float(temp[30 + 10 * i:40 + 10 * i].strip()) for i in range(3)]) * numpy.pi / 180.0
|
|
|
|
things_to_save.extend(
|
|
|
|
['lattice_type', 'lattice_constants', 'lattice_angles'])
|
2015-02-20 15:15:17 +01:00
|
|
|
except IOError:
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_misc_input: reading file %s failed" % self.struct_file)
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Read relevant data from .outputs file
|
2014-12-19 11:53:06 +01:00
|
|
|
#######################################
|
2016-05-09 10:19:56 +02:00
|
|
|
# rot_symmetries: matrix representation of all (space group) symmetry
|
|
|
|
# operations
|
|
|
|
|
2015-02-20 15:15:17 +01:00
|
|
|
if (os.path.exists(self.outputs_file)):
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % self.outputs_file)
|
|
|
|
|
2015-02-20 15:15:17 +01:00
|
|
|
rot_symmetries = []
|
|
|
|
with open(self.outputs_file) as R:
|
|
|
|
try:
|
2014-11-03 11:16:32 +01:00
|
|
|
while 1:
|
2015-02-20 15:15:17 +01:00
|
|
|
temp = R.readline().strip(' ').split()
|
2016-05-09 10:19:56 +02:00
|
|
|
if (temp[0] == 'PGBSYM:'):
|
2015-02-20 15:15:17 +01:00
|
|
|
n_symmetries = int(temp[-1])
|
|
|
|
break
|
|
|
|
for i in range(n_symmetries):
|
|
|
|
while 1:
|
2016-05-09 10:19:56 +02:00
|
|
|
if (R.readline().strip().split()[0] == 'Symmetry'):
|
|
|
|
break
|
|
|
|
sym_i = numpy.zeros((3, 3), dtype=float)
|
2015-02-20 15:15:17 +01:00
|
|
|
for ir in range(3):
|
|
|
|
temp = R.readline().strip().split()
|
|
|
|
for ic in range(3):
|
|
|
|
sym_i[ir, ic] = float(temp[ic])
|
|
|
|
R.readline()
|
|
|
|
rot_symmetries.append(sym_i)
|
2015-02-24 18:14:05 +01:00
|
|
|
things_to_save.extend(['n_symmetries', 'rot_symmetries'])
|
|
|
|
things_to_save.append('rot_symmetries')
|
2015-02-20 15:15:17 +01:00
|
|
|
except IOError:
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_misc_input: reading file %s failed" % self.outputs_file)
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
# Save it to the HDF:
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (self.misc_subgrp in ar):
|
|
|
|
ar.create_group(self.misc_subgrp)
|
|
|
|
for it in things_to_save:
|
|
|
|
ar[self.misc_subgrp][it] = locals()[it]
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
def convert_transport_input(self):
|
2022-03-01 23:51:39 +01:00
|
|
|
"""
|
2015-03-12 00:01:12 +01:00
|
|
|
Reads the necessary information for transport calculations on:
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2015-03-12 00:01:12 +01:00
|
|
|
- the optical band window and the velocity matrix elements from :file:`case.pmat`
|
|
|
|
|
|
|
|
and stores the data in the hdf5 archive.
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
"""
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
|
|
|
|
2015-02-10 11:55:44 +01:00
|
|
|
# Check if SP, SO and n_k are already in h5
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'r') as ar:
|
|
|
|
if not (self.dft_subgrp in ar):
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_transport_input: No %s subgroup in hdf file found! Call convert_dft_input first." % self.dft_subgrp)
|
2018-12-06 23:28:49 +01:00
|
|
|
SP = ar[self.dft_subgrp]['SP']
|
|
|
|
SO = ar[self.dft_subgrp]['SO']
|
|
|
|
n_k = ar[self.dft_subgrp]['n_k']
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
# Read relevant data from .pmat/up/dn files
|
|
|
|
###########################################
|
|
|
|
# band_window_optics: Contains the index of the lowest and highest band within the
|
|
|
|
# band window (used by optics) for each k-point.
|
|
|
|
# velocities_k: velocity (momentum) matrix elements between all bands in band_window_optics
|
|
|
|
# and each k-point.
|
|
|
|
|
2019-06-26 20:19:18 +02:00
|
|
|
if (SP == 0 and SO == 0): # read .pmat file
|
2015-02-10 11:55:44 +01:00
|
|
|
files = [self.pmat_file]
|
2019-06-26 20:19:18 +02:00
|
|
|
elif (SP == 1 and SO == 0): # read .pmatup and pmatdn
|
2016-05-09 10:19:56 +02:00
|
|
|
files = [self.pmat_file + 'up', self.pmat_file + 'dn']
|
2019-06-26 20:19:18 +02:00
|
|
|
elif (SP == 1 and SO == 1): # read either .pmatup or .pmatdn
|
|
|
|
if os.path.exists(self.pmat_file + 'up'):
|
|
|
|
files = [self.pmat_file + 'up']
|
|
|
|
elif os.path.exists(self.pmat_file + 'dn'):
|
|
|
|
files = [self.pmat_file + 'dn']
|
|
|
|
else:
|
|
|
|
assert 0, "convert_transport_input: If SO and SP are 1 provide either .pmatup or .pmatdn file"
|
2019-06-14 17:18:58 +02:00
|
|
|
else:
|
2019-06-14 17:08:12 +02:00
|
|
|
assert 0, "convert_transport_input: Reading velocity file error! Check SP and SO, if SO=1 SP must be 1."
|
2015-02-10 11:55:44 +01:00
|
|
|
|
|
|
|
velocities_k = [[] for f in files]
|
|
|
|
band_window_optics = []
|
2014-12-09 16:47:40 +01:00
|
|
|
for isp, f in enumerate(files):
|
2016-05-09 10:19:56 +02:00
|
|
|
if not os.path.exists(f):
|
2020-04-08 21:35:59 +02:00
|
|
|
raise IOError("convert_transport_input: File %s does not exist" % f)
|
2016-05-09 10:19:56 +02:00
|
|
|
mpi.report("Reading input from %s..." % f)
|
2015-02-10 11:55:44 +01:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, f, {'D': 'E', '(': '', ')': '', ',': ' '})
|
2015-02-10 11:55:44 +01:00
|
|
|
band_window_optics_isp = []
|
2020-04-08 21:35:59 +02:00
|
|
|
for ik in range(n_k):
|
|
|
|
next(R)
|
|
|
|
nu1 = int(next(R))
|
|
|
|
nu2 = int(next(R))
|
2015-02-10 11:55:44 +01:00
|
|
|
band_window_optics_isp.append((nu1, nu2))
|
|
|
|
n_bands = nu2 - nu1 + 1
|
2016-05-09 10:19:56 +02:00
|
|
|
for _ in range(4):
|
2020-04-08 21:35:59 +02:00
|
|
|
next(R)
|
2015-02-10 11:55:44 +01:00
|
|
|
if n_bands <= 0:
|
2016-05-09 10:19:56 +02:00
|
|
|
velocity_xyz = numpy.zeros((1, 1, 3), dtype=complex)
|
2015-02-10 11:55:44 +01:00
|
|
|
else:
|
2016-05-09 10:19:56 +02:00
|
|
|
velocity_xyz = numpy.zeros(
|
|
|
|
(n_bands, n_bands, 3), dtype=complex)
|
2015-02-10 11:55:44 +01:00
|
|
|
for nu_i in range(n_bands):
|
|
|
|
for nu_j in range(nu_i, n_bands):
|
|
|
|
for i in range(3):
|
2016-05-09 10:19:56 +02:00
|
|
|
velocity_xyz[nu_i][nu_j][
|
2020-04-08 21:35:59 +02:00
|
|
|
i] = next(R) + next(R) * 1j
|
2016-05-09 10:19:56 +02:00
|
|
|
if (nu_i != nu_j):
|
|
|
|
velocity_xyz[nu_j][nu_i][i] = velocity_xyz[
|
|
|
|
nu_i][nu_j][i].conjugate()
|
2015-02-10 11:55:44 +01:00
|
|
|
velocities_k[isp].append(velocity_xyz)
|
|
|
|
band_window_optics.append(numpy.array(band_window_optics_isp))
|
2022-09-29 18:27:04 +02:00
|
|
|
# check the number of kpoints is correct
|
|
|
|
last_kpt = None
|
|
|
|
try:
|
|
|
|
last_kpt = next(R)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if last_kpt is not None:
|
|
|
|
raise ValueError("The number of kpoints in case.pmat is larger than number of kpoints of Green's function. Please rerun dmftproj")
|
2016-05-09 10:19:56 +02:00
|
|
|
R.close() # Reading done!
|
2014-11-03 11:16:32 +01:00
|
|
|
|
|
|
|
# Put data to HDF5 file
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (self.transp_subgrp in ar):
|
|
|
|
ar.create_group(self.transp_subgrp)
|
|
|
|
# The subgroup containing the data. If it does not exist, it is
|
|
|
|
# created. If it exists, the data is overwritten!!!
|
|
|
|
things_to_save = ['band_window_optics', 'velocities_k']
|
|
|
|
for it in things_to_save:
|
|
|
|
ar[self.transp_subgrp][it] = locals()[it]
|
2014-11-03 11:16:32 +01:00
|
|
|
|
2014-10-31 18:52:32 +01:00
|
|
|
def convert_symmetry_input(self, orbits, symm_file, symm_subgrp, SO, SP):
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
2015-03-12 00:01:12 +01:00
|
|
|
Reads and stores symmetrisation data from symm_file, which can be is case.sympar or case.symqmc.
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
orbits : list of dicts
|
2022-03-01 23:51:39 +01:00
|
|
|
This is either shells or corr_shells depending on whether the symmetry
|
2015-03-12 00:01:12 +01:00
|
|
|
information is for correlated shells or partial projectors.
|
|
|
|
symm_file : string
|
2022-03-01 23:51:39 +01:00
|
|
|
Name of the file containing symmetry data.
|
2015-03-12 00:01:12 +01:00
|
|
|
This is case.symqmc for correlated shells and case.sympar for partial projectors.
|
|
|
|
symm_subgrp : string, optional
|
|
|
|
Name of subgroup storing symmetry data.
|
|
|
|
SO : integer
|
|
|
|
Is spin-orbit coupling considered?
|
|
|
|
SP : integer
|
|
|
|
Is the system spin-polarised?
|
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
"""
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if not (mpi.is_master_node()):
|
|
|
|
return
|
|
|
|
mpi.report("Reading input from %s..." % symm_file)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
n_orbits = len(orbits)
|
2014-11-08 23:51:24 +01:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
R = ConverterTools.read_fortran_file(
|
|
|
|
self, symm_file, self.fortran_to_replace)
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
try:
|
2020-04-08 21:35:59 +02:00
|
|
|
n_symm = int(next(R)) # Number of symmetry operations
|
|
|
|
n_atoms = int(next(R)) # number of atoms involved
|
|
|
|
perm = [[int(next(R)) for i in range(n_atoms)]
|
2016-05-09 10:19:56 +02:00
|
|
|
for j in range(n_symm)] # list of permutations of the atoms
|
|
|
|
if SP:
|
|
|
|
# time inversion for SO coupling
|
2020-04-08 21:35:59 +02:00
|
|
|
time_inv = [int(next(R)) for j in range(n_symm)]
|
2013-07-23 19:49:42 +02:00
|
|
|
else:
|
2016-05-09 10:19:56 +02:00
|
|
|
time_inv = [0 for j in range(n_symm)]
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Now read matrices:
|
2016-05-09 10:19:56 +02:00
|
|
|
mat = []
|
2014-11-26 16:24:02 +01:00
|
|
|
for i_symm in range(n_symm):
|
2016-05-09 10:19:56 +02:00
|
|
|
|
|
|
|
mat.append([numpy.zeros([orbits[orb]['dim'], orbits[orb][
|
2023-01-23 21:40:57 +01:00
|
|
|
'dim']], complex) for orb in range(n_orbits)])
|
2013-07-23 19:49:42 +02:00
|
|
|
for orb in range(n_orbits):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2016-05-09 10:19:56 +02:00
|
|
|
# real part
|
2020-04-08 21:35:59 +02:00
|
|
|
mat[i_symm][orb][i, j] = next(R)
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2016-05-09 10:19:56 +02:00
|
|
|
mat[i_symm][orb][i, j] += 1j * \
|
2020-04-08 21:35:59 +02:00
|
|
|
next(R) # imaginary part
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2023-01-23 21:40:57 +01:00
|
|
|
mat_tinv = [numpy.identity(orbits[orb]['dim'], complex)
|
2013-07-23 19:49:42 +02:00
|
|
|
for orb in range(n_orbits)]
|
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
if ((SO == 0) and (SP == 0)):
|
|
|
|
# here we need an additional time inversion operation, so read
|
|
|
|
# it:
|
2013-07-23 19:49:42 +02:00
|
|
|
for orb in range(n_orbits):
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2016-05-09 10:19:56 +02:00
|
|
|
# real part
|
2020-04-08 21:35:59 +02:00
|
|
|
mat_tinv[orb][i, j] = next(R)
|
2014-11-26 16:24:02 +01:00
|
|
|
for i in range(orbits[orb]['dim']):
|
|
|
|
for j in range(orbits[orb]['dim']):
|
2016-05-09 10:19:56 +02:00
|
|
|
mat_tinv[orb][i, j] += 1j * \
|
2020-04-08 21:35:59 +02:00
|
|
|
next(R) # imaginary part
|
2013-07-23 19:49:42 +02:00
|
|
|
|
2016-05-09 10:19:56 +02:00
|
|
|
except StopIteration: # a more explicit error if the file is corrupted.
|
2020-06-23 11:13:00 +02:00
|
|
|
raise IOError("wien2k : reading file %s failed!" %symm_file)
|
2016-05-09 10:19:56 +02:00
|
|
|
|
2013-07-23 19:49:42 +02:00
|
|
|
R.close()
|
2014-11-03 14:47:55 +01:00
|
|
|
# Reading done!
|
2013-07-23 19:49:42 +02:00
|
|
|
|
|
|
|
# Save it to the HDF:
|
2018-12-06 23:28:49 +01:00
|
|
|
with HDFArchive(self.hdf_file, 'a') as ar:
|
|
|
|
if not (symm_subgrp in ar):
|
|
|
|
ar.create_group(symm_subgrp)
|
|
|
|
things_to_save = ['n_symm', 'n_atoms', 'perm',
|
2016-05-09 10:19:56 +02:00
|
|
|
'orbits', 'SO', 'SP', 'time_inv', 'mat', 'mat_tinv']
|
2018-12-06 23:28:49 +01:00
|
|
|
for it in things_to_save:
|
|
|
|
ar[symm_subgrp][it] = locals()[it]
|