pymdkit 1.6.7__tar.gz → 1.6.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 (59) hide show
  1. {pymdkit-1.6.7/src/pymdkit.egg-info → pymdkit-1.6.8}/PKG-INFO +12 -1
  2. {pymdkit-1.6.7 → pymdkit-1.6.8}/README.md +11 -0
  3. {pymdkit-1.6.7 → pymdkit-1.6.8}/pyproject.toml +1 -1
  4. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/__init__.py +1 -1
  5. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/compute_ehull.py +51 -12
  6. {pymdkit-1.6.7 → pymdkit-1.6.8/src/pymdkit.egg-info}/PKG-INFO +12 -1
  7. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit.egg-info/SOURCES.txt +1 -0
  8. pymdkit-1.6.8/tests/test_ehull.py +84 -0
  9. {pymdkit-1.6.7 → pymdkit-1.6.8}/LICENSE +0 -0
  10. {pymdkit-1.6.7 → pymdkit-1.6.8}/setup.cfg +0 -0
  11. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/_config.py +0 -0
  12. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/__init__.py +0 -0
  13. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_cifio.py +0 -0
  14. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_extxyz.py +0 -0
  15. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_fileio.py +0 -0
  16. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_geometry.py +0 -0
  17. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_gpumd.py +0 -0
  18. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_lattice.py +0 -0
  19. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_oxidation.py +0 -0
  20. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_precision.py +0 -0
  21. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_reduction.py +0 -0
  22. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_submit_vasp.py +0 -0
  23. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_supercell.py +0 -0
  24. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_symmetry.py +0 -0
  25. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_vasp_output.py +0 -0
  26. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/_vaspset.py +0 -0
  27. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/chemsys_entry.py +0 -0
  28. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/compute_rmsd.py +0 -0
  29. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/config.py +0 -0
  30. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/convert.py +0 -0
  31. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/ewald.py +0 -0
  32. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gather_fs.py +0 -0
  33. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gpumd_group.py +0 -0
  34. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gpumd_job.py +0 -0
  35. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gpumd_msd.py +0 -0
  36. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gpumd_thermo.py +0 -0
  37. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/gpumd_trjcat.py +0 -0
  38. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/nep_rmse.py +0 -0
  39. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/perturb.py +0 -0
  40. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/rd.py +0 -0
  41. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/realloc_occ.py +0 -0
  42. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/substitute.py +0 -0
  43. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/supercell.py +0 -0
  44. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/trjconv.py +0 -0
  45. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/vasp2xyz.py +0 -0
  46. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/vasp_job.py +0 -0
  47. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/commands/vasp_out.py +0 -0
  48. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit/pymdkit_main.py +0 -0
  49. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit.egg-info/dependency_links.txt +0 -0
  50. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit.egg-info/entry_points.txt +0 -0
  51. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit.egg-info/requires.txt +0 -0
  52. {pymdkit-1.6.7 → pymdkit-1.6.8}/src/pymdkit.egg-info/top_level.txt +0 -0
  53. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_config_logging.py +0 -0
  54. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_convert.py +0 -0
  55. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_lattice_symmetry.py +0 -0
  56. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_realloc_occ.py +0 -0
  57. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_v165.py +0 -0
  58. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_vasp_out.py +0 -0
  59. {pymdkit-1.6.7 → pymdkit-1.6.8}/tests/test_vaspset.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymdkit
3
- Version: 1.6.7
3
+ Version: 1.6.8
4
4
  Summary: A unified command-line toolkit for atomistic / MD structure workflows.
5
5
  Author-email: Yueda Wang <ydwang0608@ustc.edu.cn>
6
6
  License-Expression: GPL-3.0-or-later
@@ -159,6 +159,7 @@ pmk vasp-out -all
159
159
 
160
160
  pmk gpumd-trjcat -all
161
161
  pmk ehull -local Li-La-Ta-Cl-stable-entries-opted
162
+ pmk ehull -ref-form-e -1.1
162
163
  pmk gather-fs -job vasp -fs-name CONTCAR -of vasp-opted
163
164
  pmk vasp2xyz -position-only
164
165
  pmk realloc-occ -if cifs -of disorder -formula Li3YCl6 -occ 0.25 0.5 0.75 1
@@ -213,6 +214,16 @@ The standalone `supercell` command is now structure-only. Its removed
213
214
  `gpumd-job`. The standalone `gpumd-group` command remains available for tagging
214
215
  existing files.
215
216
 
217
+ ### E_hull reference
218
+
219
+ `ehull -ref-form-e EV_PER_ATOM` keeps the normal Materials Project or `-local`
220
+ formation-energy calculation, but replaces the phase-diagram hull distance with
221
+ `E_hull = E_form - EV_PER_ATOM`. All scanned structures must have the same
222
+ reduced formula because one scalar reference applies to one composition. The
223
+ exact difference is retained, including a negative value when a structure lies
224
+ below the supplied reference.
225
+
226
+
216
227
  ### VASP jobs
217
228
 
218
229
  `vasp-job -i/-if/-it -incar INCAR` creates one job folder per structure. PMK
@@ -131,6 +131,7 @@ pmk vasp-out -all
131
131
 
132
132
  pmk gpumd-trjcat -all
133
133
  pmk ehull -local Li-La-Ta-Cl-stable-entries-opted
134
+ pmk ehull -ref-form-e -1.1
134
135
  pmk gather-fs -job vasp -fs-name CONTCAR -of vasp-opted
135
136
  pmk vasp2xyz -position-only
136
137
  pmk realloc-occ -if cifs -of disorder -formula Li3YCl6 -occ 0.25 0.5 0.75 1
@@ -185,6 +186,16 @@ The standalone `supercell` command is now structure-only. Its removed
185
186
  `gpumd-job`. The standalone `gpumd-group` command remains available for tagging
186
187
  existing files.
187
188
 
189
+ ### E_hull reference
190
+
191
+ `ehull -ref-form-e EV_PER_ATOM` keeps the normal Materials Project or `-local`
192
+ formation-energy calculation, but replaces the phase-diagram hull distance with
193
+ `E_hull = E_form - EV_PER_ATOM`. All scanned structures must have the same
194
+ reduced formula because one scalar reference applies to one composition. The
195
+ exact difference is retained, including a negative value when a structure lies
196
+ below the supplied reference.
197
+
198
+
188
199
  ### VASP jobs
189
200
 
190
201
  `vasp-job -i/-if/-it -incar INCAR` creates one job folder per structure. PMK
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pymdkit"
7
- version = "1.6.7"
7
+ version = "1.6.8"
8
8
  description = "A unified command-line toolkit for atomistic / MD structure workflows."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,3 +1,3 @@
1
1
  """pymdkit -- a unified CLI for atomistic / MD structure workflows."""
2
2
 
3
- __version__ = "1.6.7"
3
+ __version__ = "1.6.8"
@@ -110,6 +110,26 @@ def local_phase_diagram(local_folder):
110
110
  return build_phase_diagram(entries), len(entries)
111
111
 
112
112
 
113
+ def formation_and_hull(pd, entry, reference_formation_energy=None):
114
+ """Return formation energy and either phase-diagram or reference E_hull."""
115
+ e_form = float(pd.get_form_energy_per_atom(entry))
116
+ if reference_formation_energy is not None:
117
+ return e_form, e_form - float(reference_formation_energy)
118
+ try:
119
+ return e_form, float(pd.get_e_above_hull(entry))
120
+ except ValueError:
121
+ return e_form, 0.0
122
+
123
+
124
+ def reference_description(source, reference_formation_energy):
125
+ if reference_formation_energy is None:
126
+ return source
127
+ return (
128
+ f"{source}; E_hull = E_form - "
129
+ f"({reference_formation_energy:.8f} eV/atom)"
130
+ )
131
+
132
+
113
133
  def write_report(results, root, filename, reference):
114
134
  def fmt(val, w=10, prec=8):
115
135
  return f"{val:>{w}.{prec}f}" if val is not None else f"{'N/A':>{w}}"
@@ -140,6 +160,11 @@ def add_arguments(parser):
140
160
  help="Materials Project API key.")
141
161
  parser.add_argument("-local", type=Path, default=None,
142
162
  help="Folder of local stable VASP entries used to build the hull.")
163
+ parser.add_argument(
164
+ "-ref-form-e", type=float, default=None, metavar="EV_PER_ATOM",
165
+ help=("Reference formation energy in eV/atom; compute E_hull as "
166
+ "E_form minus this value for structures of one formula."),
167
+ )
143
168
 
144
169
 
145
170
  def run(args):
@@ -149,26 +174,39 @@ def run(args):
149
174
  print("No VASP job folders found. Nothing to do.")
150
175
  return 0
151
176
 
177
+ if args.ref_form_e is not None:
178
+ formulas = sorted({
179
+ entry.composition.reduced_formula for _, entry, _ in entries
180
+ })
181
+ if len(formulas) != 1:
182
+ raise SystemExit(
183
+ "Error: -ref-form-e requires structures with one reduced "
184
+ f"formula; found: {', '.join(formulas)}"
185
+ )
186
+
152
187
  groups = defaultdict(list)
153
188
  for folder, entry, final_energy in entries:
154
189
  groups[chemsys_label(entry)].append((folder, entry, final_energy))
155
190
 
156
191
  print(f"Found {len(entries)} VASP job folder(s) across "
157
192
  f"{len(groups)} chemical system(s): {', '.join(sorted(groups))}")
193
+ if args.ref_form_e is not None:
194
+ print(f"Reference formation energy: {args.ref_form_e:.8f} eV/atom")
158
195
 
159
196
  results = []
160
197
  if args.local:
161
198
  pd, nref = local_phase_diagram(args.local)
162
- reference = f"local entries from {args.local} ({nref} parsed)"
199
+ reference = reference_description(
200
+ f"local entries from {args.local} ({nref} parsed)",
201
+ args.ref_form_e,
202
+ )
163
203
  for label in sorted(groups):
164
204
  members = groups[label]
165
205
  print(f" [{label}] {len(members)} structure(s) -> local hull")
166
206
  for folder, entry, final_energy in members:
167
- e_form = pd.get_form_energy_per_atom(entry)
168
- try:
169
- e_hull = pd.get_e_above_hull(entry)
170
- except ValueError:
171
- e_hull = 0.0
207
+ e_form, e_hull = formation_and_hull(
208
+ pd, entry, args.ref_form_e
209
+ )
172
210
  results.append({
173
211
  "folder": folder,
174
212
  "formula": entry.composition.reduced_formula,
@@ -178,7 +216,10 @@ def run(args):
178
216
  "e_hull": e_hull,
179
217
  })
180
218
  else:
181
- reference = "Materials Project, MP2020 corrections applied"
219
+ reference = reference_description(
220
+ "Materials Project, MP2020 corrections applied",
221
+ args.ref_form_e,
222
+ )
182
223
  for label in sorted(groups):
183
224
  members = groups[label]
184
225
  elements = label.split("-")
@@ -187,11 +228,9 @@ def run(args):
187
228
  pd = build_phase_diagram(refs)
188
229
  corrected = apply_mp2020_corrections([e for _, e, _ in members])
189
230
  for (folder, _, final_energy), entry in zip(members, corrected):
190
- e_form = pd.get_form_energy_per_atom(entry)
191
- try:
192
- e_hull = pd.get_e_above_hull(entry)
193
- except ValueError:
194
- e_hull = 0.0
231
+ e_form, e_hull = formation_and_hull(
232
+ pd, entry, args.ref_form_e
233
+ )
195
234
  results.append({
196
235
  "folder": folder,
197
236
  "formula": entry.composition.reduced_formula,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymdkit
3
- Version: 1.6.7
3
+ Version: 1.6.8
4
4
  Summary: A unified command-line toolkit for atomistic / MD structure workflows.
5
5
  Author-email: Yueda Wang <ydwang0608@ustc.edu.cn>
6
6
  License-Expression: GPL-3.0-or-later
@@ -159,6 +159,7 @@ pmk vasp-out -all
159
159
 
160
160
  pmk gpumd-trjcat -all
161
161
  pmk ehull -local Li-La-Ta-Cl-stable-entries-opted
162
+ pmk ehull -ref-form-e -1.1
162
163
  pmk gather-fs -job vasp -fs-name CONTCAR -of vasp-opted
163
164
  pmk vasp2xyz -position-only
164
165
  pmk realloc-occ -if cifs -of disorder -formula Li3YCl6 -occ 0.25 0.5 0.75 1
@@ -213,6 +214,16 @@ The standalone `supercell` command is now structure-only. Its removed
213
214
  `gpumd-job`. The standalone `gpumd-group` command remains available for tagging
214
215
  existing files.
215
216
 
217
+ ### E_hull reference
218
+
219
+ `ehull -ref-form-e EV_PER_ATOM` keeps the normal Materials Project or `-local`
220
+ formation-energy calculation, but replaces the phase-diagram hull distance with
221
+ `E_hull = E_form - EV_PER_ATOM`. All scanned structures must have the same
222
+ reduced formula because one scalar reference applies to one composition. The
223
+ exact difference is retained, including a negative value when a structure lies
224
+ below the supplied reference.
225
+
226
+
216
227
  ### VASP jobs
217
228
 
218
229
  `vasp-job -i/-if/-it -incar INCAR` creates one job folder per structure. PMK
@@ -49,6 +49,7 @@ src/pymdkit/commands/vasp_job.py
49
49
  src/pymdkit/commands/vasp_out.py
50
50
  tests/test_config_logging.py
51
51
  tests/test_convert.py
52
+ tests/test_ehull.py
52
53
  tests/test_lattice_symmetry.py
53
54
  tests/test_realloc_occ.py
54
55
  tests/test_v165.py
@@ -0,0 +1,84 @@
1
+ """Regression tests for reference-formation-energy E_hull calculations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import types
7
+ import unittest
8
+ from pathlib import Path
9
+ from unittest.mock import patch
10
+
11
+ from pymdkit.commands import compute_ehull
12
+
13
+
14
+ class PhaseDiagram:
15
+ def __init__(self, formation_energy, phase_diagram_hull=0.0):
16
+ self.formation_energy = formation_energy
17
+ self.phase_diagram_hull = phase_diagram_hull
18
+ self.hull_calls = 0
19
+
20
+ def get_form_energy_per_atom(self, entry):
21
+ return self.formation_energy
22
+
23
+ def get_e_above_hull(self, entry):
24
+ self.hull_calls += 1
25
+ return self.phase_diagram_hull
26
+
27
+
28
+ class EhullTests(unittest.TestCase):
29
+ def test_parser_accepts_negative_reference_formation_energy(self):
30
+ parser = argparse.ArgumentParser()
31
+ compute_ehull.add_arguments(parser)
32
+ args = parser.parse_args(["-ref-form-e", "-1.1"])
33
+ self.assertEqual(args.ref_form_e, -1.1)
34
+
35
+ def test_reference_formation_energy_is_subtracted_exactly(self):
36
+ pd = PhaseDiagram(-1.0, phase_diagram_hull=9.9)
37
+ e_form, e_hull = compute_ehull.formation_and_hull(
38
+ pd, object(), reference_formation_energy=-1.1
39
+ )
40
+ self.assertEqual(e_form, -1.0)
41
+ self.assertAlmostEqual(e_hull, 0.1)
42
+ self.assertEqual(pd.hull_calls, 0)
43
+
44
+ def test_reference_difference_is_not_clamped(self):
45
+ pd = PhaseDiagram(-1.2)
46
+ _, e_hull = compute_ehull.formation_and_hull(
47
+ pd, object(), reference_formation_energy=-1.1
48
+ )
49
+ self.assertAlmostEqual(e_hull, -0.1)
50
+
51
+ def test_default_mode_still_uses_phase_diagram_hull(self):
52
+ pd = PhaseDiagram(-1.0, phase_diagram_hull=0.25)
53
+ self.assertEqual(
54
+ compute_ehull.formation_and_hull(pd, object()),
55
+ (-1.0, 0.25),
56
+ )
57
+ self.assertEqual(pd.hull_calls, 1)
58
+
59
+ def test_one_reference_rejects_mixed_formulas(self):
60
+ def entry(formula):
61
+ composition = types.SimpleNamespace(reduced_formula=formula)
62
+ return types.SimpleNamespace(composition=composition)
63
+
64
+ args = types.SimpleNamespace(
65
+ entry_path=Path("."),
66
+ mp_api_key=None,
67
+ local=None,
68
+ ref_form_e=-1.1,
69
+ )
70
+ entries = [
71
+ ("AB-1", entry("AB"), -2.0),
72
+ ("A2B-1", entry("A2B"), -3.0),
73
+ ]
74
+ with patch.object(compute_ehull, "collect_entries", return_value=entries):
75
+ with self.assertRaisesRegex(
76
+ SystemExit,
77
+ "-ref-form-e requires structures with one reduced formula",
78
+ ):
79
+ compute_ehull.run(args)
80
+
81
+
82
+ if __name__ == "__main__":
83
+ unittest.main()
84
+
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes