stfc / janus-core

Tools for machine learnt interatomic potentials
https://stfc.github.io/janus-core/
BSD 3-Clause "New" or "Revised" License
10 stars 7 forks source link

`--file-prefix` does not create directories #269

Closed ajjackson closed 2 weeks ago

ajjackson commented 1 month ago

If the --file-prefix argument to janus phonons includes a new directory e.g. phonons/system, Janus will calculate the forces and then fail to write anything as Phonopy complains it cannot write to a file in a non-existent directory.

We can avoid this situation by using Pathlib to create the new filename and make the directory if necessary before moving on:

phonopy_file = Path(file_prefix).with_suffix("-phonopy.yml")
phonopy_file.parent.mkdir(parents=True, exist_ok=True)
self.write_force_constants(...)