Skip to content

Commit

Permalink
Refuse to everwrite existing calcs in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jochym committed Oct 29, 2024
1 parent 2f3b21f commit a51d662
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 77 deletions.
134 changes: 60 additions & 74 deletions 02_CLI.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hecss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.5.27"
__version__ = "0.5.28"

from .core import *

21 changes: 20 additions & 1 deletion hecss/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import ase
from ase.calculators.vasp import Vasp
from ase import units as un
from numpy import savetxt, loadtxt, array
from numpy import savetxt, loadtxt, array, sqrt
from hecss import *
import hecss
from hecss.util import write_dfset, calc_init_xscale
Expand Down Expand Up @@ -99,6 +99,7 @@ def hecss_sampler(fname, workdir, label, temp, width, ampl, scale, symprec, calc
f'Calculator: {calc}')

src_path = Path(fname)
workdir = Path(workdir)
Ep0 = None
if calc=="VASP":
calculator = Vasp(label=label, directory=src_path.parent, restart=True)
Expand Down Expand Up @@ -153,13 +154,31 @@ def hecss_sampler(fname, workdir, label, temp, width, ampl, scale, symprec, calc
sampler.xscale_init = loadtxt(ampl)

if width is None and neta > 0:
if (workdir/'w_est').exists() :
print(f'Directory {workdir/"w_est"} exists.')
print('Make sure you specified correct working directory.')
print('I refuse to overwrite existing calculations.')
print(f'Either specify w on the command line, \n'
f'or remove w_est directory from {workdir}.')
if (workdir/'w_est/w_est.dat').exists():
wm = loadtxt(workdir/'w_est/w_est.dat').T
y = sqrt((3*wm[1]*un.kB)/(2*wm[2]))
print(f'Width scale from {workdir/"w_est/w_est.dat"} data: {y.mean():.3g}+/-{y.std():.3g}')
return
print('Estimating width scale.')
eta, sigma, xscale = sampler.estimate_width_scale(neta, Tmin=temp/2, Tmax=temp, pbar=sampler._pbar, nwork=nwork)
if nsamples <= 1:
print(f'Width scale from {neta} pts.: {eta:.3g}+/-{sigma:.3g}')
print('Width scale estimation run (N<2). Not running sampling.')
return

if (workdir/f"T_{temp:.1f}K").exists():
print(f'Directory {workdir/f"T_{temp:.1f}K"} exists.')
print('Make sure you specified correct working directory.')
print('I refuse to overwrite existing calculations.')
print(f'Correct your workdir or move {workdir/f"T_{temp:.1f}K"} to a different location.')
return

print('Sampling configurations')
samples = sampler.sample(temp, nsamples,
width_list=wl,
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ author = Paweł T. Jochym
author_email = [email protected]
copyright = Paweł T. Jochym
branch = devel
version = 0.5.27
version = 0.5.28
min_python = 3.7
audience = Science/Research
language = English
Expand Down

0 comments on commit a51d662

Please sign in to comment.