pwdata 0.5.4.dev0__tar.gz → 0.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/PKG-INFO +1 -1
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/check_envs.py +3 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/config.py +1 -1
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/convert_files.py +89 -8
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/extendedxyz.py +6 -2
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/lammpsdata.py +4 -4
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/main.py +114 -2
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/meta_omol.py +20 -17
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/molecule.py +21 -21
- pwdata-0.5.5/pwdata/test/oc25.py +55 -0
- pwdata-0.5.5/pwdata/test/omol25.py +29 -0
- pwdata-0.5.5/pwdata/test/readasedb.py +20 -0
- pwdata-0.5.5/pwdata/test/surf_test.py +28 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/SOURCES.txt +3 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/setup.py +7 -1
- pwdata-0.5.4.dev0/pwdata/test/omol25.py +0 -13
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/LICENSE +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/README.md +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/atomconfig.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/build/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/build/cell.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/build/geometry.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/build/supercells.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/build/write_struc.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/calculators/const.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/calculators/units.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/deepmd.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/dump.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/common/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/common/registry.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/common/typing.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/common/utils.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/_utils.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/base_dataset.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/modules/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/modules/transforms.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/preprocessing/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/image.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/lmps.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/meta.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/movement.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/movement_saver.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/outcar.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/poscar.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/pwmlff.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/bamboo2lmdb.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/extact_outcar_with_ml.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/matpbe2lmdb.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/matrcan2lmdb.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/mdtrajs2config.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/mptraj2lmdb.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test/outcar2mvms.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/test.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/tmp.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/utils/__init__.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/utils/constant.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/utils/format_change.py +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/entry_points.txt +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/requires.txt +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.5.4.dev0 → pwdata-0.5.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
|
|
5
5
|
Home-page: https://github.com/LonxunQuantum/pwdata
|
|
6
6
|
Author: LonxunQuantum
|
|
@@ -15,6 +15,9 @@ def cmd_infos():
|
|
|
15
15
|
info += "\tpwdata super_cell -i input_file -f input_file_format -n output_format_name -o output_format\n"
|
|
16
16
|
info += "\tYou can also use 'pwdata super_cell -h' to obtain a more detailed parameter list\n\n"
|
|
17
17
|
|
|
18
|
+
info += "surf or surface: Under Development (2025.10.31)\n"
|
|
19
|
+
info += "\n"
|
|
20
|
+
|
|
18
21
|
info += "perturb:\n"
|
|
19
22
|
info += "\tDisturb the atomic positions and unit cells of the structure, the command example:\n"
|
|
20
23
|
info += "\tpwdata perturb -e 0.01 -d 0.04 -n 20 -i LiSi_POSCAR -f vasp/poscar -s perturb_lammps -o lammps/lmp -c\n\n"
|
|
@@ -185,7 +185,7 @@ class Config(object):
|
|
|
185
185
|
elif format.lower() == "vasp/outcar":
|
|
186
186
|
image = OUTCAR(data_path).image_list[index]
|
|
187
187
|
elif format.lower() == "extxyz":
|
|
188
|
-
image = EXTXYZ(data_path
|
|
188
|
+
image = EXTXYZ(data_path).image_list[index]
|
|
189
189
|
elif format.lower() == "vasp/xml":
|
|
190
190
|
image = None
|
|
191
191
|
elif format.lower() == 'cp2k/md':
|
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import sys
|
|
3
3
|
import glob
|
|
4
4
|
import numpy as np
|
|
5
|
+
import random
|
|
5
6
|
from pwdata.config import Config
|
|
6
7
|
from pwdata.build.supercells import make_supercell
|
|
7
8
|
from pwdata.pertub.perturbation import perturb_structure
|
|
@@ -9,6 +10,7 @@ from pwdata.pertub.scale import scale_cell
|
|
|
9
10
|
from pwdata.utils.constant import FORMAT, ELEMENTTABLE, get_atomic_name_from_number
|
|
10
11
|
from pwdata.image import Image
|
|
11
12
|
from collections import Counter
|
|
13
|
+
from ase.build import general_surface
|
|
12
14
|
from ase.db.row import AtomsRow
|
|
13
15
|
from pwdata.fairchem.datasets.ase_datasets import AseDBDataset
|
|
14
16
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
@@ -57,6 +59,85 @@ def do_scale_cell(input_file:str,
|
|
|
57
59
|
sort = True)
|
|
58
60
|
return os.path.abspath(savename)
|
|
59
61
|
|
|
62
|
+
def do_surface(input_file:str,
|
|
63
|
+
input_format:str = None,
|
|
64
|
+
atom_types:list[str] = None,
|
|
65
|
+
savename:str = None,
|
|
66
|
+
output_format:str = None,
|
|
67
|
+
supercell_matrix:list[int] = None,
|
|
68
|
+
direct:bool = True,
|
|
69
|
+
cartesian:bool=True,
|
|
70
|
+
pbc:list =[1, 1, 1],
|
|
71
|
+
wrap=True,
|
|
72
|
+
tol=1e-5,
|
|
73
|
+
millers = None,
|
|
74
|
+
layer_num = None,
|
|
75
|
+
z_min = None,
|
|
76
|
+
vacuum_max = None,
|
|
77
|
+
vacuum_min = None,
|
|
78
|
+
vacuum_resol = None,
|
|
79
|
+
vacuum_numb = None,
|
|
80
|
+
mid_point = None,
|
|
81
|
+
cell_type:str=None,
|
|
82
|
+
lattice:float=None
|
|
83
|
+
): # True: save as fractional coordinates, False for cartesian coordinates
|
|
84
|
+
# for pwamt/movement movement or MLMD.OUT files
|
|
85
|
+
from pymatgen.core import Element, Structure
|
|
86
|
+
from pymatgen.io.ase import AseAtomsAdaptor
|
|
87
|
+
max_layer_numb = 50
|
|
88
|
+
random.seed(2025)
|
|
89
|
+
prefix_random=random.randint(1000000, 9999999)
|
|
90
|
+
tmp_file = f"{prefix_random}-surf-POSCAR"
|
|
91
|
+
image = Config(data_path=input_file, format=input_format, atom_names=atom_types)
|
|
92
|
+
image.to(data_path = "./",
|
|
93
|
+
data_name = tmp_file,
|
|
94
|
+
format = "vasp/poscar",
|
|
95
|
+
direct = direct
|
|
96
|
+
)
|
|
97
|
+
# for vasp poscar
|
|
98
|
+
ss = Structure.from_file(tmp_file)
|
|
99
|
+
os.remove(tmp_file)
|
|
100
|
+
res_path = []
|
|
101
|
+
for miller in millers:
|
|
102
|
+
miller_str = ""
|
|
103
|
+
for ii in miller:
|
|
104
|
+
miller_str += str(ii)
|
|
105
|
+
tmp_file = f"{prefix_random}-surf-{miller_str}-POSCAR"
|
|
106
|
+
# slabgen = SlabGenerator(ss, miller, z_min, 1e-3)
|
|
107
|
+
if layer_num is not None:
|
|
108
|
+
slab = general_surface.surface(
|
|
109
|
+
ss, indices=miller, vacuum=vacuum_min, layers=layer_num
|
|
110
|
+
)
|
|
111
|
+
else:
|
|
112
|
+
# build slab according to z_min value
|
|
113
|
+
for layer_numb in range(1, max_layer_numb + 1):
|
|
114
|
+
slab = general_surface.surface(
|
|
115
|
+
ss, indices=miller, vacuum=vacuum_min, layers=layer_numb
|
|
116
|
+
)
|
|
117
|
+
if slab.cell.lengths()[-1] >= z_min:
|
|
118
|
+
break
|
|
119
|
+
if layer_numb == max_layer_numb:
|
|
120
|
+
raise RuntimeError("can't build the required slab")
|
|
121
|
+
slab.write(tmp_file, vasp5=True)
|
|
122
|
+
image = Config(data_path=tmp_file, format="vasp/poscar", atom_names=atom_types)
|
|
123
|
+
os.remove(tmp_file)
|
|
124
|
+
if supercell_matrix is not None:
|
|
125
|
+
scaled_structs = make_supercell(image, supercell_matrix, pbc=pbc, wrap=wrap, tol=tol)
|
|
126
|
+
else:
|
|
127
|
+
scaled_structs = image
|
|
128
|
+
if output_format is None:
|
|
129
|
+
output_format = FORMAT.pwmat_config if image.format == FORMAT.cp2k_scf else image.format
|
|
130
|
+
if savename is None:
|
|
131
|
+
savename = FORMAT.get_filename_by_format(image.format)
|
|
132
|
+
data_name = f"surf-{miller}-super-{os.path.basename(savename)}" if supercell_matrix is not None else f"surf-{miller}-{os.path.basename(savename)}"
|
|
133
|
+
scaled_structs.to(data_path = os.path.dirname(os.path.abspath(savename)),
|
|
134
|
+
data_name = data_name,
|
|
135
|
+
format = output_format,
|
|
136
|
+
direct = direct,
|
|
137
|
+
sort = True)
|
|
138
|
+
res_path.append(os.path.abspath(data_name))
|
|
139
|
+
return res_path
|
|
140
|
+
|
|
60
141
|
def do_super_cell(input_file:str,
|
|
61
142
|
input_format:str = None,
|
|
62
143
|
atom_types:list[str] = None,
|
|
@@ -127,7 +208,7 @@ def do_convert_images(
|
|
|
127
208
|
merge:bool=True
|
|
128
209
|
):
|
|
129
210
|
data_files = search_images(input, input_format)
|
|
130
|
-
image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums)
|
|
211
|
+
image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums, index=gap)
|
|
131
212
|
save_images(savepath, image_data, output_format, data_shuffle, merge)
|
|
132
213
|
|
|
133
214
|
def do_count_images(
|
|
@@ -272,7 +353,7 @@ def search_by_format(workDir, format):
|
|
|
272
353
|
return data_path[format]
|
|
273
354
|
|
|
274
355
|
|
|
275
|
-
def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None, query:str=None, cpu_nums=None):
|
|
356
|
+
def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None, query:str=None, cpu_nums=None, index=":"):
|
|
276
357
|
image_data = None
|
|
277
358
|
if input_format is not None:
|
|
278
359
|
if input_format == FORMAT.meta:
|
|
@@ -281,31 +362,31 @@ def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None
|
|
|
281
362
|
metadatas = [input_dict[FORMAT.meta][i:i + chunk_size] for i in range(0, lmdb_nums, chunk_size)]
|
|
282
363
|
for idx, metapaths in enumerate(tqdm(metadatas, total=lmdb_nums // chunk_size)):
|
|
283
364
|
if image_data is None:
|
|
284
|
-
image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
365
|
+
image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
285
366
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
286
367
|
image_data.images = [image_data.images]
|
|
287
368
|
else:
|
|
288
|
-
tmp_image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
369
|
+
tmp_image_data = Config(input_format, metapaths, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
289
370
|
image_data.images.extend(tmp_image_data.images)
|
|
290
371
|
# print("There are a total of {} aselmdb, and the current progress has been loaded {} %".format(lmdb_nums, np.round(idx*chunk_size/lmdb_nums, 2)))
|
|
291
372
|
else:
|
|
292
373
|
if len(input_dict[FORMAT.traj]) > 0:# the input is traj files
|
|
293
374
|
for data_path in tqdm(input_dict[FORMAT.traj], total=len(input_dict[FORMAT.traj])):
|
|
294
375
|
if image_data is None:
|
|
295
|
-
image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
376
|
+
image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
296
377
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
297
378
|
image_data.images = [image_data.images]
|
|
298
379
|
else:
|
|
299
|
-
tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
380
|
+
tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
300
381
|
image_data.images.extend(tmp_image_data.images)
|
|
301
382
|
else:
|
|
302
383
|
for data_path in tqdm(input_dict[input_format], total=len(input_dict[input_format])):
|
|
303
384
|
if image_data is None:
|
|
304
|
-
image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
385
|
+
image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
305
386
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
306
387
|
image_data.images = [image_data.images]
|
|
307
388
|
else:
|
|
308
|
-
tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums)
|
|
389
|
+
tmp_image_data = Config(input_format, data_path, atom_names=atom_types, query=query, cpu_nums=cpu_nums, index=index)
|
|
309
390
|
image_data.images.extend(tmp_image_data.images)
|
|
310
391
|
return image_data
|
|
311
392
|
|
|
@@ -8,7 +8,8 @@ from math import ceil
|
|
|
8
8
|
from collections import Counter
|
|
9
9
|
|
|
10
10
|
class EXTXYZ(object):
|
|
11
|
-
|
|
11
|
+
# index is not used in this reading
|
|
12
|
+
def __init__(self, xyz_file, index=None) -> None:
|
|
12
13
|
self.image_list:list[Image] = []
|
|
13
14
|
self.number_pattern = re.compile(r"[-+]?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?")
|
|
14
15
|
self.load_xyz_file(xyz_file, index)
|
|
@@ -88,10 +89,12 @@ def read_structures(
|
|
|
88
89
|
List[Structure]: A list of structures read from the file.
|
|
89
90
|
"""
|
|
90
91
|
image_list = []
|
|
92
|
+
index_cout = 0
|
|
91
93
|
with open(file_name, "r") as file:
|
|
92
94
|
|
|
93
95
|
while True:
|
|
94
96
|
num_lines_per_frame = file.readline().strip()
|
|
97
|
+
index_cout += 1
|
|
95
98
|
if not num_lines_per_frame:
|
|
96
99
|
break
|
|
97
100
|
num_lines_per_frame = int(num_lines_per_frame)
|
|
@@ -100,11 +103,12 @@ def read_structures(
|
|
|
100
103
|
), "Number of lines per frame should be a positive integer"
|
|
101
104
|
|
|
102
105
|
frames = [file.readline().strip()]
|
|
103
|
-
|
|
106
|
+
index_cout += 1
|
|
104
107
|
for _ in range(num_lines_per_frame):
|
|
105
108
|
line = file.readline().strip()
|
|
106
109
|
if line:
|
|
107
110
|
frames.append(line)
|
|
111
|
+
index_cout += num_lines_per_frame
|
|
108
112
|
image = read_one_structures_from_lines(frames)
|
|
109
113
|
image_list.append(image)
|
|
110
114
|
assert len(image_list) > 0, "extxyz file {} parsing failed".format(file_name)
|
|
@@ -323,12 +323,12 @@ class LMP(object):
|
|
|
323
323
|
ids[ind] = id
|
|
324
324
|
# by type
|
|
325
325
|
types[ind] = type
|
|
326
|
-
if
|
|
326
|
+
if len(atom_names) > 0: # use lammps.config atom type
|
|
327
|
+
atom_types_image[ind] = atom_names[type - 1]
|
|
328
|
+
elif self.atom_names is not None and len(self.atom_names) > 0: # use input atom type
|
|
327
329
|
atom_types_image[ind] = ELEMENTTABLE[self.atom_names[type - 1]]
|
|
328
|
-
if len(atom_names) == 0:
|
|
329
|
-
atom_types_image[ind] = type
|
|
330
330
|
else:
|
|
331
|
-
atom_types_image[ind] =
|
|
331
|
+
atom_types_image[ind] = type
|
|
332
332
|
if masses is not None:
|
|
333
333
|
masses[ind] = mass_in[type]
|
|
334
334
|
|
|
@@ -22,7 +22,7 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
22
22
|
# from pwdata.datasets_saver import save_to_dataset, get_pw, save_to_raw, save_to_npy
|
|
23
23
|
# from pwdata.build.write_struc import write_config, write_vasp, write_lammps
|
|
24
24
|
import argparse
|
|
25
|
-
from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images, do_count_images
|
|
25
|
+
from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images, do_count_images, do_surface
|
|
26
26
|
from pwdata.utils.constant import FORMAT, get_atomic_name_from_number, check_atom_type_name
|
|
27
27
|
from pwdata.check_envs import print_cmd, comm_info
|
|
28
28
|
|
|
@@ -80,6 +80,11 @@ def main(cmd_list:list=None):
|
|
|
80
80
|
run_scale_cell(cmd_list[2:])
|
|
81
81
|
elif "super_cell".upper() == cmd_list[1].upper() or "super".upper() == cmd_list[1].upper():
|
|
82
82
|
run_super_cell(cmd_list[2:])
|
|
83
|
+
elif "surface_config".upper() == cmd_list[1].upper() or "surf_config".upper() == cmd_list[1].upper() or "surf".upper() == cmd_list[1].upper():
|
|
84
|
+
run_surf_from_config(cmd_list[2:])
|
|
85
|
+
elif "surface_cell".upper() == cmd_list[1].upper() or "surf_cell".upper() == cmd_list[1].upper():
|
|
86
|
+
run_surf_from_cell(cmd_list[2:])
|
|
87
|
+
|
|
83
88
|
elif "perturb".upper() == cmd_list[1].upper():
|
|
84
89
|
run_pertub(cmd_list[2:])
|
|
85
90
|
elif "convert_config".upper() == cmd_list[1].upper() or "cvt_config".upper() == cmd_list[1].upper():
|
|
@@ -161,6 +166,110 @@ def run_super_cell(cmd_list:list[str]):
|
|
|
161
166
|
do_super_cell(args.input, args.input_format, args.atom_types, args.savename, args.output_format, args.supercell_matrix, args.cartesian is False, pbc=args.periodicity, tol=args.tolerance)
|
|
162
167
|
print("supercell the config done!")
|
|
163
168
|
|
|
169
|
+
def run_surf_from_config(cmd_list:list[str]): # Creating surface structures
|
|
170
|
+
parser = argparse.ArgumentParser(description='Construct a surface structures based on the input original structure!')
|
|
171
|
+
parser.add_argument('-m', '--supercell_matrix', type=int, nargs='+', required=False, default=None, help="Supercell matrix, 3 or 9 values, for example, '2 0 0 0 2 0 0 0 1' or '2 2 1' represents that the supercell is 2x2 in the x and y directions")
|
|
172
|
+
parser.add_argument('-i', '--input', type=str, required=True, help='The input file path')
|
|
173
|
+
parser.add_argument('-f', '--input_format', type=str, required=False, default=None, help="The input file format, the supported format as ['pwmat/config','vasp/poscar', 'lammps/lmp', 'cp2k/scf']")
|
|
174
|
+
parser.add_argument('-s', '--savename', type=str, required=False, default=None, help="The output file name, if not provided, the 'atom.config' for pwmat/config, 'POSCAR' for vasp/poscar, 'lammps.lmp' for lammps/lmp will be used")
|
|
175
|
+
parser.add_argument('-o', '--output_format', type=str, required=False, default=None, help="the output file format, only support the format ['pwmat/config','vasp/poscar', 'lammps/lmp'], if not provided, the input format be used. \nNote: that outputting cp2k/scf format is not supported. In this case, the default will be adjusted to pwmat atom.config")
|
|
176
|
+
parser.add_argument('-c', '--cartesian', action='store_true', help="If '-c' is set, the cartesian coordinates will be used, otherwise the fractional coordinates will be used.")
|
|
177
|
+
parser.add_argument('-p', '--periodicity', type=int, nargs='+', required=False, help="'-p 1 1 1' indicates that the system is periodic in the x, y, and z directions. The default value is [1,1,1]", default=[1,1,1])
|
|
178
|
+
parser.add_argument('-l', '--tolerance', type=float, required=False, help="Tolerance of fractional coordinates. The default is 1e-5. Prevent slight negative coordinates from being mapped into the simulation box.", default=1e-5)
|
|
179
|
+
parser.add_argument('-t', '--atom_types', type=str, nargs='+',required=False, help="The atom type list of 'lammps/lmp' or 'lammps/dump' input file, the order is same as input file", default=None)
|
|
180
|
+
parser.add_argument('-e', '--miller', type=int, nargs='+',required=True, help="The miller indices, the input parameter should be multiple triplets. For example: '-m h k l', the output or '-m h1 k1 l1 h2 k2 l2 ...'")
|
|
181
|
+
parser.add_argument('-n', '--layer_num', type=int, required=False, default=None, help="The number of atom layers that make up the slab structure.")
|
|
182
|
+
parser.add_argument('-z', '--z_min', type=float, required=False, default=None, help="The thickness of the slab without vacuum (Angstrom). If layer_num is set, z_min will be ignored.")
|
|
183
|
+
parser.add_argument('-v', '--vacuum_max', type=float, required=False, default=None, help="The maximal thickness of vacuum (Angstrom).")
|
|
184
|
+
parser.add_argument('-u', '--vacuum_min', type=float, required=False, default=None, help="The minimal thickness of vacuum (Angstrom). Default value is 2 times atomic radius.")
|
|
185
|
+
parser.add_argument('-r', '--vacuum_resol', type=float, required=False, default=None, help="Interval of thickness of vacuum. If size of vacuum_resol is 1, the interval is fixed to its value. If size of vacuum_resol is 2, the interval is vacuum_resol[0] before mid_point, otherwise vacuum_resol[1] after mid_point.")
|
|
186
|
+
parser.add_argument('-b', '--vacuum_numb', type=int, required=False, default=None, help="The total number of vacuum layers Necessary if vacuum_resol is empty.")
|
|
187
|
+
parser.add_argument('-d', '--mid_point', type=float, required=False, default=None, help="The mid point separating head region and tail region. Necessary if the size of vacuum_resol is 2 or 0.")
|
|
188
|
+
|
|
189
|
+
args = parser.parse_args(cmd_list)
|
|
190
|
+
if args.supercell_matrix is not None:
|
|
191
|
+
assert len(args.supercell_matrix) == 3 or len(args.supercell_matrix) == 9, "The supercell matrix must be 3 or 9 values"
|
|
192
|
+
if len(args.supercell_matrix) == 3:
|
|
193
|
+
args.supercell_matrix = np.diag(args.supercell_matrix)
|
|
194
|
+
if args.supercell_matrix[0][2] != 0 or args.supercell_matrix[1][2] != 0 or \
|
|
195
|
+
(args.supercell_matrix[2][0] != 0 and args.supercell_matrix[2][1] != 0 and args.supercell_matrix[2][2] != 1) :
|
|
196
|
+
raise Exception("Error! The input parameter supercell_matrix value of the surface system is incorrectly verified. The Z direction should be 1. For example:[1,2,1], [2,2,0,1,2,0,0,0,1], or [[2,2,0],[1,2,0],[0,0,1]]!")
|
|
197
|
+
|
|
198
|
+
if len(args.miller) % 3 != 0:
|
|
199
|
+
raise Exception("Input error! : The input parameter should be triple. For example: -e 1 1 0 or ")
|
|
200
|
+
args.miller = np.array(args.miller).reshape(-1, 3).tolist()
|
|
201
|
+
res = do_surface(input_file = args.input,
|
|
202
|
+
input_format = args.input_format,
|
|
203
|
+
atom_types = args.atom_types,
|
|
204
|
+
savename = args.savename,
|
|
205
|
+
output_format = args.output_format,
|
|
206
|
+
supercell_matrix = args.supercell_matrix,
|
|
207
|
+
cartesian = args.cartesian is False,
|
|
208
|
+
pbc=args.periodicity,
|
|
209
|
+
tol=args.tolerance,
|
|
210
|
+
miller = args.miller,
|
|
211
|
+
layer_num = args.layer_num,
|
|
212
|
+
z_min = args.z_min,
|
|
213
|
+
vacuum_max = args.vacuum_max,
|
|
214
|
+
vacuum_min = args.vacuum_min,
|
|
215
|
+
vacuum_resol = args.vacuum_resol,
|
|
216
|
+
vacuum_numb = args.vacuum_numb,
|
|
217
|
+
mid_point = args.mid_point
|
|
218
|
+
)
|
|
219
|
+
print("Do surface done! The constructed surface structure file path: {}\n".format("\n".join(res)))
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def run_surf_from_cell(cmd_list:list[str]): # Creating surface structures
|
|
223
|
+
parser = argparse.ArgumentParser(description='Construct a surface structures based on a typical structure, such as fcc bcc hcp.')
|
|
224
|
+
parser.add_argument('-t', '--atom_types', type=str, nargs='+',required=False, help="The atom types. For example: '-t Al' ", default=None)
|
|
225
|
+
parser.add_argument('-m', '--supercell_matrix', type=int, nargs='+', required=False, default=None, help="Supercell matrix, 3 or 9 values, for example, '2 0 0 0 2 0 0 0 1' or '2 2 1' represents that the supercell is 2x2 in the x and y directions")
|
|
226
|
+
parser.add_argument('-s', '--savename', type=str, required=False, default=None, help="The output file name, if not provided, the 'atom.config' for pwmat/config, 'POSCAR' for vasp/poscar, 'lammps.lmp' for lammps/lmp will be used")
|
|
227
|
+
parser.add_argument('-o', '--output_format', type=str, required=False, default=None, help="the output file format, only support the format ['pwmat/config','vasp/poscar', 'lammps/lmp'], if not provided, the input format be used. \nNote: that outputting cp2k/scf format is not supported. In this case, the default will be adjusted to pwmat atom.config")
|
|
228
|
+
parser.add_argument('-c', '--cartesian', action='store_true', help="If '-c' is set, the cartesian coordinates will be used, otherwise the fractional coordinates will be used.")
|
|
229
|
+
parser.add_argument('-p', '--periodicity', type=int, nargs='+', required=False, help="'-p 1 1 1' indicates that the system is periodic in the x, y, and z directions. The default value is [1,1,1]", default=[1,1,1])
|
|
230
|
+
parser.add_argument('-l', '--tolerance', type=float, required=False, help="Tolerance of fractional coordinates. The default is 1e-5. Prevent slight negative coordinates from being mapped into the simulation box.", default=1e-5)
|
|
231
|
+
parser.add_argument('-e', '--miller', type=int, nargs='+',required=True, help="The miller indices, the input parameter should be multiple triplets. For example: '-m h k l', the output or '-m h1 k1 l1 h2 k2 l2 ...'")
|
|
232
|
+
parser.add_argument('-n', '--layer_num', type=int, required=False, default=None, help="The number of atom layers that make up the slab structure.")
|
|
233
|
+
parser.add_argument('-z', '--z_min', type=float, required=False, default=None, help="The thickness of the slab without vacuum (Angstrom). If layer_num is set, z_min will be ignored.")
|
|
234
|
+
parser.add_argument('-v', '--vacuum_max', type=float, required=False, default=None, help="The maximal thickness of vacuum (Angstrom).")
|
|
235
|
+
parser.add_argument('-u', '--vacuum_min', type=float, required=False, default=None, help="The minimal thickness of vacuum (Angstrom). Default value is 2 times atomic radius.")
|
|
236
|
+
parser.add_argument('-r', '--vacuum_resol', type=float, required=False, default=None, help="Interval of thickness of vacuum. If size of vacuum_resol is 1, the interval is fixed to its value. If size of vacuum_resol is 2, the interval is vacuum_resol[0] before mid_point, otherwise vacuum_resol[1] after mid_point.")
|
|
237
|
+
parser.add_argument('-b', '--vacuum_numb', type=int, required=False, default=None, help="The total number of vacuum layers Necessary if vacuum_resol is empty.")
|
|
238
|
+
parser.add_argument('-d', '--mid_point', type=float, required=False, default=None, help="The mid point separating head region and tail region. Necessary if the size of vacuum_resol is 2 or 0.")
|
|
239
|
+
parser.add_argument('-e', '--cell_type', type=str, required=False, default=None, help="The type of the structure to be generated. For example: '-e fcc', '-e hcp', '-e bcc', '-e sc', or '-e diamond'.")
|
|
240
|
+
parser.add_argument('-a', '--lattice', type=float, required=False, default=None, help="The lattice constant for single cell.")
|
|
241
|
+
|
|
242
|
+
args = parser.parse_args(cmd_list)
|
|
243
|
+
if args.supercell_matrix is not None:
|
|
244
|
+
assert len(args.supercell_matrix) == 3 or len(args.supercell_matrix) == 9, "The supercell matrix must be 3 or 9 values"
|
|
245
|
+
if len(args.supercell_matrix) == 3:
|
|
246
|
+
args.supercell_matrix = np.diag(args.supercell_matrix)
|
|
247
|
+
if args.supercell_matrix[0][2] != 0 or args.supercell_matrix[1][2] != 0 or \
|
|
248
|
+
(args.supercell_matrix[2][0] != 0 and args.supercell_matrix[2][1] != 0 and args.supercell_matrix[2][2] != 1) :
|
|
249
|
+
raise Exception("Error! The input parameter supercell_matrix value of the surface system is incorrectly verified. The Z direction should be 1. For example:[1,2,1], [2,2,0,1,2,0,0,0,1], or [[2,2,0],[1,2,0],[0,0,1]]!")
|
|
250
|
+
|
|
251
|
+
if len(args.miller) % 3 != 0:
|
|
252
|
+
raise Exception("Input error! : The input parameter should be triple. For example: -e 1 1 0 or ")
|
|
253
|
+
args.miller = np.array(args.miller).reshape(-1, 3).tolist()
|
|
254
|
+
res = do_surface(
|
|
255
|
+
savename = args.savename,
|
|
256
|
+
output_format = args.output_format,
|
|
257
|
+
supercell_matrix = args.supercell_matrix,
|
|
258
|
+
cartesian = args.cartesian is False,
|
|
259
|
+
pbc=args.periodicity,
|
|
260
|
+
tol=args.tolerance,
|
|
261
|
+
millers = args.miller,
|
|
262
|
+
layer_num = args.layer_num,
|
|
263
|
+
z_min = args.z_min,
|
|
264
|
+
vacuum_max = args.vacuum_max,
|
|
265
|
+
vacuum_min = args.vacuum_min,
|
|
266
|
+
vacuum_resol = args.vacuum_resol,
|
|
267
|
+
vacuum_numb = args.vacuum_numb,
|
|
268
|
+
mid_point = args.mid_point,
|
|
269
|
+
cell_type = args.cell_type,
|
|
270
|
+
lattice = args.lattice
|
|
271
|
+
)
|
|
272
|
+
print("Do surface done! The constructed surface structure file path: {}\n".format("\n".join(res)))
|
|
164
273
|
|
|
165
274
|
def run_pertub(cmd_list:list[str]):
|
|
166
275
|
parser = argparse.ArgumentParser(description='Disturb the atomic positions and unit cells of the structure!')
|
|
@@ -258,7 +367,10 @@ def run_convert_configs(cmd_list:list[str]):
|
|
|
258
367
|
else:
|
|
259
368
|
assert os.path.exists(_input)
|
|
260
369
|
input_list.append(_input)
|
|
261
|
-
|
|
370
|
+
if not isinstance(args.gap, int) or args.gap <= 0:
|
|
371
|
+
raise Exception("Error! The input '-g' or '--gap' must be a positive integer!")
|
|
372
|
+
else:
|
|
373
|
+
args.gap = f"::{args.gap}"
|
|
262
374
|
# FORMAT.check_format(args.input_format, FORMAT.support_images_format)
|
|
263
375
|
FORMAT.check_format(args.output_format, [FORMAT.pwmlff_npy, FORMAT.extxyz])
|
|
264
376
|
|
|
@@ -56,24 +56,27 @@ class META_OMol(object):
|
|
|
56
56
|
cpu_nums = min(cpu_nums, multiprocessing.cpu_count())
|
|
57
57
|
if isinstance(input, str):
|
|
58
58
|
input = [input]
|
|
59
|
+
|
|
60
|
+
atom_lists = []
|
|
59
61
|
# single cpu debug
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
if cpu_nums == 1:
|
|
63
|
+
for i, _ in enumerate(input):
|
|
64
|
+
print(i)
|
|
65
|
+
_atom_lists = load_and_query_db(_, atom_types, query, filter_with_elements)
|
|
66
|
+
for _ in _atom_lists:
|
|
67
|
+
print(_.formula)
|
|
68
|
+
atom_lists.append(_atom_lists)
|
|
69
|
+
else:
|
|
70
|
+
# 使用多进程并行加载和查询数据库
|
|
71
|
+
with ProcessPoolExecutor(max_workers=cpu_nums) as executor:
|
|
72
|
+
futures = []
|
|
73
|
+
for db_address in input:
|
|
74
|
+
futures.append(executor.submit(load_and_query_db, db_address, atom_types, query, filter_with_elements))
|
|
75
|
+
|
|
76
|
+
# 收集查询结果
|
|
77
|
+
atom_lists = []
|
|
78
|
+
for future in as_completed(futures):
|
|
79
|
+
atom_lists.append(future.result())
|
|
77
80
|
|
|
78
81
|
# 处理所有结果
|
|
79
82
|
for atom_list in atom_lists:
|
|
@@ -33,27 +33,27 @@ class Molecule():
|
|
|
33
33
|
"""
|
|
34
34
|
# from atoms_row.data which is dict
|
|
35
35
|
self.data = atoms_row.data
|
|
36
|
-
self.source = atoms_row.data['source']
|
|
37
|
-
self.reference_source = atoms_row.data['reference_source']
|
|
38
|
-
self.data_id = atoms_row.data['data_id']
|
|
39
|
-
self.charge = atoms_row.data['charge']
|
|
40
|
-
self.spin = atoms_row.data['spin']
|
|
41
|
-
self.num_atoms = atoms_row.data['num_atoms']
|
|
42
|
-
self.num_electrons = atoms_row.data['num_electrons']
|
|
43
|
-
self.num_ecp_electrons = atoms_row.data['num_ecp_electrons']
|
|
44
|
-
self.n_scf_steps = atoms_row.data['n_scf_steps']
|
|
45
|
-
self.n_basis = atoms_row.data['n_basis']
|
|
46
|
-
self.unrestricted = atoms_row.data['unrestricted']
|
|
47
|
-
self.nl_energy = atoms_row.data['nl_energy']
|
|
48
|
-
self.integrated_densities = atoms_row.data['integrated_densities']
|
|
49
|
-
self.homo_energy = atoms_row.data['homo_energy']
|
|
50
|
-
self.homo_lumo_gap = atoms_row.data['homo_lumo_gap']
|
|
51
|
-
self.s_squared = atoms_row.data['s_squared']
|
|
52
|
-
self.s_squared_dev = atoms_row.data['s_squared_dev']
|
|
53
|
-
self.warnings = atoms_row.data['warnings']
|
|
54
|
-
self.mulliken_charges = atoms_row.data['mulliken_charges']
|
|
55
|
-
self.lowdin_charges = atoms_row.data['lowdin_charges']
|
|
56
|
-
self.composition = atoms_row.data['composition']
|
|
36
|
+
self.source = atoms_row.data['source'] if "source" in atoms_row.data.keys() else None
|
|
37
|
+
self.reference_source = atoms_row.data['reference_source'] if "reference_source" in atoms_row.data.keys() else None
|
|
38
|
+
self.data_id = atoms_row.data['data_id'] if "data_id" in atoms_row.data.keys() else None
|
|
39
|
+
self.charge = atoms_row.data['charge'] if "charge" in atoms_row.data.keys() else None
|
|
40
|
+
self.spin = atoms_row.data['spin'] if "spin" in atoms_row.data.keys() else None
|
|
41
|
+
self.num_atoms = atoms_row.data['num_atoms'] if "num_atoms" in atoms_row.data.keys() else None
|
|
42
|
+
self.num_electrons = atoms_row.data['num_electrons'] if "num_electrons" in atoms_row.data.keys() else None
|
|
43
|
+
self.num_ecp_electrons = atoms_row.data['num_ecp_electrons'] if "num_ecp_electrons" in atoms_row.data.keys() else None
|
|
44
|
+
self.n_scf_steps = atoms_row.data['n_scf_steps'] if "n_scf_steps" in atoms_row.data.keys() else None
|
|
45
|
+
self.n_basis = atoms_row.data['n_basis'] if "n_basis" in atoms_row.data.keys() else None
|
|
46
|
+
self.unrestricted = atoms_row.data['unrestricted'] if "unrestricted" in atoms_row.data.keys() else None
|
|
47
|
+
self.nl_energy = atoms_row.data['nl_energy'] if "nl_energy" in atoms_row.data.keys() else None
|
|
48
|
+
self.integrated_densities = atoms_row.data['integrated_densities'] if "integrated_densities" in atoms_row.data.keys() else None
|
|
49
|
+
self.homo_energy = atoms_row.data['homo_energy'] if "homo_energy" in atoms_row.data.keys() else None
|
|
50
|
+
self.homo_lumo_gap = atoms_row.data['homo_lumo_gap'] if "homo_lumo_gap" in atoms_row.data.keys() else None
|
|
51
|
+
self.s_squared = atoms_row.data['s_squared'] if "s_squared" in atoms_row.data.keys() else None
|
|
52
|
+
self.s_squared_dev = atoms_row.data['s_squared_dev'] if "s_squared_dev" in atoms_row.data.keys() else None
|
|
53
|
+
self.warnings = atoms_row.data['warnings'] if "warnings" in atoms_row.data.keys() else None
|
|
54
|
+
self.mulliken_charges = atoms_row.data['mulliken_charges'] if "mulliken_charges" in atoms_row.data.keys() else None
|
|
55
|
+
self.lowdin_charges = atoms_row.data['lowdin_charges'] if "lowdin_charges" in atoms_row.data.keys() else None
|
|
56
|
+
self.composition = atoms_row.data['composition'] if "composition" in atoms_row.data.keys() else None
|
|
57
57
|
|
|
58
58
|
# for search param from atoms_row
|
|
59
59
|
self.calculator = atoms_row.calculator
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from pwdata import Config
|
|
2
|
+
from tqdm import tqdm
|
|
3
|
+
import json
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
|
|
8
|
+
""" 转换脚本
|
|
9
|
+
os.chdir("/a800/wuxingxing/OC25/train")
|
|
10
|
+
file_name = [
|
|
11
|
+
"data0000.aselmdb",
|
|
12
|
+
"data0001.aselmdb",
|
|
13
|
+
"data0002.aselmdb",
|
|
14
|
+
"data0003.aselmdb",
|
|
15
|
+
"data0004.aselmdb",
|
|
16
|
+
"data0005.aselmdb",
|
|
17
|
+
"data0006.aselmdb",
|
|
18
|
+
"data0007.aselmdb",
|
|
19
|
+
"data0008.aselmdb",
|
|
20
|
+
"data0009.aselmdb",
|
|
21
|
+
"data0010.aselmdb",
|
|
22
|
+
"data0011.aselmdb",
|
|
23
|
+
"data0012.aselmdb",
|
|
24
|
+
"data0013.aselmdb",
|
|
25
|
+
"data0014.aselmdb",
|
|
26
|
+
"data0015.aselmdb",
|
|
27
|
+
"data0016.aselmdb",
|
|
28
|
+
"data0017.aselmdb",
|
|
29
|
+
"data0018.aselmdb",
|
|
30
|
+
"data0019.aselmdb"
|
|
31
|
+
]
|
|
32
|
+
for file in file_name:
|
|
33
|
+
oc_data = Config(format="meta", data_path=file)
|
|
34
|
+
oc_data.to(format='extxyz', data_path=f"{file.split('.')[0]}-extxyz")
|
|
35
|
+
# check file
|
|
36
|
+
try:
|
|
37
|
+
check_data= Config(format="extxyz", data_path=f"{file.split('.')[0]}-extxyz/train.xyz")
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print(e)
|
|
40
|
+
print(f"{file} cvt error!")
|
|
41
|
+
|
|
42
|
+
print(f"{file} cvt done!")
|
|
43
|
+
"""
|
|
44
|
+
# file_list = [
|
|
45
|
+
# "/a800/wuxingxing/OC25/train/data0008.aselmdb"
|
|
46
|
+
# ]
|
|
47
|
+
# atom_names = None# ["C", "H"]
|
|
48
|
+
# query = None
|
|
49
|
+
# cpu_nums = 1
|
|
50
|
+
|
|
51
|
+
# oc_data = Config(format="meta", data_path=file_list, atom_names=atom_names, query=query, cpu_nums=cpu_nums)
|
|
52
|
+
# oc_data.to(format="extxyz", data_path="/a800/wuxingxing/OC25/tmp")
|
|
53
|
+
|
|
54
|
+
oc_data = Config(format="extxyz", data_path="/a800/wuxingxing/OC25/train/train.xyz")
|
|
55
|
+
print(f"read done! image nums: {len(oc_data.images)}")
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pwdata import META_OMol, Molecule, read_oMol_data
|
|
2
|
+
from tqdm import tqdm
|
|
3
|
+
import json
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
file_list = [
|
|
8
|
+
"/a800/wuxingxing/omol25-test.aselmdb"
|
|
9
|
+
]
|
|
10
|
+
atom_names = None# ["C", "H"]
|
|
11
|
+
query = None
|
|
12
|
+
cpu_nums = 3
|
|
13
|
+
|
|
14
|
+
omol_data = read_oMol_data(file_list, atom_names, query, cpu_nums)
|
|
15
|
+
print(len(omol_data.image_list))
|
|
16
|
+
save_path = "/a800/wuxingxing/omol25-test.json"
|
|
17
|
+
out_put = {}
|
|
18
|
+
for idx, image in tqdm(enumerate(omol_data.image_list), total=len(omol_data.image_list), desc="Convert to json file:"):
|
|
19
|
+
tmp = {}
|
|
20
|
+
for var_name, var_value in vars(image).items():
|
|
21
|
+
if var_name != "data":
|
|
22
|
+
tmp[var_name] = var_value
|
|
23
|
+
for key in image.data.keys():
|
|
24
|
+
tmp[key] = image.data[key]
|
|
25
|
+
for key in tmp.keys():
|
|
26
|
+
if isinstance(tmp[key], np.ndarray):
|
|
27
|
+
tmp[key] = tmp[key].flatten().tolist()
|
|
28
|
+
out_put[idx] = tmp
|
|
29
|
+
json.dump(out_put, open(save_path, "w"), indent=4)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import os, sys
|
|
2
|
+
from pwdata import Config
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
def run_convert_configs(cmd_list:list[str]):
|
|
7
|
+
# parser = argparse.ArgumentParser(description='This command is used for transferring structural files between different apps. For extxyz format, all configs will save to one file, \nFor pwmlff/npy, configs with same atom types and atom nums in each type will save to one dir.\n')
|
|
8
|
+
|
|
9
|
+
# parser.add_argument('-i', '--input', type=str, required=True, help="The directory or file path of the datas.\nYou can also use JSON file to list all file paths in 'datapath': [], such as 'pwdata/test/meta_data.json'")
|
|
10
|
+
# parser.add_argument('-s', '--savepath', type=str, required=False, default="MOVEMENT", help="The output dir path, if not provided, the current dir will be used")
|
|
11
|
+
# args = parser.parse_args(cmd_list)
|
|
12
|
+
args_input = "/share/public/wuxingxing/SandboxAQ/train_id_v2/data.0021.aselmdb"
|
|
13
|
+
args_savepath = "~/tmp/"
|
|
14
|
+
image = Config(data_path=args_input, format="meta")
|
|
15
|
+
image.to(format="extxyz", data_path=args_savepath)
|
|
16
|
+
print("covert extxyz done!")
|
|
17
|
+
|
|
18
|
+
if __name__=="__main__":
|
|
19
|
+
print(sys.argv)
|
|
20
|
+
run_convert_configs([])# cmd_list = sys.argv[1:]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from pwdata.image import Image
|
|
3
|
+
from pwdata.config import Config
|
|
4
|
+
from pwdata.build.supercells import make_supercell
|
|
5
|
+
from pwdata.pertub.perturbation import perturb_structure
|
|
6
|
+
from pwdata.pertub.scale import scale_cell
|
|
7
|
+
|
|
8
|
+
def test_super_cell(input_format, config_file, super_cell_matrix, pbc, save_path, save_name, save_format, direct = True, sort = False, wrap = False):
|
|
9
|
+
config = Config(format=input_format, data_path=config_file, atom_names=None)
|
|
10
|
+
# Make a supercell
|
|
11
|
+
supercell = make_supercell(config, super_cell_matrix, pbc)
|
|
12
|
+
# Write out the structure
|
|
13
|
+
supercell.to(data_path = save_path,
|
|
14
|
+
data_name = save_name,
|
|
15
|
+
format = save_format,
|
|
16
|
+
direct = True,
|
|
17
|
+
sort = False,
|
|
18
|
+
wrap = False)
|
|
19
|
+
|
|
20
|
+
def test_scale():
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
def test_pertub():
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__=="__main__":
|
|
28
|
+
test_super_cell()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.5
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.
|
|
5
5
|
Home-page: https://github.com/LonxunQuantum/pwdata
|
|
6
6
|
Author: LonxunQuantum
|
|
@@ -69,8 +69,11 @@ pwdata/test/matpbe2lmdb.py
|
|
|
69
69
|
pwdata/test/matrcan2lmdb.py
|
|
70
70
|
pwdata/test/mdtrajs2config.py
|
|
71
71
|
pwdata/test/mptraj2lmdb.py
|
|
72
|
+
pwdata/test/oc25.py
|
|
72
73
|
pwdata/test/omol25.py
|
|
73
74
|
pwdata/test/outcar2mvms.py
|
|
75
|
+
pwdata/test/readasedb.py
|
|
76
|
+
pwdata/test/surf_test.py
|
|
74
77
|
pwdata/utils/__init__.py
|
|
75
78
|
pwdata/utils/constant.py
|
|
76
79
|
pwdata/utils/format_change.py
|
|
@@ -3,9 +3,15 @@ import setuptools
|
|
|
3
3
|
with open("README.md", "r") as fh:
|
|
4
4
|
long_description = fh.read()
|
|
5
5
|
|
|
6
|
+
# pip3 install setuptools wheel twine
|
|
7
|
+
|
|
8
|
+
# rm dist/ -r
|
|
9
|
+
# python3 setup.py sdist bdist_wheel
|
|
10
|
+
# twine upload dist/* --verbose
|
|
11
|
+
|
|
6
12
|
setuptools.setup(
|
|
7
13
|
name="pwdata",
|
|
8
|
-
version="0.5.
|
|
14
|
+
version="0.5.5",
|
|
9
15
|
author="LonxunQuantum",
|
|
10
16
|
author_email="lonxun@pwmat.com",
|
|
11
17
|
description="pwdata is a data pre-processing tool for MatPL, which can be used to extract features and labels. It also provides convenient interfaces for data conversion between different software.",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from pwdata import META_OMol, Molecule, read_oMol_data
|
|
2
|
-
|
|
3
|
-
if __name__ == "__main__":
|
|
4
|
-
file_list = [
|
|
5
|
-
"/data/home/wuxingxing/codespace/pwdata_dev/examples/omol_data"
|
|
6
|
-
]
|
|
7
|
-
|
|
8
|
-
atom_names = ["C", "H"]
|
|
9
|
-
query = None
|
|
10
|
-
cpu_nums = 3
|
|
11
|
-
|
|
12
|
-
omol_data = read_oMol_data(file_list, atom_names, query, cpu_nums)
|
|
13
|
-
print(len(omol_data.image_list))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
{pwdata-0.5.4.dev0 → pwdata-0.5.5}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|