Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Murnaghan: Round children names #1121

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions pyiron_atomistics/atomistics/master/murnaghan.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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 @@ -79,6 +80,16 @@ def publication(self):


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 @@ -87,22 +98,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
Loading