pwdata 0.2.1__tar.gz → 0.2.3__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.2.1 → pwdata-0.2.3}/PKG-INFO +1 -1
- pwdata-0.2.3/pwdata/__init__.py +12 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/build/supercells.py +2 -1
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/build/write_struc.py +3 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/configop.py +19 -19
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/extendedxyz.py +8 -8
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/image.py +12 -13
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/main.py +34 -11
- pwdata-0.2.3/pwdata/movement_saver.py +36 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/pertub/perturbation.py +22 -3
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/pertub/scale.py +3 -2
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.2.1 → pwdata-0.2.3}/setup.py +1 -1
- pwdata-0.2.1/pwdata/__init__.py +0 -6
- pwdata-0.2.1/pwdata/movement_saver.py +0 -36
- {pwdata-0.2.1 → pwdata-0.2.3}/LICENSE +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/README.md +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/atomconfig.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/build/__init__.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/build/cell.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/build/geometry.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/calculators/const.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/calculators/units.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/dump.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/lmps.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/movement.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/outcar.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata/poscar.py +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata.egg-info/SOURCES.txt +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.2.1 → pwdata-0.2.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
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
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .main import Save_Data, Config
|
|
2
|
+
from .build.supercells import make_supercell
|
|
3
|
+
from .pertub.perturbation import perturb_structure
|
|
4
|
+
from .pertub.scale import scale_cell
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"Save_Data",
|
|
8
|
+
"Config",
|
|
9
|
+
"make_supercell",
|
|
10
|
+
"perturb_structure",
|
|
11
|
+
"scale_cell"
|
|
12
|
+
]
|
|
@@ -5,7 +5,7 @@ from pwdata.image import Image
|
|
|
5
5
|
class SupercellError(Exception):
|
|
6
6
|
"""Use if construction of supercell fails"""
|
|
7
7
|
|
|
8
|
-
def make_supercell(image_data
|
|
8
|
+
def make_supercell(image_data, supercell_matrix: list, pbc: list = None, wrap=True, tol=1e-5):
|
|
9
9
|
"""Construct supercell from image_data and supercell_matrix
|
|
10
10
|
|
|
11
11
|
Args:
|
|
@@ -13,6 +13,7 @@ def make_supercell(image_data: Image, supercell_matrix: list, pbc: list = None,
|
|
|
13
13
|
supercell_matrix (list): supercell matrix (3x3)
|
|
14
14
|
pbc (list): Periodic boundary conditions flags.
|
|
15
15
|
"""
|
|
16
|
+
image_data = image_data if isinstance(image_data, Image) else image_data.images
|
|
16
17
|
prim = image_data
|
|
17
18
|
supercell_matrix = np.array(supercell_matrix)
|
|
18
19
|
supercell = clean_matrix(supercell_matrix @ prim.lattice)
|
|
@@ -118,6 +118,7 @@ def write_config(atoms,
|
|
|
118
118
|
(symbols[i], coord[i][0], coord[i][1], coord[i][2],
|
|
119
119
|
1, 1, 1))
|
|
120
120
|
output_file.close()
|
|
121
|
+
print("Convert to %s successfully!" % data_name)
|
|
121
122
|
|
|
122
123
|
def write_vasp(atoms,
|
|
123
124
|
filepath,
|
|
@@ -246,6 +247,7 @@ def write_vasp(atoms,
|
|
|
246
247
|
# output_file.write(' %s %s %s' % tuple(sflags[i]))
|
|
247
248
|
output_file.write('\n')
|
|
248
249
|
output_file.close()
|
|
250
|
+
print("Convert to %s successfully!" % data_name)
|
|
249
251
|
|
|
250
252
|
def write_lammps(atoms,
|
|
251
253
|
filepath,
|
|
@@ -402,4 +404,5 @@ def write_lammps(atoms,
|
|
|
402
404
|
for i in range(atom_nums):
|
|
403
405
|
output_file.write("%-12d %-12d %16.12f %16.12f %16.12f\n" % (i+1, atype[i], LX[i,0], LX[i,1], LX[i,2]))
|
|
404
406
|
output_file.close()
|
|
407
|
+
print("Convert to %s successfully!" % data_name)
|
|
405
408
|
|
|
@@ -5,7 +5,7 @@ from pwdata.atomconfig import CONFIG
|
|
|
5
5
|
from pwdata.build.supercells import make_supercell
|
|
6
6
|
from pwdata.pertub.perturbation import BatchPerturbStructure
|
|
7
7
|
from pwdata.pertub.scale import BatchScaleCell
|
|
8
|
-
from pwdata
|
|
8
|
+
from pwdata import Config
|
|
9
9
|
from pwdata.lammpsdata import LMP
|
|
10
10
|
from pwdata.dump import DUMP
|
|
11
11
|
|
|
@@ -27,9 +27,9 @@ def save_config(config, input_format:str = None, wrap = False, direct = True, so
|
|
|
27
27
|
if isinstance(config, str):
|
|
28
28
|
config = extract_config(config_path=config, format=input_format, atom_names=atom_names)
|
|
29
29
|
|
|
30
|
-
config.to(
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
config.to(output_path=save_path,
|
|
31
|
+
data_name =save_name,
|
|
32
|
+
save_format=save_format,
|
|
33
33
|
direct =direct,
|
|
34
34
|
sort =sort,
|
|
35
35
|
wrap =wrap
|
|
@@ -43,9 +43,9 @@ def do_super_cell(config, input_format:str=None, supercell_matrix:list[int]=None
|
|
|
43
43
|
# Make a supercell
|
|
44
44
|
supercell = make_supercell(config, supercell_matrix, pbc)
|
|
45
45
|
# Write out the structure
|
|
46
|
-
supercell.to(
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
supercell.to(output_path = save_path,
|
|
47
|
+
data_name = save_name,
|
|
48
|
+
save_format = save_format,
|
|
49
49
|
direct = direct,
|
|
50
50
|
sort = sort)
|
|
51
51
|
return os.path.join(save_path, save_name)
|
|
@@ -55,9 +55,9 @@ def do_scale(config, input_format:str=None, scale_factor:float=None,
|
|
|
55
55
|
if isinstance(config, str):
|
|
56
56
|
config = extract_config(config_path=config, format=input_format)
|
|
57
57
|
scaled_struct = BatchScaleCell.batch_scale(config, scale_factor)
|
|
58
|
-
scaled_struct.to(
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
scaled_struct.to(output_path = save_path,
|
|
59
|
+
data_name = save_name,
|
|
60
|
+
save_format = save_format,
|
|
61
61
|
direct = direct,
|
|
62
62
|
sort = sort)
|
|
63
63
|
return os.path.join(save_path, save_name)
|
|
@@ -71,9 +71,9 @@ def do_pertub(config, input_format:str=None, pert_num:int=None, cell_pert_fracti
|
|
|
71
71
|
os.makedirs(save_path)
|
|
72
72
|
perturbed_structs = BatchPerturbStructure.batch_perturb(config, pert_num, cell_pert_fraction, atom_pert_distance)
|
|
73
73
|
for tmp_perturbed_idx, tmp_pertubed_struct in enumerate(perturbed_structs):
|
|
74
|
-
tmp_pertubed_struct.to(
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
tmp_pertubed_struct.to(output_path = save_path,
|
|
75
|
+
data_name = "{}_{}".format(tmp_perturbed_idx, save_name),
|
|
76
|
+
save_format = save_format,
|
|
77
77
|
direct = direct,
|
|
78
78
|
sort = sort)
|
|
79
79
|
print("pertub {} done!".format(os.path.join(save_path, "{}_{}".format(tmp_perturbed_idx, save_name))))
|
|
@@ -103,10 +103,10 @@ def extract_pwdata(data_list:list[str],
|
|
|
103
103
|
datasets_path = os.path.dirname(datasets_path)
|
|
104
104
|
multi_data = []
|
|
105
105
|
for data_path in data_list:
|
|
106
|
-
image_data =
|
|
106
|
+
image_data = Config.read(data_format, data_path)
|
|
107
107
|
multi_data += image_data
|
|
108
|
-
get_all =
|
|
109
|
-
|
|
108
|
+
get_all = Config.get(multi_data)
|
|
109
|
+
Config.save(image_data_dict=get_all,
|
|
110
110
|
datasets_path=datasets_path,
|
|
111
111
|
train_data_path="train",
|
|
112
112
|
valid_data_path="valid",
|
|
@@ -118,9 +118,9 @@ def extract_pwdata(data_list:list[str],
|
|
|
118
118
|
)
|
|
119
119
|
else:
|
|
120
120
|
for data_path in data_list:
|
|
121
|
-
image_data =
|
|
122
|
-
get_all =
|
|
123
|
-
|
|
121
|
+
image_data = Config.read(data_format, data_path)
|
|
122
|
+
get_all = Config.get(image_data)
|
|
123
|
+
Config.save(image_data_dict=get_all,
|
|
124
124
|
datasets_path=datasets_path,
|
|
125
125
|
train_data_path="train",
|
|
126
126
|
valid_data_path="valid",
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import os
|
|
2
2
|
from pwdata.calculators.const import elements
|
|
3
3
|
|
|
4
|
-
def save_to_extxyz(image_data_all: list, output_path: str,
|
|
5
|
-
|
|
4
|
+
def save_to_extxyz(image_data_all: list, output_path: str, data_name: str, write_patthen='w'):
|
|
5
|
+
data_name = open(os.path.join(output_path, data_name), write_patthen)
|
|
6
6
|
for i in range(len(image_data_all)):
|
|
7
7
|
image_data = image_data_all[i]
|
|
8
8
|
if not image_data.cartesian:
|
|
9
9
|
image_data._set_cartesian()
|
|
10
|
-
|
|
11
|
-
#
|
|
10
|
+
data_name.write("%d\n" % image_data.atom_nums)
|
|
11
|
+
# data_name.write("Iteration: %s\n" % image_data.iteration)
|
|
12
12
|
output_head = 'Lattice="%.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f" Properties=species:S:1:pos:R:3:force:R:3:local_energy:R:1 pbc="T T T" energy={}\n'.format(image_data.Ep)
|
|
13
13
|
output_extended = (image_data.lattice[0][0], image_data.lattice[0][1], image_data.lattice[0][2],
|
|
14
14
|
image_data.lattice[1][0], image_data.lattice[1][1], image_data.lattice[1][2],
|
|
15
15
|
image_data.lattice[2][0], image_data.lattice[2][1], image_data.lattice[2][2])
|
|
16
|
-
|
|
16
|
+
data_name.write(output_head % output_extended)
|
|
17
17
|
for j in range(image_data.atom_nums):
|
|
18
18
|
properties_format = "%s %14.8f %14.8f %14.8f %14.8f %14.8f %14.8f %14.8f\n"
|
|
19
19
|
properties = (elements[image_data.atom_types_image[j]], image_data.position[j][0], image_data.position[j][1], image_data.position[j][2],
|
|
20
20
|
image_data.force[j][0], image_data.force[j][1], image_data.force[j][2],
|
|
21
21
|
image_data.atomic_energy[j])
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
print("Convert to %s successfully!" %
|
|
22
|
+
data_name.write(properties_format % properties)
|
|
23
|
+
data_name.close()
|
|
24
|
+
print("Convert to %s successfully!" % data_name)
|
|
@@ -68,9 +68,7 @@ class Image(object):
|
|
|
68
68
|
atoms.arrays[name] = a.copy()
|
|
69
69
|
return atoms
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
No use, Replace by the `Configs.to()` function
|
|
73
|
-
def to(self, output_path, file_name = None, file_format = None, direct = True, sort = False, wrap = False):
|
|
71
|
+
def to(self, output_path, data_name = None, save_format = None, direct = True, sort = False, wrap = False):
|
|
74
72
|
"""
|
|
75
73
|
Write atoms object to a new file.
|
|
76
74
|
|
|
@@ -78,24 +76,25 @@ class Image(object):
|
|
|
78
76
|
|
|
79
77
|
Args:
|
|
80
78
|
output_path (str): The path to save the file.
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
data_name (str): Save name of the configuration file.
|
|
80
|
+
save_format (str): The format of the file. Default is None.
|
|
83
81
|
direct (bool): The coordinates of the atoms are in fractional coordinates or cartesian coordinates. (0 0 0) -> (1 1 1)
|
|
84
82
|
sort (bool): Whether to sort the atoms by atomic number. Default is False.
|
|
85
83
|
wrap (bool): hether to wrap the atoms into the simulation box (for pbc). Default is False.
|
|
86
84
|
"""
|
|
87
|
-
assert
|
|
85
|
+
assert save_format is not None, "output file format is not specified"
|
|
88
86
|
if not os.path.exists(output_path):
|
|
89
87
|
os.makedirs(output_path)
|
|
90
|
-
if
|
|
91
|
-
write_config(
|
|
92
|
-
elif
|
|
93
|
-
write_vasp(
|
|
94
|
-
elif
|
|
95
|
-
write_lammps(
|
|
88
|
+
if save_format.lower() == 'pwmat/config':
|
|
89
|
+
write_config(self, output_path, data_name, sort=sort, wrap=wrap)
|
|
90
|
+
elif save_format.lower() == 'vasp/poscar':
|
|
91
|
+
write_vasp(self, output_path, data_name, direct=direct, sort=sort, wrap=wrap)
|
|
92
|
+
elif save_format.lower() == "lammps/lmp":
|
|
93
|
+
write_lammps(self, output_path, data_name, sort=sort, wrap=wrap)
|
|
94
|
+
elif save_format.lower() == "extxyz":
|
|
95
|
+
raise Exception()
|
|
96
96
|
else:
|
|
97
97
|
raise RuntimeError('Unknown file format')
|
|
98
|
-
'''
|
|
99
98
|
|
|
100
99
|
def prim_dict(self):
|
|
101
100
|
"""Return a dictionary of the primitive image data."""
|
|
@@ -6,6 +6,7 @@ from typing import (List, Union, Optional)
|
|
|
6
6
|
# import time
|
|
7
7
|
# os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
|
8
8
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
9
|
+
from pwdata.image import Image
|
|
9
10
|
from pwdata.movement import MOVEMENT
|
|
10
11
|
from pwdata.outcar import OUTCAR
|
|
11
12
|
from pwdata.poscar import POSCAR
|
|
@@ -105,7 +106,7 @@ class Save_Data(object):
|
|
|
105
106
|
save_to_npy(val_data, val_path)
|
|
106
107
|
|
|
107
108
|
|
|
108
|
-
class
|
|
109
|
+
class Config(object):
|
|
109
110
|
def __init__(self, format: str, data_path: str, pbc = None, atom_names = None, index = ':', **kwargs):
|
|
110
111
|
self.format = format
|
|
111
112
|
self.data_path = data_path
|
|
@@ -113,13 +114,15 @@ class Configs(object):
|
|
|
113
114
|
self.atom_names = atom_names
|
|
114
115
|
self.index = index
|
|
115
116
|
self.kwargs = kwargs
|
|
116
|
-
self.
|
|
117
|
+
self.images = self._read()
|
|
117
118
|
|
|
118
|
-
def
|
|
119
|
-
return
|
|
119
|
+
def _read(self):
|
|
120
|
+
return Config.read(self.format, self.data_path, self.pbc, self.atom_names, self.index, **self.kwargs)
|
|
120
121
|
|
|
121
|
-
def
|
|
122
|
-
|
|
122
|
+
def append(self, images_obj):
|
|
123
|
+
if not hasattr(self, 'images'):
|
|
124
|
+
self.images = []
|
|
125
|
+
self.images += images_obj.images
|
|
123
126
|
|
|
124
127
|
@staticmethod
|
|
125
128
|
def read(format: str, data_path: str, pbc = None, atom_names = None, index = ':', **kwargs):
|
|
@@ -172,8 +175,7 @@ class Configs(object):
|
|
|
172
175
|
raise Exception("Error! The format of the input file is not supported!")
|
|
173
176
|
return image
|
|
174
177
|
|
|
175
|
-
|
|
176
|
-
def to(image, output_path, save_format = None, **kwargs):
|
|
178
|
+
def to(self, output_path, save_format = None, **kwargs):
|
|
177
179
|
"""
|
|
178
180
|
Write all images (>= 1) object to a new file.
|
|
179
181
|
|
|
@@ -207,6 +209,27 @@ class Configs(object):
|
|
|
207
209
|
assert save_format is not None, "output file format is not specified"
|
|
208
210
|
if not os.path.exists(output_path):
|
|
209
211
|
os.makedirs(output_path)
|
|
212
|
+
|
|
213
|
+
images = self if isinstance(self, Image) else self.images
|
|
214
|
+
|
|
215
|
+
if isinstance(images, list):
|
|
216
|
+
self.multi_to(images, output_path, save_format, **kwargs)
|
|
217
|
+
else:
|
|
218
|
+
self.write_image(images, output_path, save_format, **kwargs)
|
|
219
|
+
|
|
220
|
+
def multi_to(self, images, output_path, save_format, **kwargs):
|
|
221
|
+
"""
|
|
222
|
+
Write multiple images to new files.
|
|
223
|
+
"""
|
|
224
|
+
if save_format.lower() in ['pwmat/config', 'vasp/poscar', 'lammps/lmp']:
|
|
225
|
+
data_name = kwargs['data_name']
|
|
226
|
+
for i, image in enumerate(images):
|
|
227
|
+
kwargs['data_name'] = data_name + "_{0}".format(i)
|
|
228
|
+
self.write_image(image, output_path, save_format, **kwargs)
|
|
229
|
+
else:
|
|
230
|
+
self.write_image(images, output_path, save_format, **kwargs)
|
|
231
|
+
|
|
232
|
+
def write_image(self, image, output_path, save_format, **kwargs):
|
|
210
233
|
if save_format.lower() == 'pwmat/config':
|
|
211
234
|
write_config(image, output_path, **kwargs)
|
|
212
235
|
elif save_format.lower() == 'vasp/poscar':
|
|
@@ -250,9 +273,9 @@ if __name__ == "__main__":
|
|
|
250
273
|
output_file = "supercell.config"
|
|
251
274
|
format = "config"
|
|
252
275
|
pbc = [1, 1, 1]
|
|
253
|
-
# config =
|
|
254
|
-
config =
|
|
255
|
-
|
|
276
|
+
# config = Config.read(format, data_file, atom_names=["Si"], index=-1) # read dump
|
|
277
|
+
config = Config.read(format, data_file)
|
|
278
|
+
Config.to(file_path = output_path,
|
|
256
279
|
file_name = output_file,
|
|
257
280
|
file_format = 'config',
|
|
258
281
|
direct = True,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import numpy.linalg as LA
|
|
4
|
+
|
|
5
|
+
def save_to_movement(image_data_all: list, output_path: str, data_name: str):
|
|
6
|
+
data_name = open(os.path.join(output_path, data_name), 'w')
|
|
7
|
+
for i in range(len(image_data_all)):
|
|
8
|
+
image_data = image_data_all[i]
|
|
9
|
+
if image_data.cartesian:
|
|
10
|
+
image_data._set_fractional()
|
|
11
|
+
# with open(os.path.join(output_path, data_name), 'a') as wf:
|
|
12
|
+
data_name.write(" %d atoms,Iteration (fs) = %16.10E, Etot,Ep,Ek (eV) = %16.10E %16.10E %16.10E, SCF = %d\n"\
|
|
13
|
+
% (image_data.atom_nums, 0.0, image_data.Ep, image_data.Ep, 0.0, image_data.scf))
|
|
14
|
+
data_name.write(" MD_INFO: METHOD(1-VV,2-NH,3-LV,4-LVPR,5-NHRP) TIME(fs) TEMP(K) DESIRED_TEMP(K) AVE_TEMP(K) TIME_INTERVAL(fs) TOT_TEMP(K) \n")
|
|
15
|
+
data_name.write(" * ************ ******** ******** ******** ******** ********\n")
|
|
16
|
+
data_name.write(" TOTAL MOMENTUM\n")
|
|
17
|
+
data_name.write(" ******** ******** ********\n")
|
|
18
|
+
data_name.write(" MD_VV_INFO: Basic Velocity Verlet Dynamics (NVE), Initialized total energy(Hartree)\n")
|
|
19
|
+
data_name.write(" ******* \n")
|
|
20
|
+
data_name.write("Lattice vector (Angstrom)\n")
|
|
21
|
+
for j in range(3):
|
|
22
|
+
if image_data.stress != []:
|
|
23
|
+
data_name.write(" %16.10E %16.10E %16.10E stress (eV): %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2], image_data.virials[j][0], image_data.virials[j][1], image_data.virials[j][2]))
|
|
24
|
+
else:
|
|
25
|
+
data_name.write(" %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2]))
|
|
26
|
+
data_name.write(" Position (normalized), move_x, move_y, move_z\n")
|
|
27
|
+
for j in range(image_data.atom_nums):
|
|
28
|
+
data_name.write(" %4d %20.15F %20.15F %20.15F 1 1 1\n"\
|
|
29
|
+
% (image_data.atom_types_image[j], image_data.position[j][0], image_data.position[j][1], image_data.position[j][2]))
|
|
30
|
+
data_name.write(" Force (-force, eV/Angstrom)\n")
|
|
31
|
+
for j in range(image_data.atom_nums):
|
|
32
|
+
data_name.write(" %4d %20.15F %20.15F %20.15F\n"\
|
|
33
|
+
% (image_data.atom_types_image[j], -image_data.force[j][0], -image_data.force[j][1], -image_data.force[j][2]))
|
|
34
|
+
data_name.write(" -------------------------------------\n")
|
|
35
|
+
data_name.close()
|
|
36
|
+
print("Convert to %s successfully!" % data_name)
|
|
@@ -2,8 +2,25 @@ import numpy as np
|
|
|
2
2
|
from typing import List
|
|
3
3
|
from pwdata.image import Image
|
|
4
4
|
|
|
5
|
+
class PerturbedStructures:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.structures = []
|
|
8
|
+
|
|
9
|
+
def append(self, structure):
|
|
10
|
+
self.structures.append(structure)
|
|
11
|
+
|
|
12
|
+
def __getitem__(self, index):
|
|
13
|
+
return self.structures[index]
|
|
14
|
+
|
|
15
|
+
def __len__(self):
|
|
16
|
+
return len(self.structures)
|
|
17
|
+
|
|
18
|
+
def to(self, output_path, data_name = None, save_format = None, direct = True, sort = False, wrap = False):
|
|
19
|
+
for i, structure in enumerate(self.structures):
|
|
20
|
+
structure.to(output_path, data_name=data_name+"_{0}".format(i), save_format=save_format, direct=direct, sort=sort, wrap=wrap)
|
|
21
|
+
|
|
5
22
|
def perturb_structure(
|
|
6
|
-
image_data
|
|
23
|
+
image_data,
|
|
7
24
|
pert_num:int,
|
|
8
25
|
cell_pert_fraction:float,
|
|
9
26
|
atom_pert_distance:float):
|
|
@@ -13,7 +30,7 @@ def perturb_structure(
|
|
|
13
30
|
|
|
14
31
|
Parameters
|
|
15
32
|
----------
|
|
16
|
-
image_data : Image object, The system to be perturbed.
|
|
33
|
+
image_data : Include Image object, The system to be perturbed.
|
|
17
34
|
pert_num : int Each frame in the system will make `pert_num` copies,
|
|
18
35
|
and all the copies will be perturbed.
|
|
19
36
|
That means the system to be returned will contain `pert_num` * frame_num of the input system.
|
|
@@ -32,7 +49,9 @@ def perturb_structure(
|
|
|
32
49
|
perturbed_system : A list of new Image objects. Each Image object contains the information of a perturbed configuration.
|
|
33
50
|
The perturbed structs. It contains `pert_num` * frame_num of the input system frames.
|
|
34
51
|
"""
|
|
35
|
-
|
|
52
|
+
image_data = image_data if isinstance(image_data, Image) else image_data.images
|
|
53
|
+
# perturbed_structs = []
|
|
54
|
+
perturbed_structs = PerturbedStructures()
|
|
36
55
|
for _ in range(pert_num):
|
|
37
56
|
tmp_system = image_data.copy()
|
|
38
57
|
cell_perturb_matrix = get_cell_perturb_matrix(cell_pert_fraction)
|
|
@@ -3,14 +3,14 @@ from typing import List
|
|
|
3
3
|
from pwdata.image import Image
|
|
4
4
|
|
|
5
5
|
def scale_cell(
|
|
6
|
-
image_data
|
|
6
|
+
image_data,
|
|
7
7
|
scale_factor:float):
|
|
8
8
|
"""
|
|
9
9
|
Scale the cell of the system.
|
|
10
10
|
|
|
11
11
|
Parameters
|
|
12
12
|
----------
|
|
13
|
-
image_data : Image Object
|
|
13
|
+
image_data : Include Image Object
|
|
14
14
|
The system to be scaled.
|
|
15
15
|
scale_factor : float
|
|
16
16
|
The scale factor of the cell.
|
|
@@ -20,6 +20,7 @@ def scale_cell(
|
|
|
20
20
|
tmp_system : a new Image object
|
|
21
21
|
The scaled system.
|
|
22
22
|
"""
|
|
23
|
+
image_data = image_data if isinstance(image_data, Image) else image_data.images
|
|
23
24
|
tmp_system = image_data.copy()
|
|
24
25
|
if tmp_system.cartesian:
|
|
25
26
|
tmp_system.position = tmp_system.get_scaled_positions(wrap=False) # for cartesian coordinates, we need to convert it to fractional coordinates
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
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
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="pwdata",
|
|
8
|
-
version="0.2.
|
|
8
|
+
version="0.2.3",
|
|
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.",
|
pwdata-0.2.1/pwdata/__init__.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import numpy as np
|
|
3
|
-
import numpy.linalg as LA
|
|
4
|
-
|
|
5
|
-
def save_to_movement(image_data_all: list, output_path: str, output_file: str):
|
|
6
|
-
output_file = open(os.path.join(output_path, output_file), 'w')
|
|
7
|
-
for i in range(len(image_data_all)):
|
|
8
|
-
image_data = image_data_all[i]
|
|
9
|
-
if image_data.cartesian:
|
|
10
|
-
image_data._set_fractional()
|
|
11
|
-
# with open(os.path.join(output_path, output_file), 'a') as wf:
|
|
12
|
-
output_file.write(" %d atoms,Iteration (fs) = %16.10E, Etot,Ep,Ek (eV) = %16.10E %16.10E %16.10E, SCF = %d\n"\
|
|
13
|
-
% (image_data.atom_nums, 0.0, image_data.Ep, image_data.Ep, 0.0, image_data.scf))
|
|
14
|
-
output_file.write(" MD_INFO: METHOD(1-VV,2-NH,3-LV,4-LVPR,5-NHRP) TIME(fs) TEMP(K) DESIRED_TEMP(K) AVE_TEMP(K) TIME_INTERVAL(fs) TOT_TEMP(K) \n")
|
|
15
|
-
output_file.write(" * ************ ******** ******** ******** ******** ********\n")
|
|
16
|
-
output_file.write(" TOTAL MOMENTUM\n")
|
|
17
|
-
output_file.write(" ******** ******** ********\n")
|
|
18
|
-
output_file.write(" MD_VV_INFO: Basic Velocity Verlet Dynamics (NVE), Initialized total energy(Hartree)\n")
|
|
19
|
-
output_file.write(" ******* \n")
|
|
20
|
-
output_file.write("Lattice vector (Angstrom)\n")
|
|
21
|
-
for j in range(3):
|
|
22
|
-
if image_data.stress != []:
|
|
23
|
-
output_file.write(" %16.10E %16.10E %16.10E stress (eV): %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2], image_data.virials[j][0], image_data.virials[j][1], image_data.virials[j][2]))
|
|
24
|
-
else:
|
|
25
|
-
output_file.write(" %16.10E %16.10E %16.10E\n" % (image_data.lattice[j][0], image_data.lattice[j][1], image_data.lattice[j][2]))
|
|
26
|
-
output_file.write(" Position (normalized), move_x, move_y, move_z\n")
|
|
27
|
-
for j in range(image_data.atom_nums):
|
|
28
|
-
output_file.write(" %4d %20.15F %20.15F %20.15F 1 1 1\n"\
|
|
29
|
-
% (image_data.atom_types_image[j], image_data.position[j][0], image_data.position[j][1], image_data.position[j][2]))
|
|
30
|
-
output_file.write(" Force (-force, eV/Angstrom)\n")
|
|
31
|
-
for j in range(image_data.atom_nums):
|
|
32
|
-
output_file.write(" %4d %20.15F %20.15F %20.15F\n"\
|
|
33
|
-
% (image_data.atom_types_image[j], -image_data.force[j][0], -image_data.force[j][1], -image_data.force[j][2]))
|
|
34
|
-
output_file.write(" -------------------------------------\n")
|
|
35
|
-
output_file.close()
|
|
36
|
-
print("Convert to %s successfully!" % output_file)
|
|
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
|