[ase-users] ASE Calculator: delete temporary directory after calculation
Adam Jackson
a.j.jackson at physics.org
Thu May 11 12:44:21 CEST 2017
Dear ASE users,
I'd like to inquire if there is a way to clean-up the temporary files
created by the calculator after running a calculation.
To keep the scripts clean, you could set up a context manager as described here: http://stackoverflow.com/questions/431684/how-do-i-cd-in-python/13197763#13197763
I keep something similar to this example in a personal python library and import it when needed;
it allows calculations to be cleanly wrapped to work in their own folders. Most of my ASE scripts then look something like this:
import ase.io
import ase.db
from ase.calculators.vasp import Vasp
from cookbook import run_directory # import context manager from personal library
atoms = ase.io.read('somefile.cif')
calc = Vasp(xc='pbesol')
with run_directory('vasp_calc'):
atoms.set_calculator(calc)
atoms.get_total_energy()
db = ase.db.connect('results.db')
db.write(atoms)
If you wanted to you could write the __exit__ method to delete the calculation folder after returning to your original working directory. The Atoms and Calculator objects, which contain calculation information, should survive for further analysis and file writing.
-Adam
Dr Adam J. Jackson
Post-doctoral research associate
Dept of Chemistry
University College London
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20170511/e7f88dc3/attachment.html>
More information about the ase-users
mailing list