1010# Suppresses NaturalNameWarning warnings from PyTables.
1111warnings .filterwarnings ("ignore" , category = pt .NaturalNameWarning )
1212
13- max_norba = 30 # needs to be calculated
13+ max_norba = 56
1414
1515SLATER_PROPERTY_CONFIGS = [
1616 {
17- "SpeciesInfo" : "elem" , #
17+ "SpeciesInfo" : "elem" ,
1818 "type" : "string" ,
1919 },
2020 {
21- "SpeciesInfo" : "nexc" , #
21+ "SpeciesInfo" : "nexc" ,
2222 "type" : "int" ,
2323 },
2424 {
25- "SpeciesInfo" : "charge" , #
25+ "SpeciesInfo" : "charge" ,
2626 "type" : "int" ,
2727 },
2828 {
29- "SpeciesInfo" : "mult" , #
29+ "SpeciesInfo" : "mult" ,
3030 "type" : "int" ,
3131 },
3232 {
33- "SpeciesInfo" : "nelec" , #
33+ "SpeciesInfo" : "nelec" ,
3434 "type" : "int" ,
3535 },
3636 {
37- "SpeciesInfo" : "nspin" , #
37+ "SpeciesInfo" : "nspin" ,
3838 "type" : "int" ,
3939 },
4040 {
41- "SpeciesInfo" : "energy" , #
41+ "SpeciesInfo" : "energy" ,
4242 "type" : "float" ,
4343 },
4444 {
45- "SpeciesInfo" : "ip" , #
45+ "SpeciesInfo" : "ip" ,
4646 "type" : "float" ,
4747 },
4848 {
49- "SpeciesInfo" : "mu" , #
49+ "SpeciesInfo" : "mu" ,
5050 "type" : "float" ,
5151 },
5252 {
53- "SpeciesInfo" : "eta" , #
53+ "SpeciesInfo" : "eta" ,
5454 "type" : "float" ,
5555 },
5656 {
57- "SpeciesInfo" : "nbasis" , #
57+ "SpeciesInfo" : "nbasis" ,
5858 "type" : "int" ,
5959 },
6060 {
133133 "folder" : "DensityLaplacian" ,
134134 "spins" : "no" ,
135135 },
136- # {
137- # ' Carray_property': ' mo_ked_a' ,
138- # ' table_name': ' mo_ked_a' ,
139- # ' folder': ' KineticEnergyDensity' ,
140- # ' spins': ' yes'
141- # },
142- # {
143- # ' Carray_property': ' mo_ked_b' ,
144- # ' table_name': ' mo_ked_b' ,
145- # ' folder': ' KineticEnergyDensity' ,
146- # ' spins': ' yes'
147- # },
148- # {
149- # ' Carray_property': ' ked_tot' ,
150- # ' table_name': ' ked_tot' ,
151- # ' folder': ' KineticEnergyDensity' ,
152- # ' spins': 'no'
153- # }
136+ {
137+ " Carray_property" : " mo_ked_a" ,
138+ " table_name" : " mo_ked_a" ,
139+ " folder" : " KineticEnergyDensity" ,
140+ " spins" : " yes" ,
141+ },
142+ {
143+ " Carray_property" : " mo_ked_b" ,
144+ " table_name" : " mo_ked_b" ,
145+ " folder" : " KineticEnergyDensity" ,
146+ " spins" : " yes" ,
147+ },
148+ {
149+ " Carray_property" : " ked_tot" ,
150+ " table_name" : " ked_tot" ,
151+ " folder" : " KineticEnergyDensity" ,
152+ " spins" : "no" ,
153+ },
154154]
155155
156156
@@ -257,9 +257,12 @@ def create_properties_arrays(hdf5_file, parent_folder, table_name, description,
257257 description (str): Description of the table.
258258 data (numpy.ndarray): The array data to store in the table.
259259 """
260+ filters = pt .Filters (complevel = 5 , complib = "blosc2" )
260261
261262 # Create the table and populate the data
262- table = hdf5_file .create_table (parent_folder , table_name , ArrayPropertyDescription , description )
263+ table = hdf5_file .create_table (
264+ parent_folder , table_name , ArrayPropertyDescription , description , filters = filters
265+ )
263266 row = table .row
264267 padded_data = np .pad (data , (0 , max_norba - len (data )), "constant" , constant_values = 0 )
265268 row ["value" ] = padded_data
@@ -278,9 +281,12 @@ def create_spins_array(h5file, parent_folder, key, array_data, shape):
278281 shape (int): The total size of the CArray.
279282 """
280283 data_length = len (array_data )
284+ filters = pt .Filters (complevel = 5 , complib = "blosc2" )
281285
282286 # Create the CArray and populate the data
283- array = h5file .create_carray (parent_folder , key , pt .Float64Atom (), shape = (shape ,))
287+ array = h5file .create_carray (
288+ parent_folder , key , pt .Float64Atom (), shape = (shape ,), filters = filters
289+ )
284290 array [:data_length ] = array_data
285291 array [data_length :] = 0
286292
@@ -294,24 +300,29 @@ def create_tot_array(h5file, parent_folder, key, array_data):
294300 key (str): Name of the CArray.
295301 array_data (numpy.ndarray): The array data to store in the CArray.
296302 """
303+ data_length = len (array_data )
304+ filters = pt .Filters (complevel = 5 , complib = "blosc2" )
297305
298306 # Create the CArray and populate the data
299307 tot_gradient_array = h5file .create_carray (
300- parent_folder , key , pt .Float64Atom (), shape = (NPOINTS ,)
308+ parent_folder , key , pt .Float64Atom (), shape = (NPOINTS ,), filters = filters
301309 )
302- tot_gradient_array [:] = array_data
310+ if data_length < NPOINTS :
311+ tot_gradient_array [:data_length ] = array_data
312+ tot_gradient_array [data_length :] = 0
313+
314+ else :
315+ tot_gradient_array [:] = array_data
303316
304317
305- def create_hdf5_file (DATASETS_H5FILE , fields , dataset ):
318+ def create_hdf5_file (DATASETS_H5FILE , fields , dataset , mult ):
306319 """Creates an HDF5 folder with structured data for a specific dataset and element.
307320
308321 Args:
322+ DATASETS_H5FILE (tables.File): An open PyTables HDF5 file object to store the data.
309323 fields (dataclass): A dataclass containing the fields to store in the HDF5 file.
310324 dataset (str): Name of the dataset.
311- elem (str): Element symbol.
312- charge (int): Charge of the system.
313- mult (int): Multiplicity of the system.
314- nexc (int): Number of excitations.
325+ mult (int): Multiplicity.
315326 """
316327 fields = asdict (fields )
317328 dataset = dataset .lower ()
@@ -320,7 +331,6 @@ def create_hdf5_file(DATASETS_H5FILE, fields, dataset):
320331 elem = fields ["elem" ]
321332 nexc = fields ["nexc" ]
322333 atnum = element_symbol_map [elem ][ElementAttr .atnum ]
323- mult = get_scalar_data ("mult" , atnum , fields ["nelec" ])
324334 charge = atnum - fields ["nelec" ]
325335
326336 # charge and mult can be calculated (instead of passing them)?
0 commit comments