Skip to content

Commit 6e0e41d

Browse files
committed
Fixed the save ensemble also in the vc_relax mode if ensemble_loc is not explicitly specified during submission
1 parent 585ff1f commit 6e0e41d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Modules/Relax.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,33 @@ def vc_relax(self, target_press = 0, static_bulk_modulus = 100,
441441
True if the minimization converged, False if the maximum number of
442442
populations has been reached.
443443
"""
444+
445+
# Prepare the saving directory
446+
if ensemble_loc is None:
447+
ensemble_loc = self.data_dir
448+
449+
if (not ensemble_loc) and self.save_ensemble:
450+
ERR_MSG = """
451+
Error, you must specify where to save the ensembles.
452+
this can be done either passing ensemble_loc = "path/to/dir"
453+
for the ensemble, or by setting the data_dir attribute of this object.
454+
"""
455+
raise IOError(ERR_MSG)
456+
457+
if self.save_ensemble:
458+
if not os.path.exists(ensemble_loc):
459+
os.makedirs(ensemble_loc)
460+
else:
461+
if not os.path.isdir(ensemble_loc):
462+
ERR_MSG = """
463+
Error, the specified location to save the ensemble:
464+
'{}'
465+
already exists and it is not a directory.
466+
""".format(ensemble_loc)
467+
raise IOError(ERR_MSG)
468+
469+
470+
444471
# Rescale the target pressure in eV / A^3
445472
target_press_evA3 = target_press / sscha.SchaMinimizer.__evA3_to_GPa__
446473
I = np.eye(3, dtype = np.float64)

0 commit comments

Comments
 (0)