pwdata 0.2.8__tar.gz → 0.2.10__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.8 → pwdata-0.2.10}/PKG-INFO +1 -1
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/build/write_struc.py +22 -24
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/image.py +10 -2
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/main.py +5 -1
- pwdata-0.2.10/pwdata/pwmlff.py +59 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata.egg-info/PKG-INFO +1 -1
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata.egg-info/SOURCES.txt +1 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/setup.py +1 -1
- {pwdata-0.2.8 → pwdata-0.2.10}/LICENSE +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/README.md +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/__init__.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/atomconfig.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/build/__init__.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/build/cell.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/build/geometry.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/build/supercells.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/calculators/__init__.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/calculators/const.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/calculators/unitconvert_lmps.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/calculators/units.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/cp2kdata.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/datasets_saver.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/deepmd.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/dump.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/extendedxyz.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/lammpsdata.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/lmps.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/movement.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/movement_saver.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/outcar.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/pertub/__init__.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/pertub/perturbation.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/pertub/scale.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata/poscar.py +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata.egg-info/dependency_links.txt +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/pwdata.egg-info/top_level.txt +0 -0
- {pwdata-0.2.8 → pwdata-0.2.10}/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.10
|
|
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
|
|
@@ -2,7 +2,6 @@ import numpy as np
|
|
|
2
2
|
import os
|
|
3
3
|
from collections import Counter
|
|
4
4
|
from pwdata.build.cell import cell_to_cellpar
|
|
5
|
-
from pwdata.lmps import Box2l
|
|
6
5
|
from pwdata.calculators.const import elements, ELEMENTMASSTABLE
|
|
7
6
|
|
|
8
7
|
|
|
@@ -163,7 +162,7 @@ def write_vasp(image,
|
|
|
163
162
|
raise RuntimeError(
|
|
164
163
|
'Lattice vectors must be finite and not coincident. '
|
|
165
164
|
'At least one lattice length or angle is zero.')
|
|
166
|
-
|
|
165
|
+
|
|
167
166
|
# Write atom positions in scaled or cartesian coordinates
|
|
168
167
|
if direct and image.cartesian: # cartesian -> direct
|
|
169
168
|
coord = image.get_scaled_positions(wrap=wrap)
|
|
@@ -292,12 +291,13 @@ def write_lammps(image,
|
|
|
292
291
|
'At least one lattice length or angle is zero.')
|
|
293
292
|
|
|
294
293
|
# Write atom positions in cartesian coordinates
|
|
295
|
-
if
|
|
294
|
+
if image.cartesian: # cartesian -> direct
|
|
296
295
|
coord = image.get_scaled_positions(wrap=wrap)
|
|
297
|
-
|
|
296
|
+
image._set_orthorhombic()
|
|
297
|
+
else: # direct -> cartesian
|
|
298
|
+
image._set_orthorhombic()
|
|
298
299
|
coord = image._set_cartesian().position
|
|
299
|
-
|
|
300
|
-
coord = image.position
|
|
300
|
+
|
|
301
301
|
|
|
302
302
|
if sort:
|
|
303
303
|
if len(image.get_atomic_numbers()) == 0:
|
|
@@ -324,8 +324,6 @@ def write_lammps(image,
|
|
|
324
324
|
atom_type = image.atom_type
|
|
325
325
|
atom_type_num = image.atom_type_num
|
|
326
326
|
|
|
327
|
-
lmps_box = Box2l(image.lattice)
|
|
328
|
-
|
|
329
327
|
p = 1
|
|
330
328
|
atype = []
|
|
331
329
|
# atom num & type list
|
|
@@ -344,24 +342,24 @@ def write_lammps(image,
|
|
|
344
342
|
# output preparation
|
|
345
343
|
# return [xx,xy,yy,xz,yz,zz]
|
|
346
344
|
xlo = 0.0
|
|
347
|
-
xhi =
|
|
345
|
+
xhi = image.lattice[0][0]
|
|
348
346
|
ylo = 0.0
|
|
349
|
-
yhi =
|
|
347
|
+
yhi = image.lattice[1][1]
|
|
350
348
|
zlo = 0.0
|
|
351
|
-
zhi =
|
|
352
|
-
xy =
|
|
353
|
-
xz =
|
|
354
|
-
yz =
|
|
349
|
+
zhi = image.lattice[2][2]
|
|
350
|
+
xy = image.lattice[1][0]
|
|
351
|
+
xz = image.lattice[2][0]
|
|
352
|
+
yz = image.lattice[2][1]
|
|
355
353
|
|
|
356
354
|
LX = np.zeros([atom_nums,3],dtype=float)
|
|
357
355
|
A = np.zeros([3,3],dtype=float)
|
|
358
356
|
|
|
359
|
-
A[0,0] =
|
|
360
|
-
A[0
|
|
361
|
-
A[1,1] =
|
|
362
|
-
A[0
|
|
363
|
-
A[1
|
|
364
|
-
A[2,2] =
|
|
357
|
+
A[0,0] = image.lattice[0][0]
|
|
358
|
+
A[1,0] = image.lattice[1][0]
|
|
359
|
+
A[1,1] = image.lattice[1][1]
|
|
360
|
+
A[2,0] = image.lattice[2][0]
|
|
361
|
+
A[2,1] = image.lattice[2][1]
|
|
362
|
+
A[2,2] = image.lattice[2][2]
|
|
365
363
|
|
|
366
364
|
print("converted LAMMPS upper trangualr box:")
|
|
367
365
|
|
|
@@ -372,11 +370,11 @@ def write_lammps(image,
|
|
|
372
370
|
# A.T x = LX
|
|
373
371
|
# LX = A*x in LAMMPS. see https://docs.lammps.org/Howto_triclinic.html
|
|
374
372
|
|
|
375
|
-
if
|
|
373
|
+
if not image.cartesian:
|
|
376
374
|
for i in range(atom_nums):
|
|
377
|
-
LX[i,0] = A[0,0]*x[i,0] + A[0
|
|
378
|
-
LX[i,1] = A[1
|
|
379
|
-
LX[i,2] = A[2
|
|
375
|
+
LX[i,0] = A[0,0]*x[i,0] + A[1,0]*x[i,1] + A[2,0]*x[i,2]
|
|
376
|
+
LX[i,1] = A[0,1]*x[i,0] + A[1,1]*x[i,1] + A[2,1]*x[i,2]
|
|
377
|
+
LX[i,2] = A[0,2]*x[i,0] + A[1,2]*x[i,1] + A[2,2]*x[i,2]
|
|
380
378
|
else:
|
|
381
379
|
for i in range(atom_nums):
|
|
382
380
|
LX[i,0] = x[i,0]
|
|
@@ -5,6 +5,7 @@ from pwdata.build.write_struc import write_config, write_vasp, write_lammps
|
|
|
5
5
|
from pwdata.calculators.const import elements
|
|
6
6
|
from pwdata.build.geometry import wrap_positions
|
|
7
7
|
from pwdata.build.cell import scaled_positions
|
|
8
|
+
from pwdata.lmps import Box2l
|
|
8
9
|
# 1. initial the image class
|
|
9
10
|
class Image(object):
|
|
10
11
|
def __init__(self,
|
|
@@ -176,7 +177,6 @@ class Image(object):
|
|
|
176
177
|
plane."""
|
|
177
178
|
|
|
178
179
|
fractional = scaled_positions(self.lattice, self.position)
|
|
179
|
-
|
|
180
180
|
if wrap:
|
|
181
181
|
for i, periodic in enumerate(self.pbc):
|
|
182
182
|
if periodic:
|
|
@@ -184,7 +184,7 @@ class Image(object):
|
|
|
184
184
|
# See the scaled_positions.py test.
|
|
185
185
|
fractional[:, i] %= 1.0
|
|
186
186
|
fractional[:, i] %= 1.0
|
|
187
|
-
|
|
187
|
+
self.cartesian = False
|
|
188
188
|
return fractional
|
|
189
189
|
|
|
190
190
|
def get_atomic_numbers(self):
|
|
@@ -195,6 +195,14 @@ class Image(object):
|
|
|
195
195
|
"""Return reference to positions-array for in-place manipulations."""
|
|
196
196
|
return self.arrays['position']
|
|
197
197
|
|
|
198
|
+
def _set_orthorhombic(self):
|
|
199
|
+
"""Set the cell to be orthorhombic."""
|
|
200
|
+
lattice = Box2l(self.lattice)
|
|
201
|
+
xx = [lattice[0], 0, 0]
|
|
202
|
+
yy = [lattice[1], lattice[2], 0]
|
|
203
|
+
zz = [lattice[3], lattice[4], lattice[5]]
|
|
204
|
+
self.lattice = [xx, yy, zz]
|
|
205
|
+
|
|
198
206
|
def _set_cartesian(self):
|
|
199
207
|
"""Set positions in Cartesian coordinates."""
|
|
200
208
|
self.position = frac2cart(self.position, self.lattice)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import os, sys, glob
|
|
3
3
|
from math import ceil
|
|
4
|
-
from collections import Counter
|
|
5
4
|
from typing import (List, Union, Optional)
|
|
6
5
|
# import time
|
|
7
6
|
# os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
|
@@ -15,6 +14,7 @@ from pwdata.dump import DUMP
|
|
|
15
14
|
from pwdata.lammpsdata import LMP
|
|
16
15
|
from pwdata.cp2kdata import CP2KMD, CP2KSCF
|
|
17
16
|
from pwdata.deepmd import DPNPY, DPRAW
|
|
17
|
+
from pwdata.pwmlff import PWNPY
|
|
18
18
|
from pwdata.movement_saver import save_to_movement
|
|
19
19
|
from pwdata.extendedxyz import save_to_extxyz
|
|
20
20
|
from pwdata.datasets_saver import save_to_dataset, get_pw, save_to_raw, save_to_npy
|
|
@@ -58,6 +58,8 @@ class Save_Data(object):
|
|
|
58
58
|
self.image_data = DPNPY(data_path)
|
|
59
59
|
elif format.lower() == 'deepmd/raw':
|
|
60
60
|
self.image_data = DPRAW(data_path)
|
|
61
|
+
elif format.lower() == 'pwmlff/npy':
|
|
62
|
+
self.image_data = PWNPY(data_path)
|
|
61
63
|
self.lattice, self.position, self.energies, self.ei, self.forces, self.virials, self.atom_type, self.atom_types_image, self.image_nums = get_pw(self.image_data.get())
|
|
62
64
|
|
|
63
65
|
if train_ratio is not None: # inference 时不存数据
|
|
@@ -184,6 +186,8 @@ class Config(object):
|
|
|
184
186
|
image = DPNPY(data_path).image_list[index]
|
|
185
187
|
elif format.lower() == 'deepmd/raw':
|
|
186
188
|
image = DPRAW(data_path).image_list[index]
|
|
189
|
+
elif format.lower() == 'pwmlff/npy':
|
|
190
|
+
image = PWNPY(data_path).image_list[index]
|
|
187
191
|
else:
|
|
188
192
|
raise Exception("Error! The format of the input file is not supported!")
|
|
189
193
|
return image
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import os, glob
|
|
3
|
+
from tqdm import tqdm
|
|
4
|
+
from pwdata.image import Image
|
|
5
|
+
|
|
6
|
+
class PWNPY(object):
|
|
7
|
+
def __init__(self, files):
|
|
8
|
+
self.image_list:list[Image] = []
|
|
9
|
+
self.load_files(files)
|
|
10
|
+
|
|
11
|
+
assert len(self.image_list) > 0, "No data loaded!"
|
|
12
|
+
|
|
13
|
+
def get(self):
|
|
14
|
+
return self.image_list
|
|
15
|
+
|
|
16
|
+
def load_files(self, files):
|
|
17
|
+
# Search for .npy files in the current directory
|
|
18
|
+
npy_files = glob.glob(os.path.join(files, "*.npy"))
|
|
19
|
+
if not npy_files:
|
|
20
|
+
npy_files = glob.glob(os.path.join(files, "*/*.npy"))
|
|
21
|
+
|
|
22
|
+
atom_type, atomic_energy, Ep, force, atom_types_image, lattice, coord, stress, image_nums, atom_nums = self.load_npy(npy_files)
|
|
23
|
+
lattice = lattice.reshape(-1, 3, 3)
|
|
24
|
+
coord = coord.reshape(-1, atom_nums, 3)
|
|
25
|
+
for i in tqdm(range(image_nums), desc="Loading data"):
|
|
26
|
+
image = Image(lattice=lattice[i], position=coord[i], force=force[i], Ep=Ep[i], stress=stress[i],
|
|
27
|
+
cartesian=False, image_nums=i, atom_nums=atom_nums,
|
|
28
|
+
atomic_energy=atomic_energy[i], atom_type=atom_type, atom_types_image=atom_types_image)
|
|
29
|
+
self.image_list.append(image)
|
|
30
|
+
|
|
31
|
+
def load_npy(self, npy_files):
|
|
32
|
+
atomic_energy = None
|
|
33
|
+
Ep = None
|
|
34
|
+
force = None
|
|
35
|
+
lattice = None
|
|
36
|
+
stress = None
|
|
37
|
+
coord = None
|
|
38
|
+
for npy_file in npy_files:
|
|
39
|
+
if "atom_type" in npy_file:
|
|
40
|
+
atom_type = np.load(npy_file).squeeze()
|
|
41
|
+
elif "ei" in npy_file:
|
|
42
|
+
atomic_energy = np.load(npy_file) if atomic_energy is None else np.concatenate((atomic_energy, np.load(npy_file)))
|
|
43
|
+
elif "energies" in npy_file:
|
|
44
|
+
Ep = np.load(npy_file) if Ep is None else np.concatenate((Ep, np.load(npy_file)))
|
|
45
|
+
elif "forces" in npy_file:
|
|
46
|
+
force = np.load(npy_file) if force is None else np.concatenate((force, np.load(npy_file)))
|
|
47
|
+
elif "image_type" in npy_file:
|
|
48
|
+
atom_types_image = np.load(npy_file).squeeze()
|
|
49
|
+
elif "lattice" in npy_file:
|
|
50
|
+
lattice = np.load(npy_file) if lattice is None else np.concatenate((lattice, np.load(npy_file)))
|
|
51
|
+
elif "virials" in npy_file:
|
|
52
|
+
stress = np.load(npy_file) if stress is None else np.concatenate((stress, np.load(npy_file)))
|
|
53
|
+
elif "position" in npy_file:
|
|
54
|
+
coord = np.load(npy_file) if coord is None else np.concatenate((coord, np.load(npy_file)))
|
|
55
|
+
|
|
56
|
+
image_nums = len(Ep)
|
|
57
|
+
atom_nums = len(atom_types_image)
|
|
58
|
+
|
|
59
|
+
return atom_type, atomic_energy.squeeze(), Ep.squeeze(), force.squeeze(), atom_types_image, lattice.squeeze(), coord.squeeze(), stress.squeeze(), image_nums, atom_nums
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pwdata
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
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.10",
|
|
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
|