|
| 1 | +import ast |
1 | 2 | import json |
2 | 3 |
|
3 | 4 |
|
@@ -252,15 +253,11 @@ def map_cdict_to_ob(user_name, cdict, concept_dict): |
252 | 253 | ) |
253 | 254 |
|
254 | 255 | if "kpoint_Monkhorst_Pack" in cdict.keys(): |
255 | | - kpoint_algo = "KPOINTS_MP" |
256 | | - kpts_x = int(cdict["kpoint_Monkhorst_Pack"].split()[0]) |
257 | | - kpts_y = int(cdict["kpoint_Monkhorst_Pack"].split()[1]) |
258 | | - kpts_z = int(cdict["kpoint_Monkhorst_Pack"].split()[2]) |
259 | 256 | props |= { |
260 | | - "atom_kpoint_type": kpoint_algo, |
261 | | - "atomistic_n_kpt_x": kpts_x, |
262 | | - "atomistic_n_kpt_y": kpts_y, |
263 | | - "atomistic_n_kpt_z": kpts_z, |
| 257 | + "atom_kpoint_type": "KPOINTS_MP", |
| 258 | + "atomistic_n_kpt_x": int(cdict["kpoint_Monkhorst_Pack"].split()[0]), |
| 259 | + "atomistic_n_kpt_y": int(cdict["kpoint_Monkhorst_Pack"].split()[1]), |
| 260 | + "atomistic_n_kpt_z": int(cdict["kpoint_Monkhorst_Pack"].split()[2]), |
264 | 261 | } |
265 | 262 |
|
266 | 263 | else: |
@@ -296,14 +293,11 @@ def map_struct_to_ob( |
296 | 293 | props["composition_desc"] = "ATOMIC_FRACTION" |
297 | 294 | sorted_atoms = sorted_atoms[:max_num_atoms] |
298 | 295 | for i, species in enumerate(sorted_atoms, 1): |
299 | | - prop_el = f"element_{i}" |
300 | | - prop_el_pct = f"element_{i}_at_percent" |
301 | | - prop_el_num = f"element_{i}_number" |
302 | | - props[prop_el] = species["label"] |
303 | | - props[prop_el_pct] = np.round( |
| 296 | + props[f"element_{i}"] = species["label"] |
| 297 | + props[f"element_{i}_at_percent"] = np.round( |
304 | 298 | species["value"] * 100 / cdict["total_number_atoms"], decimals |
305 | 299 | ) |
306 | | - props[prop_el_num] = species["value"] |
| 300 | + props[f"element_{i}_number"] = species["value"] |
307 | 301 |
|
308 | 302 | if "simulation_cell_lengths" in cdict.keys(): |
309 | 303 | dim_list = [ |
@@ -361,31 +355,22 @@ def dataset_atom_struct_h5( |
361 | 355 | ) |
362 | 356 | items = list(sorted_atoms.items())[:max_num_atoms] |
363 | 357 | for i, (species, count) in enumerate(items, 1): |
364 | | - prop_el = f"element_{i}" |
365 | | - prop_el_pct = f"element_{i}_at_percent" |
366 | | - prop_el_num = f"element_{i}_number" |
367 | | - ds_props[prop_el] = species |
368 | | - ds_props[prop_el_pct] = np.round( |
| 358 | + ds_props[f"element_{i}"] = species |
| 359 | + ds_props[f"element_{i}_at_percent"] = np.round( |
369 | 360 | count * 100 / cdict["total_number_atoms"], decimals |
370 | 361 | ) |
371 | | - ds_props[prop_el_num] = count |
| 362 | + ds_props[f"element_{i}_number"] = count |
372 | 363 |
|
373 | 364 | ds_props["number_of_atoms"] = cdict["total_number_atoms"] |
374 | 365 | ds_props["number_of_species"] = len(sorted_atoms.keys()) |
375 | 366 | ds_props["list_of_species"] = ", ".join(sorted_atoms.keys()) |
376 | 367 | if "simulation_cell_angles" in cdict.keys(): |
377 | | - angles = [ |
378 | | - float(x) for x in cdict["simulation_cell_angles"].strip("[]").split(",") |
379 | | - ] |
380 | 368 | ds_props["angle_alpha"], ds_props["angle_beta"], ds_props["angle_gamma"] = ( |
381 | | - angles |
| 369 | + ast.literal_eval(cdict["simulation_cell_angles"]) |
382 | 370 | ) |
383 | 371 | if "simulation_cell_lengths" in cdict.keys(): |
384 | | - lengths = [ |
385 | | - float(x) for x in cdict["simulation_cell_lengths"].strip("[]").split(",") |
386 | | - ] |
387 | 372 | ds_props["box_length_a"], ds_props["box_length_b"], ds_props["box_length_c"] = ( |
388 | | - lengths |
| 373 | + ast.literal_eval(cdict["simulation_cell_lengths"]) |
389 | 374 | ) |
390 | 375 | if "space_group_number" in cdict.keys(): |
391 | 376 | ds_props["space_group"] = cdict["space_group_number"] |
|
0 commit comments