pymdkit 1.4.6__tar.gz → 1.4.7__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.
- {pymdkit-1.4.6 → pymdkit-1.4.7}/PKG-INFO +5 -4
- {pymdkit-1.4.6 → pymdkit-1.4.7}/README.md +5 -4
- {pymdkit-1.4.6 → pymdkit-1.4.7}/pyproject.toml +1 -1
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/__init__.py +1 -1
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_gpumd.py +6 -7
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/gpumd_trjcat.py +92 -46
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/PKG-INFO +5 -4
- {pymdkit-1.4.6 → pymdkit-1.4.7}/LICENSE +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/setup.cfg +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/__init__.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_extxyz.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_fileio.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_geometry.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_reduction.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_vasp_output.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/_vaspset.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/add_config_type.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/chemsys_entry.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/compute_ehull.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/compute_msd_all_groups.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/compute_rmsd.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/convert.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/ewald.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/gather_contcar.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/gpumd_group.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/gpumd_thermo.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/nep_rmse.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/pca.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/perturb.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/submit_vasp.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/substitute.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/supercell.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/symmetrize.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/trj_extract.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/trj_sparse.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/umap.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/vasp2xyz.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/vasp_fe.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/vasp_relax.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/commands/vasp_static.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit/pymdkit_main.py +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/SOURCES.txt +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/dependency_links.txt +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/entry_points.txt +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/requires.txt +0 -0
- {pymdkit-1.4.6 → pymdkit-1.4.7}/src/pymdkit.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pymdkit
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.7
|
|
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
|
|
@@ -70,7 +70,7 @@ directory for job sub-folders automatically.
|
|
|
70
70
|
| `vasp-fe` | List VASP job final energies from lowest to highest |
|
|
71
71
|
| `gather-contcar` | Collect CONTCARs from VASP job folders into one folder, renamed `<folder>.vasp` |
|
|
72
72
|
| `gpumd-thermo` | Export and plot GPUMD thermo data and detect sustained equilibrium changes |
|
|
73
|
-
| `gpumd-trjcat` | Merge
|
|
73
|
+
| `gpumd-trjcat` | Merge normal or all GPUMD trajectories and extract the first abnormal region |
|
|
74
74
|
| `pca` | Reduce descriptor data to two dimensions; optional FPS sampling |
|
|
75
75
|
| `trj-extract` | Extract a GPUMD XYZ trajectory by time range |
|
|
76
76
|
| `trj-sparse` | Deterministically retain a requested fraction of XYZ trajectory frames |
|
|
@@ -137,6 +137,7 @@ pmk gpumd-thermo # current job, or recursively scan
|
|
|
137
137
|
pmk gpumd-thermo -t thermo.out -in run.in
|
|
138
138
|
pmk gpumd-trjcat # stable frames -> train.xyz; abnormal regions -> abnormal.xyz
|
|
139
139
|
pmk gpumd-trjcat -i traj.xyz -o train.xyz -ao abnormal.xyz
|
|
140
|
+
pmk gpumd-trjcat -all # merge every readable trajectory into train.xyz
|
|
140
141
|
pmk trj-extract -it traj.xyz -in run.in -b 100 -e 200 -o traj-100ps-200ps.xyz
|
|
141
142
|
pmk trj-sparse -it example.xyz -r 0.5 -o sparse-example.xyz
|
|
142
143
|
|
|
@@ -177,11 +178,11 @@ When `pca` or `umap` receives `-it train.xyz`, it reads `Config_type` from every
|
|
|
177
178
|
|
|
178
179
|
For folder conversion, `convert -if INPUT -of OUTPUT` writes `.xyz` by default. Set another target extension with `-oe`, for example `-oe cif` or `-oe vasp`. Single-file and trajectory modes infer the target format from `-o` and `-ot`.
|
|
179
180
|
|
|
180
|
-
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. When at least two
|
|
181
|
+
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. An abnormal classification always requires a mapped potential-energy change. When at least two lattice-parameter or volume signals show the same mapped transition, they may enable a more sensitive noise-relative energy test; this avoids a fixed eV or percentage-of-total-energy threshold that would depend on system size. Cell signals can corroborate and refine the energy interval, but can never classify a run by themselves. Temperature and all six pressure components remain diagnostics only and cannot classify an otherwise stationary run as abnormal by themselves. A lone cell-axis drift, an isolated spike, or an empty anomaly mask never triggers a whole-run fallback. Thermo plots use Arial when available and Matplotlib's built-in qualitative `Dark2` color cycle. They plot all six pressure components, use frameless upper-right legends with added vertical headroom, preserve correct Å units, and show abnormal regions as shaded legend entries on potential energy, lattice parameters, and volume. Potential energy and volume are divided by 1000 and labeled ×10³ only when their absolute plotted values reach 1000. The analysis uses the last `run` segment, or the last 80% when `run.in` has no `run` record; inspect the plot before making a final scientific judgment.
|
|
181
182
|
|
|
182
183
|
The thermo parser follows the [official GPUMD thermo.out format](https://gpumd.org/gpumd/output_files/thermo_out.html): 18 columns are required, `pressure.txt` exports `Pxx Pyy Pzz Pyz Pxz Pxy`, box vectors are interpreted as a full 3×3 matrix, `time_step` propagates between runs, and `dump_thermo` does not.
|
|
183
184
|
|
|
184
|
-
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`.
|
|
185
|
+
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`. By default, normal trajectories are merged in deterministic folder order into `train.xyz` (or `-o`), while only frames from the earliest mapped abnormal interval of each abnormal job are written to `abnormal.xyz` (or `-ao`). With `-all`, every readable full trajectory is merged into `train.xyz` regardless of normal, abnormal, missing-thermo, or failed-thermo status; an analyzable abnormal job still contributes its earliest abnormal interval to `abnormal.xyz`. If no mapped abnormal frames are found, `abnormal.xyz` is not created and a stale file at the selected `-ao` path is removed. Frame times are obtained from `time_step` and `dump_xyz` in that job's `run.in`. In default mode, missing, unreadable, or unmappable jobs are skipped. When `<job>/model.xyz` contains `Config_type`, that value is applied to every exported frame while all other extended-XYZ bytes remain unchanged.
|
|
185
186
|
|
|
186
187
|
`trj-sparse` keeps `max(1, floor(frame_count × ratio))` frames without rewriting their extended-XYZ content. Selection is deterministic and starts with frame zero; for 100 frames and `-r 0.5`, it writes source indices `0, 2, ..., 98`.
|
|
187
188
|
|
|
@@ -44,7 +44,7 @@ directory for job sub-folders automatically.
|
|
|
44
44
|
| `vasp-fe` | List VASP job final energies from lowest to highest |
|
|
45
45
|
| `gather-contcar` | Collect CONTCARs from VASP job folders into one folder, renamed `<folder>.vasp` |
|
|
46
46
|
| `gpumd-thermo` | Export and plot GPUMD thermo data and detect sustained equilibrium changes |
|
|
47
|
-
| `gpumd-trjcat` | Merge
|
|
47
|
+
| `gpumd-trjcat` | Merge normal or all GPUMD trajectories and extract the first abnormal region |
|
|
48
48
|
| `pca` | Reduce descriptor data to two dimensions; optional FPS sampling |
|
|
49
49
|
| `trj-extract` | Extract a GPUMD XYZ trajectory by time range |
|
|
50
50
|
| `trj-sparse` | Deterministically retain a requested fraction of XYZ trajectory frames |
|
|
@@ -110,7 +110,8 @@ pmk umap -i descriptor.out -o umap-descriptor.txt -fps 0.01 -it train.xyz
|
|
|
110
110
|
pmk gpumd-thermo # current job, or recursively scan job folders
|
|
111
111
|
pmk gpumd-thermo -t thermo.out -in run.in
|
|
112
112
|
pmk gpumd-trjcat # stable frames -> train.xyz; abnormal regions -> abnormal.xyz
|
|
113
|
-
pmk gpumd-trjcat -i traj.xyz -o train.xyz -ao abnormal.xyz
|
|
113
|
+
pmk gpumd-trjcat -i traj.xyz -o train.xyz -ao abnormal.xyz
|
|
114
|
+
pmk gpumd-trjcat -all # merge every readable trajectory into train.xyz
|
|
114
115
|
pmk trj-extract -it traj.xyz -in run.in -b 100 -e 200 -o traj-100ps-200ps.xyz
|
|
115
116
|
pmk trj-sparse -it example.xyz -r 0.5 -o sparse-example.xyz
|
|
116
117
|
|
|
@@ -151,11 +152,11 @@ When `pca` or `umap` receives `-it train.xyz`, it reads `Config_type` from every
|
|
|
151
152
|
|
|
152
153
|
For folder conversion, `convert -if INPUT -of OUTPUT` writes `.xyz` by default. Set another target extension with `-oe`, for example `-oe cif` or `-oe vasp`. Single-file and trajectory modes infer the target format from `-o` and `-ot`.
|
|
153
154
|
|
|
154
|
-
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. When at least two
|
|
155
|
+
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. An abnormal classification always requires a mapped potential-energy change. When at least two lattice-parameter or volume signals show the same mapped transition, they may enable a more sensitive noise-relative energy test; this avoids a fixed eV or percentage-of-total-energy threshold that would depend on system size. Cell signals can corroborate and refine the energy interval, but can never classify a run by themselves. Temperature and all six pressure components remain diagnostics only and cannot classify an otherwise stationary run as abnormal by themselves. A lone cell-axis drift, an isolated spike, or an empty anomaly mask never triggers a whole-run fallback. Thermo plots use Arial when available and Matplotlib's built-in qualitative `Dark2` color cycle. They plot all six pressure components, use frameless upper-right legends with added vertical headroom, preserve correct Å units, and show abnormal regions as shaded legend entries on potential energy, lattice parameters, and volume. Potential energy and volume are divided by 1000 and labeled ×10³ only when their absolute plotted values reach 1000. The analysis uses the last `run` segment, or the last 80% when `run.in` has no `run` record; inspect the plot before making a final scientific judgment.
|
|
155
156
|
|
|
156
157
|
The thermo parser follows the [official GPUMD thermo.out format](https://gpumd.org/gpumd/output_files/thermo_out.html): 18 columns are required, `pressure.txt` exports `Pxx Pyy Pzz Pyz Pxz Pxy`, box vectors are interpreted as a full 3×3 matrix, `time_step` propagates between runs, and `dump_thermo` does not.
|
|
157
158
|
|
|
158
|
-
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`.
|
|
159
|
+
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`. By default, normal trajectories are merged in deterministic folder order into `train.xyz` (or `-o`), while only frames from the earliest mapped abnormal interval of each abnormal job are written to `abnormal.xyz` (or `-ao`). With `-all`, every readable full trajectory is merged into `train.xyz` regardless of normal, abnormal, missing-thermo, or failed-thermo status; an analyzable abnormal job still contributes its earliest abnormal interval to `abnormal.xyz`. If no mapped abnormal frames are found, `abnormal.xyz` is not created and a stale file at the selected `-ao` path is removed. Frame times are obtained from `time_step` and `dump_xyz` in that job's `run.in`. In default mode, missing, unreadable, or unmappable jobs are skipped. When `<job>/model.xyz` contains `Config_type`, that value is applied to every exported frame while all other extended-XYZ bytes remain unchanged.
|
|
159
160
|
|
|
160
161
|
`trj-sparse` keeps `max(1, floor(frame_count × ratio))` frames without rewriting their extended-XYZ content. Selection is deterministic and starts with frame zero; for 100 frames and `-r 0.5`, it writes source indices `0, 2, ..., 98`.
|
|
161
162
|
|
|
@@ -389,8 +389,8 @@ def load_thermo(thermo_path, run_path):
|
|
|
389
389
|
segment_mask = potential_abnormal_mask(potential[start:])
|
|
390
390
|
warning_prefix = "potential-energy: localized"
|
|
391
391
|
|
|
392
|
-
#
|
|
393
|
-
#
|
|
392
|
+
# Potential energy is mandatory evidence. Coherent cell changes may lower
|
|
393
|
+
# its threshold and refine the interval, but cannot classify a run alone.
|
|
394
394
|
if not segment_mask.any() and len(cell_warnings) >= 2:
|
|
395
395
|
structural_mask = structural_abnormal_mask(
|
|
396
396
|
lengths[start:], volume[start:]
|
|
@@ -401,13 +401,12 @@ def load_thermo(thermo_path, run_path):
|
|
|
401
401
|
)
|
|
402
402
|
overlap = relaxed_energy & structural_mask
|
|
403
403
|
if overlap.any():
|
|
404
|
-
|
|
404
|
+
corroborated = _keep_major_regions(
|
|
405
405
|
_bridge_mask(overlap, max(1, segment_length // 20))
|
|
406
406
|
)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
warning_prefix = "structure: coherently mapped"
|
|
407
|
+
if corroborated.any():
|
|
408
|
+
segment_mask = corroborated
|
|
409
|
+
warning_prefix = "potential-energy: structurally corroborated"
|
|
411
410
|
|
|
412
411
|
abnormal_mask = np.zeros(len(data), dtype=bool)
|
|
413
412
|
abnormal_mask[start:] = segment_mask
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Merge
|
|
1
|
+
"""Merge GPUMD trajectories and extract each job's first abnormal region."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ except ImportError:
|
|
|
16
16
|
from _gpumd import load_thermo, mask_intervals, trajectory_interval
|
|
17
17
|
|
|
18
18
|
COMMAND = "gpumd-trjcat"
|
|
19
|
-
HELP = "Merge
|
|
19
|
+
HELP = "Merge normal or all GPUMD trajectories; extract first abnormal regions."
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@dataclass(frozen=True)
|
|
@@ -44,6 +44,11 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
|
|
|
44
44
|
help="Structure filename supplying Config_type.")
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"-all", dest="all", action="store_true",
|
|
49
|
+
help="Merge every readable trajectory, regardless of thermo status.",
|
|
50
|
+
)
|
|
51
|
+
|
|
47
52
|
def find_trajectories(root, input_name, outputs):
|
|
48
53
|
root = Path(root).resolve()
|
|
49
54
|
excluded = {Path(path).resolve() for path in outputs}
|
|
@@ -60,18 +65,6 @@ def find_trajectories(root, input_name, outputs):
|
|
|
60
65
|
|
|
61
66
|
def inspect_job(trajectory, args):
|
|
62
67
|
folder = trajectory.parent
|
|
63
|
-
thermo_path = folder / Path(args.thermo).name
|
|
64
|
-
run_path = folder / Path(args.run_input).name
|
|
65
|
-
missing = [path.name for path in (thermo_path, run_path) if not path.is_file()]
|
|
66
|
-
if missing:
|
|
67
|
-
return None, None, f"missing {', '.join(missing)}"
|
|
68
|
-
|
|
69
|
-
try:
|
|
70
|
-
thermo = load_thermo(thermo_path, run_path)
|
|
71
|
-
_, _, interval_ps = trajectory_interval(run_path, trajectory)
|
|
72
|
-
except Exception as exc:
|
|
73
|
-
return None, None, f"thermo check failed ({exc})"
|
|
74
|
-
|
|
75
68
|
try:
|
|
76
69
|
blocks, _ = read_blocks(trajectory)
|
|
77
70
|
except Exception as exc:
|
|
@@ -88,21 +81,31 @@ def inspect_job(trajectory, args):
|
|
|
88
81
|
print(f"{folder}: warning: could not read Config_type ({exc})")
|
|
89
82
|
|
|
90
83
|
job = TrajectoryJob(trajectory, len(blocks), config_type)
|
|
91
|
-
|
|
84
|
+
thermo_path = folder / Path(args.thermo).name
|
|
85
|
+
run_path = folder / Path(args.run_input).name
|
|
86
|
+
missing = [path.name for path in (thermo_path, run_path) if not path.is_file()]
|
|
87
|
+
if missing:
|
|
88
|
+
return job, None, f"missing {', '.join(missing)}"
|
|
92
89
|
|
|
90
|
+
try:
|
|
91
|
+
thermo = load_thermo(thermo_path, run_path)
|
|
92
|
+
_, _, interval_ps = trajectory_interval(run_path, trajectory)
|
|
93
|
+
except Exception as exc:
|
|
94
|
+
return job, None, f"thermo check failed ({exc})"
|
|
95
|
+
return job, (thermo, interval_ps), None
|
|
93
96
|
|
|
94
97
|
def abnormal_frame_indices(thermo, frame_count, interval_ps):
|
|
95
98
|
intervals = mask_intervals(thermo.time, thermo.abnormal_mask)
|
|
99
|
+
if not intervals:
|
|
100
|
+
return ()
|
|
101
|
+
|
|
102
|
+
begin, end = intervals[0]
|
|
96
103
|
tolerance = max(1e-12, interval_ps * 1e-9)
|
|
97
104
|
return tuple(
|
|
98
105
|
index for index in range(frame_count)
|
|
99
|
-
if
|
|
100
|
-
begin - tolerance <= index * interval_ps <= end + tolerance
|
|
101
|
-
for begin, end in intervals
|
|
102
|
-
)
|
|
106
|
+
if begin - tolerance <= index * interval_ps <= end + tolerance
|
|
103
107
|
)
|
|
104
108
|
|
|
105
|
-
|
|
106
109
|
def write_merged(output, jobs):
|
|
107
110
|
output = Path(output)
|
|
108
111
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -138,60 +141,103 @@ def run(args) -> int:
|
|
|
138
141
|
f"Error: no {Path(args.input).name} files found in subfolders of {root}."
|
|
139
142
|
)
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
merged_jobs = []
|
|
142
145
|
abnormal_jobs = []
|
|
143
146
|
skipped = 0
|
|
144
147
|
print(f"Found {len(trajectories)} trajectory file(s).")
|
|
145
148
|
for trajectory in trajectories:
|
|
146
149
|
job, analysis, reason = inspect_job(trajectory, args)
|
|
147
150
|
relative_folder = trajectory.parent.relative_to(root)
|
|
148
|
-
if
|
|
151
|
+
if job is None:
|
|
149
152
|
skipped += 1
|
|
150
153
|
print(f"{relative_folder}: skipped - {reason}")
|
|
151
154
|
continue
|
|
152
155
|
|
|
153
|
-
thermo, interval_ps = analysis
|
|
154
156
|
config = (
|
|
155
157
|
f", Config_type={job.config_type}" if job.config_type is not None else ""
|
|
156
158
|
)
|
|
159
|
+
if analysis is None:
|
|
160
|
+
if args.all:
|
|
161
|
+
merged_jobs.append(job)
|
|
162
|
+
print(
|
|
163
|
+
f"{relative_folder}: included by -all - {job.frame_count} "
|
|
164
|
+
f"frame(s){config}; thermo not checked ({reason})"
|
|
165
|
+
)
|
|
166
|
+
else:
|
|
167
|
+
skipped += 1
|
|
168
|
+
print(f"{relative_folder}: skipped - {reason}")
|
|
169
|
+
continue
|
|
170
|
+
|
|
171
|
+
thermo, interval_ps = analysis
|
|
157
172
|
if not thermo.warnings:
|
|
158
|
-
|
|
159
|
-
|
|
173
|
+
merged_jobs.append(job)
|
|
174
|
+
status = "included by -all (normal)" if args.all else "stable"
|
|
175
|
+
print(
|
|
176
|
+
f"{relative_folder}: {status} - {job.frame_count} frame(s){config}"
|
|
177
|
+
)
|
|
160
178
|
continue
|
|
161
179
|
|
|
180
|
+
if args.all:
|
|
181
|
+
merged_jobs.append(job)
|
|
162
182
|
indices = abnormal_frame_indices(thermo, job.frame_count, interval_ps)
|
|
163
183
|
details = "; ".join(thermo.warnings)
|
|
164
184
|
if not indices:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
185
|
+
if args.all:
|
|
186
|
+
print(
|
|
187
|
+
f"{relative_folder}: included by -all - {job.frame_count} "
|
|
188
|
+
f"frame(s){config}; abnormal interval could not be mapped - {details}"
|
|
189
|
+
)
|
|
190
|
+
else:
|
|
191
|
+
skipped += 1
|
|
192
|
+
print(
|
|
193
|
+
f"{relative_folder}: abnormal but no potential-energy region "
|
|
194
|
+
f"mapped to trajectory frames - {details}"
|
|
195
|
+
)
|
|
170
196
|
continue
|
|
197
|
+
|
|
171
198
|
abnormal_jobs.append(TrajectoryJob(
|
|
172
199
|
job.trajectory, job.frame_count, job.config_type, indices
|
|
173
200
|
))
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
201
|
+
if args.all:
|
|
202
|
+
print(
|
|
203
|
+
f"{relative_folder}: included by -all (abnormal) - all "
|
|
204
|
+
f"{job.frame_count} frame(s){config}; extracted {len(indices)} "
|
|
205
|
+
f"frame(s) from the first abnormal region - {details}"
|
|
206
|
+
)
|
|
207
|
+
else:
|
|
208
|
+
print(
|
|
209
|
+
f"{relative_folder}: abnormal - extracted {len(indices)} of "
|
|
210
|
+
f"{job.frame_count} frame(s) from the first abnormal region"
|
|
211
|
+
f"{config} - {details}"
|
|
212
|
+
)
|
|
178
213
|
|
|
179
|
-
write_merged(output,
|
|
180
|
-
|
|
181
|
-
|
|
214
|
+
write_merged(output, merged_jobs)
|
|
215
|
+
if abnormal_jobs:
|
|
216
|
+
write_merged(abnormal_output, abnormal_jobs)
|
|
217
|
+
else:
|
|
218
|
+
abnormal_output.unlink(missing_ok=True)
|
|
219
|
+
merged_frames = sum(job.frame_count for job in merged_jobs)
|
|
182
220
|
abnormal_frames = sum(len(job.indices) for job in abnormal_jobs)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
221
|
+
if args.all:
|
|
222
|
+
print(
|
|
223
|
+
f"Wrote {merged_frames} frame(s) from {len(merged_jobs)} readable "
|
|
224
|
+
f"job(s) to {args.output}"
|
|
225
|
+
)
|
|
226
|
+
else:
|
|
227
|
+
print(
|
|
228
|
+
f"Wrote {merged_frames} frame(s) from {len(merged_jobs)} stable "
|
|
229
|
+
f"job(s) to {args.output}"
|
|
230
|
+
)
|
|
231
|
+
if abnormal_jobs:
|
|
232
|
+
print(
|
|
233
|
+
f"Wrote {abnormal_frames} frame(s) from {len(abnormal_jobs)} "
|
|
234
|
+
f"abnormal job(s) to {args.abnormal_output}"
|
|
235
|
+
)
|
|
236
|
+
else:
|
|
237
|
+
print(f"No abnormal frames found; did not write {args.abnormal_output}")
|
|
191
238
|
print(f"Skipped {skipped} unreadable or unmappable job(s).")
|
|
192
239
|
return 0
|
|
193
240
|
|
|
194
|
-
|
|
195
241
|
if __name__ == "__main__":
|
|
196
242
|
_parser = argparse.ArgumentParser(description=__doc__)
|
|
197
243
|
add_arguments(_parser)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pymdkit
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.7
|
|
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
|
|
@@ -70,7 +70,7 @@ directory for job sub-folders automatically.
|
|
|
70
70
|
| `vasp-fe` | List VASP job final energies from lowest to highest |
|
|
71
71
|
| `gather-contcar` | Collect CONTCARs from VASP job folders into one folder, renamed `<folder>.vasp` |
|
|
72
72
|
| `gpumd-thermo` | Export and plot GPUMD thermo data and detect sustained equilibrium changes |
|
|
73
|
-
| `gpumd-trjcat` | Merge
|
|
73
|
+
| `gpumd-trjcat` | Merge normal or all GPUMD trajectories and extract the first abnormal region |
|
|
74
74
|
| `pca` | Reduce descriptor data to two dimensions; optional FPS sampling |
|
|
75
75
|
| `trj-extract` | Extract a GPUMD XYZ trajectory by time range |
|
|
76
76
|
| `trj-sparse` | Deterministically retain a requested fraction of XYZ trajectory frames |
|
|
@@ -137,6 +137,7 @@ pmk gpumd-thermo # current job, or recursively scan
|
|
|
137
137
|
pmk gpumd-thermo -t thermo.out -in run.in
|
|
138
138
|
pmk gpumd-trjcat # stable frames -> train.xyz; abnormal regions -> abnormal.xyz
|
|
139
139
|
pmk gpumd-trjcat -i traj.xyz -o train.xyz -ao abnormal.xyz
|
|
140
|
+
pmk gpumd-trjcat -all # merge every readable trajectory into train.xyz
|
|
140
141
|
pmk trj-extract -it traj.xyz -in run.in -b 100 -e 200 -o traj-100ps-200ps.xyz
|
|
141
142
|
pmk trj-sparse -it example.xyz -r 0.5 -o sparse-example.xyz
|
|
142
143
|
|
|
@@ -177,11 +178,11 @@ When `pca` or `umap` receives `-it train.xyz`, it reads `Config_type` from every
|
|
|
177
178
|
|
|
178
179
|
For folder conversion, `convert -if INPUT -of OUTPUT` writes `.xyz` by default. Set another target extension with `-oe`, for example `-oe cif` or `-oe vasp`. Single-file and trajectory modes infer the target format from `-o` and `-ot`.
|
|
179
180
|
|
|
180
|
-
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. When at least two
|
|
181
|
+
`gpumd-thermo` writes `temperature.txt`, `potential-energy.txt`, `pressure.txt`, `lattice-parameters.txt`, `volume.txt`, `lattice-angles.txt`, and a headless `thermo.png` in every detected GPUMD job folder. For an abnormal run it also writes `abnormal-time.txt`, with one `BEGIN ps to END ps` interval per line; a normal rerun removes a stale file. Potential energy is the primary equilibrium signal. Detection requires a persistent change with a meaningful magnitude relative to the robust natural energy fluctuations, so ordinary correlated thermal noise and isolated spikes are not classified as abnormal. An abnormal classification always requires a mapped potential-energy change. When at least two lattice-parameter or volume signals show the same mapped transition, they may enable a more sensitive noise-relative energy test; this avoids a fixed eV or percentage-of-total-energy threshold that would depend on system size. Cell signals can corroborate and refine the energy interval, but can never classify a run by themselves. Temperature and all six pressure components remain diagnostics only and cannot classify an otherwise stationary run as abnormal by themselves. A lone cell-axis drift, an isolated spike, or an empty anomaly mask never triggers a whole-run fallback. Thermo plots use Arial when available and Matplotlib's built-in qualitative `Dark2` color cycle. They plot all six pressure components, use frameless upper-right legends with added vertical headroom, preserve correct Å units, and show abnormal regions as shaded legend entries on potential energy, lattice parameters, and volume. Potential energy and volume are divided by 1000 and labeled ×10³ only when their absolute plotted values reach 1000. The analysis uses the last `run` segment, or the last 80% when `run.in` has no `run` record; inspect the plot before making a final scientific judgment.
|
|
181
182
|
|
|
182
183
|
The thermo parser follows the [official GPUMD thermo.out format](https://gpumd.org/gpumd/output_files/thermo_out.html): 18 columns are required, `pressure.txt` exports `Pxx Pyy Pzz Pyz Pxz Pxy`, box vectors are interpreted as a full 3×3 matrix, `time_step` propagates between runs, and `dump_thermo` does not.
|
|
183
184
|
|
|
184
|
-
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`.
|
|
185
|
+
`gpumd-trjcat` recursively scans job subfolders for `traj.xyz`, `thermo.out`, and `run.in`. By default, normal trajectories are merged in deterministic folder order into `train.xyz` (or `-o`), while only frames from the earliest mapped abnormal interval of each abnormal job are written to `abnormal.xyz` (or `-ao`). With `-all`, every readable full trajectory is merged into `train.xyz` regardless of normal, abnormal, missing-thermo, or failed-thermo status; an analyzable abnormal job still contributes its earliest abnormal interval to `abnormal.xyz`. If no mapped abnormal frames are found, `abnormal.xyz` is not created and a stale file at the selected `-ao` path is removed. Frame times are obtained from `time_step` and `dump_xyz` in that job's `run.in`. In default mode, missing, unreadable, or unmappable jobs are skipped. When `<job>/model.xyz` contains `Config_type`, that value is applied to every exported frame while all other extended-XYZ bytes remain unchanged.
|
|
185
186
|
|
|
186
187
|
`trj-sparse` keeps `max(1, floor(frame_count × ratio))` frames without rewriting their extended-XYZ content. Selection is deterministic and starts with frame zero; for 100 frames and `-r 0.5`, it writes source indices `0, 2, ..., 98`.
|
|
187
188
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|