mirror of
https://github.com/triqs/dft_tools
synced 2025-01-03 18:16:03 +01:00
small fix to read_inp_from_h5 function of Sumk
split things_to_read into req and optional properties. Only throw error show warning if req parameters are missing.
This commit is contained in:
parent
491bf30795
commit
a158fec7eb
@ -97,15 +97,20 @@ class SumkDFT(object):
|
||||
self.block_structure = BlockStructure()
|
||||
|
||||
# Read input from HDF:
|
||||
things_to_read = ['energy_unit', 'n_k', 'k_dep_projection', 'SP', 'SO', 'charge_below', 'density_required',
|
||||
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', 'proj_mat_csc', 'bz_weights', 'hopping',
|
||||
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr','proj_or_hk','kpts_cart']
|
||||
self.subgroup_present, self.value_read = self.read_input_from_hdf(
|
||||
subgrp=self.dft_data, things_to_read=things_to_read)
|
||||
# if self.proj_or_hk == 'hk':
|
||||
# self.subgroup_present, self.value_read = self.read_input_from_hdf(
|
||||
# subgrp=self.dft_data, things_to_read=['proj_mat_csc'])
|
||||
'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']
|
||||
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)
|
||||
|
||||
# optional properties to load
|
||||
optional_things_to_read = ['proj_mat_csc', 'proj_or_hk', 'kpts_cart']
|
||||
subgroup_present, self.optional_values_not_read = self.read_input_from_hdf(subgrp=self.dft_data, things_to_read=optional_things_to_read)
|
||||
|
||||
if self.symm_op:
|
||||
self.symmcorr = Symmetry(hdf_file, subgroup=self.symmcorr_data)
|
||||
|
||||
@ -187,12 +192,12 @@ class SumkDFT(object):
|
||||
-------
|
||||
subgroup_present : boolean
|
||||
Is the subgrp is present in hdf5 file?
|
||||
value_read : boolean
|
||||
Did the reading of requested datasets succeed?
|
||||
values_not_read : list of strings
|
||||
List of things that could not be read
|
||||
|
||||
"""
|
||||
|
||||
value_read = True
|
||||
values_not_read = []
|
||||
# initialise variables on all nodes to ensure mpi broadcast works at
|
||||
# the end
|
||||
for it in things_to_read:
|
||||
@ -208,21 +213,21 @@ class SumkDFT(object):
|
||||
if it in ar[subgrp]:
|
||||
setattr(self, it, ar[subgrp][it])
|
||||
else:
|
||||
mpi.report("Loading %s failed!" % it)
|
||||
value_read = False
|
||||
values_not_read.append(it)
|
||||
else:
|
||||
if (len(things_to_read) != 0):
|
||||
mpi.report(
|
||||
"Loading failed: No %s subgroup in hdf5!" % subgrp)
|
||||
subgroup_present = False
|
||||
value_read = False
|
||||
values_not_read = things_to_read
|
||||
|
||||
# now do the broadcasting:
|
||||
for it in things_to_read:
|
||||
setattr(self, it, mpi.bcast(getattr(self, it)))
|
||||
subgroup_present = mpi.bcast(subgroup_present)
|
||||
value_read = mpi.bcast(value_read)
|
||||
values_not_read = mpi.bcast(values_not_read)
|
||||
|
||||
return subgroup_present, value_read
|
||||
return subgroup_present, values_not_read
|
||||
|
||||
def save(self, things_to_save, subgrp='user_data'):
|
||||
r"""
|
||||
|
Loading…
Reference in New Issue
Block a user