From 1c3e88fcfee948511a0454d6ea7ad0aff3511938 Mon Sep 17 00:00:00 2001 From: Alexander Hampel Date: Mon, 23 Jan 2023 15:00:47 -0500 Subject: [PATCH] fix: add backward compatibility layer for dft_code flag --- doc/h5structure.rst | 1 + python/triqs_dft_tools/sumk_dft.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/h5structure.rst b/doc/h5structure.rst index af01c191..d6262c8f 100644 --- a/doc/h5structure.rst +++ b/doc/h5structure.rst @@ -26,6 +26,7 @@ calculation. The default name of this group is `dft_input`. Its contents are Name Type Meaning ================= ====================================================================== ===================================================================================== energy_unit numpy.float Unit of energy used for the calculation. +dft_code string DFT code used to generate input data. n_k numpy.int Number of k-points used for the BZ integration. k_dep_projection numpy.int 1 if the dimension of the projection operators depend on the k-point, 0 otherwise. diff --git a/python/triqs_dft_tools/sumk_dft.py b/python/triqs_dft_tools/sumk_dft.py index eddb2385..8e8159de 100644 --- a/python/triqs_dft_tools/sumk_dft.py +++ b/python/triqs_dft_tools/sumk_dft.py @@ -126,18 +126,24 @@ class SumkDFT(object): req_things_to_read = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required', 'symm_op', 'n_shells', 'shells', 'n_corr_shells', 'corr_shells', 'use_rotations', 'rot_mat', 'rot_mat_time_inv', 'n_reps', 'dim_reps', 'T', 'n_orbitals', 'proj_mat', 'bz_weights', 'hopping', - 'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr', 'dft_code'] + 'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr'] self.subgroup_present, self.values_not_read = self.read_input_from_hdf( subgrp=self.dft_data, things_to_read=req_things_to_read) + # test if all required properties have been found if len(self.values_not_read) > 0 and mpi.is_master_node: - raise ValueError('ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:',self.values_not_read) + raise ValueError('ERROR: One or more necessary SumK input properties have not been found in the given h5 archive:', self.values_not_read) # optional properties to load # soon bz_weights is depraced and replaced by kpt_weights, kpts_basis and kpts will become required to read soon - optional_things_to_read = ['proj_mat_csc', 'proj_or_hk', 'kpt_basis','kpts','kpt_weights'] + optional_things_to_read = ['proj_mat_csc', 'proj_or_hk', 'kpt_basis', 'kpts', 'kpt_weights', 'dft_code'] subgroup_present, self.optional_values_not_read = self.read_input_from_hdf(subgrp=self.dft_data, things_to_read=optional_things_to_read) + # warning if dft_code was not read (old h5 structure) + if 'dft_code' in self.optional_values_not_read: + self.dft_code = None + mpi.report('\nWarning: old h5 archive without dft_code input flag detected. Please specify sumk.dft_code manually!\n') + if self.symm_op: self.symmcorr = Symmetry(hdf_file, subgroup=self.symmcorr_data)