From 7999a442a4edb553e3adff7c98b158db401b6167 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Mon, 26 Oct 2026 17:37:59 +0000 Subject: [PATCH 1/6] remove unused and outdated parameters in test run_process.conf --- tests/integration/data/run_process.conf | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/integration/data/run_process.conf b/tests/integration/data/run_process.conf index 6abe2f7034..6f922eb729 100644 --- a/tests/integration/data/run_process.conf +++ b/tests/integration/data/run_process.conf @@ -22,18 +22,3 @@ FACTOR = 1.5 * Number of allowed unfeasible points that do not trigger rerunning. NO_ALLOWED_UNFEASIBLE = 0 - -* include a summary file with the iteration variables at each stage. -INCLUDE_ITERVAR_DIFF = True - -* add iteration variables - comma separated -ADD_IXC = - -* remove iteration variables - comma separated -DEL_IXC = - -* add constraint equations - comma separated -ADD_ICC = - -* remove constraint equations - comma separated -DEL_ICC = From c26802a0d8b83be0288e3f3f6c4423b685b9d7be Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Tue, 27 Oct 2026 10:07:57 +0000 Subject: [PATCH 2/6] get varyrun file to converge again (now 4_IN.DAT converges) --- examples/data/large_tokamak_varyrun_IN.DAT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/data/large_tokamak_varyrun_IN.DAT b/examples/data/large_tokamak_varyrun_IN.DAT index 75e2a2759f..08b0f17df8 100644 --- a/examples/data/large_tokamak_varyrun_IN.DAT +++ b/examples/data/large_tokamak_varyrun_IN.DAT @@ -141,7 +141,7 @@ sig_tf_wp_max = 7.5E8 * Allowable maximum shear stress in TF coil conduit (Tr *---------------------* icc = 5 ixc = 6 * nd_plasma_electrons_vol_avg [m-3] -nd_plasma_electrons_vol_avg = 8E20 +nd_plasma_electrons_vol_avg = 6E19 * Neutron wall load upper limit * *-------------------------------* From df6e083aa1dc5d01165b81a4571d1a9cf19c5645 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:42:46 +0000 Subject: [PATCH 3/6] raise an error if varyrun fails to find a converging IN.DAT within the maximum number of iterations, instead of just printing to the terminal --- process/core/io/vary_run/config.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/process/core/io/vary_run/config.py b/process/core/io/vary_run/config.py index 2b6f3f5f10..8d16de4a6e 100644 --- a/process/core/io/vary_run/config.py +++ b/process/core/io/vary_run/config.py @@ -14,6 +14,7 @@ from numpy.random import default_rng from process.core.data_structure.base import DataStructure +from process.core.exceptions import ProcessError from process.core.io.in_dat import InDat from process.core.io.mfile import MFile from process.core.io.vary_run.tools import ( @@ -262,7 +263,14 @@ def create_readme(self): Path(self.wdir, "README.txt").write_text(self.comment) def error_status2readme(self, mfile): - """Appends PROCESS outcome to README.txt if reached maximum iterations""" + """Appends PROCESS outcome to README.txt if reached maximum iterations + + Raises + ------ + ProcessError + If VaryRun does not find a converging IN.DAT within the maximum + number of iterations + """ m_file = MFile(filename=self.wdir / mfile) try: @@ -298,6 +306,8 @@ def error_status2readme(self, mfile): with open(Path(self.wdir, "README.txt"), "a") as readme: readme.write(error_status) print(ifail_msg) + if ifail != SolverOutputCondition.CONVERGED: + raise ProcessError(ifail_msg) def modify_in_dat(self): """Modifies the original IN.DAT file""" From 08c2ae756fdb983e0e2df065aa9b262e6636fffa Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Tue, 27 Oct 2026 16:59:01 +0000 Subject: [PATCH 4/6] get correct file in vary run example --- examples/vary_run_example.ex.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/vary_run_example.ex.py b/examples/vary_run_example.ex.py index 6e4d1b3018..057bb643f8 100644 --- a/examples/vary_run_example.ex.py +++ b/examples/vary_run_example.ex.py @@ -100,6 +100,7 @@ # %autoreload 2 import os +import re import shutil import tempfile from pathlib import Path @@ -108,6 +109,7 @@ from process.core.repository import get_process_root from process.main import VaryRun +# %% # Path to files data_dir = get_process_root() / "../examples/data/" conf_file = data_dir / "run_process.conf" @@ -132,6 +134,21 @@ vary_run.run() os.chdir(cwd) +# %% +# Find the final file created, as this file converges +# VaryRun will raise an error if it does not find a converging input file +# within the maximum number of iterations +path_to_varyrun_files = Path(temp_dir.name) + +in_dats_created = [ + file.name + for file in path_to_varyrun_files.iterdir() + if re.match(r"([0-9]+)_IN.DAT", file.name) is not None +] + +final_file_prefix = max(name.strip("_IN.DAT") for name in in_dats_created) +converging_in_dat = final_file_prefix + "_IN.DAT" + # %% # Get the initial values from the original input file iteration_variable_names, original_iteration_variable_values = ( @@ -142,13 +159,14 @@ # VaryRun always produces a file called IN.DAT in the same directory # as the conf file _, updated_iteration_variable_values = get_mfile_initial_ixc_values( - Path(temp_dir.name) / "2_IN.DAT", vary_run.data + path_to_varyrun_files / converging_in_dat, vary_run.data ) # %% [markdown] # ## Compare iteration variable values # -# `VaryRun` has changed the values of some iteration variables. +# `VaryRun` has found a converging input file and has changed the initial values of the +# iteration variables: # %% import pandas as pd From 0bb164df0e48f32aed045b8ee9ccd42ed6815d27 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Wed, 28 Oct 2026 11:25:15 +0000 Subject: [PATCH 5/6] correctly select largest value --- examples/vary_run_example.ex.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/vary_run_example.ex.py b/examples/vary_run_example.ex.py index 057bb643f8..7fbf05c0f9 100644 --- a/examples/vary_run_example.ex.py +++ b/examples/vary_run_example.ex.py @@ -146,8 +146,8 @@ if re.match(r"([0-9]+)_IN.DAT", file.name) is not None ] -final_file_prefix = max(name.strip("_IN.DAT") for name in in_dats_created) -converging_in_dat = final_file_prefix + "_IN.DAT" +final_file_prefix = max(int(name.strip("_IN.DAT")) for name in in_dats_created) +converging_in_dat = str(final_file_prefix) + "_IN.DAT" # %% # Get the initial values from the original input file @@ -181,4 +181,4 @@ df # %% -temp_dir.cleanup() +# temp_dir.cleanup() From 3390471778793c54304c0524a6d3257e5ba6a4d3 Mon Sep 17 00:00:00 2001 From: Clair Mould <86794332+clmould@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:26:38 +0000 Subject: [PATCH 6/6] uncomment accidental testing --- examples/vary_run_example.ex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vary_run_example.ex.py b/examples/vary_run_example.ex.py index 7fbf05c0f9..b56b935279 100644 --- a/examples/vary_run_example.ex.py +++ b/examples/vary_run_example.ex.py @@ -181,4 +181,4 @@ df # %% -# temp_dir.cleanup() +temp_dir.cleanup()