pwdata 0.5.5.dev0__tar.gz → 0.5.6__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.5.dev0 → pwdata-0.5.6}/PKG-INFO +1 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/atomconfig.py +5 -4
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/check_envs.py +1 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/config.py +1 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/convert_files.py +8 -8
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/extendedxyz.py +2 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/main.py +4 -1
- pwdata-0.5.6/pwdata/test/lmdb2aselmdb.py +131 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/SOURCES.txt +1 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/setup.py +7 -1
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/LICENSE +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/README.md +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/build/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/build/cell.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/build/geometry.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/build/supercells.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/build/write_struc.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/calculators/const.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/calculators/units.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/deepmd.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/dump.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/common/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/common/registry.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/common/typing.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/common/utils.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/_utils.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/base_dataset.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/modules/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/modules/transforms.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/preprocessing/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/image.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/lmps.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/meta.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/meta_omol.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/molecule.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/movement.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/movement_saver.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/outcar.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/poscar.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/pwmlff.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/bamboo2lmdb.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/extact_outcar_with_ml.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/matpbe2lmdb.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/matrcan2lmdb.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/mdtrajs2config.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/mptraj2lmdb.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/oc25.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/omol25.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/outcar2mvms.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/readasedb.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test/surf_test.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/test.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/tmp.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/utils/__init__.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/utils/constant.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata/utils/format_change.py +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/entry_points.txt +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/requires.txt +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.5.5.dev0 → pwdata-0.5.6}/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.6
|
|
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
|
|
@@ -2,6 +2,7 @@ import re
|
|
|
2
2
|
from tqdm import tqdm
|
|
3
3
|
from collections import Counter
|
|
4
4
|
from pwdata.image import Image
|
|
5
|
+
from pwdata.utils.format_change import to_numpy_array, to_integer, to_float
|
|
5
6
|
|
|
6
7
|
class CONFIG(object):
|
|
7
8
|
def __init__(self, config_file, pbc = None) -> None:
|
|
@@ -29,10 +30,10 @@ class CONFIG(object):
|
|
|
29
30
|
image.atom_nums = atom_nums
|
|
30
31
|
elif "position" in ii.lower():
|
|
31
32
|
position = self.parse_position(config_contents[idx+1:idx+image.atom_nums+1])
|
|
32
|
-
image.position = position["position"]
|
|
33
|
-
image.atom_type = position["atom_type"]
|
|
34
|
-
image.atom_type_num = position["atom_type_num"]
|
|
35
|
-
image.atom_types_image = position["atom_types_image"]
|
|
33
|
+
image.position = to_numpy_array(position["position"])
|
|
34
|
+
image.atom_type = to_numpy_array(position["atom_type"])
|
|
35
|
+
image.atom_type_num = to_numpy_array(position["atom_type_num"])
|
|
36
|
+
image.atom_types_image = to_numpy_array(position["atom_types_image"])
|
|
36
37
|
image.image_nums = len(self.image_list)
|
|
37
38
|
print("Load data %s successfully!" % config_file)
|
|
38
39
|
|
|
@@ -15,7 +15,7 @@ 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
|
|
18
|
+
info += "surf or surface: Under Development (2025.12.24)\n"
|
|
19
19
|
info += "\n"
|
|
20
20
|
|
|
21
21
|
info += "perturb:\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':
|
|
@@ -208,7 +208,7 @@ def do_convert_images(
|
|
|
208
208
|
merge:bool=True
|
|
209
209
|
):
|
|
210
210
|
data_files = search_images(input, input_format)
|
|
211
|
-
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)
|
|
212
212
|
save_images(savepath, image_data, output_format, data_shuffle, merge)
|
|
213
213
|
|
|
214
214
|
def do_count_images(
|
|
@@ -353,7 +353,7 @@ def search_by_format(workDir, format):
|
|
|
353
353
|
return data_path[format]
|
|
354
354
|
|
|
355
355
|
|
|
356
|
-
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=":"):
|
|
357
357
|
image_data = None
|
|
358
358
|
if input_format is not None:
|
|
359
359
|
if input_format == FORMAT.meta:
|
|
@@ -362,31 +362,31 @@ def load_files(input_dict:dict, input_format:str=None, atom_types:list[str]=None
|
|
|
362
362
|
metadatas = [input_dict[FORMAT.meta][i:i + chunk_size] for i in range(0, lmdb_nums, chunk_size)]
|
|
363
363
|
for idx, metapaths in enumerate(tqdm(metadatas, total=lmdb_nums // chunk_size)):
|
|
364
364
|
if image_data is None:
|
|
365
|
-
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)
|
|
366
366
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
367
367
|
image_data.images = [image_data.images]
|
|
368
368
|
else:
|
|
369
|
-
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)
|
|
370
370
|
image_data.images.extend(tmp_image_data.images)
|
|
371
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)))
|
|
372
372
|
else:
|
|
373
373
|
if len(input_dict[FORMAT.traj]) > 0:# the input is traj files
|
|
374
374
|
for data_path in tqdm(input_dict[FORMAT.traj], total=len(input_dict[FORMAT.traj])):
|
|
375
375
|
if image_data is None:
|
|
376
|
-
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)
|
|
377
377
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
378
378
|
image_data.images = [image_data.images]
|
|
379
379
|
else:
|
|
380
|
-
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)
|
|
381
381
|
image_data.images.extend(tmp_image_data.images)
|
|
382
382
|
else:
|
|
383
383
|
for data_path in tqdm(input_dict[input_format], total=len(input_dict[input_format])):
|
|
384
384
|
if image_data is None:
|
|
385
|
-
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)
|
|
386
386
|
if not isinstance(image_data.images, list): # for the first pwmlff/npy dir only has one picture
|
|
387
387
|
image_data.images = [image_data.images]
|
|
388
388
|
else:
|
|
389
|
-
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)
|
|
390
390
|
image_data.images.extend(tmp_image_data.images)
|
|
391
391
|
return image_data
|
|
392
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)
|
|
@@ -367,7 +367,10 @@ def run_convert_configs(cmd_list:list[str]):
|
|
|
367
367
|
else:
|
|
368
368
|
assert os.path.exists(_input)
|
|
369
369
|
input_list.append(_input)
|
|
370
|
-
|
|
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}"
|
|
371
374
|
# FORMAT.check_format(args.input_format, FORMAT.support_images_format)
|
|
372
375
|
FORMAT.check_format(args.output_format, [FORMAT.pwmlff_npy, FORMAT.extxyz])
|
|
373
376
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import glob
|
|
3
|
+
from ase import Atoms
|
|
4
|
+
from ase.db.row import AtomsRow
|
|
5
|
+
from pwdata.utils.constant import get_atomic_number_from_name
|
|
6
|
+
from tqdm import tqdm
|
|
7
|
+
import numpy as np
|
|
8
|
+
import torch
|
|
9
|
+
from pwdata.fairchem.datasets.ase_datasets import LMDBDatabase
|
|
10
|
+
|
|
11
|
+
atomic_number_to_symbol = {
|
|
12
|
+
1: 'H', 2: 'He', 3: 'Li', 4: 'Be', 5: 'B', 6: 'C', 7: 'N', 8: 'O', 9: 'F', 10: 'Ne',
|
|
13
|
+
11: 'Na', 12: 'Mg', 13: 'Al', 14: 'Si', 15: 'P', 16: 'S', 17: 'Cl', 18: 'Ar', 19: 'K', 20: 'Ca',
|
|
14
|
+
21: 'Sc', 22: 'Ti', 23: 'V', 24: 'Cr', 25: 'Mn', 26: 'Fe', 27: 'Co', 28: 'Ni', 29: 'Cu', 30: 'Zn',
|
|
15
|
+
31: 'Ga', 32: 'Ge', 33: 'As', 34: 'Se', 35: 'Br', 36: 'Kr', 37: 'Rb', 38: 'Sr', 39: 'Y', 40: 'Zr',
|
|
16
|
+
41: 'Nb', 42: 'Mo', 43: 'Tc', 44: 'Ru', 45: 'Rh', 46: 'Pd', 47: 'Ag', 48: 'Cd', 49: 'In', 50: 'Sn',
|
|
17
|
+
51: 'Sb', 52: 'Te', 53: 'I', 54: 'Xe', 55: 'Cs', 56: 'Ba', 57: 'La', 58: 'Ce', 59: 'Pr', 60: 'Nd',
|
|
18
|
+
61: 'Pm', 62: 'Sm', 63: 'Eu', 64: 'Gd', 65: 'Tb', 66: 'Dy', 67: 'Ho', 68: 'Er', 69: 'Tm', 70: 'Yb',
|
|
19
|
+
71: 'Lu', 72: 'Hf', 73: 'Ta', 74: 'W', 75: 'Re', 76: 'Os', 77: 'Ir', 78: 'Pt', 79: 'Au', 80: 'Hg',
|
|
20
|
+
81: 'Tl', 82: 'Pb', 83: 'Bi', 84: 'Po', 85: 'At', 86: 'Rn', 87: 'Fr', 88: 'Ra', 89: 'Ac', 90: 'Th',
|
|
21
|
+
91: 'Pa', 92: 'U', 93: 'Np', 94: 'Pu', 95: 'Am', 96: 'Cm', 97: 'Bk', 98: 'Cf', 99: 'Es', 100: 'Fm',
|
|
22
|
+
101: 'Md', 102: 'No', 103: 'Lr', 104: 'Rf', 105: 'Db', 106: 'Sg', 107: 'Bh', 108: 'Hs', 109: 'Mt',
|
|
23
|
+
110: 'Ds', 111: 'Rg', 112: 'Cn', 113: 'Nh', 114: 'Fl', 115: 'Mc', 116: 'Lv', 117: 'Ts', 118: 'Og'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def cvt_matdict_2_atomrow(config:dict):
|
|
27
|
+
cell = read_from_dict('matrix', config['structure']['lattice'], require=True)
|
|
28
|
+
atom_type_list = get_atomic_number_from_name([_['label'] for _ in config['structure']['sites']])
|
|
29
|
+
position = [_['xyz'] for _ in config['structure']['sites']]
|
|
30
|
+
magmom = [_['properties']['magmom'] for _ in config['structure']['sites']]
|
|
31
|
+
# magmom = read_from_dict('magmom', config, require=True)
|
|
32
|
+
atom = Atoms(positions=position,
|
|
33
|
+
numbers=atom_type_list,
|
|
34
|
+
magmoms=magmom,
|
|
35
|
+
cell=cell)
|
|
36
|
+
|
|
37
|
+
atom_rows = AtomsRow(atom)
|
|
38
|
+
atom_rows.pbc = np.ones(3, bool)
|
|
39
|
+
# read stress -> xx, yy, zz, yz, xz, xy
|
|
40
|
+
virial = read_from_dict('stress', config, require=True) # this is vrial and the order is xx, yy, zz, yz, xz, xy
|
|
41
|
+
stress = -np.array(virial) / config['volume']
|
|
42
|
+
atom_rows.stress = [stress[0],stress[1],stress[2],stress[3],stress[4],stress[5]]
|
|
43
|
+
force = read_from_dict('forces', config, require=True) #mat is s
|
|
44
|
+
energy = read_from_dict('energy', config, require=True)
|
|
45
|
+
atom_rows.__setattr__('force', force)
|
|
46
|
+
atom_rows.__setattr__('forces', force)
|
|
47
|
+
atom_rows.__setattr__('energy', energy)
|
|
48
|
+
data = {}
|
|
49
|
+
return atom_rows, data
|
|
50
|
+
|
|
51
|
+
def read_from_dict(key:str, config:dict, default=None, require=False):
|
|
52
|
+
if key in config:
|
|
53
|
+
return config[key]
|
|
54
|
+
else:
|
|
55
|
+
if require:
|
|
56
|
+
raise ValueError("key {} not found in config".format(key))
|
|
57
|
+
else:
|
|
58
|
+
return default
|
|
59
|
+
|
|
60
|
+
def atom_type_to_symbol(atom_type):
|
|
61
|
+
return atomic_number_to_symbol.get(int(atom_type), 'X') # Default to 'X' for unknown types
|
|
62
|
+
|
|
63
|
+
def atom_types_to_symbol(atom_types):
|
|
64
|
+
return [atom_type_to_symbol(atom) for atom in atom_types]
|
|
65
|
+
|
|
66
|
+
# xyz_file = "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/eval/stabel_pwmat/0/molecule_stable_000.xyz"
|
|
67
|
+
# atoms = read(xyz_file)
|
|
68
|
+
# atoms.center(vacuum=8)
|
|
69
|
+
# # 获取原子符号列表,并排序
|
|
70
|
+
# symbols = atoms.get_chemical_symbols()
|
|
71
|
+
# sorted_indices = sorted(range(len(symbols)), key=lambda i: symbols[i])
|
|
72
|
+
|
|
73
|
+
# # 按排序后的索引重新排列原子
|
|
74
|
+
# atoms_sorted = atoms[sorted_indices]
|
|
75
|
+
|
|
76
|
+
# save_file = "/data/home/wuxingxing/codespace/EDM/outputs/edm_qm9/bk_eval/stabel_pwmat/0/sort.0.POSCAR"
|
|
77
|
+
# write(filename=save_file, images=atoms_sorted, format="vasp")
|
|
78
|
+
|
|
79
|
+
def read2atoms(pt_file, db, prefix):
|
|
80
|
+
atom_row_list = []
|
|
81
|
+
val = torch.load(pt_file, map_location="cpu")
|
|
82
|
+
# Get the necessary tensors
|
|
83
|
+
cumsum_atom = val['cumsum_atom'].numpy() # Convert to numpy for easier handling
|
|
84
|
+
positions = val['pos'].numpy() # Shape: [410945, 3]
|
|
85
|
+
atom_types = val['atom_types'].numpy() # Shape: [410945]
|
|
86
|
+
forces = val['forces'].numpy()
|
|
87
|
+
charges = val['charge'].numpy()
|
|
88
|
+
for id, i in tqdm(enumerate(range(len(cumsum_atom) - 1)), total=len(cumsum_atom) - 1, desc="bamboo ptfile to aselmdb"):
|
|
89
|
+
start_idx = cumsum_atom[i]
|
|
90
|
+
end_idx = cumsum_atom[i + 1]
|
|
91
|
+
energy = val['energy'][id].item()
|
|
92
|
+
# Get positions and atom types for the current structure
|
|
93
|
+
struct_pos = positions[start_idx:end_idx]
|
|
94
|
+
struct_types = atom_types[start_idx:end_idx]
|
|
95
|
+
force = forces[start_idx:end_idx]
|
|
96
|
+
charge = charges[start_idx:end_idx]
|
|
97
|
+
symbol = atom_types_to_symbol(struct_types)
|
|
98
|
+
atom = Atoms(symbols=symbol,
|
|
99
|
+
positions=struct_pos,
|
|
100
|
+
charges=charge,
|
|
101
|
+
pbc=False)
|
|
102
|
+
atom.center(vacuum=5)
|
|
103
|
+
atom_rows = AtomsRow(atom)
|
|
104
|
+
atom_rows.__setattr__('force', force)
|
|
105
|
+
atom_rows.__setattr__('forces', force)
|
|
106
|
+
atom_rows.__setattr__('energy', energy)
|
|
107
|
+
data = {}
|
|
108
|
+
data['total_charge'] = val['total_charge'][id].item()
|
|
109
|
+
data['dipole'] = list(val['dipole'][id].numpy())
|
|
110
|
+
data['quadrupole'] = list(val['quadrupole'][id].numpy())
|
|
111
|
+
data["idx"] = f"{id}-{prefix}"
|
|
112
|
+
db._write(atom_rows, key_value_pairs={}, data=data)
|
|
113
|
+
atom_row_list.append(atom_rows)
|
|
114
|
+
db.close()
|
|
115
|
+
|
|
116
|
+
def cvtbamboo(pt_dir, save_dir, prefix):
|
|
117
|
+
pt_list = glob.glob(os.path.join(pt_dir, "*.lmdb"))
|
|
118
|
+
for pt in pt_list:
|
|
119
|
+
save_path = os.path.join(save_dir, os.path.basename(pt).replace('.lmdb', '.aselmdb'))
|
|
120
|
+
source = LMDBDatabase(filename=pt, readonly=True)
|
|
121
|
+
db = LMDBDatabase(filename=save_path, readonly=False)
|
|
122
|
+
atom_row_list = read2atoms(pt, db, prefix)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if __name__=="__main__":
|
|
126
|
+
pt_dir="/data/public/wuxingxing/catalyticLAM/metal/train"
|
|
127
|
+
save_dir="/data/public/wuxingxing/catalyticLAM/metal/train/tmp"
|
|
128
|
+
if not os.path.exists(save_dir):
|
|
129
|
+
os.makedirs(save_dir)
|
|
130
|
+
prefix = "2d"
|
|
131
|
+
cvtbamboo(pt_dir, save_dir, prefix)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.6
|
|
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
|
|
@@ -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.6",
|
|
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.",
|
|
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.5.dev0 → pwdata-0.5.6}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py
RENAMED
|
File without changes
|
|
File without changes
|
{pwdata-0.5.5.dev0 → pwdata-0.5.6}/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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|