pwdata 0.4.5__tar.gz → 0.4.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pwdata might be problematic. Click here for more details.

Files changed (68) hide show
  1. {pwdata-0.4.5 → pwdata-0.4.6}/PKG-INFO +1 -1
  2. pwdata-0.4.5/pwdata/build/write_struc.py +0 -412
  3. pwdata-0.4.5/pwdata/calculators/__init__.py +0 -0
  4. pwdata-0.4.5/pwdata/calculators/const.py +0 -264
  5. pwdata-0.4.5/pwdata/calculators/unitconvert_lmps.py +0 -157
  6. pwdata-0.4.5/pwdata/calculators/units.py +0 -231
  7. pwdata-0.4.5/pwdata/check_envs.py +0 -55
  8. pwdata-0.4.5/pwdata/config.py +0 -356
  9. pwdata-0.4.5/pwdata/convert_files.py +0 -383
  10. pwdata-0.4.5/pwdata/cp2kdata.py +0 -266
  11. pwdata-0.4.5/pwdata/datasets_saver.py +0 -159
  12. pwdata-0.4.5/pwdata/deepmd.py +0 -148
  13. pwdata-0.4.5/pwdata/dump.py +0 -197
  14. pwdata-0.4.5/pwdata/extendedxyz.py +0 -196
  15. pwdata-0.4.5/pwdata/fairchem/__init__.py +0 -0
  16. pwdata-0.4.5/pwdata/fairchem/common/__init__.py +0 -6
  17. pwdata-0.4.5/pwdata/fairchem/common/registry.py +0 -296
  18. pwdata-0.4.5/pwdata/fairchem/common/typing.py +0 -19
  19. pwdata-0.4.5/pwdata/fairchem/common/utils.py +0 -758
  20. pwdata-0.4.5/pwdata/fairchem/datasets/__init__.py +0 -23
  21. pwdata-0.4.5/pwdata/fairchem/datasets/_utils.py +0 -40
  22. pwdata-0.4.5/pwdata/fairchem/datasets/ase_datasets.py +0 -569
  23. pwdata-0.4.5/pwdata/fairchem/datasets/base_dataset.py +0 -140
  24. pwdata-0.4.5/pwdata/fairchem/datasets/embeddings/__init__.py +0 -13
  25. pwdata-0.4.5/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -111
  26. pwdata-0.4.5/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -1122
  27. pwdata-0.4.5/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -9414
  28. pwdata-0.4.5/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -7638
  29. pwdata-0.4.5/pwdata/fairchem/datasets/lmdb_database.py +0 -357
  30. pwdata-0.4.5/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -192
  31. pwdata-0.4.5/pwdata/fairchem/modules/__init__.py +0 -6
  32. pwdata-0.4.5/pwdata/fairchem/modules/transforms.py +0 -38
  33. pwdata-0.4.5/pwdata/fairchem/preprocessing/__init__.py +0 -7
  34. pwdata-0.4.5/pwdata/image.py +0 -314
  35. pwdata-0.4.5/pwdata/lammpsdata.py +0 -351
  36. pwdata-0.4.5/pwdata/lmps.py +0 -75
  37. pwdata-0.4.5/pwdata/main.py +0 -536
  38. pwdata-0.4.5/pwdata/meta.py +0 -173
  39. pwdata-0.4.5/pwdata/movement.py +0 -105
  40. pwdata-0.4.5/pwdata/movement_saver.py +0 -37
  41. pwdata-0.4.5/pwdata/outcar.py +0 -149
  42. pwdata-0.4.5/pwdata/pertub/__init__.py +0 -0
  43. pwdata-0.4.5/pwdata/pertub/perturbation.py +0 -222
  44. pwdata-0.4.5/pwdata/pertub/scale.py +0 -69
  45. pwdata-0.4.5/pwdata/poscar.py +0 -61
  46. pwdata-0.4.5/pwdata/pwmlff.py +0 -65
  47. pwdata-0.4.5/pwdata/test/__init__.py +0 -0
  48. pwdata-0.4.5/pwdata/test/mdtrajs2config.py +0 -30
  49. pwdata-0.4.5/pwdata/test/mptraj2lmdb.py +0 -86
  50. pwdata-0.4.5/pwdata/test.py +0 -192
  51. pwdata-0.4.5/pwdata/utils/__init__.py +0 -0
  52. pwdata-0.4.5/pwdata/utils/constant.py +0 -129
  53. pwdata-0.4.5/pwdata.egg-info/PKG-INFO +0 -17
  54. pwdata-0.4.5/pwdata.egg-info/SOURCES.txt +0 -66
  55. pwdata-0.4.5/pwdata.egg-info/dependency_links.txt +0 -1
  56. pwdata-0.4.5/pwdata.egg-info/entry_points.txt +0 -2
  57. pwdata-0.4.5/pwdata.egg-info/requires.txt +0 -8
  58. pwdata-0.4.5/pwdata.egg-info/top_level.txt +0 -1
  59. pwdata-0.4.5/setup.cfg +0 -4
  60. pwdata-0.4.5/setup.py +0 -37
  61. {pwdata-0.4.5 → pwdata-0.4.6}/LICENSE +0 -0
  62. {pwdata-0.4.5 → pwdata-0.4.6}/README.md +0 -0
  63. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/__init__.py +0 -0
  64. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/atomconfig.py +0 -0
  65. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/build/__init__.py +0 -0
  66. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/build/cell.py +0 -0
  67. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/build/geometry.py +0 -0
  68. {pwdata-0.4.5 → pwdata-0.4.6}/pwdata/build/supercells.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.4.5
3
+ Version: 0.4.6
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
@@ -1,412 +0,0 @@
1
- import numpy as np
2
- import os
3
- from collections import Counter
4
- from pwdata.build.cell import cell_to_cellpar
5
- from pwdata.calculators.const import elements, ELEMENTMASSTABLE
6
-
7
-
8
- def write_config(image,
9
- filepath,
10
- data_name="tmp.pwdada",
11
- direct=True,
12
- sort=None,
13
- symbol_count=None,
14
- long_format=True,
15
- ignore_constraints=False,
16
- wrap=False):
17
- """Method to write PWmat position (atom.config) files.
18
-
19
- Writes label, unitcell, # of various kinds of atoms,
20
- positions scaled coordinates (Direct), and constraints
21
- to file. fractional coordinates is default.
22
- """
23
- # assert direct==True, "PWmat only support direct coordinates"
24
- atom_nums = len(image) if image.atom_nums is None else image.atom_nums
25
- if isinstance(image, (list, tuple)):
26
- if atom_nums > 1:
27
- raise RuntimeError('Don\'t know how to save more than ' +
28
- 'one image to PWmat input')
29
- else:
30
- image = image[0]
31
-
32
- # Check lattice vectors are finite
33
- """Get unit cell parameters. Sequence of 6 numbers.
34
-
35
- First three are unit cell vector lengths and second three
36
- are angles between them::
37
-
38
- [len(a), len(b), len(c), angle(b,c), angle(a,c), angle(a,b)]
39
-
40
- in degrees.
41
-
42
- radians: bool, Convert angles to radians.
43
-
44
- See also :func:`cell.cell_to_cellpar`."""
45
- cellpar = cell_to_cellpar(image.lattice, radians = False)
46
- if np.any(cellpar == 0.):
47
- raise RuntimeError(
48
- 'Lattice vectors must be finite and not coincident. '
49
- 'At least one lattice length or angle is zero.')
50
-
51
- # Write atom positions in scaled coordinates. For PWmat, we must use fractional coordinates
52
- if image.cartesian: # cartesian -> direct
53
- coord = image.get_scaled_positions(wrap=wrap)
54
- else: # get direct
55
- coord = image.position
56
-
57
- '''constraints = image.constraints and not ignore_constraints
58
-
59
- if constraints:
60
- sflags = np.zeros((atom_nums, 3), dtype=bool)
61
- for constr in image.constraints:
62
- if isinstance(constr, FixScaled):
63
- sflags[constr.a] = constr.mask
64
- elif isinstance(constr, FixAtoms):
65
- sflags[constr.index] = [True, True, True]
66
- elif isinstance(constr, FixedPlane):
67
- mask = np.all(np.abs(np.cross(constr.dir, image.cell)) < 1e-5,
68
- axis=1)
69
- if sum(mask) != 1:
70
- raise RuntimeError(
71
- 'VASP requires that the direction of FixedPlane '
72
- 'constraints is parallel with one of the cell axis')
73
- sflags[constr.a] = mask
74
- elif isinstance(constr, FixedLine):
75
- mask = np.all(np.abs(np.cross(constr.dir, image.cell)) < 1e-5,
76
- axis=1)
77
- if sum(mask) != 1:
78
- raise RuntimeError(
79
- 'VASP requires that the direction of FixedLine '
80
- 'constraints is parallel with one of the cell axis')
81
- sflags[constr.a] = ~mask'''
82
-
83
- if sort:
84
- if len(image.get_atomic_numbers()) == 0:
85
- atom_types_image = np.array(image.atom_types_image)
86
- indices_dict = {type: np.where(atom_types_image == type)[0] for type in image.atom_type}
87
- sorted_indices = np.concatenate([np.sort(indices) for indices in indices_dict.values()])
88
- symbols = atom_types_image[sorted_indices]
89
- else:
90
- sorted_indices = np.argsort(image.get_atomic_numbers())
91
- symbols = np.array(image.get_atomic_numbers())[sorted_indices]
92
- coord = np.array(coord)[sorted_indices]
93
- # if constraints:
94
- # sflags = sflags[ind]
95
- else:
96
- symbols = image.atom_types_image
97
-
98
- # Create a list sc of (symbol, count) pairs
99
- if symbol_count:
100
- # sc = symbol_count
101
- pass
102
- elif image.atom_type_num is None:
103
- sc = Counter(symbols)
104
- atom_type = list(sc.keys())
105
- atom_type_num = list(sc.values())
106
- else:
107
- atom_type = image.atom_type
108
- atom_type_num = image.atom_type_num
109
-
110
- # Write to file
111
- output_file = open(os.path.join(filepath, data_name), 'w')
112
- output_file.write('%d\n' % atom_nums)
113
- output_file.write('Lattice vector\n')
114
- for i in range(3):
115
- output_file.write('%19.16f %19.16f %19.16f\n' % tuple(image.lattice[i]))
116
- output_file.write(' Position, move_x, mov_y, move_z\n')
117
- for i in range(atom_nums):
118
- output_file.write('%4d %19.16f %19.16f %19.16f %2d %2d %2d\n' %
119
- (symbols[i], coord[i][0], coord[i][1], coord[i][2],
120
- 1, 1, 1))
121
- output_file.close()
122
- print("Convert to %s successfully!" % data_name)
123
-
124
- def write_vasp(image,
125
- filepath,
126
- data_name="tmp.pwdada",
127
- direct=False,
128
- sort=None,
129
- symbol_count=None,
130
- long_format=True,
131
- vasp5=True,
132
- ignore_constraints=False,
133
- wrap=False):
134
- """Method to write VASP position (POSCAR/CONTCAR) files.
135
-
136
- Writes label, scalefactor, unitcell, # of various kinds of atoms,
137
- positions in cartesian or scaled coordinates (Direct), and constraints
138
- to file. Cartesian coordinates is default and default label is the
139
- atomic species, e.g. 'C N H Cu'.
140
- """
141
- atom_nums = len(image) if image.atom_nums is None else image.atom_nums
142
- if isinstance(image, (list, tuple)):
143
- if atom_nums > 1:
144
- raise RuntimeError('Don\'t know how to save more than ' +
145
- 'one image to VASP input')
146
- else:
147
- image = image[0]
148
-
149
- # Check lattice vectors are finite
150
- """Get unit cell parameters. Sequence of 6 numbers.
151
-
152
- First three are unit cell vector lengths and second three
153
- are angles between them::
154
-
155
- [len(a), len(b), len(c), angle(b,c), angle(a,c), angle(a,b)]
156
-
157
- in degrees.
158
-
159
- radians: bool, Convert angles to radians.
160
-
161
- See also :func:`cell.cell_to_cellpar`."""
162
- cellpar = cell_to_cellpar(image.lattice, radians = False)
163
- if np.any(cellpar == 0.):
164
- raise RuntimeError(
165
- 'Lattice vectors must be finite and not coincident. '
166
- 'At least one lattice length or angle is zero.')
167
-
168
- # Write atom positions in scaled or cartesian coordinates
169
- if direct and image.cartesian: # cartesian -> direct
170
- coord = image.get_scaled_positions(wrap=wrap)
171
- elif not direct and not image.cartesian: # direct -> cartesian
172
- coord = image._set_cartesian().position
173
- else: # get cartesian/direct
174
- coord = image.position
175
-
176
- '''constraints = image.constraints and not ignore_constraints
177
-
178
- if constraints:
179
- sflags = np.zeros((atom_nums, 3), dtype=bool)
180
- for constr in image.constraints:
181
- if isinstance(constr, FixScaled):
182
- sflags[constr.a] = constr.mask
183
- elif isinstance(constr, FixAtoms):
184
- sflags[constr.index] = [True, True, True]
185
- elif isinstance(constr, FixedPlane):
186
- mask = np.all(np.abs(np.cross(constr.dir, image.cell)) < 1e-5,
187
- axis=1)
188
- if sum(mask) != 1:
189
- raise RuntimeError(
190
- 'VASP requires that the direction of FixedPlane '
191
- 'constraints is parallel with one of the cell axis')
192
- sflags[constr.a] = mask
193
- elif isinstance(constr, FixedLine):
194
- mask = np.all(np.abs(np.cross(constr.dir, image.cell)) < 1e-5,
195
- axis=1)
196
- if sum(mask) != 1:
197
- raise RuntimeError(
198
- 'VASP requires that the direction of FixedLine '
199
- 'constraints is parallel with one of the cell axis')
200
- sflags[constr.a] = ~mask'''
201
-
202
-
203
- if sort:
204
- if len(image.get_atomic_numbers()) == 0:
205
- atom_types_image = np.array(image.atom_types_image)
206
- indices_dict = {type: np.where(atom_types_image == type)[0] for type in image.atom_type}
207
- sorted_indices = np.concatenate([np.sort(indices) for indices in indices_dict.values()])
208
- symbols = atom_types_image[sorted_indices]
209
- else:
210
- sorted_indices = np.argsort(image.get_atomic_numbers())
211
- symbols = np.array(image.get_atomic_numbers())[sorted_indices]
212
- coord = np.array(coord)[sorted_indices]
213
- # if constraints:
214
- # sflags = sflags[ind]
215
- else:
216
- symbols = image.atom_types_image
217
-
218
- # Create a list sc of (symbol, count) pairs
219
- if symbol_count:
220
- # sc = symbol_count
221
- pass
222
- elif image.atom_type_num is None:
223
- sc = Counter(symbols)
224
- atom_type = list(sc.keys())
225
- atom_type_num = list(sc.values())
226
- else:
227
- atom_type = image.atom_type
228
- atom_type_num = image.atom_type_num
229
-
230
- atom_type = [elements[_] for _ in atom_type]
231
- # Write to file
232
- output_file = open(os.path.join(filepath, data_name), 'w')
233
- output_file.write('Created from %s\n' % data_name)
234
- output_file.write('1.0\n')
235
- for i in range(3):
236
- output_file.write('%19.16f %19.16f %19.16f\n' % tuple(image.lattice[i]))
237
- output_file.write(' '.join(atom_type) + '\n')
238
- output_file.write(' '.join([str(_) for _ in atom_type_num]) + '\n')
239
-
240
- # if constraints:
241
- # output_file.write('Selective dynamics\n')
242
-
243
- if direct:
244
- output_file.write('Direct\n')
245
- else:
246
- output_file.write('Cartesian\n')
247
-
248
- for i in range(atom_nums):
249
- output_file.write('%19.16f %19.16f %19.16f' % tuple(coord[i]))
250
- # if constraints:
251
- # output_file.write(' %s %s %s' % tuple(sflags[i]))
252
- output_file.write('\n')
253
- output_file.close()
254
- print("Convert to %s successfully!" % data_name)
255
-
256
- def write_lammps(image,
257
- filepath,
258
- data_name="tmp.pwdada",
259
- direct=False,
260
- sort=None,
261
- symbol_count=None,
262
- long_format=True,
263
- ignore_constraints=False,
264
- wrap=False):
265
- """Method to write LAMMPS position (lmp.init) files.
266
-
267
- Writes label, unitcell, # of various kinds of atoms,
268
- positions in cartesian coordinates and constraints
269
- to file. Cartesian coordinates is default.
270
- """
271
- atom_nums = len(image) if image.atom_nums is None else image.atom_nums
272
- if isinstance(image, (list, tuple)):
273
- if atom_nums > 1:
274
- raise RuntimeError('Don\'t know how to save more than ' +
275
- 'one image to LAMMPS input')
276
- else:
277
- image = image[0]
278
-
279
- # Check lattice vectors are finite
280
- """Get unit cell parameters. Sequence of 6 numbers.
281
-
282
- First three are unit cell vector lengths and second three
283
- are angles between them::
284
-
285
- [len(a), len(b), len(c), angle(b,c), angle(a,c), angle(a,b)]
286
-
287
- in degrees.
288
-
289
- radians: bool, Convert angles to radians.
290
-
291
- See also :func:`cell.cell_to_cellpar`."""
292
- cellpar = cell_to_cellpar(image.lattice, radians = False)
293
- if np.any(cellpar == 0.):
294
- raise RuntimeError(
295
- 'Lattice vectors must be finite and not coincident. '
296
- 'At least one lattice length or angle is zero.')
297
-
298
- # Write atom positions in cartesian coordinates
299
- if image.cartesian: # cartesian -> direct
300
- coord = image.get_scaled_positions(wrap=wrap)
301
- image._set_orthorhombic()
302
- else: # direct -> cartesian
303
- image._set_orthorhombic()
304
- coord = image._set_cartesian().position
305
-
306
- if sort:
307
- if len(image.get_atomic_numbers()) == 0:
308
- atom_types_image = np.array(image.atom_types_image)
309
- indices_dict = {type: np.where(atom_types_image == type)[0] for type in image.atom_type}
310
- sorted_indices = np.concatenate([np.sort(indices) for indices in indices_dict.values()])
311
- symbols = atom_types_image[sorted_indices]
312
- else:
313
- sorted_indices = np.argsort(image.get_atomic_numbers())
314
- symbols = np.array(image.get_atomic_numbers())[sorted_indices]
315
- coord = np.array(coord)[sorted_indices]
316
- # if constraints:
317
- # sflags = sflags[ind]
318
- else:
319
- symbols = image.atom_types_image
320
-
321
- # Create a list sc of (symbol, count) pairs
322
- if symbol_count:
323
- # sc = symbol_count
324
- pass
325
- elif image.atom_type_num is None:
326
- sc = Counter(symbols)
327
- atom_type = list(sc.keys())
328
- atom_type_num = list(sc.values())
329
- else:
330
- atom_type = image.atom_type
331
- atom_type_num = image.atom_type_num
332
-
333
- p = 1
334
- atype = []
335
- # atom num & type list
336
- for item in atom_type_num:
337
- atype += [p for _ in range(int(item))]
338
- p +=1
339
-
340
- # x array
341
- x = np.zeros([atom_nums,3],dtype=float)
342
-
343
- for idx,line in enumerate(coord):
344
- x[idx,0] = line[0]
345
- x[idx,1] = line[1]
346
- x[idx,2] = line[2]
347
-
348
- # output preparation
349
- # return [xx,xy,yy,xz,yz,zz]
350
- xlo = 0.0
351
- xhi = image.lattice[0][0]
352
- ylo = 0.0
353
- yhi = image.lattice[1][1]
354
- zlo = 0.0
355
- zhi = image.lattice[2][2]
356
- xy = image.lattice[1][0]
357
- xz = image.lattice[2][0]
358
- yz = image.lattice[2][1]
359
-
360
- LX = np.zeros([atom_nums,3],dtype=float)
361
- A = np.zeros([3,3],dtype=float)
362
-
363
- A[0,0] = image.lattice[0][0]
364
- A[1,0] = image.lattice[1][0]
365
- A[1,1] = image.lattice[1][1]
366
- A[2,0] = image.lattice[2][0]
367
- A[2,1] = image.lattice[2][1]
368
- A[2,2] = image.lattice[2][2]
369
-
370
- print("converted LAMMPS upper trangualr box:")
371
-
372
- print(A)
373
-
374
- # print("Ref:https://docs.lammps.org/Howto_triclinic.html")
375
- # convert lamda (fraction) coords x to box coords LX
376
- # A.T x = LX
377
- # LX = A*x in LAMMPS. see https://docs.lammps.org/Howto_triclinic.html
378
-
379
- if not image.cartesian:
380
- for i in range(atom_nums):
381
- LX[i,0] = A[0,0]*x[i,0] + A[1,0]*x[i,1] + A[2,0]*x[i,2]
382
- LX[i,1] = A[0,1]*x[i,0] + A[1,1]*x[i,1] + A[2,1]*x[i,2]
383
- LX[i,2] = A[0,2]*x[i,0] + A[1,2]*x[i,1] + A[2,2]*x[i,2]
384
- else:
385
- for i in range(atom_nums):
386
- LX[i,0] = x[i,0]
387
- LX[i,1] = x[i,1]
388
- LX[i,2] = x[i,2]
389
-
390
- # Write to file
391
- output_file = open(os.path.join(filepath, data_name), 'w')
392
- output_file.write('Created from %s\n' % data_name)
393
- output_file.write("%-12d atoms\n" % (atom_nums))
394
- output_file.write("%-12d atom types\n" % (len(atom_type)))
395
- output_file.write("%16.12f %16.12f xlo xhi\n" % (xlo, xhi))
396
- output_file.write("%16.12f %16.12f ylo yhi\n" % (ylo, yhi))
397
- output_file.write("%16.12f %16.12f zlo zhi\n" % (zlo, zhi))
398
- output_file.write("%16.12f %16.12f %16.12f xy xz yz\n" % (xy, xz, yz))
399
- output_file.write("\n")
400
- output_file.write("Masses\n")
401
- output_file.write("\n")
402
- for i in range(len(atom_type)):
403
- output_file.write("%-12d %16.12f # %s\n" % (i+1, ELEMENTMASSTABLE[atom_type[i]], atom_type[i]))
404
- output_file.write("\n")
405
- output_file.write("Atoms # atomic\n")
406
- output_file.write("\n")
407
-
408
- for i in range(atom_nums):
409
- 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]))
410
- output_file.close()
411
- print("Convert to %s successfully!" % data_name)
412
-
File without changes