Running and visualising a PROCESS scan¶
Perform a parameter scan for a given input file and plot the results.
Scan details¶
The input file is a scan-enabled version of the large tokamak IN.DAT, as found in the tests directory. The scan-relevant values are:
nsweep = 17 * b_tf_inboard_max, maximum peak toroidal field (T) (`constraint equation 25`)
isweep = 6
sweep = 11., 11.2, 11.4, 11.6, 11.8, 12.
nsweep: integer denoting the variable to scan (seescan_modulefor options). Here17corresponds tob_tf_inboard_maxbeing scannedisweep: the number of scan points to runsweep: array of values for the scanned variable to take; one for each run. Should be of lengthisweep
In [1]:
Copied!
from pathlib import Path
from process.main import SingleRun, setup_loggers
# setup the loggers so that the output is not spammed with model errors/warnings
setup_loggers()
data_dir = Path("data")
input_name = data_dir / "scan_example_file_IN.DAT"
# Perform a SingleRun on a scan-enabled input file
single_run = SingleRun(str(input_name), solver="vmcon_bounded")
single_run.run()
from pathlib import Path
from process.main import SingleRun, setup_loggers
# setup the loggers so that the output is not spammed with model errors/warnings
setup_loggers()
data_dir = Path("data")
input_name = data_dir / "scan_example_file_IN.DAT"
# Perform a SingleRun on a scan-enabled input file
single_run = SingleRun(str(input_name), solver="vmcon_bounded")
single_run.run()
The IN.DAT file does not contain any obsolete variables. ************************************************************************************************************** ************************************************** PROCESS *************************************************** ************************************** Power Reactor Optimisation Code *************************************** ************************************************************************************************************** Version : 3.2.1 Git Tag : v3.2.2-14-g1448faf3 Git Branch : main Date : 05/12/2025 UTC Time : 18:09 User : runner Computer : runnervmoqczp Directory : /home/runner/work/PROCESS/PROCESS/examples Input : /home/runner/work/PROCESS/PROCESS/examples/data/scan_example_file_IN.DAT Run title : Generic large tokamak Run type : Reactor concept design: Pulsed tokamak model, (c) UK Atomic Energy Authority ************************************************************************************************************** Equality constraints : 26 Inequality constraints : 0 Total constraints : 26 Iteration variables : 43 Max iterations : 200 Figure of merit : +1 -- minimise major radius Convergence parameter : 1e-07 ************************************************************************************************************** Starting scan point 1 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 11.0
/home/runner/work/PROCESS/PROCESS/process/init.py:92: UserWarning: Lower limit of volume averaged electron temperature (temp_plasma_electron_vol_avg_kev) has been raised to ensure temp_plasma_electron_vol_avg_kev > temp_plasma_pedestal_kev check_process(inputs) /home/runner/work/PROCESS/PROCESS/process/init.py:92: UserWarning: temp_cs_superconductor_margin_min and tmargmin should not both be specified in IN.DAT temp_cs_superconductor_margin_min has been ignored check_process(inputs)
/home/runner/work/PROCESS/PROCESS/process/physics.py:7764: RuntimeWarning: divide by zero encountered in scalar divide * (nd_plasma_pedestal_electron / n_greenwald) ** -0.174
/home/runner/work/PROCESS/PROCESS/process/costs.py:3033: RuntimeWarning: invalid value encountered in sqrt annoam = cost_variables.ucoam[cost_variables.lsa - 1] * np.sqrt( /home/runner/work/PROCESS/PROCESS/process/costs.py:3104: RuntimeWarning: invalid value encountered in sqrt annwst = cost_variables.ucwst[cost_variables.lsa - 1] * np.sqrt(
1 | Convergence Parameter: 2.841E+00
/home/runner/work/PROCESS/PROCESS/process/current_drive.py:1992: RuntimeWarning: invalid value encountered in scalar divide * (c_hcd_driven / p_hcd_injected)
2 | Convergence Parameter: 2.954E-01
3 | Convergence Parameter: 1.247E-01
4 | Convergence Parameter: 4.656E-02
5 | Convergence Parameter: 1.987E-02
6 | Convergence Parameter: 5.997E-05
7 | Convergence Parameter: 1.081E-09
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible Starting scan point 2 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 11.2
1 | Convergence Parameter: 3.044E-04
2 | Convergence Parameter: 1.102E-10
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible Starting scan point 3 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 11.4
1 | Convergence Parameter: 2.956E-04
2 | Convergence Parameter: 3.512E-11
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible Starting scan point 4 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 11.6
1 | Convergence Parameter: 2.864E-04
2 | Convergence Parameter: 7.695E-11
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible Starting scan point 5 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 11.8
1 | Convergence Parameter: 2.768E-04
2 | Convergence Parameter: 7.664E-11
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible Starting scan point 6 of 6 : Max_toroidal_field_(T) , b_tf_inboard_max = 12.0
1 | Convergence Parameter: 2.677E-04
2 | Convergence Parameter: 1.082E-10
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/physics.py:6725) Diamagnetic fraction is more than 1%, but not calculated. Consider using i_diamagnetic_current=2 and i_pfirsch_schluter_current=1 (/home/runner/work/PROCESS/PROCESS/process/tf_coil.py:246) dr_tf_plasma_case to small to accommodate the WP, forced to minimum value (/home/runner/work/PROCESS/PROCESS/process/pfcoil.py:2385) CS not using max current density: further optimisation may be possible ****************************************** Scan Convergence Summary ****************************************** Scan 01: b_tf_inboard_max = 11.0 CONVERGED Scan 02: b_tf_inboard_max = 11.2 CONVERGED Scan 03: b_tf_inboard_max = 11.4 CONVERGED Scan 04: b_tf_inboard_max = 11.6 CONVERGED Scan 05: b_tf_inboard_max = 11.8 CONVERGED Scan 06: b_tf_inboard_max = 12.0 CONVERGED Convergence Percentage: 100.00% ******************************************* End of PROCESS Output ********************************************
Plot scan results¶
Use plot_scans.py to plot the resulting MFILE.DAT.
In [2]:
Copied!
%matplotlib inline
from process.io import plot_scans
# Define working directory relative to project dir and input file name
mfile_name = data_dir / "scan_example_file_MFILE.DAT"
output_dir = data_dir
plot_scans.main(
args=[
"-f",
str(mfile_name),
"-yv",
"b_plasma_toroidal_on_axis rmajor p_plant_electric_net_mw p_fusion_total_mw capcost",
"--outputdir",
str(output_dir),
]
)
%matplotlib inline
from process.io import plot_scans
# Define working directory relative to project dir and input file name
mfile_name = data_dir / "scan_example_file_MFILE.DAT"
output_dir = data_dir
plot_scans.main(
args=[
"-f",
str(mfile_name),
"-yv",
"b_plasma_toroidal_on_axis rmajor p_plant_electric_net_mw p_fusion_total_mw capcost",
"--outputdir",
str(output_dir),
]
)