From 43cf6f79880aedff5107743a85e1a113b8ae6daa Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 11:59:57 +0100 Subject: [PATCH 01/10] Rename numeric variables to adhere to style guide --- documentation/source/development/add-vars.md | 2 +- process/core/input.py | 2 +- process/data_structure/numerics.py | 36 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/documentation/source/development/add-vars.md b/documentation/source/development/add-vars.md index e62fcfa23c..504ae0e9a4 100644 --- a/documentation/source/development/add-vars.md +++ b/documentation/source/development/add-vars.md @@ -55,7 +55,7 @@ Code example in the `input.py` file: To add a `PROCESS` iteration variable please follow the steps below, in addition to the instructions for adding an input variable: -1. The parameter `ipnvars` in module `numerics` of `numerics.f90` will normally be greater than the actual number of iteration variables, and does not need to be changed. +1. The parameter `N_ITERATION_VARIABLES_MAX` in module `numerics` of `numerics.f90` will normally be greater than the actual number of iteration variables, and does not need to be changed. 2. Append a new iteration number key to the end of the `ITERATION_VARIABLES` dictionary in `iteration_variables.py`. The associated variable is the corresponding key value. 3. Set the variable origin file and then the associated lower and upper bounds 4. Update the `lablxc` description in `numerics.f90`. diff --git a/process/core/input.py b/process/core/input.py index efd35b33ba..8a0b237545 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -1277,7 +1277,7 @@ def __post_init__(self): "ixc": InputVariable( None, int, - range=(1, data_structure.numerics.ipnvars), + range=(1, data_structure.numerics.N_ITERATION_VARIABLES_MAX), additional_actions=_ixc_additional_actions, set_variable=False, ), diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index cbe7f39283..b6652800e1 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -1,6 +1,6 @@ import numpy as np -ipnvars: int = 177 +N_ITERATION_VARIABLES_MAX: int = 177 """total number of variables available for iteration""" ipeqns: int = 92 @@ -9,9 +9,9 @@ ipnfoms: int = 19 """number of available figures of merit""" -ipvlam: int = ipeqns + 2 * ipnvars + 1 +ipvlam: int = ipeqns + 2 * N_ITERATION_VARIABLES_MAX + 1 iptnt: int = (ipeqns * (3 * ipeqns + 13)) / 2 -ipvp1: int = ipnvars + 1 +ipvp1: int = N_ITERATION_VARIABLES_MAX + 1 ioptimz: int = None """Code operation switch: @@ -620,11 +620,11 @@ def init_numerics(): "Fuel composition consistency ", ] - ixc = np.array([0] * ipnvars) + ixc = np.array([0] * N_ITERATION_VARIABLES_MAX) # WARNING These labels are used as variable names by write_new_in_dat.py, and possibly # other python utilities, so they cannot easily be changed. - lablxc = [""] * ipnvars + lablxc = [""] * N_ITERATION_VARIABLES_MAX sqsumsq = 0.0 objf_name = "" @@ -634,18 +634,18 @@ def init_numerics(): factor = 0.1e0 ftol = 1.0e-4 - boundl = np.array([9.0e-99] * ipnvars) - boundu = np.array([9.0e99] * ipnvars) - - itv_scaled_lower_bounds = np.array([0.0] * ipnvars) - itv_scaled_upper_bounds = np.array([0.0] * ipnvars) - rcm = np.array([0.0] * ipnvars) - resdl = np.array([0.0] * ipnvars) - scafc = np.array([0.0] * ipnvars) - scale = np.array([0.0] * ipnvars) - xcm = np.array([0.0] * ipnvars) - xcs = np.array([0.0] * ipnvars) - vlam = np.array([0.0] * ipnvars) - name_xc = [""] * ipnvars + boundl = np.array([9.0e-99] * N_ITERATION_VARIABLES_MAX) + boundu = np.array([9.0e99] * N_ITERATION_VARIABLES_MAX) + + itv_scaled_lower_bounds = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + itv_scaled_upper_bounds = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + rcm = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + resdl = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + scafc = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + scale = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + xcm = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + xcs = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + vlam = np.array([0.0] * N_ITERATION_VARIABLES_MAX) + name_xc = [""] * N_ITERATION_VARIABLES_MAX force_vmcon_inequality_satisfication = 1 force_vmcon_inequality_tolerance = 1e-8 From e24cfc91b981c16aec56eb428adbbc57612cdea1 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 12:06:22 +0100 Subject: [PATCH 02/10] Rename numeric variable `ipeqns` to `N_CONSTRAINT_EQUATIONS_MAX` for style guide compliance --- process/core/input.py | 2 +- process/data_structure/numerics.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/process/core/input.py b/process/core/input.py index 8a0b237545..f2211d87a6 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -1284,7 +1284,7 @@ def __post_init__(self): "icc": InputVariable( None, int, - range=(1, data_structure.numerics.ipeqns), + range=(1, data_structure.numerics.N_CONSTRAINT_EQUATIONS_MAX), additional_actions=_icc_additional_actions, set_variable=False, ), diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index b6652800e1..a4f76b7c8f 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -3,14 +3,14 @@ N_ITERATION_VARIABLES_MAX: int = 177 """total number of variables available for iteration""" -ipeqns: int = 92 +N_CONSTRAINT_EQUATIONS_MAX: int = 92 """number of constraint equations available""" ipnfoms: int = 19 """number of available figures of merit""" -ipvlam: int = ipeqns + 2 * N_ITERATION_VARIABLES_MAX + 1 -iptnt: int = (ipeqns * (3 * ipeqns + 13)) / 2 +ipvlam: int = N_CONSTRAINT_EQUATIONS_MAX + 2 * N_ITERATION_VARIABLES_MAX + 1 +iptnt: int = (N_CONSTRAINT_EQUATIONS_MAX * (3 * N_CONSTRAINT_EQUATIONS_MAX + 13)) / 2 ipvp1: int = N_ITERATION_VARIABLES_MAX + 1 ioptimz: int = None @@ -522,8 +522,8 @@ def init_numerics(): nvar = 0 n_constraints = 0 nviter = 0 - icc = np.array([0] * ipeqns) - active_constraints = [False] * ipeqns + icc = np.array([0] * N_CONSTRAINT_EQUATIONS_MAX) + active_constraints = [False] * N_CONSTRAINT_EQUATIONS_MAX lablcc = [ "⟨β⟩ consistency ", From 192135838e35fa6f8be5a7f99de1431c810c3dcd Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 12:08:53 +0100 Subject: [PATCH 03/10] Rename numeric variable `ipnfoms` to `N_FIGURES_MERIT_MAX` and update related documentation for style guide compliance --- documentation/source/development/add-vars.md | 2 +- process/data_structure/numerics.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/documentation/source/development/add-vars.md b/documentation/source/development/add-vars.md index 504ae0e9a4..07dbaffe9d 100644 --- a/documentation/source/development/add-vars.md +++ b/documentation/source/development/add-vars.md @@ -80,7 +80,7 @@ ITERATION_VARIABLES = { New figures of merit are added to `PROCESS` in the following way: -1. Increment the parameter `ipnfoms` in module `numerics` in source file `numerics.f90` to accommodate the new figure of merit. +1. Increment the parameter `N_FIGURES_MERIT_MAX` in module `numerics` in source file `numerics.f90` to accommodate the new figure of merit. 2. Assign a description of the new figure of merit to the relevant element of array `lablmm` in module `numerics` in the source file `numerics.f90`. diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index a4f76b7c8f..16500068e3 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -1,12 +1,12 @@ import numpy as np N_ITERATION_VARIABLES_MAX: int = 177 -"""total number of variables available for iteration""" +"""Total number of variables available for iteration (i.e. optimisation)""" N_CONSTRAINT_EQUATIONS_MAX: int = 92 -"""number of constraint equations available""" +"""Number of constraint equations available to be activated""" -ipnfoms: int = 19 +N_FIGURES_MERIT_MAX: int = 19 """number of available figures of merit""" ipvlam: int = N_CONSTRAINT_EQUATIONS_MAX + 2 * N_ITERATION_VARIABLES_MAX + 1 @@ -26,7 +26,7 @@ """ lablmm: list[str] = None -"""lablmm(ipnfoms) : labels describing figures of merit:
    +"""lablmm(N_FIGURES_MERIT_MAX) : labels describing figures of merit:
      * ( 1) major radius * ( 2) not used * ( 3) neutron wall load From c72758401abee8edd0b877e86c5e3f1456d5dd59 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 14:24:40 +0100 Subject: [PATCH 04/10] Rename numeric variable `ioptimz` to `i_process_run_mode` across documentation, input files, and codebase for style guide compliance --- documentation/source/io/input-guide.md | 2 +- documentation/source/solver/solver-guide.md | 6 +++--- documentation/source/usage/running-process.md | 8 ++++---- examples/data/large_tokamak_eval_IN.DAT | 2 +- process/core/final.py | 2 +- process/core/init.py | 13 ++++++++----- process/core/input.py | 2 +- process/core/io/in_dat/base.py | 14 +++++++------- process/core/io/plot/summary.py | 2 +- process/core/scan.py | 5 ++++- process/data_structure/numerics.py | 6 +++--- process/main.py | 10 +++++----- process/models/physics/l_h_transition.py | 2 +- process/models/power.py | 2 +- tests/integration/data/large_tokamak_eval.IN.DAT | 2 +- tests/regression/input_files/helias_5b.IN.DAT | 2 +- .../input_files/large_tokamak_eval.IN.DAT | 2 +- .../input_files/low_aspect_ratio_DEMO.IN.DAT | 2 +- .../input_files/spherical_tokamak_eval.IN.DAT | 2 +- tests/regression/input_files/st_regression.IN.DAT | 2 +- .../input_files/stellarator_helias.IN.DAT | 2 +- tests/regression/test_process_input_files.py | 2 +- tests/unit/core/test_input.py | 6 +++--- tests/unit/models/test_power.py | 8 ++++---- 24 files changed, 56 insertions(+), 50 deletions(-) diff --git a/documentation/source/io/input-guide.md b/documentation/source/io/input-guide.md index 4176d5ba1b..9f0f2e8f72 100644 --- a/documentation/source/io/input-guide.md +++ b/documentation/source/io/input-guide.md @@ -112,7 +112,7 @@ If bounds are not specified default values are used. The user can select which solver to use, but only one solver is available at present (VMCON). ``` -ioptimz = 1 * for optimisation VMCON only +i_process_run_mode = 1 * for optimisation VMCON only ``` The user can select the figure of merit to be used: diff --git a/documentation/source/solver/solver-guide.md b/documentation/source/solver/solver-guide.md index 361cd43017..9173f205f8 100644 --- a/documentation/source/solver/solver-guide.md +++ b/documentation/source/solver/solver-guide.md @@ -106,9 +106,9 @@ maximised figure of merit is desired, `minmax` should be **negative**. ## Optimisation mode -Switch `ioptimz` should be set to 1 for optimisation mode. +Switch `i_process_run_mode` should be set to 1 for optimisation mode. -If `ioptimz = 0`, a non-optimisation pass is performed first. Occasionally this provides a feasible set of initial conditions that aids convergence of the optimiser, but it is recommended to use `ioptimz = 1`. +If `i_process_run_mode = 0`, a non-optimisation pass is performed first. Occasionally this provides a feasible set of initial conditions that aids convergence of the optimiser, but it is recommended to use `i_process_run_mode = 1`. Enable all the relevant consistency equations, and it is advisable to enable the corresponding iterations variables. A number of limit equations (inequality constraints) can also be activated. In optimisation mode, the number of iteration variables is unlimited. @@ -137,7 +137,7 @@ Running `PROCESS` in evaluation mode requires few changes to be made to the inpu As before, the user must decide which constraint equations and iteration variables to activate. For example, an extract from an input file might look like: ``` * Evaluation problem: evaluate models consistently by solving equality constraints only -ioptimz = -2 * evaluation mode +i_process_run_mode = -2 * evaluation mode *---------------Constraint Equations---------------* * Define number of equality constraints diff --git a/documentation/source/usage/running-process.md b/documentation/source/usage/running-process.md index c709679158..08fac323c6 100644 --- a/documentation/source/usage/running-process.md +++ b/documentation/source/usage/running-process.md @@ -1,12 +1,12 @@ # Running PROCESS -There are a number of ways to run PROCESS. The first two are determined by the value of the switch `ioptimz` in the input file: +There are a number of ways to run PROCESS. The first two are determined by the value of the switch `i_process_run_mode` in the input file: -`ioptimz = -2` for evaluation. The physics and engineering models are evaluated and the equality (e.g. model consistency) constraints will be solved using `scipy`'s `fsolve`. The input file and default values together define the input values of all variables. The values of the parameters used to solve the equalities (solution parameters) will be different in the solution, however. This is used when evaluating a set of input parameters (e.g. a "point") whilst ensuring that the models are self-consistent. +`i_process_run_mode = -2` for evaluation. The physics and engineering models are evaluated and the equality (e.g. model consistency) constraints will be solved using `scipy`'s `fsolve`. The input file and default values together define the input values of all variables. The values of the parameters used to solve the equalities (solution parameters) will be different in the solution, however. This is used when evaluating a set of input parameters (e.g. a "point") whilst ensuring that the models are self-consistent. -`ioptimz = 1` for optimisation. Those variables specified as iteration variables (specified by equations such as `ixc = 1` in the input file) are automatically varied during the iteration process, between the bounds given by the arrays `boundl` (lower bounds) and `boundu` (upper bounds). The input file contains the *initial* values of the iteration variables, but the final values will not be same. The iteration process continues until convergence, or until the maximum number of iterations (`maxcal`) is reached. If the code converges, the constraints will be satisfied and the Figure of Merit will be maximised or minimised. +`i_process_run_mode = 1` for optimisation. Those variables specified as iteration variables (specified by equations such as `ixc = 1` in the input file) are automatically varied during the iteration process, between the bounds given by the arrays `boundl` (lower bounds) and `boundu` (upper bounds). The input file contains the *initial* values of the iteration variables, but the final values will not be same. The iteration process continues until convergence, or until the maximum number of iterations (`maxcal`) is reached. If the code converges, the constraints will be satisfied and the Figure of Merit will be maximised or minimised. -If the optimisation fails to converge, a third option is available by using the command line option `-v` (VaryRun), together with a configuration file. PROCESS is run repeatedly in optimisation mode (`ioptimz` = 1 must be set), but a new input file is written each time, with different, randomly selected *initial* values of the iteration variables. The factor within which the initial values of the iteration variables are changed is `FACTOR` (in the configuration file). For example, `FACTOR = 1.1` will vary the initial values randomly by up to 10%. This is repeated until PROCESS converges, or until the maximum number of PROCESS runs (`NITER`) is reached. Sometimes this procedure will generate a converged solution when a single optimisation run does not. +If the optimisation fails to converge, a third option is available by using the command line option `-v` (VaryRun), together with a configuration file. PROCESS is run repeatedly in optimisation mode (`i_process_run_mode` = 1 must be set), but a new input file is written each time, with different, randomly selected *initial* values of the iteration variables. The factor within which the initial values of the iteration variables are changed is `FACTOR` (in the configuration file). For example, `FACTOR = 1.1` will vary the initial values randomly by up to 10%. This is repeated until PROCESS converges, or until the maximum number of PROCESS runs (`NITER`) is reached. Sometimes this procedure will generate a converged solution when a single optimisation run does not. A SCAN is available in any of these modes. One input variable can be scanned (`scan_dim = 1`) or two input variables (`scan_dim = 2`). A scan variable must not be an iteration variable. For details, see ScanVariables in the [scan module](../../source/reference/process/scan). diff --git a/examples/data/large_tokamak_eval_IN.DAT b/examples/data/large_tokamak_eval_IN.DAT index 464a9a84ba..1e0e735d6b 100644 --- a/examples/data/large_tokamak_eval_IN.DAT +++ b/examples/data/large_tokamak_eval_IN.DAT @@ -1,5 +1,5 @@ * Evaluation problem: evaluate models consistently by solving equality constraints only -ioptimz = -2 +i_process_run_modess_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints diff --git a/process/core/final.py b/process/core/final.py index be55db69cb..adf5d43bd1 100644 --- a/process/core/final.py +++ b/process/core/final.py @@ -32,7 +32,7 @@ def finalise(models, data, ifail: int, non_idempotent_msg: str | None = None): po.oheadr(constants.NOUT, "Final UNFEASIBLE Point") # Output relevant to no optimisation - if numerics.ioptimz == -2: + if numerics.i_process_run_mode == -2: output_evaluation(data) # Print non-idempotence warning to OUT.DAT only diff --git a/process/core/init.py b/process/core/init.py index 731d3d7e6d..77e41e9aa8 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -174,7 +174,7 @@ def run_summary(): outfile, f"Iteration variables : {data_structure.numerics.nvar}" ) # If optimising, write objective function and convergence parameter - if data_structure.numerics.ioptimz == 1: + if data_structure.numerics.i_process_run_mode == 1: process_output.ocmmnt( outfile, f"Max iterations : {data_structure.global_variables.maxcal}", @@ -217,10 +217,13 @@ def run_summary(): process_output.ovarst(mfile, "Input filename", "(fileprefix)", f'"{fileprefix}"') process_output.ovarin( - mfile, "Optimisation switch", "(ioptimz)", data_structure.numerics.ioptimz + mfile, + "Optimisation switch", + "(i_process_run_mode)", + data_structure.numerics.i_process_run_mode, ) # If optimising, write figure of merit switch - if data_structure.numerics.ioptimz == 1: + if data_structure.numerics.i_process_run_mode == 1: process_output.ovarin( mfile, "Figure of merit switch", "(minmax)", data_structure.numerics.minmax ) @@ -412,7 +415,7 @@ def check_process(inputs, data): # noqa: ARG001 ) if ( - data_structure.numerics.ioptimz >= 0 + data_structure.numerics.i_process_run_mode >= 0 and (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 4).any() and data_structure.numerics.boundl[3] < data.physics.temp_plasma_pedestal_kev * 1.001 @@ -468,7 +471,7 @@ def check_process(inputs, data): # noqa: ARG001 # Issue #862 : Variable nd_plasma_electron_on_axis/nd_plasma_pedestal_electron ratio without constraint eq 81 (nd_plasma_electron_on_axis>nd_plasma_pedestal_electron) # -> Potential hollowed density profile if ( - data_structure.numerics.ioptimz >= 0 + data_structure.numerics.i_process_run_mode >= 0 and not ( data_structure.numerics.icc[ : data_structure.numerics.neqns + data_structure.numerics.nineqns diff --git a/process/core/input.py b/process/core/input.py index f2211d87a6..98a00b5b95 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -106,7 +106,7 @@ def __post_init__(self): "runtitle": InputVariable(data_structure.global_variables, str), "verbose": InputVariable(data_structure.global_variables, int, choices=[0, 1]), "run_tests": InputVariable(data_structure.global_variables, int, choices=[0, 1]), - "ioptimz": InputVariable(data_structure.numerics, int, choices=[1, -2]), + "i_process_run_mode": InputVariable(data_structure.numerics, int, choices=[1, -2]), "epsvmc": InputVariable(data_structure.numerics, float, range=(0.0, 1.0)), "boundl": InputVariable(data_structure.numerics, float, array=True), "boundu": InputVariable(data_structure.numerics, float, array=True), diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index 1ac910e677..05d71ba74e 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -17,7 +17,7 @@ from process.core.io.data_structure_dicts import get_dicts from process.core.solver.constraints import ConstraintManager -# ioptimz values +# i_process_run_mode values ioptimz_des = { "-2": "for no optimisation, no VMCOM or HYBRD", "-1": "for no optimisation HYBRD only", @@ -453,14 +453,14 @@ def get_parameters(data, use_string_values=True): value = data["f_nd_impurity_electrons"].get_value[k] parameters[module][name] = value - elif item == "ioptimz": + elif item == "i_process_run_mode": name = item - ioptimz = {} - iop_val = data["ioptimz"].get_value + i_process_run_mode = {} + iop_val = data["i_process_run_mode"].get_value iop_comment = ioptimz_des[str(iop_val)] - ioptimz["value"] = iop_val - ioptimz["comment"] = iop_comment - parameters[module][name] = ioptimz + i_process_run_mode["value"] = iop_val + i_process_run_mode["comment"] = iop_comment + parameters[module][name] = i_process_run_mode elif item == "zref": for j in range(len(data["zref"].get_value)): diff --git a/process/core/io/plot/summary.py b/process/core/io/plot/summary.py index 866224a4fb..f4dd36e236 100644 --- a/process/core/io/plot/summary.py +++ b/process/core/io/plot/summary.py @@ -11578,7 +11578,7 @@ def plot_cover_page( tagno = mfile.get("tagno", scan=-1) branch_name = mfile.get("branch_name", scan=-1) fileprefix = mfile.get("fileprefix", scan=-1) - optmisation_switch = mfile.get("ioptimz", scan=-1) + optmisation_switch = mfile.get("i_process_run_mode", scan=-1) minmax_switch = mfile.get("minmax", scan=-1) or "N/A" ifail = mfile.get("ifail", scan=-1) nvars = mfile.get("nvar", scan=-1) diff --git a/process/core/scan.py b/process/core/scan.py index 1d08e034c1..62629a0631 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -344,7 +344,10 @@ def post_optimise(self, ifail: int): numerics.neqns + numerics.nineqns, ) process_output.ovarin( - constants.NOUT, "Optimisation switch", "(ioptimz)", numerics.ioptimz + constants.NOUT, + "Optimisation switch", + "(i_process_run_mode)", + numerics.i_process_run_mode, ) # Objective function output: none for fsolve if self.solver != "fsolve": diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 16500068e3..25116da974 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -13,7 +13,7 @@ iptnt: int = (N_CONSTRAINT_EQUATIONS_MAX * (3 * N_CONSTRAINT_EQUATIONS_MAX + 13)) / 2 ipvp1: int = N_ITERATION_VARIABLES_MAX + 1 -ioptimz: int = None +i_process_run_mode: int = None """Code operation switch: * -2 for evaluation mode (i.e. no optimisation) * 1 for optimisation mode (e.g. via VMCON) @@ -452,7 +452,7 @@ def init_numerics(): global \ - ioptimz, \ + i_process_run_mode, \ minmax, \ lablmm, \ n_constraints, \ @@ -490,7 +490,7 @@ def init_numerics(): force_vmcon_inequality_satisfication, \ force_vmcon_inequality_tolerance """Initialise module variables""" - ioptimz = 1 + i_process_run_mode = 1 minmax = 7 lablmm = [ "major radius ", diff --git a/process/main.py b/process/main.py index 3420c01e12..a3dbdfbf75 100644 --- a/process/main.py +++ b/process/main.py @@ -423,16 +423,16 @@ def initialise(self): def run_scan(self): """Create scan object if required.""" # TODO Move this solver logic up to init? - # ioptimz == 1: optimisation - if data_structure.numerics.ioptimz == 1: + # i_process_run_mode == 1: optimisation + if data_structure.numerics.i_process_run_mode == 1: pass - # ioptimz == -2: evaluation - elif data_structure.numerics.ioptimz == -2: + # i_process_run_mode == -2: evaluation + elif data_structure.numerics.i_process_run_mode == -2: # No optimisation: solve equality (consistency) constraints only using fsolve (HYBRD) self.solver = "fsolve" else: raise ValueError( - f"Invalid ioptimz value: {data_structure.numerics.ioptimz}. Please " + f"Invalid i_process_run_mode value: {data_structure.numerics.i_process_run_mode}. Please " "select either 1 (optimise) or -2 (no optimisation)." ) self.scan = Scan(self.models, self.solver, self.data) diff --git a/process/models/physics/l_h_transition.py b/process/models/physics/l_h_transition.py index 48b8760af0..923d220197 100644 --- a/process/models/physics/l_h_transition.py +++ b/process/models/physics/l_h_transition.py @@ -308,7 +308,7 @@ def output(self) -> None: self.outfile, f"{PlasmaConfinementTransitionModel(self.data.physics.i_l_h_threshold).full_name}", ) - if (numerics.ioptimz > 0) and (numerics.active_constraints[14]): + if (numerics.i_process_run_mode > 0) and (numerics.active_constraints[14]): po.ovarre( self.outfile, "L-H threshold power (MW)", diff --git a/process/models/power.py b/process/models/power.py index c68a582584..3c168ea4d9 100644 --- a/process/models/power.py +++ b/process/models/power.py @@ -652,7 +652,7 @@ def pfpwr(self, output: bool): "OP ", ) - if (numerics.ioptimz > 0) and (numerics.active_constraints[65]): + if (numerics.i_process_run_mode > 0) and (numerics.active_constraints[65]): po.ovarre( self.outfile, "Max permitted abs rate of change of stored energy in poloidal " diff --git a/tests/integration/data/large_tokamak_eval.IN.DAT b/tests/integration/data/large_tokamak_eval.IN.DAT index 9b41d2fe5a..2c3ce7a804 100644 --- a/tests/integration/data/large_tokamak_eval.IN.DAT +++ b/tests/integration/data/large_tokamak_eval.IN.DAT @@ -1,5 +1,5 @@ * Evaluation problem: evaluate models consistently by solving equality constraints only -ioptimz = -2 +i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints diff --git a/tests/regression/input_files/helias_5b.IN.DAT b/tests/regression/input_files/helias_5b.IN.DAT index 4122e50d6f..67118f68df 100644 --- a/tests/regression/input_files/helias_5b.IN.DAT +++ b/tests/regression/input_files/helias_5b.IN.DAT @@ -150,7 +150,7 @@ f_nd_impurity_electrons(14) = 1.0E-5 *Tungsten *---------------------Numerics---------------------* -ioptimz = 1 *Code operation switch (1: Optimisation, VMCON only) +i_process_run_mode = 1 *Code operation switch (1: Optimisation, VMCON only) maxcal = 100 *Maximum number of VMCON iterations minmax = 7 *Switch for figure-of-merit (7: Min Capital Cost) runtitle = HELIAS-5B diff --git a/tests/regression/input_files/large_tokamak_eval.IN.DAT b/tests/regression/input_files/large_tokamak_eval.IN.DAT index e11c591ae0..6eb78b2ef2 100644 --- a/tests/regression/input_files/large_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/large_tokamak_eval.IN.DAT @@ -1,5 +1,5 @@ * Evaluation problem: evaluate models consistently by solving equality constraints only -ioptimz = -2 +i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints diff --git a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT index 03d4ab16ae..4ce9fa8e9a 100644 --- a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT +++ b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT @@ -24,7 +24,7 @@ epsvmc = 1.0e-8 * DESCRIPTION: Error tolerance for VMCON * JUSTIFICATION: Same tolerance as used on on previous DEMO -ioptimz = 1 +i_process_run_mode = 1 * DESCRIPTION: Code operation switch (1: VMCON) * JUSTIFICATION: Optimised run diff --git a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT index 73a3b9f4be..641a225504 100644 --- a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT @@ -1,5 +1,5 @@ * Evaluation problem: evaluate models consistently by solving equality constraints only -ioptimz = -2 +i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 76d5cc679e..8fc9bd8daf 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -47,7 +47,7 @@ epsvmc = 1e-9 * DESCRIPTION: HYBRD/VMCON derivative step length * JUSTIFICATION: Default step length -ioptimz = 1 +i_process_run_mode = 1 * DESCRIPTION: Code operation switch (1: VMCON) * JUSTIFICATION: Optimised run diff --git a/tests/regression/input_files/stellarator_helias.IN.DAT b/tests/regression/input_files/stellarator_helias.IN.DAT index 1ca02320e9..5a49bb5b99 100644 --- a/tests/regression/input_files/stellarator_helias.IN.DAT +++ b/tests/regression/input_files/stellarator_helias.IN.DAT @@ -224,7 +224,7 @@ f_nd_impurity_electrons(14) = 1.0E-5 *Tungsten *---------------------Numerics---------------------* -ioptimz = 1 *Code operation switch (1: Optimisation, VMCON only) +i_process_run_mode = 1 *Code operation switch (1: Optimisation, VMCON only) maxcal = 100 *Maximum number of VMCON iterations minmax = 6 *Switch for figure-of-merit (7: Min Capital Cost) epsfcn = 0.001 diff --git a/tests/regression/test_process_input_files.py b/tests/regression/test_process_input_files.py index 0b62666dd7..0e6b700b5d 100644 --- a/tests/regression/test_process_input_files.py +++ b/tests/regression/test_process_input_files.py @@ -116,7 +116,7 @@ def compare( ifail = mfile.data["ifail"].get_scan(-1) - assert ifail == 1 or mfile.data["ioptimz"].get_scan(-1) == -2, ( + assert ifail == 1 or mfile.data["i_process_run_mode"].get_scan(-1) == -2, ( f"\033[0;36m ifail of {ifail} indicates PROCESS did not solve successfully\033[0m" ) diff --git a/tests/unit/core/test_input.py b/tests/unit/core/test_input.py index 34d18223a0..22d2756c32 100644 --- a/tests/unit/core/test_input.py +++ b/tests/unit/core/test_input.py @@ -106,14 +106,14 @@ def test_parse_input(tmp_path, data_structure_obj): init.init_process(data_structure_obj) assert data_structure.global_variables.runtitle == "my run title" - assert data_structure.numerics.ioptimz == -2 + assert data_structure.numerics.i_process_run_mode == -2 assert pytest.approx(data_structure.numerics.epsvmc) == 0.6 assert pytest.approx(data_structure.numerics.boundl[0]) == 0.5 def test_input_choices(tmp_path, data_structure_obj): data_structure.global_variables.fileprefix = _create_input_file( - tmp_path, ("ioptimz = -1") + tmp_path, ("i_process_run_mode = -1") ) with pytest.raises(ProcessValidationError): @@ -155,7 +155,7 @@ def test_input_not_array_when_is(tmp_path, data_structure_obj): def test_input_float_when_int(tmp_path, data_structure_obj): data_structure.global_variables.fileprefix = _create_input_file( - tmp_path, ("ioptimz = 0.5") + tmp_path, ("i_process_run_mode = 0.5") ) with pytest.raises(ProcessValidationError): diff --git a/tests/unit/models/test_power.py b/tests/unit/models/test_power.py index ed99f7f088..81a51c168a 100644 --- a/tests/unit/models/test_power.py +++ b/tests/unit/models/test_power.py @@ -214,7 +214,7 @@ class PfpwrParam(NamedTuple): active_constraints: Any = None - ioptimz: Any = None + i_process_run_mode: Any = None t_pulse_cumulative: Any = None @@ -941,7 +941,7 @@ class PfpwrParam(NamedTuple): False, False, ), - ioptimz=1, + i_process_run_mode=1, t_pulse_cumulative=np.array( np.array( ( @@ -1684,7 +1684,7 @@ class PfpwrParam(NamedTuple): False, False, ), - ioptimz=1, + i_process_run_mode=1, t_pulse_cumulative=np.array( np.array( ( @@ -1851,7 +1851,7 @@ def test_pfpwr(pfpwrparam, monkeypatch, power): monkeypatch.setattr(numerics, "active_constraints", pfpwrparam.active_constraints) - monkeypatch.setattr(numerics, "ioptimz", pfpwrparam.ioptimz) + monkeypatch.setattr(numerics, "i_process_run_mode", pfpwrparam.i_process_run_mode) monkeypatch.setattr( power.data.times, "t_pulse_cumulative", pfpwrparam.t_pulse_cumulative From 7c68f3c41ade3c608bcf49dbc9af74cca4956007 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 14:28:26 +0100 Subject: [PATCH 05/10] Rename variable `minmax` to `i_figure_merit` across documentation, input files, and codebase for style guide compliance --- documentation/source/io/input-guide.md | 4 ++-- documentation/source/solver/solver-guide.md | 6 +++--- .../data/large_tokamak_varied_min_net_electric_IN.DAT | 2 +- examples/data/large_tokamak_varyrun_IN.DAT | 2 +- examples/data/mfile_to_csv_vars.json | 2 +- process/core/caller.py | 2 +- process/core/final.py | 2 +- process/core/init.py | 8 ++++---- process/core/input.py | 2 +- process/core/io/plot/solutions.py | 6 +++--- process/core/io/plot/summary.py | 8 ++++---- process/core/scan.py | 6 +++--- process/core/solver/objectives.py | 8 ++++---- process/data_structure/numerics.py | 6 +++--- tests/regression/input_files/IFE.IN.DAT | 2 +- tests/regression/input_files/helias_5b.IN.DAT | 2 +- tests/regression/input_files/large_tokamak_nof.IN.DAT | 2 +- tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT | 2 +- tests/regression/input_files/st_regression.IN.DAT | 2 +- tests/regression/input_files/stellarator_helias.IN.DAT | 2 +- 20 files changed, 38 insertions(+), 38 deletions(-) diff --git a/documentation/source/io/input-guide.md b/documentation/source/io/input-guide.md index 9f0f2e8f72..af3daad215 100644 --- a/documentation/source/io/input-guide.md +++ b/documentation/source/io/input-guide.md @@ -118,10 +118,10 @@ i_process_run_mode = 1 * for optimisation VMCON only The user can select the figure of merit to be used: ``` -minmax = 1 * Switch for figure-of-merit (see lablmm for descriptions) +i_figure_merit = 1 * Switch for figure-of-merit (see lablmm for descriptions) ``` -In this case the user is choosing option `1`, which is major radius. For `minmax` +In this case the user is choosing option `1`, which is major radius. For `i_figure_merit` * a **positive** value means **minimise** the figure of merit * a **negative** value means **maximise** the figure of merit diff --git a/documentation/source/solver/solver-guide.md b/documentation/source/solver/solver-guide.md index 9173f205f8..9bd1d9a3f9 100644 --- a/documentation/source/solver/solver-guide.md +++ b/documentation/source/solver/solver-guide.md @@ -96,9 +96,9 @@ known as the figure of merit. Several possible figures of merit are available, all of which are in the source file `evaluators.f90`. -Switch `minmax` is used to control which figure of merit is to be used. If the -figure of merit is to be minimised, `minmax` should be **positive**, and if a -maximised figure of merit is desired, `minmax` should be **negative**. +Switch `i_figure_merit` is used to control which figure of merit is to be used. If the +figure of merit is to be minimised, `i_figure_merit` should be **positive**, and if a +maximised figure of merit is desired, `i_figure_merit` should be **negative**. ## Convergence diff --git a/examples/data/large_tokamak_varied_min_net_electric_IN.DAT b/examples/data/large_tokamak_varied_min_net_electric_IN.DAT index 62bca42a29..695fc8b618 100644 --- a/examples/data/large_tokamak_varied_min_net_electric_IN.DAT +++ b/examples/data/large_tokamak_varied_min_net_electric_IN.DAT @@ -12,7 +12,7 @@ runtitle = Generic large tokamak * Figure of merit - minimise major radius -minmax = 1 +i_figure_merit = 1 * Error tolerance for VMCON epsvmc = 1e-7 diff --git a/examples/data/large_tokamak_varyrun_IN.DAT b/examples/data/large_tokamak_varyrun_IN.DAT index 9aacab06e3..251a3f17a6 100644 --- a/examples/data/large_tokamak_varyrun_IN.DAT +++ b/examples/data/large_tokamak_varyrun_IN.DAT @@ -12,7 +12,7 @@ runtitle = Generic large tokamak * Figure of merit - minimise major radius -minmax = 1 +i_figure_merit = 1 * Error tolerance for VMCON epsvmc = 1e-7 diff --git a/examples/data/mfile_to_csv_vars.json b/examples/data/mfile_to_csv_vars.json index e7e6849de7..93657f5ab7 100644 --- a/examples/data/mfile_to_csv_vars.json +++ b/examples/data/mfile_to_csv_vars.json @@ -1,6 +1,6 @@ { "vars": [ - "minmax", + "i_figure_merit", "p_hcd_injected_max", "p_plant_electric_net_required_mw", "ripple_b_tf_plasma_edge_max", diff --git a/process/core/caller.py b/process/core/caller.py index 4d842d29f9..851caea9ae 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -98,7 +98,7 @@ def call_models(self, xc: np.ndarray, m: int) -> tuple[float, np.ndarray]: for _ in range(10): self._call_models_once(xc, self.data) # Evaluate objective function and constraints - objf = objective_function(data_structure.numerics.minmax, self.data) + objf = objective_function(data_structure.numerics.i_figure_merit, self.data) conf, _, _, _, _ = constraints.constraint_eqns(m, -1, self.data) if objf_prev is None and conf_prev is None: diff --git a/process/core/final.py b/process/core/final.py index adf5d43bd1..47965f7a55 100644 --- a/process/core/final.py +++ b/process/core/final.py @@ -57,7 +57,7 @@ def output_evaluation(data): po.oblnkl(constants.NOUT) # Evaluate objective function - norm_objf = objective_function(numerics.minmax, data) + norm_objf = objective_function(numerics.i_figure_merit, data) po.ovarre(constants.MFILE, "Normalised objective function", "(norm_objf)", norm_objf) # Print the residuals of the constraint equations diff --git a/process/core/init.py b/process/core/init.py index 77e41e9aa8..0bad5d872a 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -180,7 +180,7 @@ def run_summary(): f"Max iterations : {data_structure.global_variables.maxcal}", ) - if data_structure.numerics.minmax > 0: + if data_structure.numerics.i_figure_merit > 0: minmax_string = " -- minimise " minmax_sign = "+" else: @@ -188,11 +188,11 @@ def run_summary(): minmax_sign = "-" fom_string = data_structure.numerics.lablmm[ - abs(data_structure.numerics.minmax) - 1 + abs(data_structure.numerics.i_figure_merit) - 1 ] process_output.ocmmnt( outfile, - f"Figure of merit : {minmax_sign}{abs(data_structure.numerics.minmax)}{minmax_string}{fom_string}", + f"Figure of merit : {minmax_sign}{abs(data_structure.numerics.i_figure_merit)}{minmax_string}{fom_string}", ) process_output.ocmmnt( outfile, @@ -225,7 +225,7 @@ def run_summary(): # If optimising, write figure of merit switch if data_structure.numerics.i_process_run_mode == 1: process_output.ovarin( - mfile, "Figure of merit switch", "(minmax)", data_structure.numerics.minmax + mfile, "Figure of merit switch", "(i_figure_merit)", data_structure.numerics.i_figure_merit ) diff --git a/process/core/input.py b/process/core/input.py index 98a00b5b95..99ea6cee66 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -112,7 +112,7 @@ def __post_init__(self): "boundu": InputVariable(data_structure.numerics, float, array=True), "epsfcn": InputVariable(data_structure.numerics, float, range=(0.0, 1.0)), "maxcal": InputVariable(data_structure.global_variables, int, range=(0, 10000)), - "minmax": InputVariable(data_structure.numerics, int), + "i_figure_merit": InputVariable(data_structure.numerics, int), "neqns": InputVariable( data_structure.numerics, int, range=(0, ConstraintManager.num_constraints()) ), diff --git a/process/core/io/plot/solutions.py b/process/core/io/plot/solutions.py index 1e3848e13d..66aaeba904 100644 --- a/process/core/io/plot/solutions.py +++ b/process/core/io/plot/solutions.py @@ -137,7 +137,7 @@ def plot_mfile_solutions( filtered_results_df = _filter_vars_of_interest( results_df, opt_param_value_pattern=opt_param_value_pattern, - extra_var_names=["minmax"], + extra_var_names=["i_figure_merit"], ) if normalising_tag is not None: @@ -436,7 +436,7 @@ def _plot_solutions( # Acquire objective function name(s), then check only one type is being plotted # The objective function is found by first checking the NORM_OBJF_NAME column. # If this entry does not exist for any of the MFiles (ie they are old), - # then the code 'falls back' to the the minmax output. Which holds the same + # then the code 'falls back' to the the i_figure_merit output. Which holds the same # information, but is less descriptive. if ( NORM_OBJF_NAME in norm_objf_df.columns @@ -446,7 +446,7 @@ def _plot_solutions( else: numerics.init_numerics() objf_list = { - numerics.lablmm[int(abs(minmax)) - 1] for minmax in diffs_df["minmax"] + numerics.lablmm[int(abs(i_figure_merit)) - 1] for i_figure_merit in diffs_df["i_figure_merit"] } if len(objf_list) != 1: diff --git a/process/core/io/plot/summary.py b/process/core/io/plot/summary.py index f4dd36e236..5b3a1c7fcc 100644 --- a/process/core/io/plot/summary.py +++ b/process/core/io/plot/summary.py @@ -7820,9 +7820,9 @@ def plot_header(axis: plt.Axes, mfile: MFile, scan: int): (f"!{mfile.get('time', scan=-1)}", "Time:", ""), (f"!{mfile.get('username', scan=-1)}", "User:", ""), ("!Evaluation", "Run type", "") - if isinstance(mfile.data["minmax"], MFileErrorClass) + if isinstance(mfile.data["i_figure_merit"], MFileErrorClass) else ( - f"!{OBJECTIVE_NAMES[abs(int(mfile.get('minmax', scan=-1)))]}", + f"!{OBJECTIVE_NAMES[abs(int(mfile.get('i_figure_merit', scan=-1)))]}", "Optimising:", "", ), @@ -11579,7 +11579,7 @@ def plot_cover_page( branch_name = mfile.get("branch_name", scan=-1) fileprefix = mfile.get("fileprefix", scan=-1) optmisation_switch = mfile.get("i_process_run_mode", scan=-1) - minmax_switch = mfile.get("minmax", scan=-1) or "N/A" + minmax_switch = mfile.get("i_figure_merit", scan=-1) or "N/A" ifail = mfile.get("ifail", scan=-1) nvars = mfile.get("nvar", scan=-1) # Objective_function_name @@ -11660,7 +11660,7 @@ def plot_cover_page( # Box 3: Run Settings settings_info = ( f"• Optimisation Switch: {int(optmisation_switch)}\n" - f"• Figure of Merit Switch (minmax): {minmax_switch}\n" + f"• Figure of Merit Switch (i_figure_merit): {minmax_switch}\n" f"• Fail Status (ifail): {int(ifail)}\n" f"• Number of Iteration Variables: {int(nvars)}\n" f"{objective_text}\n" diff --git a/process/core/scan.py b/process/core/scan.py index 62629a0631..9157015e44 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -352,10 +352,10 @@ def post_optimise(self, ifail: int): # Objective function output: none for fsolve if self.solver != "fsolve": process_output.ovarin( - constants.NOUT, "Figure of merit switch", "(minmax)", numerics.minmax + constants.NOUT, "Figure of merit switch", "(i_figure_merit)", numerics.i_figure_merit ) - objf_name = f'"{numerics.lablmm[abs(numerics.minmax) - 1]}"' + objf_name = f'"{numerics.lablmm[abs(numerics.i_figure_merit) - 1]}"' numerics.objf_name = objf_name @@ -412,7 +412,7 @@ def post_optimise(self, ifail: int): else: string1 = "PROCESS has failed to optimise" - string2 = "minimise" if numerics.minmax > 0 else "maximise" + string2 = "minimise" if numerics.i_figure_merit > 0 else "maximise" process_output.write( constants.NOUT, diff --git a/process/core/solver/objectives.py b/process/core/solver/objectives.py index 852bbd86f9..9d80341630 100644 --- a/process/core/solver/objectives.py +++ b/process/core/solver/objectives.py @@ -24,7 +24,7 @@ } -def objective_function(minmax: int, data: DataStructure) -> float: +def objective_function(i_figure_merit: int, data: DataStructure) -> float: """Calculate the specified objective function Parameters @@ -53,11 +53,11 @@ def objective_function(minmax: int, data: DataStructure) -> float: data structure object for providing data to the objective function """ - figure_of_merit = abs(minmax) + figure_of_merit = abs(i_figure_merit) # -1 = maximise # +1 = minimise - objective_sign = np.sign(minmax) + objective_sign = np.sign(i_figure_merit) match figure_of_merit: case 1: @@ -94,7 +94,7 @@ def objective_function(minmax: int, data: DataStructure) -> float: objective_metric = data.times.t_plant_pulse_burn / 2.0e4 case 15: if data.costs.i_plant_availability != 1: - raise ProcessValueError("minmax=15 requires i_plant_availability=1") + raise ProcessValueError("i_figure_merit=15 requires i_plant_availability=1") objective_metric = data.costs.f_t_plant_available case 16: objective_metric = 0.95 * (data.physics.rmajor / 9.0) - 0.05 * ( diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 25116da974..1ac9f25f59 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -19,7 +19,7 @@ * 1 for optimisation mode (e.g. via VMCON) """ -minmax: int = None +i_figure_merit: int = None """ Switch for figure-of-merit (see lablmm for descriptions) negative => maximise, positive => minimise @@ -453,7 +453,7 @@ def init_numerics(): global \ i_process_run_mode, \ - minmax, \ + i_figure_merit, \ lablmm, \ n_constraints, \ ncalls, \ @@ -491,7 +491,7 @@ def init_numerics(): force_vmcon_inequality_tolerance """Initialise module variables""" i_process_run_mode = 1 - minmax = 7 + i_figure_merit = 7 lablmm = [ "major radius ", "not used ", diff --git a/tests/regression/input_files/IFE.IN.DAT b/tests/regression/input_files/IFE.IN.DAT index 06493b2de5..f8be574fd6 100644 --- a/tests/regression/input_files/IFE.IN.DAT +++ b/tests/regression/input_files/IFE.IN.DAT @@ -24,7 +24,7 @@ p_plant_electric_net_required_mw = 1000.0 *Required net electric power (MW) *---------------Numerics Variables-----------------* IOPTIMZ = 1 *Code operation switch (1: for optimisation VMCON only) -minmax = 18 *Null FoM, find feasible +i_figure_merit = 18 *Null FoM, find feasible maxcal = 100 *Maximum number of solver iterations diff --git a/tests/regression/input_files/helias_5b.IN.DAT b/tests/regression/input_files/helias_5b.IN.DAT index 67118f68df..f7494aa611 100644 --- a/tests/regression/input_files/helias_5b.IN.DAT +++ b/tests/regression/input_files/helias_5b.IN.DAT @@ -152,7 +152,7 @@ f_nd_impurity_electrons(14) = 1.0E-5 *Tungsten i_process_run_mode = 1 *Code operation switch (1: Optimisation, VMCON only) maxcal = 100 *Maximum number of VMCON iterations -minmax = 7 *Switch for figure-of-merit (7: Min Capital Cost) +i_figure_merit = 7 *Switch for figure-of-merit (7: Min Capital Cost) runtitle = HELIAS-5B *-----------------Tfcoil Variables-----------------* diff --git a/tests/regression/input_files/large_tokamak_nof.IN.DAT b/tests/regression/input_files/large_tokamak_nof.IN.DAT index 663fd28fe5..182184909d 100644 --- a/tests/regression/input_files/large_tokamak_nof.IN.DAT +++ b/tests/regression/input_files/large_tokamak_nof.IN.DAT @@ -12,7 +12,7 @@ runtitle = Generic large tokamak * Figure of merit - minimise major radius -minmax = 1 +i_figure_merit = 1 * Error tolerance for VMCON epsvmc = 1e-7 diff --git a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT index 4ce9fa8e9a..182b538854 100644 --- a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT +++ b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT @@ -28,7 +28,7 @@ i_process_run_mode = 1 * DESCRIPTION: Code operation switch (1: VMCON) * JUSTIFICATION: Optimised run -minmax = -14 * Switch for figure-of-merit (see lablmm for descriptions) +i_figure_merit = -14 * Switch for figure-of-merit (see lablmm for descriptions) * 14: pulse legnth * DESCRIPTION: Switch for Figure-of-Merit (1: Minimise major radius) * JUSTIFICATION: Aim to minimise major radius diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index 8fc9bd8daf..f2e3d57705 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -51,7 +51,7 @@ i_process_run_mode = 1 * DESCRIPTION: Code operation switch (1: VMCON) * JUSTIFICATION: Optimised run -minmax = -5 +i_figure_merit = -5 * DESCRIPTION: Switch for Figure-of-Merit * JUSTIFICATION: Selected optimisation diff --git a/tests/regression/input_files/stellarator_helias.IN.DAT b/tests/regression/input_files/stellarator_helias.IN.DAT index 5a49bb5b99..449e427404 100644 --- a/tests/regression/input_files/stellarator_helias.IN.DAT +++ b/tests/regression/input_files/stellarator_helias.IN.DAT @@ -226,7 +226,7 @@ f_nd_impurity_electrons(14) = 1.0E-5 *Tungsten i_process_run_mode = 1 *Code operation switch (1: Optimisation, VMCON only) maxcal = 100 *Maximum number of VMCON iterations -minmax = 6 *Switch for figure-of-merit (7: Min Capital Cost) +i_figure_merit = 6 *Switch for figure-of-merit (7: Min Capital Cost) epsfcn = 0.001 runtitle = SQuID From 4e63792ca5a6f73ad7034db8ed3c7d0bb1470e62 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 14:37:20 +0100 Subject: [PATCH 06/10] Rename numeric variable `neqns` to `n_equality_constraints` across codebase and documentation for style guide compliance --- documentation/source/solver/solver-guide.md | 6 +- examples/data/large_tokamak_eval_IN.DAT | 2 +- ...rge_tokamak_varied_min_net_electric_IN.DAT | 2 +- examples/data/large_tokamak_varyrun_IN.DAT | 2 +- process/core/final.py | 15 ++-- process/core/init.py | 75 ++++++++++++------- process/core/input.py | 2 +- process/core/io/in_dat/base.py | 4 +- process/core/io/obsolete_vars.py | 2 + process/core/io/plot/solutions.py | 3 +- process/core/scan.py | 22 ++++-- process/core/solver/objectives.py | 4 +- process/core/solver/solver_handler.py | 4 +- process/data_structure/numerics.py | 10 +-- .../data/large_tokamak_eval.IN.DAT | 2 +- tests/integration/test_vmcon.py | 30 ++++---- tests/regression/input_files/IFE.IN.DAT | 2 +- tests/regression/input_files/helias_5b.IN.DAT | 2 +- .../input_files/large_tokamak_eval.IN.DAT | 2 +- .../input_files/large_tokamak_nof.IN.DAT | 4 +- .../input_files/low_aspect_ratio_DEMO.IN.DAT | 2 +- .../input_files/spherical_tokamak_eval.IN.DAT | 2 +- .../input_files/st_regression.IN.DAT | 4 +- .../input_files/stellarator_helias.IN.DAT | 2 +- 24 files changed, 122 insertions(+), 83 deletions(-) diff --git a/documentation/source/solver/solver-guide.md b/documentation/source/solver/solver-guide.md index 9bd1d9a3f9..be891cce1a 100644 --- a/documentation/source/solver/solver-guide.md +++ b/documentation/source/solver/solver-guide.md @@ -15,7 +15,7 @@ A PROCESS input file will, for example, define which constraint equations are be ``` ... -neqns = 3 +n_equality_constraints = 3 * Equalities icc = 1 * Beta @@ -33,7 +33,7 @@ icc = 15 * LH power threshold limit Here each `icc=n` statement tells PROCESS to activate a constraint with the name `n`. A list of the constraints and their corresponding names can be found [here](../../source/reference/process/data_structure/numerics/#process.data_structure.numerics.lablcc). -The `neqns = 3` statement is telling PROCESS to treat the first `3` equations as equality constraints, and the rest as inequality constraints. Therefore, it is imperative that all equality constraints are stated before any inequality constraints. +The `n_equality_constraints = 3` statement is telling PROCESS to treat the first `3` equations as equality constraints, and the rest as inequality constraints. Therefore, it is imperative that all equality constraints are stated before any inequality constraints. In both types of equations, an optimiser/solver uses the normalised residuals $c_i$ of the constraints (and sometimes its gradient, depending on the solver/optimiser) to guide the solution towards one that satisfies all of the constraints. @@ -141,7 +141,7 @@ i_process_run_mode = -2 * evaluation mode *---------------Constraint Equations---------------* * Define number of equality constraints -neqns = 2 +n_equality_constraints = 2 * Equalities icc = 1 * Beta diff --git a/examples/data/large_tokamak_eval_IN.DAT b/examples/data/large_tokamak_eval_IN.DAT index 1e0e735d6b..15c2f7fca5 100644 --- a/examples/data/large_tokamak_eval_IN.DAT +++ b/examples/data/large_tokamak_eval_IN.DAT @@ -3,7 +3,7 @@ i_process_run_modess_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints -neqns = 2 +n_equality_constraints = 2 * Equalities icc = 1 * Beta diff --git a/examples/data/large_tokamak_varied_min_net_electric_IN.DAT b/examples/data/large_tokamak_varied_min_net_electric_IN.DAT index 695fc8b618..4596349e1b 100644 --- a/examples/data/large_tokamak_varied_min_net_electric_IN.DAT +++ b/examples/data/large_tokamak_varied_min_net_electric_IN.DAT @@ -17,7 +17,7 @@ i_figure_merit = 1 * Error tolerance for VMCON epsvmc = 1e-7 -neqns = 3 +n_equality_constraints = 3 * Constraint Equations - Consistency Equations * ************************************************ diff --git a/examples/data/large_tokamak_varyrun_IN.DAT b/examples/data/large_tokamak_varyrun_IN.DAT index 251a3f17a6..a4d2c8136b 100644 --- a/examples/data/large_tokamak_varyrun_IN.DAT +++ b/examples/data/large_tokamak_varyrun_IN.DAT @@ -17,7 +17,7 @@ i_figure_merit = 1 * Error tolerance for VMCON epsvmc = 1e-7 -neqns = 3 +n_equality_constraints = 3 * Constraint Equations - Consistency Equations * ************************************************ diff --git a/process/core/final.py b/process/core/final.py index 47965f7a55..aea0250b28 100644 --- a/process/core/final.py +++ b/process/core/final.py @@ -63,12 +63,15 @@ def output_evaluation(data): # Print the residuals of the constraint equations residual_error, value, residual, symbols, units = constraints.constraint_eqns( - numerics.neqns + numerics.nineqns, -1, data + numerics.n_equality_constraints + numerics.nineqns, -1, data ) labels = [ numerics.lablcc[j] - for j in [i - 1 for i in numerics.icc[: numerics.neqns + numerics.nineqns]] + for j in [ + i - 1 + for i in numerics.icc[: numerics.n_equality_constraints + numerics.nineqns] + ] ] physical_constraint = [f"{c} {u}" for c, u in zip(value, units, strict=False)] physical_residual = [f"{c} {u}" for c, u in zip(residual, units, strict=False)] @@ -83,7 +86,7 @@ def output_evaluation(data): po.write(constants.NOUT, tabulate(table_data, headers="keys")) - for i in range(numerics.neqns): + for i in range(numerics.n_equality_constraints): constraint_id = numerics.icc[i] po.ovarre( constants.MFILE, @@ -93,10 +96,10 @@ def output_evaluation(data): ) for i in range(numerics.nineqns): - constraint_id = numerics.icc[numerics.neqns + i] + constraint_id = numerics.icc[numerics.n_equality_constraints + i] po.ovarre( constants.MFILE, - f"{labels[numerics.neqns + i]}", + f"{labels[numerics.n_equality_constraints + i]}", f"(ineq_con{constraint_id:03d})", - residual_error[numerics.neqns + i], + residual_error[numerics.n_equality_constraints + i], ) diff --git a/process/core/init.py b/process/core/init.py index 0bad5d872a..26c57c399e 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -160,7 +160,8 @@ def run_summary(): process_output.oblnkl(outfile) process_output.ocmmnt( - outfile, f"Equality constraints : {data_structure.numerics.neqns}" + outfile, + f"Equality constraints : {data_structure.numerics.n_equality_constraints}", ) process_output.ocmmnt( outfile, @@ -168,7 +169,7 @@ def run_summary(): ) process_output.ocmmnt( outfile, - f"Total constraints : {data_structure.numerics.nineqns + data_structure.numerics.neqns}", + f"Total constraints : {data_structure.numerics.nineqns + data_structure.numerics.n_equality_constraints}", ) process_output.ocmmnt( outfile, f"Iteration variables : {data_structure.numerics.nvar}" @@ -225,7 +226,10 @@ def run_summary(): # If optimising, write figure of merit switch if data_structure.numerics.i_process_run_mode == 1: process_output.ovarin( - mfile, "Figure of merit switch", "(i_figure_merit)", data_structure.numerics.i_figure_merit + mfile, + "Figure of merit switch", + "(i_figure_merit)", + data_structure.numerics.i_figure_merit, ) @@ -254,11 +258,11 @@ def check_process(inputs, data): # noqa: ARG001 and ensures other dependent variables are given suitable values. """ # Check that there are sufficient iteration variables - if data_structure.numerics.nvar < data_structure.numerics.neqns: + if data_structure.numerics.nvar < data_structure.numerics.n_equality_constraints: raise ProcessValidationError( "Insufficient iteration variables to solve the problem! NVAR < NEQNS", nvar=data_structure.numerics.nvar, - neqns=data_structure.numerics.neqns, + n_equality_constraints=data_structure.numerics.n_equality_constraints, ) # Check that sufficient elements of ixc and icc have been specified @@ -294,13 +298,14 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 0 ).any(): raise ProcessValidationError( - "The number of constraints specified is smaller than the number stated in neqns+nineqns", - neqns=data_structure.numerics.neqns, + "The number of constraints specified is smaller than the number stated in n_equality_constraints+nineqns", + n_equality_constraints=data_structure.numerics.n_equality_constraints, nineqns=data_structure.numerics.nineqns, ) @@ -308,7 +313,8 @@ def check_process(inputs, data): # noqa: ARG001 for depcrecated_constraint in [3, 4, 10, 74, 42]: if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == depcrecated_constraint ).any(): @@ -319,7 +325,8 @@ def check_process(inputs, data): # noqa: ARG001 # MDK Report error if constraint 63 is used with old vacuum model if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 63 ).any() and data.vacuum.i_vacuum_pumping != "simple": @@ -474,7 +481,8 @@ def check_process(inputs, data): # noqa: ARG001 data_structure.numerics.i_process_run_mode >= 0 and not ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 81 ).any() @@ -495,12 +503,14 @@ def check_process(inputs, data): # noqa: ARG001 # Cannot use Psep/R and PsepB/qAR limits at the same time if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 68 ).any() and ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 56 ).any(): @@ -522,7 +532,8 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 78 ).any(): @@ -539,7 +550,8 @@ def check_process(inputs, data): # noqa: ARG001 if (data.physics.i_l_h_threshold != 6) or ( not ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 15 ).any() @@ -677,7 +689,8 @@ def check_process(inputs, data): # noqa: ARG001 == TFConductorModel.HELIUM_COOLED_ALUMINIUM and ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 85 ).any() @@ -751,7 +764,8 @@ def check_process(inputs, data): # noqa: ARG001 # Constraint 10 is dedicated to ST designs with demountable joints if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 10 ).any(): @@ -795,13 +809,15 @@ def check_process(inputs, data): # noqa: ARG001 and ( ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 31 ).any() or ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 32 ).any() @@ -1151,7 +1167,8 @@ def check_process(inputs, data): # noqa: ARG001 # Cannot use temperature margin constraint with REBCO TF coils if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 36 ).any() and ( @@ -1165,7 +1182,8 @@ def check_process(inputs, data): # noqa: ARG001 # Cannot use temperature margin constraint with REBCO CS coils if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 60 ).any() and data.pf_coil.i_cs_superconductor == 8: @@ -1183,7 +1201,8 @@ def check_process(inputs, data): # noqa: ARG001 # Cannot use TF coil strain limit if i_str_wp is off: if ( data_structure.numerics.icc[ - : data_structure.numerics.neqns + data_structure.numerics.nineqns + : data_structure.numerics.n_equality_constraints + + data_structure.numerics.nineqns ] == 88 ).any() and data_structure.tfcoil_variables.i_str_wp == 0: @@ -1200,11 +1219,15 @@ def set_active_constraints(): ] = True num_constraints += 1 - if data_structure.numerics.neqns < 0: - # The value of neqns has not been set in the input file. Default = 0. - data_structure.numerics.neqns = num_constraints - data_structure.numerics.nineqns + if data_structure.numerics.n_equality_constraints < 0: + # The value of n_equality_constraints has not been set in the input file. Default = 0. + data_structure.numerics.n_equality_constraints = ( + num_constraints - data_structure.numerics.nineqns + ) else: - data_structure.numerics.nineqns = num_constraints - data_structure.numerics.neqns + data_structure.numerics.nineqns = ( + num_constraints - data_structure.numerics.n_equality_constraints + ) def set_device_type(data): diff --git a/process/core/input.py b/process/core/input.py index 99ea6cee66..6c77df1aae 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -113,7 +113,7 @@ def __post_init__(self): "epsfcn": InputVariable(data_structure.numerics, float, range=(0.0, 1.0)), "maxcal": InputVariable(data_structure.global_variables, int, range=(0, 10000)), "i_figure_merit": InputVariable(data_structure.numerics, int), - "neqns": InputVariable( + "n_equality_constraints": InputVariable( data_structure.numerics, int, range=(0, ConstraintManager.num_constraints()) ), "nineqns": InputVariable( diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index 05d71ba74e..38a553e134 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -426,7 +426,7 @@ def get_parameters(data, use_string_values=True): # dict of all module-level variables in source, grouped by module parameters = {} # dict of all parameters set in input file, grouped by module - # Include neqns to allow eq and ineq constraints to be defined in produced IN.DAT + # Include n_equality_constraints to allow eq and ineq constraints to be defined in produced IN.DAT exclusions = ["nvar", "icc", "ixc"] # Parameters to exclude @@ -1306,7 +1306,7 @@ def process_constraint_equation(self, line): # Duplicate constraint equation number self.add_duplicate_variable(f"icc = {item}") # Don't sort the constraints! Preserves what's eq, what's ineq; - # first neqns are eqs, rest are ineqs + # first n_equality_constraints are eqs, rest are ineqs # self.data["icc"].value.sort() def process_iteration_variables(self, line): diff --git a/process/core/io/obsolete_vars.py b/process/core/io/obsolete_vars.py index 4d0197d86b..67aa2d59d1 100644 --- a/process/core/io/obsolete_vars.py +++ b/process/core/io/obsolete_vars.py @@ -448,6 +448,8 @@ "vcool": "vel_cp_coolant_midplane", "rcool": "radius_cp_coolant_channel", "fl_h_threshold": None, + "minmax": "i_figure_merit", + "neqns": "n_equality_constraints", } OBS_VARS_HELP = { diff --git a/process/core/io/plot/solutions.py b/process/core/io/plot/solutions.py index 66aaeba904..b28c026bf0 100644 --- a/process/core/io/plot/solutions.py +++ b/process/core/io/plot/solutions.py @@ -446,7 +446,8 @@ def _plot_solutions( else: numerics.init_numerics() objf_list = { - numerics.lablmm[int(abs(i_figure_merit)) - 1] for i_figure_merit in diffs_df["i_figure_merit"] + numerics.lablmm[int(abs(i_figure_merit)) - 1] + for i_figure_merit in diffs_df["i_figure_merit"] } if len(objf_list) != 1: diff --git a/process/core/scan.py b/process/core/scan.py index 9157015e44..bfb1c02f24 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -259,7 +259,9 @@ def post_optimise(self, ifail: int): ifail: int : """ - numerics.sqsumsq = sum(r**2 for r in numerics.rcm[: numerics.neqns]) ** 0.5 + numerics.sqsumsq = ( + sum(r**2 for r in numerics.rcm[: numerics.n_equality_constraints]) ** 0.5 + ) process_output.oheadr(constants.NOUT, "Numerics") if self.solver == "fsolve": @@ -340,8 +342,8 @@ def post_optimise(self, ifail: int): process_output.ovarin( constants.NOUT, "Number of constraints (total)", - "(neqns+nineqns)", - numerics.neqns + numerics.nineqns, + "(n_equality_constraints+nineqns)", + numerics.n_equality_constraints + numerics.nineqns, ) process_output.ovarin( constants.NOUT, @@ -352,7 +354,10 @@ def post_optimise(self, ifail: int): # Objective function output: none for fsolve if self.solver != "fsolve": process_output.ovarin( - constants.NOUT, "Figure of merit switch", "(i_figure_merit)", numerics.i_figure_merit + constants.NOUT, + "Figure of merit switch", + "(i_figure_merit)", + numerics.i_figure_merit, ) objf_name = f'"{numerics.lablmm[abs(numerics.i_figure_merit) - 1]}"' @@ -526,12 +531,12 @@ def post_optimise(self, ifail: int): ) con1, con2, err, _, lab = constraints.constraint_eqns( - numerics.neqns + numerics.nineqns, -1, self.data + numerics.n_equality_constraints + numerics.nineqns, -1, self.data ) # Write equality constraints to mfile equality_constraint_table = [] - for i in range(numerics.neqns): + for i in range(numerics.n_equality_constraints): name = numerics.lablcc[numerics.icc[i] - 1] equality_constraint_table.append([ @@ -599,7 +604,10 @@ def post_optimise(self, ifail: int): "might be violated.", ) - for i in range(numerics.neqns, numerics.neqns + numerics.nineqns): + for i in range( + numerics.n_equality_constraints, + numerics.n_equality_constraints + numerics.nineqns, + ): name = numerics.lablcc[numerics.icc[i] - 1] constraint = constraints.ConstraintManager.evaluate_constraint( int(numerics.icc[i]), self.data diff --git a/process/core/solver/objectives.py b/process/core/solver/objectives.py index 9d80341630..291a97fec8 100644 --- a/process/core/solver/objectives.py +++ b/process/core/solver/objectives.py @@ -94,7 +94,9 @@ def objective_function(i_figure_merit: int, data: DataStructure) -> float: objective_metric = data.times.t_plant_pulse_burn / 2.0e4 case 15: if data.costs.i_plant_availability != 1: - raise ProcessValueError("i_figure_merit=15 requires i_plant_availability=1") + raise ProcessValueError( + "i_figure_merit=15 requires i_plant_availability=1" + ) objective_metric = data.costs.f_t_plant_available case 16: objective_metric = 0.95 * (data.physics.rmajor / 9.0) - 0.05 * ( diff --git a/process/core/solver/solver_handler.py b/process/core/solver/solver_handler.py index 5094c5a9e2..541ae3b0e8 100644 --- a/process/core/solver/solver_handler.py +++ b/process/core/solver/solver_handler.py @@ -43,8 +43,8 @@ def run(self): bndu = numerics.itv_scaled_upper_bounds[:n] # Define total number of constraints and equality constraints - m = numerics.neqns + numerics.nineqns - meq = numerics.neqns + m = numerics.n_equality_constraints + numerics.nineqns + meq = numerics.n_equality_constraints # Evaluators() calculates the objective and constraint functions and # their gradients for a given vector x diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 1ac9f25f59..0fd0f164d5 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -53,14 +53,14 @@ """ n_constraints: int = None -"""Total number of constraints (neqns + nineqns)""" +"""Total number of constraints (n_equality_constraints + nineqns)""" ncalls: int = None """number of function calls during solution""" -neqns: int = None -"""number of equality constraints to be satisfied""" +n_equality_constraints: int = None +"""Number of equality constraints to be satisfied""" nfev1: int = None """number of calls to FCNHYB (HYBRD function caller) made""" @@ -457,7 +457,7 @@ def init_numerics(): lablmm, \ n_constraints, \ ncalls, \ - neqns, \ + n_equality_constraints, \ nfev1, \ nfev2, \ nineqns, \ @@ -515,7 +515,7 @@ def init_numerics(): ] ncalls = 0 - neqns = -1 + n_equality_constraints = -1 nfev1 = 0 nfev2 = 0 nineqns = 0 diff --git a/tests/integration/data/large_tokamak_eval.IN.DAT b/tests/integration/data/large_tokamak_eval.IN.DAT index 2c3ce7a804..8bd7a1f299 100644 --- a/tests/integration/data/large_tokamak_eval.IN.DAT +++ b/tests/integration/data/large_tokamak_eval.IN.DAT @@ -3,7 +3,7 @@ i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints -neqns = 2 +n_equality_constraints = 2 * Equalities icc = 1 * Beta diff --git a/tests/integration/test_vmcon.py b/tests/integration/test_vmcon.py index 1630840081..6c54f5c345 100644 --- a/tests/integration/test_vmcon.py +++ b/tests/integration/test_vmcon.py @@ -422,12 +422,12 @@ def get_case1(): case = Case("1", Evaluator1()) # Set up solver args for this case - neqns = 1 + n_equality_constraints = 1 nineqns = 1 case.solver_args.x[0:2] = 2.0e0 case.solver_args.n = 2 - case.solver_args.m = neqns + nineqns - case.solver_args.meq = neqns + case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.meq = n_equality_constraints # Expected values case.exp.x = np.array([8.228756e-1, 9.114378e-1]) @@ -456,11 +456,11 @@ def get_case2(): case = Case("2", Evaluator2()) # Solver args for this case - neqns = 0 + n_equality_constraints = 0 nineqns = 2 case.solver_args.n = 2 - case.solver_args.m = neqns + nineqns - case.solver_args.meq = neqns + case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.meq = n_equality_constraints case.solver_args.x[0:2] = 2.0e0 # Expected values @@ -493,11 +493,11 @@ def get_case3(): case = Case("3", Evaluator3()) # Solver args for this case - neqns = 1 + n_equality_constraints = 1 nineqns = 1 case.solver_args.n = 2 - case.solver_args.m = neqns + nineqns - case.solver_args.meq = neqns + case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.meq = n_equality_constraints case.solver_args.x[0:2] = 2.0e0 # Expected values @@ -527,11 +527,11 @@ def get_case4(): case = Case("4", Evaluator4()) # Set up vmcon values for this case - neqns = 1 + n_equality_constraints = 1 nineqns = 0 case.solver_args.n = 2 - case.solver_args.m = neqns + nineqns - case.solver_args.meq = neqns + case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.meq = n_equality_constraints case.solver_args.xtol = 2.0e-8 case.solver_args.x[0:2] = 1.0e0 # N.B. results can flip to minimum instead of maximum @@ -569,11 +569,11 @@ def get_case5(): case.solver_args = SolverArgs(n=1) # Set up vmcon values for this case - neqns = 1 + n_equality_constraints = 1 nineqns = 0 case.solver_args.n = 1 - case.solver_args.m = neqns + nineqns - case.solver_args.meq = neqns + case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.meq = n_equality_constraints case.solver_args.x = np.array([ 5.0 ]) # Try different values, e.g. 5.0, 2.0, 1.0, 0.0... diff --git a/tests/regression/input_files/IFE.IN.DAT b/tests/regression/input_files/IFE.IN.DAT index f8be574fd6..361b5ac9b2 100644 --- a/tests/regression/input_files/IFE.IN.DAT +++ b/tests/regression/input_files/IFE.IN.DAT @@ -9,7 +9,7 @@ *---------------Constraint Equations---------------* -neqns = 0 *No equality constraints +n_equality_constraints = 0 *No equality constraints icc = 16 *Net electric power lower limit *---------------Iteration Variables----------------* diff --git a/tests/regression/input_files/helias_5b.IN.DAT b/tests/regression/input_files/helias_5b.IN.DAT index f7494aa611..8f526ba5ac 100644 --- a/tests/regression/input_files/helias_5b.IN.DAT +++ b/tests/regression/input_files/helias_5b.IN.DAT @@ -9,7 +9,7 @@ *---------------Constraint Equations---------------* -neqns = 3 *number of equalities +n_equality_constraints = 3 *number of equalities *--------------- equaltities diff --git a/tests/regression/input_files/large_tokamak_eval.IN.DAT b/tests/regression/input_files/large_tokamak_eval.IN.DAT index 6eb78b2ef2..7299453f6d 100644 --- a/tests/regression/input_files/large_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/large_tokamak_eval.IN.DAT @@ -3,7 +3,7 @@ i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints -neqns = 2 +n_equality_constraints = 2 * Equalities icc = 1 * Beta diff --git a/tests/regression/input_files/large_tokamak_nof.IN.DAT b/tests/regression/input_files/large_tokamak_nof.IN.DAT index 182184909d..e236fe148f 100644 --- a/tests/regression/input_files/large_tokamak_nof.IN.DAT +++ b/tests/regression/input_files/large_tokamak_nof.IN.DAT @@ -18,8 +18,8 @@ i_figure_merit = 1 epsvmc = 1e-7 * Number of equality constraints -* (the first neqns icc=... statements are equality constraints) -neqns = 3 +* (the first n_equality_constraints icc=... statements are equality constraints) +n_equality_constraints = 3 * Maximum number of solver iterations maxcal = 100 diff --git a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT index 182b538854..01d93bb8ce 100644 --- a/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT +++ b/tests/regression/input_files/low_aspect_ratio_DEMO.IN.DAT @@ -33,7 +33,7 @@ i_figure_merit = -14 * Switch for figure-of-merit (see lablmm for descriptions * DESCRIPTION: Switch for Figure-of-Merit (1: Minimise major radius) * JUSTIFICATION: Aim to minimise major radius -neqns = 4 +n_equality_constraints = 4 * DESCRIPTION: No of equality constraints * JUSTIFICATION: diff --git a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT index 641a225504..a5a70f3373 100644 --- a/tests/regression/input_files/spherical_tokamak_eval.IN.DAT +++ b/tests/regression/input_files/spherical_tokamak_eval.IN.DAT @@ -3,7 +3,7 @@ i_process_run_mode = -2 *---------------Constraint Equations---------------* * Define number of equality constraints -neqns = 3 +n_equality_constraints = 3 * Equalities icc = 1 * Beta diff --git a/tests/regression/input_files/st_regression.IN.DAT b/tests/regression/input_files/st_regression.IN.DAT index f2e3d57705..f985c34c7e 100644 --- a/tests/regression/input_files/st_regression.IN.DAT +++ b/tests/regression/input_files/st_regression.IN.DAT @@ -55,8 +55,8 @@ i_figure_merit = -5 * DESCRIPTION: Switch for Figure-of-Merit * JUSTIFICATION: Selected optimisation -neqns = 3 -* DESCRIPTION: Number of equality constraints (the first neqns icc = ... statements are considered equality) +n_equality_constraints = 3 +* DESCRIPTION: Number of equality constraints (the first n_equality_constraints icc = ... statements are considered equality) * JUSTIFICATION: 3 equality (consistency) equations *________________________________________________________________________* diff --git a/tests/regression/input_files/stellarator_helias.IN.DAT b/tests/regression/input_files/stellarator_helias.IN.DAT index 449e427404..aaac3022f4 100644 --- a/tests/regression/input_files/stellarator_helias.IN.DAT +++ b/tests/regression/input_files/stellarator_helias.IN.DAT @@ -9,7 +9,7 @@ *---------------Constraint Equations---------------* -neqns = 2 *number of equalities +n_equality_constraints = 2 *number of equalities *--------------- equaltities From 77d6fb17bbe932676172f361e1026d18b9c90991 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 14:51:32 +0100 Subject: [PATCH 07/10] Rename numeric variable `nineqns` to `n_inequality_constraints` across codebase and documentation for style guide compliance --- process/core/final.py | 8 +++-- process/core/init.py | 42 +++++++++++++-------------- process/core/input.py | 2 +- process/core/io/obsolete_vars.py | 1 + process/core/scan.py | 12 ++++---- process/core/solver/solver_handler.py | 2 +- process/data_structure/numerics.py | 8 ++--- tests/integration/test_vmcon.py | 20 ++++++------- 8 files changed, 50 insertions(+), 45 deletions(-) diff --git a/process/core/final.py b/process/core/final.py index aea0250b28..657151b0ef 100644 --- a/process/core/final.py +++ b/process/core/final.py @@ -63,14 +63,16 @@ def output_evaluation(data): # Print the residuals of the constraint equations residual_error, value, residual, symbols, units = constraints.constraint_eqns( - numerics.n_equality_constraints + numerics.nineqns, -1, data + numerics.n_equality_constraints + numerics.n_inequality_constraints, -1, data ) labels = [ numerics.lablcc[j] for j in [ i - 1 - for i in numerics.icc[: numerics.n_equality_constraints + numerics.nineqns] + for i in numerics.icc[ + : numerics.n_equality_constraints + numerics.n_inequality_constraints + ] ] ] physical_constraint = [f"{c} {u}" for c, u in zip(value, units, strict=False)] @@ -95,7 +97,7 @@ def output_evaluation(data): residual_error[i], ) - for i in range(numerics.nineqns): + for i in range(numerics.n_inequality_constraints): constraint_id = numerics.icc[numerics.n_equality_constraints + i] po.ovarre( constants.MFILE, diff --git a/process/core/init.py b/process/core/init.py index 26c57c399e..dd46815696 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -165,11 +165,11 @@ def run_summary(): ) process_output.ocmmnt( outfile, - f"Inequality constraints : {data_structure.numerics.nineqns}", + f"Inequality constraints : {data_structure.numerics.n_inequality_constraints}", ) process_output.ocmmnt( outfile, - f"Total constraints : {data_structure.numerics.nineqns + data_structure.numerics.n_equality_constraints}", + f"Total constraints : {data_structure.numerics.n_inequality_constraints + data_structure.numerics.n_equality_constraints}", ) process_output.ocmmnt( outfile, f"Iteration variables : {data_structure.numerics.nvar}" @@ -299,14 +299,14 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 0 ).any(): raise ProcessValidationError( - "The number of constraints specified is smaller than the number stated in n_equality_constraints+nineqns", + "The number of constraints specified is smaller than the number stated in n_equality_constraints+n_inequality_constraints", n_equality_constraints=data_structure.numerics.n_equality_constraints, - nineqns=data_structure.numerics.nineqns, + n_inequality_constraints=data_structure.numerics.n_inequality_constraints, ) # Deprecate constraints @@ -314,7 +314,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == depcrecated_constraint ).any(): @@ -326,7 +326,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 63 ).any() and data.vacuum.i_vacuum_pumping != "simple": @@ -482,7 +482,7 @@ def check_process(inputs, data): # noqa: ARG001 and not ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 81 ).any() @@ -504,13 +504,13 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 68 ).any() and ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 56 ).any(): @@ -533,7 +533,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 78 ).any(): @@ -551,7 +551,7 @@ def check_process(inputs, data): # noqa: ARG001 not ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 15 ).any() @@ -690,7 +690,7 @@ def check_process(inputs, data): # noqa: ARG001 and ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 85 ).any() @@ -765,7 +765,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 10 ).any(): @@ -810,14 +810,14 @@ def check_process(inputs, data): # noqa: ARG001 ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 31 ).any() or ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 32 ).any() @@ -1168,7 +1168,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 36 ).any() and ( @@ -1183,7 +1183,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 60 ).any() and data.pf_coil.i_cs_superconductor == 8: @@ -1202,7 +1202,7 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.icc[ : data_structure.numerics.n_equality_constraints - + data_structure.numerics.nineqns + + data_structure.numerics.n_inequality_constraints ] == 88 ).any() and data_structure.tfcoil_variables.i_str_wp == 0: @@ -1222,10 +1222,10 @@ def set_active_constraints(): if data_structure.numerics.n_equality_constraints < 0: # The value of n_equality_constraints has not been set in the input file. Default = 0. data_structure.numerics.n_equality_constraints = ( - num_constraints - data_structure.numerics.nineqns + num_constraints - data_structure.numerics.n_inequality_constraints ) else: - data_structure.numerics.nineqns = ( + data_structure.numerics.n_inequality_constraints = ( num_constraints - data_structure.numerics.n_equality_constraints ) diff --git a/process/core/input.py b/process/core/input.py index 6c77df1aae..7afe280c30 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -116,7 +116,7 @@ def __post_init__(self): "n_equality_constraints": InputVariable( data_structure.numerics, int, range=(0, ConstraintManager.num_constraints()) ), - "nineqns": InputVariable( + "n_inequality_constraints": InputVariable( data_structure.numerics, int, range=(0, ConstraintManager.num_constraints()) ), "alphaj": InputVariable("physics", float, range=(0.0, 10.0)), diff --git a/process/core/io/obsolete_vars.py b/process/core/io/obsolete_vars.py index 67aa2d59d1..74bffe827b 100644 --- a/process/core/io/obsolete_vars.py +++ b/process/core/io/obsolete_vars.py @@ -450,6 +450,7 @@ "fl_h_threshold": None, "minmax": "i_figure_merit", "neqns": "n_equality_constraints", + "nineqns": "n_inequality_constraints", } OBS_VARS_HELP = { diff --git a/process/core/scan.py b/process/core/scan.py index bfb1c02f24..233c19ace4 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -342,8 +342,8 @@ def post_optimise(self, ifail: int): process_output.ovarin( constants.NOUT, "Number of constraints (total)", - "(n_equality_constraints+nineqns)", - numerics.n_equality_constraints + numerics.nineqns, + "(n_equality_constraints+n_inequality_constraints)", + numerics.n_equality_constraints + numerics.n_inequality_constraints, ) process_output.ovarin( constants.NOUT, @@ -531,7 +531,9 @@ def post_optimise(self, ifail: int): ) con1, con2, err, _, lab = constraints.constraint_eqns( - numerics.n_equality_constraints + numerics.nineqns, -1, self.data + numerics.n_equality_constraints + numerics.n_inequality_constraints, + -1, + self.data, ) # Write equality constraints to mfile @@ -590,7 +592,7 @@ def post_optimise(self, ifail: int): ) # Write inequality constraints - if numerics.nineqns > 0: + if numerics.n_inequality_constraints > 0: inequality_constraint_table = [] # Inequalities not necessarily satisfied when evaluating process_output.osubhd( @@ -606,7 +608,7 @@ def post_optimise(self, ifail: int): for i in range( numerics.n_equality_constraints, - numerics.n_equality_constraints + numerics.nineqns, + numerics.n_equality_constraints + numerics.n_inequality_constraints, ): name = numerics.lablcc[numerics.icc[i] - 1] constraint = constraints.ConstraintManager.evaluate_constraint( diff --git a/process/core/solver/solver_handler.py b/process/core/solver/solver_handler.py index 541ae3b0e8..d2d68545ad 100644 --- a/process/core/solver/solver_handler.py +++ b/process/core/solver/solver_handler.py @@ -43,7 +43,7 @@ def run(self): bndu = numerics.itv_scaled_upper_bounds[:n] # Define total number of constraints and equality constraints - m = numerics.n_equality_constraints + numerics.nineqns + m = numerics.n_equality_constraints + numerics.n_inequality_constraints meq = numerics.n_equality_constraints # Evaluators() calculates the objective and constraint functions and diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 0fd0f164d5..0da3831235 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -53,7 +53,7 @@ """ n_constraints: int = None -"""Total number of constraints (n_equality_constraints + nineqns)""" +"""Total number of constraints (n_equality_constraints + n_inequality_constraints)""" ncalls: int = None @@ -68,7 +68,7 @@ nfev2: int = None """number of calls to FCNVMC1 (VMCON function caller) made""" -nineqns: int = None +n_inequality_constraints: int = None """number of inequality constraints VMCON must satisfy (leave at zero for now) """ @@ -460,7 +460,7 @@ def init_numerics(): n_equality_constraints, \ nfev1, \ nfev2, \ - nineqns, \ + n_inequality_constraints, \ nvar, \ nviter, \ icc, \ @@ -518,7 +518,7 @@ def init_numerics(): n_equality_constraints = -1 nfev1 = 0 nfev2 = 0 - nineqns = 0 + n_inequality_constraints = 0 nvar = 0 n_constraints = 0 nviter = 0 diff --git a/tests/integration/test_vmcon.py b/tests/integration/test_vmcon.py index 6c54f5c345..ba2df52315 100644 --- a/tests/integration/test_vmcon.py +++ b/tests/integration/test_vmcon.py @@ -423,10 +423,10 @@ def get_case1(): # Set up solver args for this case n_equality_constraints = 1 - nineqns = 1 + n_inequality_constraints = 1 case.solver_args.x[0:2] = 2.0e0 case.solver_args.n = 2 - case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.m = n_equality_constraints + n_inequality_constraints case.solver_args.meq = n_equality_constraints # Expected values @@ -457,9 +457,9 @@ def get_case2(): # Solver args for this case n_equality_constraints = 0 - nineqns = 2 + n_inequality_constraints = 2 case.solver_args.n = 2 - case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.m = n_equality_constraints + n_inequality_constraints case.solver_args.meq = n_equality_constraints case.solver_args.x[0:2] = 2.0e0 @@ -494,9 +494,9 @@ def get_case3(): # Solver args for this case n_equality_constraints = 1 - nineqns = 1 + n_inequality_constraints = 1 case.solver_args.n = 2 - case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.m = n_equality_constraints + n_inequality_constraints case.solver_args.meq = n_equality_constraints case.solver_args.x[0:2] = 2.0e0 @@ -528,9 +528,9 @@ def get_case4(): # Set up vmcon values for this case n_equality_constraints = 1 - nineqns = 0 + n_inequality_constraints = 0 case.solver_args.n = 2 - case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.m = n_equality_constraints + n_inequality_constraints case.solver_args.meq = n_equality_constraints case.solver_args.xtol = 2.0e-8 case.solver_args.x[0:2] = 1.0e0 @@ -570,9 +570,9 @@ def get_case5(): # Set up vmcon values for this case n_equality_constraints = 1 - nineqns = 0 + n_inequality_constraints = 0 case.solver_args.n = 1 - case.solver_args.m = n_equality_constraints + nineqns + case.solver_args.m = n_equality_constraints + n_inequality_constraints case.solver_args.meq = n_equality_constraints case.solver_args.x = np.array([ 5.0 From 33863af9f6497951f251b5516b98ea8620830f8c Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 14:59:56 +0100 Subject: [PATCH 08/10] Rename variable `ncalls` to `n_model_calls` in numerics for style guide compliance --- process/core/caller.py | 2 +- process/data_structure/numerics.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/process/core/caller.py b/process/core/caller.py index 851caea9ae..02fe631d9f 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -262,7 +262,7 @@ def _call_models_once(self, xc: np.ndarray, data: DataStructure): nvars = len(xc) # Increment the call counter - data_structure.numerics.ncalls += 1 + data_structure.numerics.n_model_calls += 1 # Convert variables set_scaled_iteration_variable(xc, nvars, self.data) diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 0da3831235..ff66d07da9 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -56,8 +56,8 @@ """Total number of constraints (n_equality_constraints + n_inequality_constraints)""" -ncalls: int = None -"""number of function calls during solution""" +n_model_calls: int = None +"""Number of model calls during solution""" n_equality_constraints: int = None """Number of equality constraints to be satisfied""" @@ -456,7 +456,7 @@ def init_numerics(): i_figure_merit, \ lablmm, \ n_constraints, \ - ncalls, \ + n_model_calls, \ n_equality_constraints, \ nfev1, \ nfev2, \ @@ -514,7 +514,7 @@ def init_numerics(): "max Q, max t_plant_pulse_burn ", ] - ncalls = 0 + n_model_calls = 0 n_equality_constraints = -1 nfev1 = 0 nfev2 = 0 From d374e1408392a470be759be74bf726f7c8504f3d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 15:04:56 +0100 Subject: [PATCH 09/10] Rename numeric variable `nvar` to `n_iteration_variables` across codebase and documentation for style guide compliance --- documentation/source/usage/troubleshooting.md | 6 +- process/core/caller.py | 2 +- process/core/init.py | 118 ++++++++++++++---- process/core/input.py | 4 +- process/core/io/in_dat/base.py | 2 +- process/core/io/mfile/base.py | 2 +- process/core/io/plot/summary.py | 4 +- process/core/scan.py | 7 +- process/core/solver/iteration_variables.py | 4 +- process/core/solver/solver.py | 6 +- process/core/solver/solver_handler.py | 2 +- process/data_structure/numerics.py | 8 +- process/main.py | 2 +- process/models/build.py | 4 +- 14 files changed, 122 insertions(+), 49 deletions(-) diff --git a/documentation/source/usage/troubleshooting.md b/documentation/source/usage/troubleshooting.md index 019c217257..f50dd9831c 100644 --- a/documentation/source/usage/troubleshooting.md +++ b/documentation/source/usage/troubleshooting.md @@ -46,9 +46,9 @@ The is the option to turn on extra debugging output; to do this, set `verbose = ### Optimisation problems On reflection it is perhaps surprising that PROCESS ever does manage to find the global minimum -figure of merit value, if there are `nvar` iteration variables active the search is -over `nvar`-dimensional parameter space, in which there may be many shallow minima of approximately -equal depth. Remember that `nvar` is usually of the order of twenty. +figure of merit value, if there are `n_iteration_variables` iteration variables active the search is +over `n_iteration_variables`-dimensional parameter space, in which there may be many shallow minima of approximately +equal depth. Remember that `n_iteration_variables` is usually of the order of twenty. The machine found by PROCESS may not, therefore, be the absolute optimal device. It is quite easy to have two or more solutions, with results only a few percent different, but a long way apart in diff --git a/process/core/caller.py b/process/core/caller.py index 02fe631d9f..dbbad1601c 100644 --- a/process/core/caller.py +++ b/process/core/caller.py @@ -417,7 +417,7 @@ def write_output_files( ifail : int solver return code """ - n = data_structure.numerics.nvar + n = data_structure.numerics.n_iteration_variables x = data_structure.numerics.xcm[:n] # Call models, ensuring output mfiles are fully idempotent caller = Caller(models, data) diff --git a/process/core/init.py b/process/core/init.py index dd46815696..dfc77995bb 100644 --- a/process/core/init.py +++ b/process/core/init.py @@ -172,7 +172,8 @@ def run_summary(): f"Total constraints : {data_structure.numerics.n_inequality_constraints + data_structure.numerics.n_equality_constraints}", ) process_output.ocmmnt( - outfile, f"Iteration variables : {data_structure.numerics.nvar}" + outfile, + f"Iteration variables : {data_structure.numerics.n_iteration_variables}", ) # If optimising, write objective function and convergence parameter if data_structure.numerics.i_process_run_mode == 1: @@ -258,23 +259,32 @@ def check_process(inputs, data): # noqa: ARG001 and ensures other dependent variables are given suitable values. """ # Check that there are sufficient iteration variables - if data_structure.numerics.nvar < data_structure.numerics.n_equality_constraints: + if ( + data_structure.numerics.n_iteration_variables + < data_structure.numerics.n_equality_constraints + ): raise ProcessValidationError( "Insufficient iteration variables to solve the problem! NVAR < NEQNS", - nvar=data_structure.numerics.nvar, + n_iteration_variables=data_structure.numerics.n_iteration_variables, n_equality_constraints=data_structure.numerics.n_equality_constraints, ) # Check that sufficient elements of ixc and icc have been specified - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 0).any(): + if ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] == 0 + ).any(): raise ProcessValidationError( "The number of iteration variables specified is smaller than the number stated in ixc", - nvar=data_structure.numerics.nvar, + n_iteration_variables=data_structure.numerics.n_iteration_variables, ) # Check that dr_tf_wp_with_insulation (ixc = 140) and dr_tf_inboard (ixc = 13) are not being used simultaneously as iteration variables - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 13).any() and ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 140 + if ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 13 + ).any() and ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 140 ).any(): raise ProcessValidationError( "Iteration variables 13 and 140 cannot be used simultaneously", @@ -282,15 +292,20 @@ def check_process(inputs, data): # noqa: ARG001 # Can't use c_tf_turn as interation var, constraint or input if i_tf_turns_integer == 1 if ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 60 + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 60 ).any() and data_structure.tfcoil_variables.i_tf_turns_integer == 1: raise ProcessValidationError( "Iteration variable 60 (TF current per turn, c_tf_turn) cannot be used with the TF coil integer turn model (i_tf_turns_integer == 1) as it is a calculated output instead for this model. However, the maximum current per turn can be constrained with constraint 77." ) # Can't have icc 77 and ixc 60 at the same time - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 60).any() and ( - data_structure.numerics.icc[: data_structure.numerics.nvar] == 77 + if ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 60 + ).any() and ( + data_structure.numerics.icc[: data_structure.numerics.n_iteration_variables] + == 77 ).any(): raise ProcessValidationError( "Cannot use iteration variable 60 (TF coil current per turn, c_tf_turn) and constraint 77 (maximum TF current per turn) simultaneously." @@ -370,7 +385,10 @@ def check_process(inputs, data): # noqa: ARG001 # Stop the run if oacdcp is used as an optimisation variable # As the current density is now calculated from b_plasma_toroidal_on_axis without constraint 10 - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 12).any(): + if ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 12 + ).any(): raise ProcessValidationError( "The 1/R toroidal B field dependency constraint is being depreciated" ) @@ -423,7 +441,12 @@ def check_process(inputs, data): # noqa: ARG001 if ( data_structure.numerics.i_process_run_mode >= 0 - and (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 4).any() + and ( + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 4 + ).any() and data_structure.numerics.boundl[3] < data.physics.temp_plasma_pedestal_kev * 1.001 ): @@ -443,7 +466,10 @@ def check_process(inputs, data): # noqa: ARG001 if ( data.physics.f_nd_plasma_pedestal_greenwald < 0 or not ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 145 + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 145 ).any() ): # Issue #589 Pedestal density is set manually using nd_plasma_pedestal_electron but it is less than nd_plasma_separatrix_electron. @@ -488,13 +514,21 @@ def check_process(inputs, data): # noqa: ARG001 ).any() ): if ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 145 + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 145 ).any(): warn( "nd_plasma_pedestal_electron set with f_nd_plasma_pedestal_greenwald without constraint eq 81 (nd_plasma_pedestal_electron 273.15 K" @@ -655,7 +696,10 @@ def check_process(inputs, data): # noqa: ARG001 # Check if conductor upper limit is properly set to 50 K or below if ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 20 + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 20 ).any() and data_structure.numerics.boundu[19] > 50.0: raise ProcessValidationError( "Too large CP conductor temperature (temp_cp_average). Upper limit for cryo-al < 50 K" @@ -715,7 +759,12 @@ def check_process(inputs, data): # noqa: ARG001 # Checking the CP TF top radius if ( abs(data.build.r_cp_top) > 0 - or (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 174).any() + or ( + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 174 + ).any() ) and data.build.i_r_cp_top != 1: raise ProcessValidationError( "To set the TF CP top value, you must use i_r_cp_top = 1" @@ -788,12 +837,23 @@ def check_process(inputs, data): # noqa: ARG001 if ( ( not ( - (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 16).any() + ( + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 16 + ).any() or ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 29 + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 29 ).any() or ( - data_structure.numerics.ixc[: data_structure.numerics.nvar] == 42 + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 42 ).any() ) ) # No dr_bore,dr_cs_tf_gap, dr_cs iteration @@ -999,7 +1059,10 @@ def check_process(inputs, data): # noqa: ARG001 # Check if the WP/conductor radial thickness (dr_tf_wp_with_insulation) is large enough # To contains the insulation, cooling and the support structure # Rem : Only verified if the WP thickness is used - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 140).any(): + if ( + data_structure.numerics.ixc[: data_structure.numerics.n_iteration_variables] + == 140 + ).any(): # Minimal WP thickness if data_structure.tfcoil_variables.i_tf_sup == TFConductorModel.SUPERCONDUCTING: dr_tf_wp_min = 2.0 * ( @@ -1010,7 +1073,12 @@ def check_process(inputs, data): # noqa: ARG001 ) # Steel conduit thickness (can be an iteration variable) - if (data_structure.numerics.ixc[: data_structure.numerics.nvar] == 58).any(): + if ( + data_structure.numerics.ixc[ + : data_structure.numerics.n_iteration_variables + ] + == 58 + ).any(): dr_tf_wp_min += 2.0 * data_structure.numerics.boundl[57] else: dr_tf_wp_min += 2.0 * data_structure.tfcoil_variables.dx_tf_turn_steel diff --git a/process/core/input.py b/process/core/input.py index 7afe280c30..85b8c71c7c 100644 --- a/process/core/input.py +++ b/process/core/input.py @@ -33,8 +33,8 @@ def _ixc_additional_actions(_name, value: int, _array_index, _config): - data_structure.numerics.ixc[data_structure.numerics.nvar] = value - data_structure.numerics.nvar += 1 + data_structure.numerics.ixc[data_structure.numerics.n_iteration_variables] = value + data_structure.numerics.n_iteration_variables += 1 def _icc_additional_actions(_name, value: int, _array_index, _config): diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py index 38a553e134..dfc8849c3e 100644 --- a/process/core/io/in_dat/base.py +++ b/process/core/io/in_dat/base.py @@ -427,7 +427,7 @@ def get_parameters(data, use_string_values=True): parameters = {} # dict of all parameters set in input file, grouped by module # Include n_equality_constraints to allow eq and ineq constraints to be defined in produced IN.DAT - exclusions = ["nvar", "icc", "ixc"] + exclusions = ["n_iteration_variables", "icc", "ixc"] # Parameters to exclude # Change module keys from DICT_MODULE: replace spaces with underscores and diff --git a/process/core/io/mfile/base.py b/process/core/io/mfile/base.py index f43f92306d..91bf45d944 100644 --- a/process/core/io/mfile/base.py +++ b/process/core/io/mfile/base.py @@ -603,7 +603,7 @@ def get_mfile_initial_ixc_values(file_path: Path, data: DataStructure): iteration_variable_names = [] iteration_variable_values = [] - for i in range(data_structure.numerics.nvar): + for i in range(data_structure.numerics.n_iteration_variables): ivar = data_structure.numerics.ixc[i].item() itv = iteration_variables.ITERATION_VARIABLES[ivar] diff --git a/process/core/io/plot/summary.py b/process/core/io/plot/summary.py index 5b3a1c7fcc..e45d1730d8 100644 --- a/process/core/io/plot/summary.py +++ b/process/core/io/plot/summary.py @@ -10378,7 +10378,7 @@ def plot_iteration_variables(axis: plt.Axes, m_file: MFile, scan: int): """ # Get total number of iteration variables - n_itvars = int(m_file.get("nvar", scan=scan)) + n_itvars = int(m_file.get("n_iteration_variables", scan=scan)) y_labels = [] y_pos = [] @@ -11581,7 +11581,7 @@ def plot_cover_page( optmisation_switch = mfile.get("i_process_run_mode", scan=-1) minmax_switch = mfile.get("i_figure_merit", scan=-1) or "N/A" ifail = mfile.get("ifail", scan=-1) - nvars = mfile.get("nvar", scan=-1) + nvars = mfile.get("n_iteration_variables", scan=-1) # Objective_function_name objf_name = mfile.get("objf_name", scan=-1) # Square_root_of_the_sum_of_squares_of_the_constraint_residuals diff --git a/process/core/scan.py b/process/core/scan.py index 233c19ace4..1ffab65c59 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -337,7 +337,10 @@ def post_optimise(self, ifail: int): logger.warning(f"High final constraint residues. {numerics.sqsumsq=}") process_output.ovarin( - constants.NOUT, "Number of iteration variables", "(nvar)", numerics.nvar + constants.NOUT, + "Number of iteration variables", + "(n_iteration_variables)", + numerics.n_iteration_variables, ) process_output.ovarin( constants.NOUT, @@ -428,7 +431,7 @@ def post_optimise(self, ifail: int): # Output optimisation parameters solution_vector_table = [] - for i in range(numerics.nvar): + for i in range(numerics.n_iteration_variables): numerics.xcs[i] = numerics.xcm[i] * numerics.scafc[i] name = numerics.lablxc[numerics.ixc[i] - 1] diff --git a/process/core/solver/iteration_variables.py b/process/core/solver/iteration_variables.py index 4cbbadfff9..6a08d722da 100644 --- a/process/core/solver/iteration_variables.py +++ b/process/core/solver/iteration_variables.py @@ -266,7 +266,7 @@ def check_iteration_variable(iteration_variable_value, name: str = ""): def load_iteration_variables(data): """Loads the physics and engineering variables into the optimisation variable array.""" - for i in range(data_structure.numerics.nvar): + for i in range(data_structure.numerics.n_iteration_variables): variable_index = data_structure.numerics.ixc[i] iteration_variable = ITERATION_VARIABLES[variable_index] @@ -389,7 +389,7 @@ def set_scaled_iteration_variable(xc, nn: int, data: DataStructure): def load_scaled_bounds(): """Sets the scaled bounds of the iteration variables.""" - for i in range(data_structure.numerics.nvar): + for i in range(data_structure.numerics.n_iteration_variables): variable_index = data_structure.numerics.ixc[i] - 1 data_structure.numerics.itv_scaled_lower_bounds[i] = ( data_structure.numerics.boundl[variable_index] diff --git a/process/core/solver/solver.py b/process/core/solver/solver.py index a285de39c7..3fd58fe0f4 100644 --- a/process/core/solver/solver.py +++ b/process/core/solver/solver.py @@ -179,7 +179,7 @@ def solve(self) -> int: bb = None if self.b is not None: - bb = np.identity(numerics.nvar) * self.b + bb = np.identity(numerics.n_iteration_variables) * self.b def _solver_callback(i: int, _result, _x, convergence_param: float): numerics.nviter = i + 1 @@ -256,7 +256,9 @@ def _ineq_cons_satisfied( except ValueError: itervar_name_list = "" - for count, iter_var in enumerate(numerics.ixc[: numerics.nvar]): + for count, iter_var in enumerate( + numerics.ixc[: numerics.n_iteration_variables] + ): itervar_name = numerics.lablxc[iter_var - 1] itervar_name_list += f"{count}: {itervar_name} \n" diff --git a/process/core/solver/solver_handler.py b/process/core/solver/solver_handler.py index d2d68545ad..5b0384113f 100644 --- a/process/core/solver/solver_handler.py +++ b/process/core/solver/solver_handler.py @@ -37,7 +37,7 @@ def run(self): # Initialise iteration variables and bounds in Python: relies on Fortran # iteration variables being defined above # Trim maximum size arrays down to actually used size - n = numerics.nvar + n = numerics.n_iteration_variables x = numerics.xcm[:n] bndl = numerics.itv_scaled_lower_bounds[:n] bndu = numerics.itv_scaled_upper_bounds[:n] diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index ff66d07da9..2f5afc8c0e 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -73,8 +73,8 @@ (leave at zero for now) """ -nvar: int = None -"""number of iteration variables to use""" +n_iteration_variables: int = None +"""Number of iteration variables active during a run""" nviter: int = None """number of optimisation iterations performed""" @@ -461,7 +461,7 @@ def init_numerics(): nfev1, \ nfev2, \ n_inequality_constraints, \ - nvar, \ + n_iteration_variables, \ nviter, \ icc, \ active_constraints, \ @@ -519,7 +519,7 @@ def init_numerics(): nfev1 = 0 nfev2 = 0 n_inequality_constraints = 0 - nvar = 0 + n_iteration_variables = 0 n_constraints = 0 nviter = 0 icc = np.array([0] * N_CONSTRAINT_EQUATIONS_MAX) diff --git a/process/main.py b/process/main.py index a3dbdfbf75..0ccca290e3 100644 --- a/process/main.py +++ b/process/main.py @@ -416,7 +416,7 @@ def initialise(self): # Order optimisation parameters (arbitrary order in input file) # Ensures consistency and makes output comparisons more straightforward - n = int(data_structure.numerics.nvar) + n = int(data_structure.numerics.n_iteration_variables) # [:n] as array always at max size: contains 0s data_structure.numerics.ixc[:n].sort() diff --git a/process/models/build.py b/process/models/build.py index 9ccddc2937..fd888b0be3 100644 --- a/process/models/build.py +++ b/process/models/build.py @@ -1690,7 +1690,7 @@ def calculate_radial_build(self, output: bool): # Issue #514 Radial dimensions of inboard leg # Calculate self.data.build.dr_tf_inboard if tfcoil_variables.dr_tf_wp_with_insulation is an iteration variable (140) - if 140 in numerics.ixc[0 : numerics.nvar]: + if 140 in numerics.ixc[0 : numerics.n_iteration_variables]: self.data.build.dr_tf_inboard = ( tfcoil_variables.dr_tf_wp_with_insulation + tfcoil_variables.dr_tf_plasma_case @@ -1725,7 +1725,7 @@ def calculate_radial_build(self, output: bool): # WP radial thickness [m] # Calculated only if not used as an iteration variable - if 140 not in numerics.ixc[0 : numerics.nvar]: + if 140 not in numerics.ixc[0 : numerics.n_iteration_variables]: tfcoil_variables.dr_tf_wp_with_insulation = ( self.data.build.dr_tf_inboard - tfcoil_variables.dr_tf_plasma_case From 6a6923a47e11d6a117c0c0cc7d92a275b16e0da0 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 27 May 2026 15:07:03 +0100 Subject: [PATCH 10/10] Rename numeric variable `nviter` to `n_solver_iterations` across codebase and documentation for style guide compliance --- process/core/io/plot/summary.py | 4 ++-- process/core/scan.py | 4 ++-- process/core/solver/evaluators.py | 4 ++-- process/core/solver/solver.py | 2 +- process/core/solver/solver_handler.py | 4 ++-- process/data_structure/numerics.py | 8 ++++---- tests/regression/test_process_input_files.py | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/process/core/io/plot/summary.py b/process/core/io/plot/summary.py index e45d1730d8..0c7f37f0ac 100644 --- a/process/core/io/plot/summary.py +++ b/process/core/io/plot/summary.py @@ -11589,7 +11589,7 @@ def plot_cover_page( # VMCON_convergence_parameter convergence_parameter = mfile.get("convergence_parameter", scan=-1) or "N/A" # Number_of_optimising_solver_iterations - nviter = int(mfile.get("nviter", scan=-1)) or "N/A" + n_solver_iterations = int(mfile.get("n_solver_iterations", scan=-1)) or "N/A" # Objective name with minimising/maximising if isinstance(minmax_switch, str): @@ -11666,7 +11666,7 @@ def plot_cover_page( f"{objective_text}\n" f"• Constraint Residuals (sqrt sum sq): {sqsumsq}\n" f"• Convergence Parameter: {convergence_parameter}\n" - f"• Solver Iterations: {nviter}\n" + f"• Solver Iterations: {n_solver_iterations}\n" f"• Runtime: {mfile.get('process_runtime', scan=-1):.6f} seconds" ) axis.text( diff --git a/process/core/scan.py b/process/core/scan.py index 1ffab65c59..78f1efcdc0 100644 --- a/process/core/scan.py +++ b/process/core/scan.py @@ -399,8 +399,8 @@ def post_optimise(self, ifail: int): process_output.ovarin( constants.NOUT, "Number of optimising solver iterations", - "(nviter)", - numerics.nviter, + "(n_solver_iterations)", + numerics.n_solver_iterations, "OP ", ) process_output.oblnkl(constants.NOUT) diff --git a/process/core/solver/evaluators.py b/process/core/solver/evaluators.py index d892bb6e61..4aa31692e3 100644 --- a/process/core/solver/evaluators.py +++ b/process/core/solver/evaluators.py @@ -71,9 +71,9 @@ def fcnvmc1(self, _n, m, xv, ifail): sqsumconfsq = math.sqrt(summ) logger.debug("Key evaluator values:") - logger.debug(f"{numerics.nviter = }") + logger.debug(f"{numerics.n_solver_iterations = }") logger.debug(f"{(1 - (ifail % 7)) - 1 = }") - logger.debug(f"{(numerics.nviter % 2) - 1 = }") + logger.debug(f"{(numerics.n_solver_iterations % 2) - 1 = }") logger.debug(f"{self.data.physics.temp_plasma_electron_vol_avg_kev = }") logger.debug(f"{self.data.costs.coe = }") logger.debug(f"{self.data.physics.rmajor = }") diff --git a/process/core/solver/solver.py b/process/core/solver/solver.py index 3fd58fe0f4..dee9fd6c32 100644 --- a/process/core/solver/solver.py +++ b/process/core/solver/solver.py @@ -182,7 +182,7 @@ def solve(self) -> int: bb = np.identity(numerics.n_iteration_variables) * self.b def _solver_callback(i: int, _result, _x, convergence_param: float): - numerics.nviter = i + 1 + numerics.n_solver_iterations = i + 1 global_variables.convergence_parameter = convergence_param print( f"{i + 1} | Convergence Parameter: {convergence_param:.3E}", diff --git a/process/core/solver/solver_handler.py b/process/core/solver/solver_handler.py index 5b0384113f..2b12dd03f8 100644 --- a/process/core/solver/solver_handler.py +++ b/process/core/solver/solver_handler.py @@ -82,8 +82,8 @@ def run(self): # If VMCON has exited with error code 5 try another run using a multiple # of the identity matrix as input for the Hessian b(n,n) - # Only do this if VMCON has not iterated (nviter=1) - if ifail == 5 and numerics.nviter < 2: + # Only do this if VMCON has not iterated (n_solver_iterations=1) + if ifail == 5 and numerics.n_solver_iterations < 2: print( "VMCON error code = 5. Rerunning VMCON with a new initial " "estimate of the second derivative matrix." diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py index 2f5afc8c0e..951f265f5b 100644 --- a/process/data_structure/numerics.py +++ b/process/data_structure/numerics.py @@ -76,8 +76,8 @@ n_iteration_variables: int = None """Number of iteration variables active during a run""" -nviter: int = None -"""number of optimisation iterations performed""" +n_solver_iterations: int = None +"""Number of optimisation iterations performed""" icc: list[int] = None @@ -462,7 +462,7 @@ def init_numerics(): nfev2, \ n_inequality_constraints, \ n_iteration_variables, \ - nviter, \ + n_solver_iterations, \ icc, \ active_constraints, \ lablcc, \ @@ -521,7 +521,7 @@ def init_numerics(): n_inequality_constraints = 0 n_iteration_variables = 0 n_constraints = 0 - nviter = 0 + n_solver_iterations = 0 icc = np.array([0] * N_CONSTRAINT_EQUATIONS_MAX) active_constraints = [False] * N_CONSTRAINT_EQUATIONS_MAX diff --git a/tests/regression/test_process_input_files.py b/tests/regression/test_process_input_files.py index 0e6b700b5d..4291305987 100644 --- a/tests/regression/test_process_input_files.py +++ b/tests/regression/test_process_input_files.py @@ -27,7 +27,7 @@ "xcm", "convergence_parameter", "sqsumsq", - "nviter", + "n_solver_iterations", "commsg", "procver", r"sig_tf_r_max\(1\)", # weird value, flips between 0 and very low?