pwdata 0.1.5__tar.gz → 0.2.1__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.1.5 → pwdata-0.2.1}/PKG-INFO +1 -1
- pwdata-0.2.1/pwdata/__init__.py +6 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/build/write_struc.py +2 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/main.py +27 -115
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/pertub/perturbation.py +90 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/pertub/scale.py +26 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.1.5 → pwdata-0.2.1}/setup.py +1 -1
- pwdata-0.1.5/pwdata/__init__.py +0 -9
- {pwdata-0.1.5 → pwdata-0.2.1}/LICENSE +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/README.md +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/atomconfig.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/build/__init__.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/build/cell.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/build/geometry.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/build/supercells.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/calculators/const.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/calculators/units.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/configop.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/dump.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/extendedxyz.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/image.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/lmps.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/movement.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/movement_saver.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/outcar.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata/poscar.py +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata.egg-info/SOURCES.txt +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.1.5 → pwdata-0.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
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
|
|
@@ -9,6 +9,7 @@ from pwdata.calculators.const import elements, ELEMENTMASSTABLE
|
|
|
9
9
|
def write_config(atoms,
|
|
10
10
|
filepath,
|
|
11
11
|
data_name="tmp.pwdada",
|
|
12
|
+
direct=True,
|
|
12
13
|
sort=None,
|
|
13
14
|
symbol_count=None,
|
|
14
15
|
long_format=True,
|
|
@@ -20,6 +21,7 @@ def write_config(atoms,
|
|
|
20
21
|
positions scaled coordinates (Direct), and constraints
|
|
21
22
|
to file. fractional coordinates is default.
|
|
22
23
|
"""
|
|
24
|
+
assert direct==True, "PWmat only support direct coordinates"
|
|
23
25
|
atom_nums = len(atoms) if atoms.atom_nums is None else atoms.atom_nums
|
|
24
26
|
if isinstance(atoms, (list, tuple)):
|
|
25
27
|
if atom_nums > 1:
|
|
@@ -6,7 +6,6 @@ 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
|
|
10
9
|
from pwdata.movement import MOVEMENT
|
|
11
10
|
from pwdata.outcar import OUTCAR
|
|
12
11
|
from pwdata.poscar import POSCAR
|
|
@@ -18,9 +17,6 @@ from pwdata.movement_saver import save_to_movement
|
|
|
18
17
|
from pwdata.extendedxyz import save_to_extxyz
|
|
19
18
|
from pwdata.datasets_saver import save_to_dataset, get_pw, save_to_raw, save_to_npy
|
|
20
19
|
from pwdata.build.write_struc import write_config, write_vasp, write_lammps
|
|
21
|
-
from pwdata.build.supercells import make_supercell
|
|
22
|
-
from pwdata.pertub.perturbation import BatchPerturbStructure
|
|
23
|
-
from pwdata.pertub.scale import BatchScaleCell
|
|
24
20
|
|
|
25
21
|
class Save_Data(object):
|
|
26
22
|
def __init__(self, data_path, datasets_path = "./PWdata", train_data_path = "train", valid_data_path = "valid",
|
|
@@ -110,6 +106,21 @@ class Save_Data(object):
|
|
|
110
106
|
|
|
111
107
|
|
|
112
108
|
class Configs(object):
|
|
109
|
+
def __init__(self, format: str, data_path: str, pbc = None, atom_names = None, index = ':', **kwargs):
|
|
110
|
+
self.format = format
|
|
111
|
+
self.data_path = data_path
|
|
112
|
+
self.pbc = pbc
|
|
113
|
+
self.atom_names = atom_names
|
|
114
|
+
self.index = index
|
|
115
|
+
self.kwargs = kwargs
|
|
116
|
+
self.image = self.read()
|
|
117
|
+
|
|
118
|
+
def read(self):
|
|
119
|
+
return Configs.read(self.format, self.data_path, self.pbc, self.atom_names, self.index, **self.kwargs)
|
|
120
|
+
|
|
121
|
+
def to(self, output_path, save_format = None, **kwargs):
|
|
122
|
+
Configs.to(self.image, output_path, save_format, **kwargs)
|
|
123
|
+
|
|
113
124
|
@staticmethod
|
|
114
125
|
def read(format: str, data_path: str, pbc = None, atom_names = None, index = ':', **kwargs):
|
|
115
126
|
""" Read the data from the input file.
|
|
@@ -125,7 +136,6 @@ class Configs(object):
|
|
|
125
136
|
|
|
126
137
|
kwargs: dict
|
|
127
138
|
Additional keyword arguments for reading the input file.
|
|
128
|
-
retain_raw: bool, optional. Whether to retain raw data. Default is False.
|
|
129
139
|
unit: str, optional. for lammps, the unit of the input file. Default is 'metal'.
|
|
130
140
|
style: str, optional. for lammps, the style of the input file. Default is 'atomic'.
|
|
131
141
|
sort_by_id: bool, optional. for lammps, whether to sort the atoms by id. Default is True.
|
|
@@ -163,15 +173,15 @@ class Configs(object):
|
|
|
163
173
|
return image
|
|
164
174
|
|
|
165
175
|
@staticmethod
|
|
166
|
-
def to(image, output_path,
|
|
176
|
+
def to(image, output_path, save_format = None, **kwargs):
|
|
167
177
|
"""
|
|
168
|
-
Write
|
|
178
|
+
Write all images (>= 1) object to a new file.
|
|
169
179
|
|
|
170
180
|
Note: Set sort to False for CP2K, because data from CP2K is already sorted!!!. It will result in a wrong order if sort again.
|
|
171
181
|
|
|
172
182
|
Args:
|
|
173
183
|
output_path (str): Required. The path to save the file.
|
|
174
|
-
|
|
184
|
+
save_format (str): Required. The format of the file. Default is None.
|
|
175
185
|
|
|
176
186
|
Kwargs:
|
|
177
187
|
|
|
@@ -179,7 +189,7 @@ class Configs(object):
|
|
|
179
189
|
|
|
180
190
|
* data_name (str): Save name of the configuration file.
|
|
181
191
|
* sort (bool): Whether to sort the atoms by atomic number. Default is False.
|
|
182
|
-
* wrap (bool):
|
|
192
|
+
* wrap (bool): Whether to wrap the atoms into the simulation box (for pbc). Default is False.
|
|
183
193
|
* direct (bool): The coordinates of the atoms are in fractional coordinates or cartesian coordinates. (0 0 0) -> (1 1 1)
|
|
184
194
|
|
|
185
195
|
|
|
@@ -194,117 +204,24 @@ class Configs(object):
|
|
|
194
204
|
* retain_raw (bool): Whether to retain the raw data. Default is False.
|
|
195
205
|
|
|
196
206
|
"""
|
|
197
|
-
assert
|
|
207
|
+
assert save_format is not None, "output file format is not specified"
|
|
198
208
|
if not os.path.exists(output_path):
|
|
199
209
|
os.makedirs(output_path)
|
|
200
|
-
if
|
|
210
|
+
if save_format.lower() == 'pwmat/config':
|
|
201
211
|
write_config(image, output_path, **kwargs)
|
|
202
|
-
elif
|
|
212
|
+
elif save_format.lower() == 'vasp/poscar':
|
|
203
213
|
write_vasp(image, output_path, **kwargs)
|
|
204
|
-
elif
|
|
214
|
+
elif save_format.lower() == "lammps/lmp":
|
|
205
215
|
write_lammps(image, output_path, **kwargs)
|
|
206
|
-
elif
|
|
216
|
+
elif save_format.lower() == "pwmat/movement":
|
|
207
217
|
save_to_movement(image, output_path, **kwargs)
|
|
208
|
-
elif
|
|
218
|
+
elif save_format.lower() == "extxyz":
|
|
209
219
|
save_to_extxyz(image, output_path, **kwargs)
|
|
210
|
-
elif
|
|
220
|
+
elif save_format.lower() == "pwmlff/npy":
|
|
211
221
|
save_to_dataset(image, datasets_path=output_path, **kwargs)
|
|
212
222
|
else:
|
|
213
223
|
raise RuntimeError('Unknown file format')
|
|
214
224
|
|
|
215
|
-
class SUPERCELL(object):
|
|
216
|
-
def __init__(self, config: Image, output_path = "./", output_file = "supercell",
|
|
217
|
-
supercell_matrix = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],
|
|
218
|
-
direct = True, sort = True, pbc = None, save_format: str = None) -> None:
|
|
219
|
-
"""
|
|
220
|
-
Args:
|
|
221
|
-
config (Image): Image object.
|
|
222
|
-
output_path (str): Path to the output directory.
|
|
223
|
-
output_file (str): Name of the output file.
|
|
224
|
-
supercell_matrix (list): supercell matrix (3x3)
|
|
225
|
-
direct (bool): Whether to write the positions in direct coordinates.
|
|
226
|
-
sort (bool): Whether to sort the atoms by atomic number.
|
|
227
|
-
pbc (list): three bool, Periodic boundary conditions flags. Examples: [True, True, False] or [1, 1, 0]. True (1) means periodic, False (0) means non-periodic.
|
|
228
|
-
save_format (str): Format of the output file.
|
|
229
|
-
"""
|
|
230
|
-
|
|
231
|
-
self.output_path = os.path.abspath(output_path)
|
|
232
|
-
self.output_file = output_file
|
|
233
|
-
self.supercell_matrix = supercell_matrix
|
|
234
|
-
# Make a supercell
|
|
235
|
-
supercell = make_supercell(config, self.supercell_matrix, pbc)
|
|
236
|
-
# Write out the structure
|
|
237
|
-
supercell.to(file_path = self.output_path,
|
|
238
|
-
file_name = self.output_file,
|
|
239
|
-
file_format = save_format,
|
|
240
|
-
direct = direct,
|
|
241
|
-
sort = sort)
|
|
242
|
-
# from build.write_struc import write_config, write_vasp
|
|
243
|
-
# if format.lower() == "config":
|
|
244
|
-
# write_config(self.output_path, self.output_file, supercell, direct=direct, sort=sort)
|
|
245
|
-
# elif format.lower() == "poscar":
|
|
246
|
-
# write_vasp(self.output_path, self.output_file, supercell, direct=direct, sort=sort)
|
|
247
|
-
|
|
248
|
-
class PerturbStructure(object):
|
|
249
|
-
def __init__(self, perturbed_file: Image, pert_num = 50, cell_pert_fraction = 0.03, atom_pert_distance = 0.01,
|
|
250
|
-
output_path = "./", direct = True, sort = None, pbc = None, save_format: str = None) -> None:
|
|
251
|
-
"""
|
|
252
|
-
Perturb the structure.
|
|
253
|
-
|
|
254
|
-
Args:
|
|
255
|
-
perturbed_file (Image): Image object.
|
|
256
|
-
pert_num (int): Number of perturbed structures.
|
|
257
|
-
cell_pert_fraction (float): Fraction of the cell perturbation.
|
|
258
|
-
atom_pert_distance (float): Distance of the atom perturbation.
|
|
259
|
-
output_path (str): Path to the output directory.
|
|
260
|
-
direct (bool): Whether to write the positions in direct coordinates.
|
|
261
|
-
sort (bool): Whether to sort the atoms by atomic number.
|
|
262
|
-
pbc (list): three bool, Periodic boundary conditions flags. Examples: [True, True, False] or [1, 1, 0]. True (1) means periodic, False (0) means non-periodic.
|
|
263
|
-
save_format (str): Format of the output file.
|
|
264
|
-
|
|
265
|
-
Returns:
|
|
266
|
-
None
|
|
267
|
-
"""
|
|
268
|
-
|
|
269
|
-
self.pert_num = pert_num
|
|
270
|
-
self.cell_pert_fraction = cell_pert_fraction
|
|
271
|
-
self.atom_pert_distance = atom_pert_distance
|
|
272
|
-
self.output_path = os.path.abspath(output_path)
|
|
273
|
-
self.perturbed_structs = BatchPerturbStructure.batch_perturb(perturbed_file, self.pert_num, self.cell_pert_fraction, self.atom_pert_distance)
|
|
274
|
-
for tmp_perturbed_idx, tmp_pertubed_struct in enumerate(self.perturbed_structs):
|
|
275
|
-
tmp_pertubed_struct.to(file_path = self.output_path,
|
|
276
|
-
file_name = "{0}_pertubed.{1}".format(tmp_perturbed_idx, save_format.lower()),
|
|
277
|
-
file_format = save_format,
|
|
278
|
-
direct = direct,
|
|
279
|
-
sort = sort)
|
|
280
|
-
|
|
281
|
-
class ScaleCell(object):
|
|
282
|
-
def __init__(self, scaled_file: Image, scale_factor = 1.0, output_path = "./", direct = True, sort = None, pbc = None, save_format: str = None) -> None:
|
|
283
|
-
"""
|
|
284
|
-
Scale the lattice.
|
|
285
|
-
|
|
286
|
-
Args:
|
|
287
|
-
scaled_file (Image): Image object.
|
|
288
|
-
scale_factor (float): Scale factor.
|
|
289
|
-
output_path (str): Path to the output directory.
|
|
290
|
-
direct (bool): Whether to write the positions in direct coordinates.
|
|
291
|
-
sort (bool): Whether to sort the atoms by atomic number.
|
|
292
|
-
pbc (list): three bool, Periodic boundary conditions flags. Examples: [True, True, False] or [1, 1, 0]. True (1) means periodic, False (0) means non-periodic.
|
|
293
|
-
save_format (str): Format of the output file.
|
|
294
|
-
|
|
295
|
-
Returns:
|
|
296
|
-
None
|
|
297
|
-
"""
|
|
298
|
-
|
|
299
|
-
self.scale_factor = scale_factor
|
|
300
|
-
self.output_path = os.path.abspath(output_path)
|
|
301
|
-
self.scaled_struct = BatchScaleCell.batch_scale(scaled_file, self.scale_factor)
|
|
302
|
-
self.scaled_struct.to(file_path = self.output_path,
|
|
303
|
-
file_name = "scaled.{0}".format(save_format.lower()),
|
|
304
|
-
file_format = save_format,
|
|
305
|
-
direct = direct,
|
|
306
|
-
sort = sort)
|
|
307
|
-
|
|
308
225
|
def string2index(string: str) -> Union[int, slice, str]:
|
|
309
226
|
"""Convert index string to either int or slice"""
|
|
310
227
|
if ':' not in string:
|
|
@@ -335,15 +252,11 @@ if __name__ == "__main__":
|
|
|
335
252
|
pbc = [1, 1, 1]
|
|
336
253
|
# config = Configs.read(format, data_file, atom_names=["Si"], index=-1) # read dump
|
|
337
254
|
config = Configs.read(format, data_file)
|
|
338
|
-
|
|
339
|
-
PerturbStructure(config, output_path = "/data/home/hfhuang/Si64", save_format=format)
|
|
340
|
-
# ScaleCell(config, scale_factor = 1.1, output_path = "/data/home/hfhuang/Si64", save_format=format)
|
|
341
|
-
config.to(file_path = output_path,
|
|
255
|
+
Configs.to(file_path = output_path,
|
|
342
256
|
file_name = output_file,
|
|
343
257
|
file_format = 'config',
|
|
344
258
|
direct = True,
|
|
345
259
|
sort = False)
|
|
346
|
-
# OUTCAR2MOVEMENT(data_path, output_path, output_file)
|
|
347
260
|
parser = argparse.ArgumentParser(description='Convert and build structures.')
|
|
348
261
|
parser.add_argument('--format', type=str, required=False, help='Format of the input file', default="outcar")
|
|
349
262
|
parser.add_argument('--save_format', type=str, required=False, help='Format of the output file', default="config")
|
|
@@ -366,7 +279,6 @@ if __name__ == "__main__":
|
|
|
366
279
|
parser.add_argument('--index', type=Union[int, slice, str], required=False, help='Index of the configuration', default=-1)
|
|
367
280
|
parser.add_argument('--atom_names', type=list, required=False, help='Names of the atoms', default=["H"])
|
|
368
281
|
parser.add_argument('--style', type=str, required=False, help='Style of the lammps input file', default="atomic")
|
|
369
|
-
|
|
370
282
|
|
|
371
283
|
args = parser.parse_args()
|
|
372
284
|
|
|
@@ -2,6 +2,96 @@ import numpy as np
|
|
|
2
2
|
from typing import List
|
|
3
3
|
from pwdata.image import Image
|
|
4
4
|
|
|
5
|
+
def perturb_structure(
|
|
6
|
+
image_data:Image,
|
|
7
|
+
pert_num:int,
|
|
8
|
+
cell_pert_fraction:float,
|
|
9
|
+
atom_pert_distance:float):
|
|
10
|
+
"""
|
|
11
|
+
Perturb each frame in the system randomly.
|
|
12
|
+
The cell will be deformed randomly, and atoms will be displaced by a random distance in random direction.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
image_data : Image object, The system to be perturbed.
|
|
17
|
+
pert_num : int Each frame in the system will make `pert_num` copies,
|
|
18
|
+
and all the copies will be perturbed.
|
|
19
|
+
That means the system to be returned will contain `pert_num` * frame_num of the input system.
|
|
20
|
+
cell_pert_fraction : float
|
|
21
|
+
A fraction determines how much (relatively) will cell deform.
|
|
22
|
+
The cell of each frame is deformed by a symmetric matrix perturbed from identity.
|
|
23
|
+
The perturbation to the diagonal part is subject to a uniform distribution in [-cell_pert_fraction, cell_pert_fraction),
|
|
24
|
+
and the perturbation to the off-diagonal part is subject to a uniform distribution in [-0.5*cell_pert_fraction, 0.5*cell_pert_fraction).
|
|
25
|
+
atom_pert_distance: float
|
|
26
|
+
unit: Angstrom. A distance determines how far atoms will move.
|
|
27
|
+
Atoms will move about `atom_pert_distance` in random direction.
|
|
28
|
+
The distribution of the distance atoms move is determined by atom_pert_style
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
perturbed_system : A list of new Image objects. Each Image object contains the information of a perturbed configuration.
|
|
33
|
+
The perturbed structs. It contains `pert_num` * frame_num of the input system frames.
|
|
34
|
+
"""
|
|
35
|
+
perturbed_structs = []
|
|
36
|
+
for _ in range(pert_num):
|
|
37
|
+
tmp_system = image_data.copy()
|
|
38
|
+
cell_perturb_matrix = get_cell_perturb_matrix(cell_pert_fraction)
|
|
39
|
+
tmp_system.lattice = np.matmul(tmp_system.lattice, cell_perturb_matrix)
|
|
40
|
+
tmp_system.position = np.matmul(tmp_system.arrays['position'], cell_perturb_matrix)
|
|
41
|
+
for kk in range(len(tmp_system.position)):
|
|
42
|
+
atom_perturb_vector = get_atom_perturb_vector(atom_pert_distance)
|
|
43
|
+
tmp_system.position[kk] += atom_perturb_vector
|
|
44
|
+
new_system = rot_lower_triangular(tmp_system)
|
|
45
|
+
perturbed_structs.append(new_system)
|
|
46
|
+
return perturbed_structs
|
|
47
|
+
|
|
48
|
+
def get_cell_perturb_matrix(cell_pert_fraction):
|
|
49
|
+
if cell_pert_fraction<0:
|
|
50
|
+
raise RuntimeError('cell_pert_fraction can not be negative')
|
|
51
|
+
e0 = np.random.rand(6)
|
|
52
|
+
e = (e0 * 2 - 1)* cell_pert_fraction
|
|
53
|
+
cell_pert_matrix = np.array(
|
|
54
|
+
[[1+e[0], 0.5 * e[5], 0.5 * e[4]],
|
|
55
|
+
[0.5 * e[5], 1+e[1], 0.5 * e[3]],
|
|
56
|
+
[0.5 * e[4], 0.5 * e[3], 1+e[2]]]
|
|
57
|
+
)
|
|
58
|
+
return cell_pert_matrix
|
|
59
|
+
|
|
60
|
+
def get_atom_perturb_vector(atom_pert_distance):
|
|
61
|
+
random_vector = None
|
|
62
|
+
if atom_pert_distance < 0:
|
|
63
|
+
raise RuntimeError('atom_pert_distance can not be negative')
|
|
64
|
+
|
|
65
|
+
e = np.random.randn(3)
|
|
66
|
+
random_vector = atom_pert_distance * e / np.sqrt(3)
|
|
67
|
+
|
|
68
|
+
return random_vector
|
|
69
|
+
|
|
70
|
+
def rot_lower_triangular(image) :
|
|
71
|
+
qq, rr = np.linalg.qr(image.lattice.T)
|
|
72
|
+
if np.linalg.det(qq) < 0 :
|
|
73
|
+
qq = -qq
|
|
74
|
+
rr = -rr
|
|
75
|
+
image.lattice = np.matmul(image.lattice, qq)
|
|
76
|
+
image.position = np.matmul(image.position, qq)
|
|
77
|
+
rot = np.eye(3)
|
|
78
|
+
if image.lattice[0][0] < 0 :
|
|
79
|
+
rot[0][0] = -1
|
|
80
|
+
if image.lattice[1][1] < 0 :
|
|
81
|
+
rot[1][1] = -1
|
|
82
|
+
if image.lattice[2][2] < 0 :
|
|
83
|
+
rot[2][2] = -1
|
|
84
|
+
assert(np.linalg.det(rot) == 1)
|
|
85
|
+
new_system = Image(
|
|
86
|
+
lattice=np.matmul(image.lattice, rot),
|
|
87
|
+
atom_types_image=image.arrays['atom_types_image'],
|
|
88
|
+
position=np.matmul(image.position, rot),
|
|
89
|
+
cartesian=image.cartesian
|
|
90
|
+
)
|
|
91
|
+
return new_system
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
5
95
|
class PerturbStructure(object):
|
|
6
96
|
def __init__(self, atoms:List[Image]):
|
|
7
97
|
self.atoms = atoms
|
|
@@ -2,6 +2,32 @@ import numpy as np
|
|
|
2
2
|
from typing import List
|
|
3
3
|
from pwdata.image import Image
|
|
4
4
|
|
|
5
|
+
def scale_cell(
|
|
6
|
+
image_data:Image,
|
|
7
|
+
scale_factor:float):
|
|
8
|
+
"""
|
|
9
|
+
Scale the cell of the system.
|
|
10
|
+
|
|
11
|
+
Parameters
|
|
12
|
+
----------
|
|
13
|
+
image_data : Image Object
|
|
14
|
+
The system to be scaled.
|
|
15
|
+
scale_factor : float
|
|
16
|
+
The scale factor of the cell.
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
tmp_system : a new Image object
|
|
21
|
+
The scaled system.
|
|
22
|
+
"""
|
|
23
|
+
tmp_system = image_data.copy()
|
|
24
|
+
if tmp_system.cartesian:
|
|
25
|
+
tmp_system.position = tmp_system.get_scaled_positions(wrap=False) # for cartesian coordinates, we need to convert it to fractional coordinates
|
|
26
|
+
tmp_system.cartesian = False # set cartesian to False, this is important, otherwise, the scaled cell will be scaled again while saving (also in the write_struc.py)
|
|
27
|
+
tmp_system.lattice = np.dot(tmp_system.lattice, scale_factor)
|
|
28
|
+
tmp_system.atom_types_image = tmp_system.arrays['atom_types_image']
|
|
29
|
+
return tmp_system
|
|
30
|
+
|
|
5
31
|
class ScaleCell(object):
|
|
6
32
|
def __init__(self, atoms:List[Image]):
|
|
7
33
|
self.atoms = atoms
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
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.1
|
|
8
|
+
version="0.2.1",
|
|
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.1.5/pwdata/__init__.py
DELETED
|
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
|