From d5cabfe54eb0d5d91c259578d08c53749efc79cb Mon Sep 17 00:00:00 2001 From: Alexander Hampel Date: Thu, 23 Mar 2023 17:40:13 -0400 Subject: [PATCH] fix: read_input_from_hdf error check was not working --- python/triqs_dft_tools/sumk_dft_tools.py | 53 ++++++++++++++---------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/python/triqs_dft_tools/sumk_dft_tools.py b/python/triqs_dft_tools/sumk_dft_tools.py index 094e8923..7cbf4068 100644 --- a/python/triqs_dft_tools/sumk_dft_tools.py +++ b/python/triqs_dft_tools/sumk_dft_tools.py @@ -343,10 +343,11 @@ def dos_parproj_basis(self, mu=None, broadening=None, mesh=None, with_Sigma=True things_to_read = ['n_parproj', 'proj_mat_all', 'rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(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) if self.symm_op: self.symmpar = Symmetry(self.hdf_file, subgroup=self.symmpar_data) @@ -492,15 +493,17 @@ def elk_dos(self, mu=None, broadening=None, mesh=None, with_Sigma=True, with_dc= if (pdos): things_to_read = ['maxlm', 'bc'] - value_read = self.read_input_from_hdf( - subgrp=self.bc_data, things_to_read=things_to_read) - if not value_read: - return value_read + subgroup_present, values_not_read = self.read_input_from_hdf( + subgrp=self.bc_data, things_to_read=things_to_read) + if len(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) things_to_read = ['n_atoms'] - value_read = self.read_input_from_hdf( - subgrp=self.symmcorr_data, things_to_read=things_to_read) - if not value_read: - return value_read + subgroup_present, values_not_read = self.read_input_from_hdf( + subgrp=self.symmcorr_data, things_to_read=things_to_read) + if len(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) if (mesh is None) and (not with_Sigma): raise ValueError("lattice_gf: Give the mesh=(om_min,om_max,n_points) for the lattice GfReFreq.") @@ -662,10 +665,11 @@ def fs_plot(self, mu=None, broadening=None, mesh=None, FS=True, plane=True, sym= #read in the energy contour energies and projectors things_to_read = ['n_k','bmat','symlat','n_symm','vkl', 'n_orbitals', 'proj_mat', 'hopping'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.fs_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(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) if with_Sigma is True: om_mesh = [x.real for x in self.Sigma_imp_w[0].mesh] @@ -840,16 +844,18 @@ def spaghettis(self, broadening=None, plot_shift=0.0, plot_range=None, ishell=No self, "Sigma_imp_w"), "spaghettis: Set Sigma_imp_w first." things_to_read = ['n_k', 'n_orbitals', 'proj_mat', 'hopping', 'n_parproj', 'proj_mat_all'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.bands_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(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) if ishell is not None: things_to_read = ['rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(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) if mu is None: mu = self.chemical_potential @@ -980,10 +986,11 @@ def partial_charges(self, beta=40, mu=None, with_Sigma=True, with_dc=True): things_to_read = ['dens_mat_below', 'n_parproj', 'proj_mat_all', 'rot_mat_all', 'rot_mat_all_time_inv'] - value_read = self.read_input_from_hdf( + subgroup_present, values_not_read = self.read_input_from_hdf( subgrp=self.parproj_data, things_to_read=things_to_read) - if not value_read: - return value_read + if len(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) if self.symm_op: self.symmpar = Symmetry(self.hdf_file, subgroup=self.symmpar_data)