macer 0.1.0__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.
macer-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 The Macer Package Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
macer-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: macer
3
+ Version: 0.1.0
4
+ Summary: MACE + ASE based relaxer for fast atomic structure optimization with VASP compatible format
5
+ License: MIT
6
+ Requires-Python: >=3.8
7
+ License-File: LICENSE
8
+ Requires-Dist: numpy
9
+ Requires-Dist: matplotlib
10
+ Requires-Dist: ase>=3.20
11
+ Requires-Dist: pymatgen
12
+ Requires-Dist: monty
13
+ Requires-Dist: mace-torch
14
+ Dynamic: license-file
macer-0.1.0/README.md ADDED
@@ -0,0 +1,347 @@
1
+ <img src="docs/macer_logo.png" alt="macer Logo" width="20%">
2
+
3
+ # macer
4
+
5
+ ![Version](https://img.shields.io/badge/version-0.1.0-blue.svg)
6
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
7
+
8
+ **macer: A [MACE](https://github.com/ACEsuit/mace) + [ASE](https://github.com/DeepChoudhuri/Atomic-Simulation-Environment) based CLI for fast atomic structure optimization, molecular dynamics, and phonon calculations with VASP compatible formats.**
9
+
10
+ The `macer` package provides an automated command-line workflow for crystal structure relaxation, molecular dynamics simulations, and phonon calculations, leveraging MACE (Machine-Learned Atomistic Energy) models and ASE (Atomic Simulation Environment).
11
+
12
+ ---
13
+
14
+ ## Key Features
15
+
16
+ - **MACE Calculator**: Utilizes MACE as the interatomic potential calculator for both relaxation and MD.
17
+ - **ASE FIRE Optimizer**: Employs the robust FIRE algorithm for geometry relaxation.
18
+ - **VASP ISIF Compatibility**: Supports relaxation modes `ISIF` 0–7.
19
+ - **Molecular Dynamics**: Performs NPT and NVT (Nose–Hoover chain / Berendsen) ensemble simulations.
20
+ - **Phonon Calculations**: Uses Phonopy to calculate phonon dispersion curves and density of states (DOS).
21
+ - **pydefect Integration**: Generates `pydefect`-compatible output files with the `--pydefect` flag for relaxation.
22
+ - **Phonopy Compatibility**: Generates a minimal, Phonopy-compatible `vasprun.xml` for relaxation.
23
+ - **Batch Processing**: Automatically processes multiple structure files (e.g., `POSCAR-*`) for relaxation.
24
+ - **Flexible Model Path**: Specify any MACE model via the `--model` argument for all commands.
25
+ - **Logging & Plotting**: Automatically generates log files and PDF energy/force plots for relaxation. MD simulations produce detailed text logs, trajectory files, XDATCAR, and CSV output files.
26
+ - **Fixed-Axis Relaxation**: Supports fixed-axis relaxation via `--fix-axis a,b,c`.
27
+
28
+ ---
29
+
30
+ ## MACE Model Attribution
31
+
32
+ This project utilizes the MACE (Machine Learning for Atomistic Calculations) model for interatomic potentials. The MACE model and its foundational work are developed by the ACEsuit team.
33
+
34
+ For more information, please refer to the official MACE Foundations GitHub repository:
35
+ [https://github.com/ACEsuit/mace-foundations](https://github.com/ACEsuit/mace-foundations)
36
+
37
+ ---
38
+
39
+ ## References
40
+
41
+ If you use the MACE model, please cite these papers:
42
+
43
+ ```bibtex
44
+ @inproceedings{Batatia2022mace,
45
+ title={{MACE}: Higher Order Equivariant Message Passing Neural Networks for Fast and Accurate Force Fields},
46
+ author={Ilyes Batatia and David Peter Kovacs and Gregor N. C. Simm and Christoph Ortner and Gabor Csanyi},
47
+ booktitle={Advances in Neural Information Processing Systems},
48
+ editor={Alice H. Oh and Alekh Agarwal and Danielle Belgrave and Kyunghyun Cho},
49
+ year={2022},
50
+ url={https://openreview.net/forum?id=YPpSngE-ZU}
51
+ }
52
+
53
+ @misc{Batatia2022Design,
54
+ title = {The Design Space of E(3)-Equivariant Atom-Centered Interatomic Potentials},
55
+ author = {Batatia, Ilyes and Batzner, Simon and Kov{'a}cs, D{'a}vid P{'e}ter and Musaelian, Albert and Simm, Gregor N. C. and Drautz, Ralf and Ortner, Christoph and Kozinsky, Boris and A. Kozinsky and Cs{'a}nyi, G{'a}bor}, # Corrected author list
56
+ year = {2022},
57
+ number = {arXiv:2205.06643},
58
+ eprint = {2205.06643},
59
+ eprinttype = {arxiv},
60
+ doi = {10.48550/arXiv.2205.06643},
61
+ archiveprefix = {arXiv}
62
+ }
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Installation
68
+
69
+ You can install `macer` directly from the source directory using `pip`.
70
+
71
+ ```bash
72
+ # Navigate to the macer package directory
73
+ cd /path/to/macer
74
+
75
+ # Install the package in editable mode
76
+ pip install -e .
77
+ ```
78
+ This will install the package and make the `macer` and `macer_phonopy` commands available in your terminal.
79
+
80
+ ---
81
+
82
+ ## Usage
83
+
84
+ The `macer` CLI now supports multiple subcommands for different simulation types.
85
+
86
+ ```bash
87
+ # Get general help
88
+ macer -h
89
+
90
+ # Get help for the 'relax' command
91
+ macer relax -h
92
+
93
+ # Get help for the 'md' command
94
+ macer md -h
95
+
96
+ # Get help for the 'macer_phonopy' command
97
+ macer_phonopy -h
98
+ ```
99
+
100
+ ### Relaxation Examples (`macer relax`)
101
+
102
+ ```bash
103
+ # Standard atomic relaxation (ISIF=2: atomic positions only)
104
+ macer relax --poscar POSCAR
105
+
106
+ # Batch relaxation for multiple structures
107
+ macer relax --poscar POSCAR-* --isif 2
108
+
109
+ # Full cell relaxation (atoms + lattice)
110
+ macer relax --poscar POSCAR --isif 3
111
+
112
+ # Use a different MACE model
113
+ macer relax --poscar POSCAR --model /path/to/your/mace.model
114
+
115
+ # Generate outputs for PyDefect
116
+ macer relax --poscar POSCAR --isif 0 --pydefect
117
+
118
+ # Relaxation with fixed a-axis
119
+ macer relax --poscar POSCAR --isif 3 --fix-axis a
120
+
121
+ # Disable PDF log plotting
122
+ macer relax --poscar POSCAR --no-pdf
123
+ ```
124
+
125
+ ### Molecular Dynamics Examples (`macer md`)
126
+
127
+ ```bash
128
+ # NPT (Nose–Hoover barostat) — 600 K, 1 GPa, GPU (MPS), save every 100 steps
129
+ macer md --ensemble npt --temp 600 --press 1.0 --ttau 100 --ptau 1000 \
130
+ --device mps --nsteps 20000 --save-every 100
131
+
132
+ # NVT (NTE; prefers Nose–Hoover chain, falls back to Berendsen) — 600 K, 5000 steps
133
+ macer md --ensemble nte --temp 600 --ttau 100 --nsteps 5000
134
+
135
+ # Reproducible run (fixed seed) + adjusted print/save intervals
136
+ macer md --ensemble npt --temp 300 --press 0.0 --ttau 100 --ptau 1000 \
137
+ --seed 42 --print-every 10 --save-every 100
138
+ ```
139
+
140
+ ### Phonon Calculation Examples (`macer_phonopy`)
141
+
142
+ The `macer_phonopy` command provides utilities for Phonopy-related tasks, including unit cell relaxation/symmetrization and band path generation.
143
+
144
+ ```bash
145
+ # Get basic help for macer_phonopy and its subcommands
146
+ macer_phonopy -h
147
+ macer_phonopy ru -h
148
+ macer_phonopy bp -h
149
+ ```
150
+
151
+ #### Unit Cell Relaxation and Symmetrization (`macer_phonopy ru` or `macer_phonopy relax_unit`)
152
+
153
+ This subcommand iteratively optimizes and symmetrizes a unit cell, which is crucial for preparing structures for phonon calculations.
154
+
155
+ ```bash
156
+ # Relax and symmetrize a unit cell using the default MACE model
157
+ macer_phonopy ru --poscar POSCAR
158
+
159
+ # Relax and symmetrize with a specific MACE model and increased symmetry tolerance
160
+ macer_phonopy ru --poscar POSCAR --model /path/to/your/mace.model --tolerance 1e-2
161
+
162
+ # Relax and symmetrize with custom output prefix
163
+ macer_phonopy ru --poscar POSCAR --output-prefix my_symmetrized_cell
164
+ ```
165
+
166
+ #### Band Path Generation (`macer_phonopy bp` or `macer_phonopy bandpath`)
167
+
168
+ This subcommand generates a Phonopy `band.conf` file directly from a `POSCAR` using SeeK-path, eliminating the need for external tools like VASPKIT.
169
+
170
+ ```bash
171
+ # Generate band.conf from POSCAR
172
+ macer_phonopy bp --poscar POSCAR --out band.conf
173
+
174
+ # Generate band.conf with a specific supercell dimension and custom gamma label
175
+ macer_phonopy bp --poscar POSCAR --dim "2 2 2" --gamma "Γ" --out my_band.conf
176
+
177
+ # Generate band.conf and include default FORCE_SETS, FC_SYMMETRY, EIGENVECTORS
178
+ macer_phonopy bp --poscar POSCAR --no-defaults
179
+ ```
180
+
181
+ For precise usage of `macer_phonopy` and its subcommands, please refer to `macer_phonopy -h`, `macer_phonopy ru -h`, `macer_phonopy bp -h`, and the official Phonopy documentation.
182
+
183
+ ---
184
+
185
+ ## 📂 Output Files
186
+
187
+ ### Relaxation Output Files
188
+
189
+ For each input file (e.g., `POSCAR-001`), the following files are produced:
190
+
191
+ ```
192
+ CONTCAR-POSCAR-001
193
+ OUTCAR-POSCAR-001
194
+ vasprun-POSCAR-001.xml
195
+ relax-POSCAR-001_log.txt
196
+ relax-POSCAR-001_log.pdf
197
+ ```
198
+
199
+ If the `--pydefect` flag is used, the following additional files are created:
200
+ ```
201
+ calc_results.json
202
+ perfect_band_edge_state.json (dummy)
203
+ unitcell.yaml (dummy)
204
+ ```
205
+
206
+ ### Molecular Dynamics Output Files
207
+
208
+ For MD simulations, the following files are produced:
209
+
210
+ ```
211
+ md.traj # ASE trajectory file
212
+ md.log # Text log of MD progress
213
+ XDATCAR # VASP-like XDATCAR file
214
+ md.csv # CSV log of observables (energy, temperature, pressure, etc.)
215
+ ```
216
+
217
+ ### Phonon Calculation Output Files
218
+
219
+ `macer_phonopy` generates standard Phonopy output files. These may include:
220
+
221
+ ```
222
+ band.yaml # Phonon band structure data
223
+ mesh.yaml # Phonon density of states (DOS) data
224
+ total_dos.dat # Total DOS data
225
+ partial_dos.dat # Partial DOS data
226
+ ```
227
+ The exact files generated depend on the options passed to the `macer_phonopy` command and your Phonopy configuration.
228
+
229
+ ---
230
+
231
+ ## Command Line Options
232
+
233
+ ### `macer relax` Options
234
+
235
+ | Option | Description | Default |
236
+ |--------|-------------|---------|
237
+ | `-p`, `--poscar` | Input POSCAR file(s) or glob pattern(s) (e.g., `POSCAR-*`) | `POSCAR` |
238
+ | `--model` | Path to the MACE model file. By default, it expects `mace-omat-0-small-fp32.model` to be located in the `mace-model` directory. | `mace-model/mace-omat-0-small-fp32.model` |
239
+ | `--isif` | VASP ISIF mode (0–7) for relaxation. | 2 |
240
+ | `--fmax` | Force convergence threshold (eV/Å). | 0.01 |
241
+ | `--smax` | Stress convergence threshold (eV/ų). | 0.001 |
242
+ | `--device` | Calculation device (`cpu`, `mps`, `cuda`). | `cpu` |
243
+ | `--fix-axis` | Fix lattice axes (comma-separated, e.g., `a` or `a,c`). | None |
244
+ | `--pydefect` | Write PyDefect-compatible output files. | False |
245
+ | `--quiet` | Suppress detailed stdout logging. | False |
246
+ | `--no-pdf` | Do not write the `relax-*_log.pdf` plot. | False |
247
+ | `--contcar`| Custom name for the output CONTCAR file. | `CONTCAR-<prefix>` |
248
+ | `--outcar` | Custom name for the output OUTCAR file. | `OUTCAR-<prefix>` |
249
+ | `--vasprun`| Custom name for the output vasprun.xml file. | `vasprun-<prefix>.xml` |
250
+
251
+ ### `macer md` Options
252
+
253
+ | Option | Description | Default |
254
+ |--------|-------------|---------|
255
+ | `-p`, `--poscar` | Input POSCAR file (VASP format atomic structure input). | `POSCAR` |
256
+ | `--model` | MACE model path. | `mace-model/mace-omat-0-small-fp32.model` |
257
+ | `--device` | Compute device (`cpu`, `mps`, `cuda`). | `cpu` |
258
+ | `--ensemble` | MD ensemble: `npt` (Nose–Hoover barostat) or `nte` (=NVT; Nose–Hoover chain preferred, else Berendsen). | `npt` |
259
+ | `--temp` | Target temperature [K]. | 300.0 |
260
+ | `--press` | Target pressure [GPa] (NPT only). | 0.0 |
261
+ | `--tstep` | MD time step [fs]. | 2.0 |
262
+ | `--nsteps` | Number of MD steps. | 20000 |
263
+ | `--ttau` | Thermostat time constant [fs]. | 100.0 |
264
+ | `--ptau` | Barostat time constant [fs] (NPT only). | 1000.0 |
265
+ | `--save-every` | Trajectory/log save interval. | 100 |
266
+ | `--xdat-every` | XDATCAR write interval. | 1 |
267
+ | `--print-every` | Stdout print interval. | 1 |
268
+ | `--seed` | Random seed (None for random). | None |
269
+ | `--csv` | CSV log path for MD outputs. | `md.csv` |
270
+ | `--xdatcar` | XDATCAR path. | `XDATCAR` |
271
+ | `--traj` | ASE trajectory path. | `md.traj` |
272
+ | `--log` | MD text log path. | `md.log` |
273
+
274
+ ### `macer_phonopy` Options
275
+
276
+ The `macer_phonopy` command wraps Phonopy's command-line interface. For detailed options, refer to `macer_phonopy -h` or the official Phonopy documentation. Commonly used options include:
277
+
278
+ | Option | Description |
279
+ |--------|-------------|
280
+ | `-c`, `--conf` | Phonopy configuration file (e.g., `phonopy.conf`). |
281
+ | `--dim` | Supercell dimensions (e.g., `2 2 2`). |
282
+ | `--mesh` | Mesh sampling (e.g., `20 20 20`). |
283
+ | `--band` | Band path configuration file (e.g., `band.conf`). |
284
+ | `--dos` | Calculate density of states (DOS). |
285
+ | `--pdos` | Calculate partial density of states (PDOS). |
286
+ | `--readfc` | Read force constants. |
287
+ | `--writefc` | Write force constants. |
288
+ | `--fmax` | Force convergence threshold (used for MACE calculations). |
289
+ | `--model` | Path to the MACE model file. |
290
+ | `--device` | Calculation device (`cpu`, `mps`, `cuda`). |
291
+
292
+ ---
293
+
294
+ ## Dependencies
295
+
296
+ All required Python packages are listed in `pyproject.toml` and will be installed automatically by `pip`.
297
+
298
+ - Python ≥ 3.8
299
+ - ASE ≥ 3.20
300
+ - matplotlib
301
+ - numpy
302
+ - mace-torch
303
+ - pymatgen
304
+ - monty
305
+
306
+ ---
307
+ ## Related packages
308
+ - phonopy [https://github.com/phonopy/phonopy](https://github.com/phonopy/phonopy)
309
+ - pydefect [https://github.com/kumagai-group/pydefect](https://github.com/kumagai-group/pydefect)
310
+ ---
311
+
312
+ ## Standalone Scripts (Fallback Option)
313
+
314
+ If you encounter issues with `pip` installation or prefer to run the original scripts directly, standalone versions of the `mace_ase_relax.py` and `mace_ase_md.py` scripts are provided in the `scripts/` directory.
315
+
316
+ **Usage:**
317
+
318
+ 1. **Navigate to the `scripts` directory:**
319
+ ```
320
+ cd /path/to/macer_repo/scripts
321
+ ```
322
+ 2. **Edit the script:** Open `mace_ase_relax.py` or `mace_ase_md.py` and update the `model_path` variable within the `get_mace_calculator` function to point to your MACE model file.
323
+ 3. **Run the script:**
324
+ ```bash
325
+ python mace_ase_relax.py -i POSCAR --isif 3
326
+ python mace_ase_md.py --ensemble npt --temp 300
327
+ ```
328
+ All command-line arguments are identical to the `macer relax` and `macer md` commands, respectively.
329
+
330
+ ---
331
+
332
+ ## License
333
+
334
+ This project is licensed under the **MIT License**. See the `LICENSE` file for details.
335
+
336
+ ---
337
+
338
+ ## Notes
339
+
340
+ - `vasprun-*.xml` is a **minimal** VASP-like XML that Phonopy can parse for forces/energies.
341
+ - For batch runs, the script writes **per-input** outputs with the input file name appended (e.g., `CONTCAR-POSCAR-001`).
342
+
343
+ ---
344
+ ## Contributors
345
+ - **Soungmin Bae** — [soungminbae@gmail.com](mailto:soungminbae@gmail.com), Tohoku University
346
+ - **Yasuhide Mochizuki** — [mochigmail](mailto:mochigmail), Institute of Tokyo, Science
347
+
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ from mace.calculators import MACECalculator
2
+ from pathlib import Path
3
+
4
+ def get_mace_calculator(model_paths, device="cpu"):
5
+ """Construct MACE calculator (use float32 for MPS compatibility)."""
6
+ if model_paths is None:
7
+ # Use default model if none is provided
8
+ # Assuming the default model is in the project root under mace-model/
9
+ default_model_path = Path(__file__).parent.parent.parent / "mace-model" / "mace-omat-0-small-fp32.model"
10
+ if not default_model_path.exists():
11
+ raise FileNotFoundError(f"Default MACE model not found at {default_model_path}")
12
+ model_paths = [str(default_model_path)]
13
+
14
+ dtype = "float32" if device == "mps" else "float64"
15
+ return MACECalculator(
16
+ model_paths=model_paths,
17
+ device=device,
18
+ default_dtype=dtype,
19
+ )
File without changes
@@ -0,0 +1,123 @@
1
+ import argparse
2
+ import sys
3
+ import os
4
+ import glob
5
+
6
+ from macer.utils.logger import Logger
7
+ from macer.relaxation.optimizer import relax_structure
8
+ from macer.io.writers import write_pydefect_dummy_files
9
+ from macer.molecular_dynamics.cli import get_md_parser, run_md_simulation # Import get_md_parser and run_md_simulation
10
+
11
+ def main():
12
+ parser = argparse.ArgumentParser(
13
+ description="macer: MACE+ASE based ML-accerlatied relaxer and molecular dynamics engine with VASP compatible format.",
14
+ formatter_class=argparse.RawDescriptionHelpFormatter
15
+ )
16
+
17
+ subparsers = parser.add_subparsers(dest="command", help="Available commands")
18
+
19
+ # Relaxation command
20
+ relax_parser = subparsers.add_parser(
21
+ "relax",
22
+ description="Relax atomic structures using MACE with VASP-like ISIF modes. Supports multiple input files (POSCAR-*).",
23
+ formatter_class=argparse.RawDescriptionHelpFormatter
24
+ )
25
+ relax_parser.add_argument("--poscar", "-p", type=str, nargs="+", default=["POSCAR"],
26
+ help="Input POSCAR file(s) or pattern(s) (VASP format atomic structure input, e.g. POSCAR-*).")
27
+ relax_parser.add_argument("--model", type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "mace-model", "mace-omat-0-small-fp32.model"),
28
+ help="Path to the MACE model file.")
29
+ relax_parser.add_argument("--fmax", type=float, default=0.01, help="Force convergence threshold (eV/Å).")
30
+ relax_parser.add_argument("--smax", type=float, default=0.001, help="Stress convergence threshold (eV/ų).")
31
+ relax_parser.add_argument("--device", type=str, default="cpu", choices=["cpu", "mps", "cuda"])
32
+ relax_parser.add_argument("--isif", type=int, default=2, choices=list(range(8)))
33
+ relax_parser.add_argument("--fix-axis", type=str, default="")
34
+ relax_parser.add_argument("--quiet", action="store_true")
35
+ relax_parser.add_argument("--no-pdf", action="store_true", help="Disable log PDF output")
36
+ relax_parser.add_argument("--pydefect", action="store_true", help="Write PyDefect-compatible files (calc_results.json, unitcell.yaml, perfect_band_edge_state.json).")
37
+ relax_parser.add_argument("--contcar", type=str, default=None, help="Output CONTCAR file name.")
38
+ relax_parser.add_argument("--outcar", type=str, default=None, help="Output OUTCAR file name.")
39
+ relax_parser.add_argument("--vasprun", type=str, default=None, help="Output vasprun.xml file name.")
40
+
41
+ # MD command
42
+ # Get the MD parser from md.py and use it as a parent
43
+ md_base_parser = get_md_parser()
44
+ md_parser = subparsers.add_parser(
45
+ "md",
46
+ description=md_base_parser.description, # Use description from md_base_parser
47
+ epilog=md_base_parser.epilog, # Use epilog from md_base_parser
48
+ formatter_class=argparse.RawDescriptionHelpFormatter,
49
+ parents=[md_base_parser] # Add md_base_parser as a parent
50
+ )
51
+
52
+ args = parser.parse_args()
53
+
54
+ if args.command == "relax":
55
+ fix_axis = [ax.strip().lower() for ax in args.fix_axis.split(",") if ax.strip()]
56
+
57
+ input_patterns = args.poscar
58
+ input_files = []
59
+ for pat in input_patterns:
60
+ input_files.extend(glob.glob(pat))
61
+ input_files = sorted(set(input_files))
62
+
63
+ if not input_files:
64
+ print(f"❌ No files match pattern(s): {input_patterns}")
65
+ sys.exit(1)
66
+
67
+ if (args.contcar or args.outcar or args.vasprun) and len(input_files) > 1:
68
+ print("⚠️ WARNING: Custom output names (--contcar, --outcar, --vasprun) are used with multiple input files.")
69
+ print("Output files may be overwritten. Consider running files one by one.")
70
+
71
+ orig_stdout = sys.stdout
72
+
73
+ for infile in input_files:
74
+ prefix = os.path.basename(infile)
75
+ output_dir = os.path.dirname(infile) or "."
76
+ log_name = os.path.join(output_dir, f"relax-{prefix}_log.txt")
77
+
78
+ contcar_name = os.path.join(output_dir, args.contcar or f"CONTCAR-{prefix}")
79
+ outcar_name = os.path.join(output_dir, args.outcar or f"OUTCAR-{prefix}")
80
+ xml_name = os.path.join(output_dir, args.vasprun or f"vasprun-{prefix}.xml")
81
+
82
+ try:
83
+ with Logger(log_name) as lg:
84
+ sys.stdout = lg
85
+ if args.pydefect:
86
+ write_pydefect_dummy_files(output_dir)
87
+ print("NOTE: perfect_band_edge_state.json and unitcell.yaml were written as dummy files for pydefect dei and pydefect des.")
88
+ print(f"▶ Using MACE on '{infile}' | ISIF={args.isif} | fmax={args.fmax} | smax={args.smax} | device={args.device}")
89
+ relax_structure(
90
+ input_file=infile,
91
+ fmax=args.fmax,
92
+ smax=args.smax,
93
+ device=args.device,
94
+ isif=args.isif,
95
+ fix_axis=fix_axis,
96
+ quiet=args.quiet,
97
+ contcar_name=contcar_name,
98
+ outcar_name=outcar_name,
99
+ xml_name=xml_name,
100
+ make_pdf=not args.no_pdf,
101
+ write_json=args.pydefect,
102
+ model_path=args.model
103
+ )
104
+ results_path_info = f"in '{output_dir}'" if output_dir else "in the current directory"
105
+ print(f"✅ Finished {infile} → Results saved {results_path_info}")
106
+ print("-" * 80)
107
+ except Exception as e:
108
+ sys.stdout = orig_stdout
109
+ print(f"[SKIP] {infile}: {e}")
110
+ continue
111
+ finally:
112
+ sys.stdout = orig_stdout
113
+
114
+ elif args.command == "md":
115
+ run_md_simulation(args) # Call the run_md_simulation function with parsed args
116
+
117
+ else:
118
+ parser.print_help()
119
+ sys.exit(1)
120
+
121
+
122
+ if __name__ == "__main__":
123
+ main()