From a43b6fba578b70caed24afed7bc21595dd9c3534 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Wed, 1 Jul 2026 10:15:20 +0100 Subject: [PATCH 1/2] stop f_nd_impurity_electrons(13) being overwritten by default value in varyrun --- process/core/io/in_dat/base.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index 8ce7e7f737..628f428cfb 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -414,8 +414,16 @@ def get_parameters(data, use_string_values=True): if item == "f_nd_impurity_electrons": for k in range(len(data["f_nd_impurity_electrons"].get_value)): name = f"f_nd_impurity_electrons({str(k + 1).zfill(1)})" - value = data["f_nd_impurity_electrons"].get_value[k] - parameters[module][name] = value + # if the variable appears elsewhere in data - it is being + # used as an iteration variable. need to add to + # parameters separately otherwise its value in a + # varyrun remains the same + if name in data: + value = data[name].value + parameters[module][name] = value + else: + value = data["f_nd_impurity_electrons"].get_value[k] + parameters[module][name] = value elif item == "ioptimz": name = item From 12a345cfe073059684e51135c733aa47c79c0933 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Wed, 1 Jul 2026 18:45:19 +0100 Subject: [PATCH 2/2] make varyrun ubs&lbs consistent with initial file instead of updating at each iteration, and fix finding vars in data --- process/core/io/in_dat/base.py | 5 +++-- process/core/io/vary_run/config.py | 5 +++-- process/core/io/vary_run/tools.py | 4 +--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index 628f428cfb..8b61ae58dd 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -414,10 +414,11 @@ def get_parameters(data, use_string_values=True): if item == "f_nd_impurity_electrons": for k in range(len(data["f_nd_impurity_electrons"].get_value)): name = f"f_nd_impurity_electrons({str(k + 1).zfill(1)})" - # if the variable appears elsewhere in data - it is being + # if the variable appears elsewhere in data, it is being # used as an iteration variable. need to add to # parameters separately otherwise its value in a - # varyrun remains the same + # varyrun remains the same as it is taken from the + # default values if name in data: value = data[name].value parameters[module][name] = value diff --git a/process/core/io/vary_run/config.py b/process/core/io/vary_run/config.py index 4c6904d389..66529ac54e 100644 --- a/process/core/io/vary_run/config.py +++ b/process/core/io/vary_run/config.py @@ -145,9 +145,10 @@ def __iter__(self): return self def __next__(self): - _neqns, itervars = get_neqns_itervars(in_dat=self.infile, wdir=self.wdir) + _neqns, itervars = get_neqns_itervars(in_dat=self.initial_infile, wdir=self.wdir) + lbs, ubs = get_variable_range( - itervars, self.factor, self.infile, self.data, self.wdir + itervars, self.factor, self.initial_infile, self.data, self.wdir ) self.run_process(self.wdir / self.infile, self.solver) check_input_error(mfile=self.outfile, wdir=self.wdir) diff --git a/process/core/io/vary_run/tools.py b/process/core/io/vary_run/tools.py index 3a2e05dbb8..265a55b029 100644 --- a/process/core/io/vary_run/tools.py +++ b/process/core/io/vary_run/tools.py @@ -59,8 +59,6 @@ def get_variable_range(itervars, factor, indat, data: DataStructure, wdir="."): """Returns the lower and upper bounds of the variable range for each iteration variable. - For f-values the allowed range is equal to their process bounds. - Parameters ---------- itervars : @@ -320,7 +318,7 @@ def get_from_indat_or_default(in_dat, varname): if "(" in varname: name, index = re.match(r"([a-zA-Z0-9_]+)\(([0-9]+)\)", varname.strip()).groups() - if varname in in_dat.data: + if name in in_dat.data: return in_dat.data[name].get_value[int(index) - 1] return dicts["DICT_DEFAULT"][name][int(index) - 1]