Skip to content

Commit

Permalink
Murnaghan: Round children names
Browse files Browse the repository at this point in the history
When the job name of the murnaghan is long; using ~10 digits for the strain can blow the job name limit.
So I added some rounding here.
  • Loading branch information
pmrv committed Jul 25, 2023
1 parent e3ba5da commit c3c6230
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pyiron_atomistics/atomistics/master/murnaghan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pyiron_atomistics.atomistics.master.parallel import AtomisticParallelMaster
from pyiron_atomistics.atomistics.structure.atoms import Atoms, ase_to_pyiron
from pyiron_base import JobGenerator
from pyiron_base.jobs.job.util import _get_safe_job_name

__author__ = "Joerg Neugebauer, Jan Janssen"
__copyright__ = (
Expand Down Expand Up @@ -331,6 +332,16 @@ def _strain_axes(


class MurnaghanJobGenerator(JobGenerator):
def _get_strains(self):
strains = self._master.input.get("strains")
if strains is None:
strains = np.linspace(
-self._master.input["vol_range"],
self._master.input["vol_range"],
int(self._master.input["num_points"]),
)
return strains

@property
def parameter_list(self):
"""
Expand All @@ -339,22 +350,23 @@ def parameter_list(self):
(list)
"""
parameter_lst = []
strains = self._master.input.get("strains")
if strains is None:
strains = np.linspace(
-self._master.input["vol_range"],
self._master.input["vol_range"],
int(self._master.input["num_points"]),
)
for strain in strains:
for strain in self._get_strains():
basis = _strain_axes(
self._master.structure, self._master.input["axes"], strain
)
parameter_lst.append([1 + np.round(strain, 7), basis])
return parameter_lst

def job_name(self, parameter):
return "{}_{}".format(self._master.job_name, parameter[0]).replace(".", "_")
# writing the strain to float precision can blow up the job name of the
# children; so figure out how much we really need here
# find the smallest change in strain
delta = np.min(np.abs(np.diff(self._get_strains())))
# we need at most log(delta) decimal places to give unique children
# names; if delta >= 1, rounding to 0 is sufficient
ndigits = max(-int(np.floor(np.log10(delta))), 0)
return _get_safe_job_name((self._master.job_name, parameter[0]),
ndigits=ndigits)

def modify_job(self, job, parameter):
job.structure = parameter[1]
Expand Down

0 comments on commit c3c6230

Please sign in to comment.