update
Browse files- preprocess.py +6 -10
preprocess.py
CHANGED
|
@@ -1,10 +1,4 @@
|
|
| 1 |
-
# # %%
|
| 2 |
-
# from datasets import load_dataset
|
| 3 |
|
| 4 |
-
# dataset = load_dataset("atomind/alexandria", name='1D', streaming=True)
|
| 5 |
-
|
| 6 |
-
# print(dataset)
|
| 7 |
-
# # %%
|
| 8 |
import argparse
|
| 9 |
import bz2
|
| 10 |
import json
|
|
@@ -14,7 +8,7 @@ from tqdm.auto import tqdm
|
|
| 14 |
|
| 15 |
from ase import Atoms
|
| 16 |
from ase.calculators.singlepoint import SinglePointCalculator
|
| 17 |
-
from ase.io import write,
|
| 18 |
from pymatgen.core import Structure
|
| 19 |
|
| 20 |
|
|
@@ -41,7 +35,7 @@ def main(src_path: Path | str, dst_dir: Path | str):
|
|
| 41 |
|
| 42 |
assert isinstance(data, dict)
|
| 43 |
|
| 44 |
-
for alex_id, u in tqdm(data.items(), desc="Extracting
|
| 45 |
for calc_id, v in enumerate(u):
|
| 46 |
for ionic_step, w in enumerate(v["steps"]):
|
| 47 |
atoms = Structure.from_dict(w["structure"]).to_ase_atoms()
|
|
@@ -59,12 +53,14 @@ def main(src_path: Path | str, dst_dir: Path | str):
|
|
| 59 |
"calc_id": calc_id,
|
| 60 |
"ionic_step": ionic_step,
|
| 61 |
}
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
traj_file = dst_dir / f"{
|
| 64 |
|
| 65 |
exist = False
|
| 66 |
if traj_file.exists():
|
| 67 |
-
traj =
|
| 68 |
for frame in traj:
|
| 69 |
assert isinstance(frame, Atoms)
|
| 70 |
if frame.info == atoms.info:
|
|
|
|
|
|
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import argparse
|
| 3 |
import bz2
|
| 4 |
import json
|
|
|
|
| 8 |
|
| 9 |
from ase import Atoms
|
| 10 |
from ase.calculators.singlepoint import SinglePointCalculator
|
| 11 |
+
from ase.io import write, iread
|
| 12 |
from pymatgen.core import Structure
|
| 13 |
|
| 14 |
|
|
|
|
| 35 |
|
| 36 |
assert isinstance(data, dict)
|
| 37 |
|
| 38 |
+
for alex_id, u in tqdm(data.items(), desc=f"Extracting {src_path.name}"):
|
| 39 |
for calc_id, v in enumerate(u):
|
| 40 |
for ionic_step, w in enumerate(v["steps"]):
|
| 41 |
atoms = Structure.from_dict(w["structure"]).to_ase_atoms()
|
|
|
|
| 53 |
"calc_id": calc_id,
|
| 54 |
"ionic_step": ionic_step,
|
| 55 |
}
|
| 56 |
+
|
| 57 |
+
elements = sorted(set(atoms.get_chemical_symbols()))
|
| 58 |
|
| 59 |
+
traj_file = dst_dir / f"{'-'.join(elements)}.extxyz"
|
| 60 |
|
| 61 |
exist = False
|
| 62 |
if traj_file.exists():
|
| 63 |
+
traj = iread(traj_file, index=":")
|
| 64 |
for frame in traj:
|
| 65 |
assert isinstance(frame, Atoms)
|
| 66 |
if frame.info == atoms.info:
|