pwdata 0.4.3__tar.gz → 0.4.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.
Potentially problematic release.
This version of pwdata might be problematic. Click here for more details.
- {pwdata-0.4.3 → pwdata-0.4.5}/PKG-INFO +1 -1
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/check_envs.py +4 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/convert_files.py +13 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/main.py +43 -1
- pwdata-0.4.5/pwdata/test/mdtrajs2config.py +30 -0
- pwdata-0.4.5/pwdata/test/mptraj2lmdb.py +86 -0
- pwdata-0.4.5/pwdata/test.py +192 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/SOURCES.txt +3 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/setup.py +1 -1
- {pwdata-0.4.3 → pwdata-0.4.5}/LICENSE +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/README.md +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/atomconfig.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/build/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/build/cell.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/build/geometry.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/build/supercells.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/build/write_struc.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/calculators/const.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/calculators/units.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/config.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/deepmd.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/dump.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/extendedxyz.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/common/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/common/registry.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/common/typing.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/common/utils.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/_utils.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/base_dataset.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/modules/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/modules/transforms.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/fairchem/preprocessing/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/image.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/lmps.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/meta.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/movement.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/movement_saver.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/outcar.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/poscar.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/pwmlff.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/test/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/utils/__init__.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata/utils/constant.py +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/entry_points.txt +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/requires.txt +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.4.3 → pwdata-0.4.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for PWMLFF, 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
|
|
@@ -29,6 +29,10 @@ def cmd_infos():
|
|
|
29
29
|
info += "\tExtract various trajectory files(movement of PWmat, outcar of Vasp, lammps/dump of Lammps, cp2k-mdfile of CP2K) or data sets (deepmd/npy, deepmd/raw, extxyz, meta aselmdb) into pwmlff/npy or extxyz format, the command example:\n"
|
|
30
30
|
info += "\tpwdata convert_images -i input_file1 input_file2 ... input_filen -f input_file_format -n output_format_name -o output_format\n\n"
|
|
31
31
|
|
|
32
|
+
info += "count or count_configs:\n"
|
|
33
|
+
info += "\tThis command is used to count the number of input structures, the command example:\n"
|
|
34
|
+
info += "\tpwdata count -i input_file1 input_file2 ... input_filen -f input_file_format\n\n"
|
|
35
|
+
|
|
32
36
|
info += "format suppport\n"
|
|
33
37
|
info += "__________________________________________________________________________________________|\n"
|
|
34
38
|
info += "| Software | file | multi-Image | label | format |\n"
|
|
@@ -131,6 +131,19 @@ def do_convert_images(
|
|
|
131
131
|
image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums)
|
|
132
132
|
save_images(savepath, image_data, output_format, train_valid_ratio, data_shuffle, merge)
|
|
133
133
|
|
|
134
|
+
|
|
135
|
+
def do_count_images(
|
|
136
|
+
input:list[str],
|
|
137
|
+
input_format:str = None,
|
|
138
|
+
atom_types:list[str]=None,
|
|
139
|
+
query:str=None,
|
|
140
|
+
cpu_nums:int=None
|
|
141
|
+
):
|
|
142
|
+
data_files = search_images(input, input_format)
|
|
143
|
+
image_data = load_files(data_files, input_format, atom_types=atom_types, query=query, cpu_nums=cpu_nums)
|
|
144
|
+
print("\n\n******The number of configs is {}******\n\n".format(len(image_data.images)))
|
|
145
|
+
return len(image_data.images)
|
|
146
|
+
|
|
134
147
|
'''
|
|
135
148
|
description:
|
|
136
149
|
save the image_datas to pwmlff/npy or extxyz format
|
|
@@ -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
|
|
25
|
+
from pwdata.convert_files import do_scale_cell, do_super_cell, do_perturb, do_convert_config, do_convert_images, do_count_images
|
|
26
26
|
from pwdata.utils.constant import FORMAT, get_atomic_name_from_number
|
|
27
27
|
from pwdata.check_envs import print_cmd
|
|
28
28
|
|
|
@@ -331,6 +331,17 @@ def main(cmd_list:list=None):
|
|
|
331
331
|
run_convert_config(cmd_list[2:])
|
|
332
332
|
elif "convert_configs".upper() == cmd_list[1].upper() or "cvt_configs".upper() == cmd_list[1].upper():
|
|
333
333
|
run_convert_configs(cmd_list[2:])
|
|
334
|
+
elif "count".upper() == cmd_list[1].upper() or "count_configs".upper() == cmd_list[1].upper():
|
|
335
|
+
if '.json' in cmd_list[1].lower():
|
|
336
|
+
format = json_dict['format'] if 'format' in json_dict.keys() else None
|
|
337
|
+
raw_files = json_dict['raw_files']
|
|
338
|
+
cmd_list = ["count", "-i", cmd_list[1]]
|
|
339
|
+
if format is not None:
|
|
340
|
+
cmd_list.extend(['-f', format])
|
|
341
|
+
count_configs(cmd_list) # pwdata count extract.json
|
|
342
|
+
else:
|
|
343
|
+
count_configs(cmd_list[2:]) # pwdata count -i inputs -f pwmat/config
|
|
344
|
+
|
|
334
345
|
else:
|
|
335
346
|
print("\n\nERROR! Input cannot be recognized!\n\n\n")
|
|
336
347
|
print_cmd()
|
|
@@ -490,5 +501,36 @@ def run_convert_configs(cmd_list:list[str]):
|
|
|
490
501
|
merge = True if args.merge == 1 else False
|
|
491
502
|
do_convert_images(input_list, args.input_format, args.savepath, args.output_format, args.train_valid_ratio, args.split_rand, args.gap, atom_types, args.query, args.cpu_nums, merge)
|
|
492
503
|
|
|
504
|
+
|
|
505
|
+
def count_configs(cmd_list:list[str]):
|
|
506
|
+
parser = argparse.ArgumentParser(description='This command is used to count the number of input structures\n')
|
|
507
|
+
parser.add_argument('-i', '--input', type=str, required=True, nargs='+', 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'")
|
|
508
|
+
parser.add_argument('-f', '--input_format', type=str, required=False, default=None, help="The input file format, if not specified, the format will be automatically inferred based on the input files. the supported format as {}".format(FORMAT.support_images_format))
|
|
509
|
+
parser.add_argument('-q', '--query', type=str, required=False, help='For meta data, advanced query statement, filter Mata data based on query criteria, detailed usage reference http://doc.lonxun.com/PWMLFF/Appendix-2', default=None)
|
|
510
|
+
parser.add_argument('-n', '--cpu_nums', type=int, default=1, required=False, help='For meta data, parallel reading of meta databases using kernel count, default to using all available cores')
|
|
511
|
+
parser.add_argument('-t', '--atom_types', type=str, required=False, nargs='+', help="For 'lammps/lmp', 'lammps/dump': the atom type list of lammps lmp/dump file, the order is same as lammps dump file.\nFor meta data: Query structures that only exist for that element type", default=None)
|
|
512
|
+
|
|
513
|
+
args = parser.parse_args(cmd_list)
|
|
514
|
+
try:
|
|
515
|
+
atom_types = get_atomic_name_from_number(args.atom_types)
|
|
516
|
+
except Exception as e:
|
|
517
|
+
atom_types = args.atom_types
|
|
518
|
+
input_list = []
|
|
519
|
+
for _input in args.input:
|
|
520
|
+
if os.path.isfile(_input) and "json" in os.path.basename(_input) and os.path.exists(_input):
|
|
521
|
+
input = json.load(open(_input))['datapath']
|
|
522
|
+
dicts = json.load(open(_input))
|
|
523
|
+
input = dicts['datapath'] if 'datapath' in dicts.keys() else None
|
|
524
|
+
if input is None:
|
|
525
|
+
input = dicts['raw_files'] if 'raw_files' in dicts.keys() else None
|
|
526
|
+
if isinstance(input, str):
|
|
527
|
+
input = [input]
|
|
528
|
+
input_list.extend(input)
|
|
529
|
+
else:
|
|
530
|
+
assert os.path.exists(_input)
|
|
531
|
+
input_list.append(_input)
|
|
532
|
+
|
|
533
|
+
do_count_images(input_list, args.input_format, atom_types, args.query, args.cpu_nums)
|
|
534
|
+
|
|
493
535
|
if __name__ == "__main__":
|
|
494
536
|
main()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'''
|
|
2
|
+
description:
|
|
3
|
+
Convert various trajectory files ('pwmat/movement','vasp/outcar','cp2k/md', or 'lammps/dump')
|
|
4
|
+
to a single structure format ('pwmat/config', 'vasp/poscar', 'lammps/lmp')
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
from pwdata import Config
|
|
8
|
+
from pwdata.utils.constant import FORMAT
|
|
9
|
+
|
|
10
|
+
def trajs2config():
|
|
11
|
+
atom_types = ["Hf", "O"] # for lammps
|
|
12
|
+
input_file = "/data/home/wuxingxing/codespace/pwdata/examples/lmps_data/HfO2/30.lammpstrj"
|
|
13
|
+
input_format="lammps/dump"
|
|
14
|
+
save_format = "pwmat/config"
|
|
15
|
+
|
|
16
|
+
image = Config(data_path=input_file, format=input_format, atom_names=atom_types)
|
|
17
|
+
tmp_image_data = image.images
|
|
18
|
+
save_dir = "./tmp_test"
|
|
19
|
+
for id, config in enumerate(tmp_image_data):
|
|
20
|
+
savename = "{}_{}".format(id, FORMAT.get_filename_by_format(save_format))
|
|
21
|
+
image.iamges = [config]
|
|
22
|
+
image.to(output_path = save_dir,
|
|
23
|
+
data_name = savename,
|
|
24
|
+
save_format = save_format,
|
|
25
|
+
sort = True)
|
|
26
|
+
|
|
27
|
+
if __name__=="__main__":
|
|
28
|
+
trajs2config()
|
|
29
|
+
|
|
30
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'''
|
|
2
|
+
description:
|
|
3
|
+
Convert MPtraj JSON file to aselmdb format
|
|
4
|
+
'''
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
from pwdata.fairchem.datasets.ase_datasets import LMDBDatabase
|
|
8
|
+
from ase import Atoms
|
|
9
|
+
from ase.db.row import AtomsRow
|
|
10
|
+
from pwdata.utils.constant import get_atomic_number_from_name
|
|
11
|
+
from tqdm import tqdm
|
|
12
|
+
import numpy as np
|
|
13
|
+
|
|
14
|
+
def MPjson2lmdb():
|
|
15
|
+
mp_file = "/data/home/wuxingxing/codespace/pwdata/examples/mp_data/mptest.json"
|
|
16
|
+
save_file = "/data/home/wuxingxing/codespace/pwdata/examples/mp_data/sub.aselmdb"
|
|
17
|
+
Mpjson = json.load(open(mp_file))
|
|
18
|
+
db = LMDBDatabase(filename=save_file, readonly=False)
|
|
19
|
+
for key_1, val_1 in tqdm(Mpjson.items(), total=len(Mpjson.keys())):
|
|
20
|
+
for key_2, val_2 in val_1.items():
|
|
21
|
+
_atomrow, data = cvt_dict_2_atomrow(val_2)
|
|
22
|
+
db._write(_atomrow, key_value_pairs={}, data=data)
|
|
23
|
+
db.close()
|
|
24
|
+
|
|
25
|
+
def cvt_dict_2_atomrow(config:dict):
|
|
26
|
+
cell = read_from_dict('matrix', config['structure']['lattice'], require=True)
|
|
27
|
+
atom_type_list = get_atomic_number_from_name([_['label'] for _ in config['structure']['sites']])
|
|
28
|
+
position = [_['xyz'] for _ in config['structure']['sites']]
|
|
29
|
+
magmom = read_from_dict('magmom', config, require=True)
|
|
30
|
+
atom = Atoms(positions=position,
|
|
31
|
+
numbers=atom_type_list,
|
|
32
|
+
magmoms=magmom,
|
|
33
|
+
cell=cell)
|
|
34
|
+
|
|
35
|
+
atom_rows = AtomsRow(atom)
|
|
36
|
+
atom_rows.pbc = np.ones(3, bool)
|
|
37
|
+
# read stress -> xx, yy, zz, yz, xz, xy
|
|
38
|
+
stress = read_from_dict('stress', config, require=True)
|
|
39
|
+
atom_rows.stress = [stress[0][0],stress[1][1],stress[2][2],stress[1][2],stress[0][2],stress[0][1]]
|
|
40
|
+
force = read_from_dict('force', config, require=True)
|
|
41
|
+
energy = read_from_dict('corrected_total_energy', config, require=True)
|
|
42
|
+
atom_rows.__setattr__('force', force)
|
|
43
|
+
atom_rows.__setattr__('energy', energy)
|
|
44
|
+
data = {}
|
|
45
|
+
data['uncorrected_total_energy'] = read_from_dict('uncorrected_total_energy', config, default=None)
|
|
46
|
+
data['corrected_total_energy'] = read_from_dict('uncorrected_total_energy', config, default=None)
|
|
47
|
+
data['energy_per_atom'] = read_from_dict('energy_per_atom', config, default=None)
|
|
48
|
+
data['ef_per_atom'] = read_from_dict('ef_per_atom', config, default=None)
|
|
49
|
+
data['e_per_atom_relaxed'] = read_from_dict('e_per_atom_relaxed', config, default=None)
|
|
50
|
+
data['ef_per_atom_relaxed'] = read_from_dict('ef_per_atom_relaxed', config, default=None)
|
|
51
|
+
data['bandgap'] = read_from_dict('bandgap', config, default=None)
|
|
52
|
+
data['mp_id'] = read_from_dict('mp_id', config, default=None)
|
|
53
|
+
return atom_rows, data
|
|
54
|
+
|
|
55
|
+
def read_from_dict(key:str, config:dict, default=None, require=False):
|
|
56
|
+
if key in config:
|
|
57
|
+
return config[key]
|
|
58
|
+
else:
|
|
59
|
+
if require:
|
|
60
|
+
raise ValueError("key {} not found in config".format(key))
|
|
61
|
+
else:
|
|
62
|
+
return default
|
|
63
|
+
|
|
64
|
+
# def test_lmdb():
|
|
65
|
+
# from pwdata.fairchem.datasets.ase_datasets import AseDBDataset
|
|
66
|
+
# search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/meta_data/alex_val/alex_go_aao_001.aselmdb'}
|
|
67
|
+
# dataset = AseDBDataset(config=search_dict)
|
|
68
|
+
# atom_list = list(dataset.dbs[0].select("Li"))
|
|
69
|
+
# std = atom_list[0]
|
|
70
|
+
|
|
71
|
+
# search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/MPtrj.aselmdb'}
|
|
72
|
+
# dataset2 = AseDBDataset(config=search_dict)
|
|
73
|
+
# atom_list2 = list(dataset2.dbs[0].select("Li"))
|
|
74
|
+
# dev = atom_list2[0]
|
|
75
|
+
|
|
76
|
+
# search_dict = {'src': '/data/home/wuxingxing/codespace/pwdata/examples/mp_data/sub.aselmdb'}
|
|
77
|
+
# dataset3 = AseDBDataset(config=search_dict)
|
|
78
|
+
# atom_list3 = list(dataset3.dbs[0].select())
|
|
79
|
+
# std3 = atom_list3[0]
|
|
80
|
+
|
|
81
|
+
# print()
|
|
82
|
+
|
|
83
|
+
if __name__=="__main__":
|
|
84
|
+
MPjson2lmdb()
|
|
85
|
+
|
|
86
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from main import main
|
|
3
|
+
import json
|
|
4
|
+
from pwdata.utils.constant import FORMAT
|
|
5
|
+
from pwdata.convert_files import search_images
|
|
6
|
+
|
|
7
|
+
# scale_cell super_cell pertub convert_config convert_images
|
|
8
|
+
def test_convert_config():
|
|
9
|
+
res_list = []
|
|
10
|
+
configs = json.load(open("./config.json"))["convert_image"]
|
|
11
|
+
save_dir = "./test_workdir"
|
|
12
|
+
for config in configs:
|
|
13
|
+
config_file = config["input_file"]
|
|
14
|
+
config_format= config["input_format"]
|
|
15
|
+
if "atom_types" in config.keys():
|
|
16
|
+
atom_types = config["atom_types"]
|
|
17
|
+
else:
|
|
18
|
+
atom_types = None
|
|
19
|
+
for format in ["pwmat/config","vasp/poscar","lammps/lmp"]:
|
|
20
|
+
cmd_list = ["", "cvt_config", "-i", config_file, "-f", config_format, "-s", os.path.join(save_dir, "{}_{}".format("cvtcnf", FORMAT.get_filename_by_format(format))), "-o", format, "-c"]
|
|
21
|
+
if atom_types is not None:
|
|
22
|
+
cmd_list.append("-t")
|
|
23
|
+
cmd_list.extend(atom_types)
|
|
24
|
+
main(cmd_list)
|
|
25
|
+
res_list.append(cmd_list)
|
|
26
|
+
return res_list
|
|
27
|
+
|
|
28
|
+
def test_scale_cell():
|
|
29
|
+
res_list = []
|
|
30
|
+
configs = json.load(open("./config.json"))["convert_image"]
|
|
31
|
+
save_dir = "./test_workdir"
|
|
32
|
+
for idi, config in enumerate(configs):
|
|
33
|
+
config_file = config["input_file"]
|
|
34
|
+
config_format= config["input_format"]
|
|
35
|
+
if "atom_types" in config.keys():
|
|
36
|
+
atom_types = config["atom_types"]
|
|
37
|
+
else:
|
|
38
|
+
atom_types = None
|
|
39
|
+
for idj, format in enumerate(["pwmat/config","vasp/poscar","lammps/lmp"]):
|
|
40
|
+
save_path = os.path.join(save_dir, "scale_{}_{}_{}".format(idi, idj, FORMAT.get_filename_by_format(format)))
|
|
41
|
+
cmd_list = ["", "scale_cell", "-r", "0.98", "0.99", "0.97", "0.95", "-i", config_file, "-s", save_path, "-o", format, "-c"]#"-f", config_format,
|
|
42
|
+
if atom_types is not None:
|
|
43
|
+
cmd_list.append("-t")
|
|
44
|
+
cmd_list.extend(atom_types)
|
|
45
|
+
main(cmd_list)
|
|
46
|
+
res_list.append(cmd_list)
|
|
47
|
+
return res_list
|
|
48
|
+
|
|
49
|
+
def test_super_cell():
|
|
50
|
+
res_list = []
|
|
51
|
+
configs = json.load(open("./config.json"))["convert_image"]
|
|
52
|
+
save_dir = "./test_workdir"
|
|
53
|
+
for idi, config in enumerate(configs):
|
|
54
|
+
config_file = config["input_file"]
|
|
55
|
+
config_format= config["input_format"]
|
|
56
|
+
if "atom_types" in config.keys():
|
|
57
|
+
atom_types = config["atom_types"]
|
|
58
|
+
else:
|
|
59
|
+
atom_types = None
|
|
60
|
+
for idj, format in enumerate(["pwmat/config","vasp/poscar","lammps/lmp"]):
|
|
61
|
+
save_path = os.path.join(save_dir, "super_{}_{}_{}".format(idi, idj, FORMAT.get_filename_by_format(format)))
|
|
62
|
+
cmd_list = ["", "super_cell", "-m", "2", "3", "4", "-i", config_file, "-s", save_path, "-o", format, "-c"]# "-f", config_format,
|
|
63
|
+
if atom_types is not None:
|
|
64
|
+
cmd_list.append("-t")
|
|
65
|
+
cmd_list.extend(atom_types)
|
|
66
|
+
main(cmd_list)
|
|
67
|
+
res_list.append(cmd_list)
|
|
68
|
+
return res_list
|
|
69
|
+
|
|
70
|
+
def test_pertub():
|
|
71
|
+
res_list = []
|
|
72
|
+
configs = json.load(open("./config.json"))["convert_image"]
|
|
73
|
+
save_dir = "./test_workdir"
|
|
74
|
+
for idi, config in enumerate(configs):
|
|
75
|
+
config_file = config["input_file"]
|
|
76
|
+
config_format= config["input_format"]
|
|
77
|
+
if "atom_types" in config.keys():
|
|
78
|
+
atom_types = config["atom_types"]
|
|
79
|
+
else:
|
|
80
|
+
atom_types = None
|
|
81
|
+
for idj, format in enumerate(["pwmat/config","vasp/poscar","lammps/lmp"]):
|
|
82
|
+
save_path = os.path.join(save_dir, "perturb_{}_{}_{}".format(idi, idj, FORMAT.get_filename_by_format(format).split('.')[0]))
|
|
83
|
+
cmd_list = ["", "perturb", "-e", "0.01", "-d", "0.04", "-n", "20", "-i", config_file, "-s", save_path, "-o", format, "-c"]#"-f", config_format,
|
|
84
|
+
if atom_types is not None:
|
|
85
|
+
cmd_list.append("-t")
|
|
86
|
+
cmd_list.extend(atom_types)
|
|
87
|
+
main(cmd_list)
|
|
88
|
+
res_list.append(cmd_list)
|
|
89
|
+
return res_list
|
|
90
|
+
|
|
91
|
+
def test_convert_configs():
|
|
92
|
+
res_list = []
|
|
93
|
+
configs = json.load(open("./config.json"))["convert_configs"]
|
|
94
|
+
save_dir = "./test_workdir"
|
|
95
|
+
for idi, config in enumerate(configs):
|
|
96
|
+
config_file = config["input_file"]
|
|
97
|
+
if isinstance(config_file, str):
|
|
98
|
+
config_file = [config_file]
|
|
99
|
+
|
|
100
|
+
for _ in config_file:
|
|
101
|
+
if not os.path.exists(_):
|
|
102
|
+
print("{} not exists".format(_))
|
|
103
|
+
config_format= config["input_format"]
|
|
104
|
+
if "atom_types" in config.keys():
|
|
105
|
+
atom_types = config["atom_types"]
|
|
106
|
+
else:
|
|
107
|
+
atom_types = None
|
|
108
|
+
|
|
109
|
+
# res = search_images(config_file, config_format)
|
|
110
|
+
# print(res)
|
|
111
|
+
# if config_format == FORMAT.meta:
|
|
112
|
+
# print()
|
|
113
|
+
for idj, format in enumerate([FORMAT.pwmlff_npy, FORMAT.extxyz]):
|
|
114
|
+
save_path = os.path.join(save_dir, "{}_{}_{}_{}".format(idi, idj, config_format.replace('/','_'), FORMAT.get_filename_by_format(format).split('.')[0]))
|
|
115
|
+
cmd_list = ["", "convert_configs"]
|
|
116
|
+
cmd_list.append("-i")
|
|
117
|
+
cmd_list.extend(config_file)
|
|
118
|
+
cmd_list.extend([ "-s", save_path, "-o", format, "-p", "1.0", "-r", "-g", "1", "-m", '1'])#"-f", config_format,
|
|
119
|
+
if atom_types is not None:
|
|
120
|
+
cmd_list.append("-t")
|
|
121
|
+
cmd_list.extend(atom_types)
|
|
122
|
+
main(cmd_list)
|
|
123
|
+
res_list.append(cmd_list)
|
|
124
|
+
return res_list
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_count_configs():
|
|
128
|
+
res_list = []
|
|
129
|
+
configs = json.load(open("./config.json"))["convert_configs"]
|
|
130
|
+
for idi, config in enumerate(configs):
|
|
131
|
+
config_file = config["input_file"]
|
|
132
|
+
if isinstance(config_file, str):
|
|
133
|
+
config_file = [config_file]
|
|
134
|
+
|
|
135
|
+
for _ in config_file:
|
|
136
|
+
if not os.path.exists(_):
|
|
137
|
+
print("{} not exists".format(_))
|
|
138
|
+
if "atom_types" in config.keys():
|
|
139
|
+
atom_types = config["atom_types"]
|
|
140
|
+
else:
|
|
141
|
+
atom_types = None
|
|
142
|
+
for idj, format in enumerate([FORMAT.pwmlff_npy, FORMAT.extxyz]):
|
|
143
|
+
cmd_list = ["", "count"]
|
|
144
|
+
cmd_list.append("-i")
|
|
145
|
+
cmd_list.extend(config_file)
|
|
146
|
+
if atom_types is not None:
|
|
147
|
+
cmd_list.append("-t")
|
|
148
|
+
cmd_list.extend(atom_types)
|
|
149
|
+
main(cmd_list)
|
|
150
|
+
res_list.append(cmd_list)
|
|
151
|
+
return res_list
|
|
152
|
+
|
|
153
|
+
def test_meata_data():
|
|
154
|
+
res_list = []
|
|
155
|
+
# res = search_images(config_file, config_format)
|
|
156
|
+
# print(res)
|
|
157
|
+
atom_types = ["Pt", "Ge"]
|
|
158
|
+
save_dir = "./test_workdir"
|
|
159
|
+
for idj, format in enumerate([FORMAT.extxyz]):
|
|
160
|
+
save_path = os.path.join(save_dir, "test_{}_meta_{}".format(idj, FORMAT.get_filename_by_format(format).split('.')[0]))
|
|
161
|
+
cmd_list = ["", "convert_configs"]
|
|
162
|
+
cmd_list.append("-i")
|
|
163
|
+
cmd_list.append("./meta_data.json")
|
|
164
|
+
cmd_list.extend([ "-s", save_path, "-o", format, "-p", "0.8", "-r"])#, "-c", "10" , "-q", "HfGeH" "-f", "meta",
|
|
165
|
+
if atom_types is not None:
|
|
166
|
+
cmd_list.append("-t")
|
|
167
|
+
cmd_list.extend(atom_types)
|
|
168
|
+
main(cmd_list)
|
|
169
|
+
res_list.append(cmd_list)
|
|
170
|
+
for res in res_list:
|
|
171
|
+
print(" ".join(res))
|
|
172
|
+
|
|
173
|
+
if __name__ == "__main__":
|
|
174
|
+
# run_cmd(["", "-h"])
|
|
175
|
+
# run_cmd(["", "cvt_config", "-h"])
|
|
176
|
+
# run_cmd(["", "scale_cell", "-h"])
|
|
177
|
+
# run_cmd(["", "super_cell", "-h"])
|
|
178
|
+
# run_cmd(["", "perturb", "-h"])
|
|
179
|
+
# run_cmd(["", "cvt_configs", "-h"])
|
|
180
|
+
os.chdir(os.path.join(os.path.dirname(os.path.dirname(__file__)), "examples"))
|
|
181
|
+
cmd_list = []
|
|
182
|
+
# cmd_list.extend(test_scale_cell())
|
|
183
|
+
# cmd_list.extend(test_super_cell())
|
|
184
|
+
# cmd_list.extend(test_pertub())
|
|
185
|
+
# cmd_list.extend(test_convert_config())
|
|
186
|
+
# cmd_list.extend(test_convert_configs())
|
|
187
|
+
cmd_list.extend(test_count_configs())
|
|
188
|
+
|
|
189
|
+
for cmd in cmd_list:
|
|
190
|
+
print(" ".join(cmd))
|
|
191
|
+
|
|
192
|
+
# test_meata_data()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.5
|
|
4
4
|
Summary: pwdata is a data pre-processing tool for PWMLFF, 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
|
|
@@ -21,6 +21,7 @@ pwdata/movement_saver.py
|
|
|
21
21
|
pwdata/outcar.py
|
|
22
22
|
pwdata/poscar.py
|
|
23
23
|
pwdata/pwmlff.py
|
|
24
|
+
pwdata/test.py
|
|
24
25
|
pwdata.egg-info/PKG-INFO
|
|
25
26
|
pwdata.egg-info/SOURCES.txt
|
|
26
27
|
pwdata.egg-info/dependency_links.txt
|
|
@@ -59,5 +60,7 @@ pwdata/pertub/__init__.py
|
|
|
59
60
|
pwdata/pertub/perturbation.py
|
|
60
61
|
pwdata/pertub/scale.py
|
|
61
62
|
pwdata/test/__init__.py
|
|
63
|
+
pwdata/test/mdtrajs2config.py
|
|
64
|
+
pwdata/test/mptraj2lmdb.py
|
|
62
65
|
pwdata/utils/__init__.py
|
|
63
66
|
pwdata/utils/constant.py
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="pwdata",
|
|
8
|
-
version="0.4.
|
|
8
|
+
version="0.4.5",
|
|
9
9
|
author="LonxunQuantum",
|
|
10
10
|
author_email="lonxun@pwmat.com",
|
|
11
11
|
description="pwdata is a data pre-processing tool for PWMLFF, 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
|
|
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
|