pwdata 0.5.7__tar.gz → 0.5.8__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.
Files changed (81) hide show
  1. {pwdata-0.5.7 → pwdata-0.5.8}/PKG-INFO +1 -1
  2. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/extendedxyz.py +3 -3
  3. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/meta.py +54 -15
  4. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/PKG-INFO +1 -1
  5. {pwdata-0.5.7 → pwdata-0.5.8}/setup.py +1 -1
  6. {pwdata-0.5.7 → pwdata-0.5.8}/LICENSE +0 -0
  7. {pwdata-0.5.7 → pwdata-0.5.8}/README.md +0 -0
  8. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/__init__.py +0 -0
  9. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/atomconfig.py +0 -0
  10. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/build/__init__.py +0 -0
  11. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/build/cell.py +0 -0
  12. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/build/geometry.py +0 -0
  13. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/build/supercells.py +0 -0
  14. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/build/write_struc.py +0 -0
  15. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/calculators/__init__.py +0 -0
  16. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/calculators/const.py +0 -0
  17. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/calculators/unitconvert_lmps.py +0 -0
  18. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/calculators/units.py +0 -0
  19. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/check_envs.py +0 -0
  20. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/config.py +0 -0
  21. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/convert_files.py +0 -0
  22. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/cp2kdata.py +0 -0
  23. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/datasets_saver.py +0 -0
  24. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/deepmd.py +0 -0
  25. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/dump.py +0 -0
  26. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/__init__.py +0 -0
  27. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/common/__init__.py +0 -0
  28. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/common/registry.py +0 -0
  29. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/common/typing.py +0 -0
  30. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/common/utils.py +0 -0
  31. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/__init__.py +0 -0
  32. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/_utils.py +0 -0
  33. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/ase_datasets.py +0 -0
  34. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/base_dataset.py +0 -0
  35. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/embeddings/__init__.py +0 -0
  36. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/embeddings/atomic_radii.py +0 -0
  37. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/embeddings/continuous_embeddings.py +0 -0
  38. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/embeddings/khot_embeddings.py +0 -0
  39. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/embeddings/qmof_khot_embeddings.py +0 -0
  40. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/lmdb_database.py +0 -0
  41. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/datasets/target_metadata_guesser.py +0 -0
  42. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/modules/__init__.py +0 -0
  43. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/modules/transforms.py +0 -0
  44. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/fairchem/preprocessing/__init__.py +0 -0
  45. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/image.py +0 -0
  46. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/lammpsdata.py +0 -0
  47. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/lmps.py +0 -0
  48. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/main.py +0 -0
  49. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/meta_omol.py +0 -0
  50. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/molecule.py +0 -0
  51. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/movement.py +0 -0
  52. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/movement_saver.py +0 -0
  53. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/outcar.py +0 -0
  54. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/pertub/__init__.py +0 -0
  55. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/pertub/perturbation.py +0 -0
  56. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/pertub/scale.py +0 -0
  57. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/poscar.py +0 -0
  58. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/pwmlff.py +0 -0
  59. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/__init__.py +0 -0
  60. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/bamboo2lmdb.py +0 -0
  61. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/extact_outcar_with_ml.py +0 -0
  62. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/lmdb2aselmdb.py +0 -0
  63. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/matpbe2lmdb.py +0 -0
  64. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/matrcan2lmdb.py +0 -0
  65. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/mdtrajs2config.py +0 -0
  66. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/mptraj2lmdb.py +0 -0
  67. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/oc25.py +0 -0
  68. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/omol25.py +0 -0
  69. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/outcar2mvms.py +0 -0
  70. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/readasedb.py +0 -0
  71. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test/surf_test.py +0 -0
  72. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/test.py +0 -0
  73. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/utils/__init__.py +0 -0
  74. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/utils/constant.py +0 -0
  75. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata/utils/format_change.py +0 -0
  76. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/SOURCES.txt +0 -0
  77. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/dependency_links.txt +0 -0
  78. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/entry_points.txt +0 -0
  79. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/requires.txt +0 -0
  80. {pwdata-0.5.7 → pwdata-0.5.8}/pwdata.egg-info/top_level.txt +0 -0
  81. {pwdata-0.5.7 → pwdata-0.5.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.5.7
3
+ Version: 0.5.8
4
4
  Summary: pwdata is a data pre-processing tool for MatPL, 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
@@ -160,10 +160,10 @@ def read_one_structures_from_lines(lines:list[str]):
160
160
  virial = [float(i) for i in result_dict["virial"].split()]
161
161
  assert len(virial) == 9, "virial in extxyz file should has 9 elements"
162
162
  image.virial = np.array(virial).reshape(3, 3)
163
- if "stress" in result_dict.keys():
164
- stress = [float(i) for i in result_dict["stress"].split(" ")]
163
+ elif "stress" in result_dict.keys():
164
+ stress = [float(i) for i in result_dict["stress"].split()]
165
165
  assert len(stress) == 9, "stress in extxyz file should has 9 elements"
166
- volume = np.abs(np.linalg.det(image.lattice))
166
+ volume = np.abs(np.linalg.det(image.lattice))
167
167
  image.virial = -volume * np.reshape(stress, (3, 3))
168
168
 
169
169
  atomic_energy, _, _, _ = np.linalg.lstsq([image.atom_type_num], np.array([image.Ep]), rcond=1e-3)
@@ -1,4 +1,5 @@
1
1
  import numpy as np
2
+ import re
2
3
  import os, glob
3
4
  from tqdm import tqdm
4
5
  from pwdata.image import Image
@@ -84,6 +85,10 @@ class META(object):
84
85
  """处理每个 atom_list 并转换为对象列表"""
85
86
  return [to_image(Atoms) for Atoms in atom_list]
86
87
 
88
+ # MPtrj LMDB stores stress in kbar rather than eV/ų
89
+ # 1 kbar = 6.241509e-4 eV/ų
90
+ KBAR_TO_EV_PER_A3 = 6.241509e-4
91
+
87
92
  def load_and_query_db(db_address, atom_types, query, filter_with_elements):
88
93
  # 加载数据库
89
94
  try:
@@ -103,6 +108,16 @@ def load_and_query_db(db_address, atom_types, query, filter_with_elements):
103
108
  atom_list.extend(list(dbs.select(query, filter=filter_with_elements)))
104
109
  else: # query is not None and atom_types is None
105
110
  atom_list.extend(list(dbs.select(query)))
111
+
112
+ # MPtrj 系列数据集 stress 单位为 kbar,需转为 eV/ų
113
+ if re.search(r'mptrj', db_address, re.IGNORECASE):
114
+ for atoms in atom_list:
115
+ try:
116
+ stress_val = atoms.stress
117
+ if stress_val is not None:
118
+ atoms.stress = np.array(stress_val, dtype=float) * KBAR_TO_EV_PER_A3
119
+ except (AttributeError, TypeError):
120
+ pass
106
121
  return atom_list
107
122
 
108
123
  def query_fun(row, elements):
@@ -122,21 +137,45 @@ def to_image(Atoms):
122
137
  image.lattice = to_numpy_array(Atoms.cell).reshape(3, 3)
123
138
  image.position = to_numpy_array(Atoms.positions)
124
139
  image.cartesian = True
125
- image.force = to_numpy_array(Atoms.forces)
126
- image.Ep = to_float(Atoms.energy)
127
- # 计算 Atomic-Energy
128
- # atomic_energy, _, _, _ = np.linalg.lstsq([image.atom_type_num], np.array([image.Ep]), rcond=1e-3)
129
- # atomic_energy = np.repeat(atomic_energy, image.atom_type_num)
130
- # image.atomic_energy = atomic_energy.tolist()
131
140
 
132
- if hasattr(Atoms, 'virial') is False and hasattr(Atoms, 'stress'):
133
- vol = Atoms.volume
134
- virial = (-np.array(Atoms.stress) * vol)
135
- image.virial = np.array([
136
- [virial[0], virial[5], virial[4]],
137
- [virial[5], virial[1], virial[3]],
138
- [virial[4], virial[3], virial[2]]
139
- ])
140
- # print(image.virial)
141
+ # Get forces and energy
142
+ # AtomsRow (from LMDB select): uses direct attribute access
143
+ # Atoms (with SinglePointCalculator): uses .get_*() method calls
144
+ try:
145
+ image.force = to_numpy_array(Atoms.forces)
146
+ except AttributeError:
147
+ image.force = to_numpy_array(Atoms.get_forces())
148
+ try:
149
+ image.Ep = to_float(Atoms.energy)
150
+ except AttributeError:
151
+ image.Ep = to_float(Atoms.get_potential_energy())
152
+
153
+ # Compute virial from stress tensor
154
+ # Convention: virial = -stress * volume
155
+ # AtomsRow path: .stress is 6-element Voigt [s_xx, s_yy, s_zz, s_yz, s_xz, s_xy]
156
+ # Atoms path: .get_stress(voigt=False) returns full 3x3 tensor
157
+ try:
158
+ stress_raw = Atoms.stress
159
+ except AttributeError:
160
+ stress_raw = None
161
+ try:
162
+ stress_raw = Atoms.get_stress(voigt=False)
163
+ except Exception:
164
+ pass
165
+
166
+ if stress_raw is not None:
167
+ stress = np.array(stress_raw)
168
+ volume = Atoms.volume
169
+ if stress.shape == (6,):
170
+ virial = -stress * volume
171
+ image.virial = np.array([
172
+ [virial[0], virial[5], virial[4]],
173
+ [virial[5], virial[1], virial[3]],
174
+ [virial[4], virial[3], virial[2]]
175
+ ])
176
+ else:
177
+ # Already 3x3 tensor
178
+ image.virial = -stress * volume
179
+
141
180
  image.format = 'metadata'
142
181
  return image
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwdata
3
- Version: 0.5.7
3
+ Version: 0.5.8
4
4
  Summary: pwdata is a data pre-processing tool for MatPL, 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
@@ -11,7 +11,7 @@ with open("README.md", "r") as fh:
11
11
 
12
12
  setuptools.setup(
13
13
  name="pwdata",
14
- version="0.5.7",
14
+ version="0.5.8",
15
15
  author="LonxunQuantum",
16
16
  author_email="lonxun@pwmat.com",
17
17
  description="pwdata is a data pre-processing tool for MatPL, 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