You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #404 from SCM-NV/modica/vasp_timestep
Added timestep reading from OUTCAR file from VASP in order to correctly indentify the duration of a MD trajectory. Implemented task recognition through IBRION parameter inside the OUTCAR file.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ This changelog is effective from the 2025 releases.
16
16
17
17
### Changed
18
18
*`view` function uses stdin mode for AMSview, reducing overhead for image creation
19
+
*`vasp_output_to_ams` now reads the MD time step from `POTIM` in the OUTCAR and labels molecular-dynamics runs (`IBRION = 0`) as such, instead of using a fixed default time step
19
20
20
21
### Fixed
21
22
* Loading job `.dill` files where the molecule contains a `pathlib.Path` (e.g. `Molecule.properties.source`)
"""Read (IBRION, POTIM) from the INCAR reproduced at the top of a VASP OUTCAR.
227
+
Only the first `max_lines` lines are scanned. Either value is None if not found."""
228
+
ibrion, potim=None, None
229
+
withopen(outcar_path) asf:
230
+
fori, lineinenumerate(f):
231
+
ifi>=max_lines:
232
+
break
233
+
ifibrionisNoneand"IBRION"inline:
234
+
m=re.search(r"IBRION\s*=\s*(-?\d+)", line)
235
+
ifm:
236
+
ibrion=int(m.group(1))
237
+
ifpotimisNoneand"POTIM"inline:
238
+
m=re.search(r"POTIM\s*=\s*([\d.]+)", line)
239
+
ifm:
240
+
potim=float(m.group(1))
241
+
ifibrionisnotNoneandpotimisnotNone:
242
+
break
243
+
returnibrion, potim
244
+
245
+
222
246
defvasp_output_to_ams(
223
247
vasp_folder: str,
224
248
wdir: Optional[str] =None,
225
249
overwrite: bool=False,
226
250
write_engine_rkf: bool=True,
227
251
task: Optional[str] =None,
228
-
timestep: float=0.25,
252
+
timestep: Optional[float]=None,
229
253
) ->str:
230
254
"""
231
255
Converts VASP output (OUTCAR, ...) to AMS output (ams.rkf, vasp.rkf)
@@ -247,10 +271,14 @@ def vasp_output_to_ams(
247
271
If True, also write vasp.rkf alongside ams.rkf. The vasp.rkf file will only contain an AMSResults section (energy, gradients, stress tensor). It will not contain the DOS or the band structure.
248
272
249
273
task : str
250
-
Which task to write to ams.rkf. If None it is auto-determined (probably set to 'geometryoptimization')
251
-
252
-
timestep : float
253
-
If task='moleculardynamics', which timestep (in fs) between frames to write
274
+
Which task to write to ams.rkf. If None it is auto-determined:
275
+
'moleculardynamics' if the OUTCAR is an MD run (IBRION = 0), otherwise
276
+
determined from the trajectory (singlepoint / geometryoptimization).
277
+
278
+
timestep : float or None
279
+
Time (in fs) between frames written to ams.rkf for an MD run.
280
+
If None (default), it is taken from POTIM in the OUTCAR when the run is
281
+
molecular dynamics (IBRION = 0); for non-MD runs no physical timestep applies.
254
282
"""
255
283
ifnotos.path.isdir(vasp_folder):
256
284
raiseValueError(f"Directory {vasp_folder} does not exist")
0 commit comments