update documentation to use autosummary

* remove manual module reference files
* move hdf5 structure reference to guide
* fix various doc strings
* remove very old update_archive python script for triqs 1.2
* refine main documentation.rst file -> better overview
This commit is contained in:
Alexander Hampel 2022-03-01 17:51:39 -05:00
parent 9a512320d2
commit c4db7e6867
30 changed files with 122 additions and 320 deletions

View File

@ -1,4 +1,4 @@
{{ fullname | escape | underline}}
{{ name | escape | underline}}
.. automodule:: {{ fullname }}

View File

@ -76,7 +76,7 @@ html_theme_options = {
# Toc options
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 5,
'navigation_depth': 4,
'includehidden': True,
'titles_only': False
}

View File

@ -9,7 +9,7 @@ Basic notions
-------------
.. toctree::
:maxdepth: 2
:maxdepth: 1
basicnotions/first
basicnotions/dft_dmft
@ -23,6 +23,7 @@ Construction of local orbitals from DFT
:maxdepth: 2
guide/conversion
h5structure
DFT+DMFT
@ -38,7 +39,7 @@ Advanced Topics
---------------
.. toctree::
:maxdepth: 2
:maxdepth: 1
guide/blockstructure
guide/BasisRotation
@ -48,7 +49,7 @@ Postprocessing
--------------
.. toctree::
:maxdepth: 2
:maxdepth: 1
guide/analysis
guide/transport
@ -59,16 +60,18 @@ Reference manual
This is the reference manual for the python routines.
.. toctree::
:maxdepth: 2
.. autosummary::
:recursive:
:toctree: _python_api
:template: autosummary_module_template.rst
block_structure
converters
sumk_dft
sumk_dft_tools
symmetry
trans_basis
reference/h5structure
reference/converters
reference/sumk_dft
reference/sumk_dft_tools
reference/symmetry
reference/transbasis
reference/block_structure
FAQs

View File

@ -95,6 +95,6 @@ where :file:`hkinputfile` is the name of the input file described
above. This produces the hdf file that you need for a DMFT calculation.
For more options of this converter, have a look at the
:ref:`refconverters` section of the reference manual.
:py:mod:`Converters <triqs_dft_tools.converters>` section of the reference manual.

View File

@ -17,10 +17,10 @@ Hubbard-like model Hamiltonian. Resulting in lattice object stored in `SumkDFT`.
The implementation is presented in `M. Schüler et al. 2018 J. Phys.: Condens.
Matter 30 475901 <https://doi.org/10.1088/1361-648X/aae80a>`_.
The interface consists of two parts, :ref:`PLOVASP<refPLOVASP>`, a collection of
The interface consists of two parts, :py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>`, a collection of
python classes and functions converting the raw VASP output to proper projector
functions, and the python based :ref:`VaspConverter<refVASPconverter>`, which
creates a h5 archive from the :ref:`PLOVASP<refPLOVASP>` output readable by
functions, and the python based :py:mod:`VaspConverter<triqs_dft_tools.converters.vasp>`, which
creates a h5 archive from the :py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>` output readable by
`SumkDFT`. Therefore, the conversion consist always of two steps.
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>`.
@ -134,7 +134,7 @@ described above and it must be chosen independently of the energy range given by
PLOVASP: converting VASP output
--------------------------------
:ref:`PLOVASP<refPLOVASP>` is a collection of python functions and classes, post-processing the raw VASP `LOCPROJ` output creating proper projector functions.
:py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>` is a collection of python functions and classes, post-processing the raw VASP `LOCPROJ` output creating proper projector functions.
The following VASP files are used by PLOVASP:
* PROJCAR, LOCPROJ: raw projectors generated by VASP-PLO interface
@ -176,12 +176,12 @@ or embedded in a python script as::
# Generate and store PLOs
plo_converter.generate_and_output_as_text('plo.cfg', vasp_dir='./')
This will create the xml files `vasp.ctrl` and `vasp.pg1` containing the orthonormalized projector functions readable by the :ref:`VaspConverter<refVASPconverter>`. Moreover, `PLOVASP` will output important information of the orthonormalization process, such as the density matrix of the correlated shell and the local Hamiltonian.
This will create the xml files `vasp.ctrl` and `vasp.pg1` containing the orthonormalized projector functions readable by the :py:mod:`VaspConverter<triqs_dft_tools.converters.vasp>`. Moreover, :py:mod:`PLOVASP<triqs_dft_tools.converters.plovasp>` will output important information of the orthonormalization process, such as the density matrix of the correlated shell and the local Hamiltonian.
Running the VASP converter
-------------------------------------
The actual conversion to a h5-file is performed with the orthonormalized projector functions readable by the :ref:`VaspConverter<refVASPconverter>` in the same fashion as with the other `DFTTools` converters::
The actual conversion to a h5-file is performed with the orthonormalized projector functions readable by the :py:mod:`VaspConverter<triqs_dft_tools.converters.vasp>` in the same fashion as with the other `DFTTools` converters::
from triqs_dft_tools.converters.vasp import *
Converter = VaspConverter(filename = 'vasp')
@ -394,12 +394,14 @@ in the header. One can either copy the Fermi energy manually there after a succe
VASP run, or modify the VASP source code slightly, by replacing the following line in
`locproj.F` (around line 695):
::
< WRITE(99,'(4I6," # of spin, # of k-points, # of bands, # of proj" )') NS,NK,NB,NF
---
> WRITE(99,'(4I6,F12.7," # of spin, # of k-points, # of bands, # of proj, Efermi" )') W%WDES%NCDIJ,NK,NB,NF,EFERMI
Now one needs to pass additionally the variable `EFERMI` to the function, by changing (at arount line 560):
::
< SUBROUTINE LPRJ_WRITE(IU6,IU0,W)
---
> SUBROUTINE LPRJ_WRITE(IU6,IU0,W,EFERMI)
@ -408,6 +410,7 @@ Now one needs to pass additionally the variable `EFERMI` to the function, by cha
Next, we need to pass this option when calling from `electron.F` and `main.F`
(just search for LPRJ_WRITE in the files) and change all occurences as follows:
::
< CALL LPRJ_WRITE(IO%IU6, IO%IU0, W)
---
> CALL LPRJ_WRITE(IO%IU6, IO%IU0, W, EFERMI)
@ -424,13 +427,16 @@ Furthermore, there is a bug in `fileio.F` around line 1710 where VASP tries to
print "reading the density matrix from Gamma". This should be done only by the
master node, and VASP gets stuck sometimes. Adding a
::
IF (IO%IU0>=0) THEN
...
ENDIF
statement resolves this issue. A similar problem occurs, when VASP writes the
`OSZICAR` file and a buffer is stuck. Adding a `flush` to the buffer in
`electron.F` around line 580 after
::
CALL STOP_TIMING("G",IO%IU6,"DOS")
flush(17)
print *, ' '

View File

@ -128,7 +128,7 @@ example, the :program:`Wien2k` naming convention is that all files have the
same name, but different extensions, :file:`case.*`. The constructor opens
an hdf5 archive, named :file:`case.h5`, where all relevant data will be
stored. For other parameters of the constructor please visit the
:ref:`refconverters` section of the reference manual.
:py:mod:`Converters <triqs_dft_tools.converters>` section of the reference manual.
After initializing the interface module, we can now convert the input
text files to the hdf5 archive by::
@ -181,7 +181,7 @@ and convert the input for :class:`SumkDFTTools <dft.sumk_dft_tools.SumkDFTTools>
After having converted this input, you can further proceed with the
:ref:`analysis`. For more options on the converter module, please have
a look at the :ref:`refconverters` section of the reference manual.
a look at the :py:mod:`Converters <triqs_dft_tools.converters>` section of the reference manual.
Data for transport calculations
-------------------------------

View File

@ -39,7 +39,7 @@ Note that in presence of SOC, it is not possible to project only onto the :math:
Treatment of SOC in Elk
-------------------------
First, a Elk calculation including SOC has to be performed. For details, we refer the reader to the SOC Elk examples in Elk's example directory and `Elk manual <https//elk.sourceforge.net/elk.pdf>`_ for further information about the input flags. Then the projectors can be generated using the ``wanproj`` input flag in the same format as in :ref:`conv_elk`. Like in Wien2k, you cannot project only onto the :math:`t_{2g}` subshell because it is not an irreducible representation in SOC calculations.
First, a Elk calculation including SOC has to be performed. For details, we refer the reader to the SOC Elk examples in Elk's example directory and `Elk manual <https//elk.sourceforge.net/elk.pdf>`_ for further information about the input flags. Then the projectors can be generated using the ``wanproj`` input flag in the same format as in :ref:`convElk`. Like in Wien2k, you cannot project only onto the :math:`t_{2g}` subshell because it is not an irreducible representation in SOC calculations.
After generating the projectors
-------------------------------

View File

@ -1,9 +1,9 @@
.. _hdfstructure:
hdf5 structure
==============
standardized hdf5 structure
===========================
All the data is stored using the hdf5 standard, as described also in the
All the DFT input data is stored using the hdf5 standard, as described also in the
documentation of the TRIQS package itself. In order to do a DMFT calculation,
using input from DFT applications, a converter is needed on order to provide
the necessary data in the hdf5 format.

View File

@ -1,21 +0,0 @@
Block Structure
===============
The `BlockStructure` class allows to change and manipulate
Green functions structures and mappings from sumk to solver.
The block structure can also be written to and read from HDF files.
.. warning::
Do not write the individual elements of this class to a HDF file,
as they belong together and changing one without the other can
result in unexpected results. Always write the BlockStructure
object as a whole.
Writing the sumk_to_solver and solver_to_sumk elements
individually is not implemented.
.. autoclass:: triqs_dft_tools.block_structure.BlockStructure
:members:
:show-inheritance:

View File

@ -1,83 +0,0 @@
.. _refconverters:
Converters
==========
Wien2k Converter
----------------
.. autoclass:: triqs_dft_tools.converters.wien2k.Wien2kConverter
:members:
:special-members:
:show-inheritance:
H(k) Converter
--------------
.. autoclass:: triqs_dft_tools.converters.hk.HkConverter
:members:
:special-members:
Wannier90 Converter
-------------------
.. autoclass:: triqs_dft_tools.converters.wannier90.Wannier90Converter
: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
-------------------
.. _refVASPconverter:
.. autoclass:: triqs_dft_tools.converters.vasp.VaspConverter
:members:
:special-members:
Elk Converter
-------------------
.. _refElkconverter:
.. autoclass:: triqs_dft_tools.converters.elk.ElkConverter
:members:
:special-members:
Elk Tools
-------------------
.. _refElkTools:
.. autoclass:: triqs_dft_tools.converters.elktools.ElkConverterTools
:members:
:special-members:
.. autoclass:: triqs_dft_tools.converters.elktools.readElkfiles
:members:
:special-members:
Converter Tools
---------------
.. autoclass:: triqs_dft_tools.converters.converter_tools.ConverterTools
:members:
:special-members:

View File

@ -1,8 +0,0 @@
SumK DFT
========
.. autoclass:: triqs_dft_tools.sumk_dft.SumkDFT
:members:
:special-members:
:show-inheritance:

View File

@ -1,8 +0,0 @@
SumK DFT Tools
==============
.. autoclass:: triqs_dft_tools.sumk_dft_tools.SumkDFTTools
:members:
:special-members:
:show-inheritance:

View File

@ -1,6 +0,0 @@
Symmetry
========
.. autoclass:: triqs_dft_tools.Symmetry
:members:
:special-members:

View File

@ -1,6 +0,0 @@
TransBasis
==========
.. autoclass:: triqs_dft_tools.trans_basis.TransBasis
:members:
:special-members:

View File

@ -1,5 +1,3 @@
.. module:: triqs_dft_tools
.. _tutorials:
Tutorials

View File

@ -21,7 +21,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
Block structure class and helper functions
"""
import copy
import numpy as np
@ -38,6 +40,11 @@ class BlockStructure(object):
This class contains information about the structure of the solver
and sumk Green functions and the mapping between them.
Do not write the individual elements of this class to a HDF file,
as they belong together and changing one without the other can
result in unexpected results. Always write the BlockStructure
object as a whole.
Parameters
----------
gf_struct_sumk : list of list of tuple

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
module containing all available converters for DFTTools
"""
from .wien2k import Wien2kConverter
from .hk import HkConverter

View File

@ -19,6 +19,10 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
Converter helper module
"""
import triqs.utility.mpi as mpi
class ConverterTools:
@ -59,7 +63,7 @@ class ConverterTools:
Note
----
Should only be used before the first invokation of HDFArchive in the program,
Should only be used before the first invokation of HDFArchive in the program,
otherwise the hdf5 linking will be broken.
"""
@ -92,7 +96,7 @@ class ConverterTools:
Number of inequivalent shells.
corr_to_inequiv : list
Mapping between correlated shell index and inequivalent shell index.
corr_to_inequiv(i_corr_shells) = i_inequiv_shells
corr_to_inequiv(i_corr_shells) = i_inequiv_shells
inequiv_to_corr : list
Mapping between inequivalent shell index and correlated shell index.
inequiv_to_corr(i_inequiv_shells) = i_corr_shells

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
Elk converter
"""
from types import *
import numpy

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
elk converter tools for file I/O
"""
from .readElkfiles import readElkfiles
from .elk_converter_tools import ElkConverterTools

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
General H(k) converter
"""
from types import *
import numpy
@ -69,14 +72,14 @@ class HkConverter(ConverterTools):
def convert_dft_input(self, first_real_part_matrix=True, only_upper_triangle=False, weights_in_file=False):
"""
Reads the appropriate files and stores the data for the dft_subgrp in the hdf5 archive.
Reads the appropriate files and stores the data for the dft_subgrp in the hdf5 archive.
Parameters
----------
first_real_part_matrix : boolean, optional
Should all the real components for given k be read in first, followed by the imaginary parts?
only_upper_triangle : boolean, optional
Should only the upper triangular part of H(k) be read in?
Should only the upper triangular part of H(k) be read in?
weights_in_file : boolean, optional
Are the k-point weights to be read in?

View File

@ -22,5 +22,8 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""
plovasp module for I/O operations in the Vasp converter
"""
__all__ = []

View File

@ -23,6 +23,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""
Vasp converter
"""
from types import *
import numpy

View File

@ -45,7 +45,9 @@
# can cause a problem in creating the udis_mat in read_wannier90data
# - add_lambda does not work for multiple impurities
###
"""
Wannier90 converter
"""
import numpy
import os.path

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
Wien2k converter
"""
from types import *
import numpy
@ -99,7 +102,7 @@ class Wien2kConverter(ConverterTools):
- symmcorr_subgrp
- misc_subgrp
in the hdf5 archive.
in the hdf5 archive.
"""
@ -277,12 +280,12 @@ class Wien2kConverter(ConverterTools):
def convert_parproj_input(self):
"""
Reads the appropriate files and stores the data for the
Reads the appropriate files and stores the data for the
- parproj_subgrp
- symmpar_subgrp
in the hdf5 archive.
in the hdf5 archive.
"""
@ -382,7 +385,7 @@ class Wien2kConverter(ConverterTools):
def convert_bands_input(self):
"""
Reads the appropriate files and stores the data for the bands_subgrp in the hdf5 archive.
Reads the appropriate files and stores the data for the bands_subgrp in the hdf5 archive.
"""
@ -496,7 +499,7 @@ class Wien2kConverter(ConverterTools):
- symmetries from :file:`case.outputs`,
if those Wien2k files are present and stores the data in the hdf5 archive.
This function is automatically called by :meth:`convert_dft_input <triqs_dft_tools.converters.wien2k.Wien2kConverter.convert_dft_input>`.
This function is automatically called by :meth:`convert_dft_input <triqs_dft_tools.converters.wien2k.Wien2kConverter.convert_dft_input>`.
"""
@ -619,7 +622,7 @@ class Wien2kConverter(ConverterTools):
ar[self.misc_subgrp][it] = locals()[it]
def convert_transport_input(self):
"""
"""
Reads the necessary information for transport calculations on:
- the optical band window and the velocity matrix elements from :file:`case.pmat`
@ -712,10 +715,10 @@ class Wien2kConverter(ConverterTools):
Parameters
----------
orbits : list of dicts
This is either shells or corr_shells depending on whether the symmetry
This is either shells or corr_shells depending on whether the symmetry
information is for correlated shells or partial projectors.
symm_file : string
Name of the file containing symmetry data.
Name of the file containing symmetry data.
This is case.symqmc for correlated shells and case.sympar for partial projectors.
symm_subgrp : string, optional
Name of subgroup storing symmetry data.

View File

@ -20,6 +20,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
General SumK class and helper functions for combining ab-initio code and triqs
"""
from types import *
import numpy
@ -2215,7 +2218,7 @@ class SumkDFT(object):
valim = deltaN[spn[ispn]][ik][inu, imu].imag
f.write(" %.14f %.14f"%(valre, valim))
f.write("\n")
elif dm_type == 'qe':
assert self.SP == 0, "Spin-polarized density matrix is not implemented"

View File

@ -18,6 +18,10 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
Extension to the SumkDFT class with some analyiss tools
"""
import sys
from types import *
import numpy

View File

@ -19,6 +19,9 @@
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
"""
module for the symmetry operations in k sums
"""
import copy
import numpy
@ -85,12 +88,12 @@ class Symmetry:
def symmetrize(self, obj):
"""
Symmetrizes a given object.
Symmetrizes a given object.
Parameters
----------
obj : list
object to symmetrize. It has to be given as list, where its length is determined by the number
object to symmetrize. It has to be given as list, where its length is determined by the number
of equivalent members of the object. Two types of objects are supported:
- BlockGf : list of Green's functions,

View File

@ -1,3 +1,28 @@
##########################################################################
#
# 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/>.
#
##########################################################################
"""
Module for orbital basis transformations
"""
from triqs_dft_tools.sumk_dft import *
from triqs_dft_tools.converters import Wien2kConverter
from triqs.gf import *

View File

@ -1,142 +0,0 @@
from h5 import HDFArchive
import h5py
import sys
import numpy
import subprocess
if len(sys.argv) < 2:
print("Usage: python update_archive.py old_archive [v1.0|v1.2]")
sys.exit()
print("""
This script is an attempt to update your archive to TRIQS 1.2.
Please keep a copy of your old archive as this script is
** not guaranteed ** to work for your archive.
If you encounter any problem please report it on github!
""")
def convert_shells(shells):
shell_entries = ['atom', 'sort', 'l', 'dim']
return [{name: int(val) for name, val in zip(shell_entries, shells[ish])} for ish in range(len(shells))]
def convert_corr_shells(corr_shells):
corr_shell_entries = ['atom', 'sort', 'l', 'dim', 'SO', 'irep']
return [{name: int(val) for name, val in zip(corr_shell_entries, corr_shells[icrsh])} for icrsh in range(len(corr_shells))]
def det_shell_equivalence(corr_shells):
corr_to_inequiv = [0 for i in range(len(corr_shells))]
inequiv_to_corr = [0]
n_inequiv_shells = 1
if len(corr_shells) > 1:
inequiv_sort = [corr_shells[0]['sort']]
inequiv_l = [corr_shells[0]['l']]
for i in range(len(corr_shells) - 1):
is_equiv = False
for j in range(n_inequiv_shells):
if (inequiv_sort[j] == corr_shells[i + 1]['sort']) and (inequiv_l[j] == corr_shells[i + 1]['l']):
is_equiv = True
corr_to_inequiv[i + 1] = j
if is_equiv == False:
corr_to_inequiv[i + 1] = n_inequiv_shells
n_inequiv_shells += 1
inequiv_sort.append(corr_shells[i + 1]['sort'])
inequiv_l.append(corr_shells[i + 1]['l'])
inequiv_to_corr.append(i + 1)
return n_inequiv_shells, corr_to_inequiv, inequiv_to_corr
### Main ###
filename = sys.argv[1]
if len(sys.argv) > 2:
from_v = sys.argv[2]
else: # Assume updating an old v1.0 script
from_v = 'v1.0'
A = h5py.File(filename)
# Rename groups
old_to_new = {'SumK_LDA': 'dft_input', 'SumK_LDA_ParProj': 'dft_parproj_input',
'SymmCorr': 'dft_symmcorr_input', 'SymmPar': 'dft_symmpar_input', 'SumK_LDA_Bands': 'dft_bands_input'}
for old, new in old_to_new.items():
if old not in list(A.keys()):
continue
print("Changing %s to %s ..." % (old, new))
A.copy(old, new)
del(A[old])
# Move output items from dft_input to user_data
move_to_output = ['chemical_potential', 'dc_imp', 'dc_energ']
for obj in move_to_output:
if obj in list(A['dft_input'].keys()):
if 'user_data' not in A:
A.create_group('user_data')
print("Moving %s to user_data ..." % obj)
A.copy('dft_input/' + obj, 'user_data/' + obj)
del(A['dft_input'][obj])
# Delete obsolete quantities
to_delete = ['gf_struct_solver', 'map_inv', 'map', 'deg_shells', 'h_field']
for obj in to_delete:
if obj in list(A['dft_input'].keys()):
del(A['dft_input'][obj])
if from_v == 'v1.0':
# Update shells and corr_shells to list of dicts
shells_old = HDFArchive(filename, 'r')['dft_input']['shells']
corr_shells_old = HDFArchive(filename, 'r')['dft_input']['corr_shells']
shells = convert_shells(shells_old)
corr_shells = convert_corr_shells(corr_shells_old)
del(A['dft_input']['shells'])
del(A['dft_input']['corr_shells'])
A.close()
# Need to use HDFArchive for the following
HDFArchive(filename, 'a')['dft_input']['shells'] = shells
HDFArchive(filename, 'a')['dft_input']['corr_shells'] = corr_shells
A = h5py.File(filename)
# Add shell equivalency quantities
if 'n_inequiv_shells' not in A['dft_input']:
equiv_shell_info = det_shell_equivalence(corr_shells)
A['dft_input']['n_inequiv_shells'] = equiv_shell_info[0]
A['dft_input']['corr_to_inequiv'] = equiv_shell_info[1]
A['dft_input']['inequiv_to_corr'] = equiv_shell_info[2]
# Rename variables
groups = ['dft_symmcorr_input', 'dft_symmpar_input']
for group in groups:
if group not in list(A.keys()):
continue
if 'n_s' not in A[group]:
continue
print("Changing n_s to n_symm ...")
A[group].move('n_s', 'n_symm')
# Convert orbits to list of dicts
orbits_old = HDFArchive(filename, 'r')[group]['orbits']
orbits = convert_corr_shells(orbits_old)
del(A[group]['orbits'])
A.close()
HDFArchive(filename, 'a')[group]['orbits'] = orbits
A = h5py.File(filename)
groups = ['dft_parproj_input']
for group in groups:
if group not in list(A.keys()):
continue
if 'proj_mat_pc' not in A[group]:
continue
print("Changing proj_mat_pc to proj_mat_all ...")
A[group].move('proj_mat_pc', 'proj_mat_all')
A.close()
# Repack to reclaim disk space
retcode = subprocess.call(["h5repack", "-i%s" % filename, "-otemphgfrt.h5"])
if retcode != 0:
print("h5repack failed!")
else:
subprocess.call(["mv", "-f", "temphgfrt.h5", "%s" % filename])