Introduction to running PROCESS¶
A Jupyter notebook to demonstrate usage of the process package.
Process can be run from the command line with the process command or as a standard python package.
Using process as a package allows for more complex scripting of a process run for different tasks.
Setup¶
We run the examples in a temporary directory so all the inputs are copied there and the outputs
contained there before the directory is removed when the example has finished running.
This keeps the examples directory tidy and does not permanently modify any data files.
Use of temporary directories is not needed for regular use of PROCESS.
Basic run of Process¶
Run Process on an input file using the SingleRun class. This outputs an MFILE.DAT and an OUT.DAT.
This is equivalent to running process -i data/large_tokamak_IN.DAT in the examples folder.
%load_ext autoreload
%autoreload 2
import shutil
import tempfile
from pathlib import Path
from process.core.repository import get_process_root
from process.main import SingleRun
# Define project root dir; this is using the current working directory
PROJ_DIR = Path.cwd().parent
# Define input file name relative to project dir, then copy to temp dir
data_dir = get_process_root() / "../examples/data/"
input_file = data_dir / "large_tokamak_IN.DAT"
# Copy the file to avoid polluting the project directory with example files
temp_dir = tempfile.TemporaryDirectory()
input_path = Path(temp_dir.name) / "large_tokamak_IN.DAT"
shutil.copy(input_file, input_path)
# Run process on an input file in a temporary directory
single_run = SingleRun(input_path.as_posix())
single_run.run()
The IN.DAT file does not contain any obsolete variables. ************************************************************************************************************** ************************************************** PROCESS *************************************************** ************************************** Power Reactor Optimisation Code *************************************** ************************************************************************************************************** Version : 3.3.1.dev34+g6d036d5d5 Git Tag : v3.3.0-34-g6d036d5d Git Branch : main Date : 26/02/2026 UTC Time : 16:28 User : runner Computer : runnervmnay03 Directory : /home/runner/work/PROCESS/PROCESS Input : /tmp/tmpw_odpj7l/large_tokamak_IN.DAT Run title : Generic large tokamak Run type : Reactor concept design: Pulsed tokamak model, (c) UK Atomic Energy Authority ************************************************************************************************************** Equality constraints : 3 Inequality constraints : 23 Total constraints : 26 Iteration variables : 19 Max iterations : 200 Figure of merit : +1 -- minimise major radius Convergence parameter : 1e-07 **************************************************************************************************************
/home/runner/work/PROCESS/PROCESS/process/core/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/core/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/models/physics/physics.py:7176: RuntimeWarning: divide by zero encountered in scalar divide * (nd_plasma_pedestal_electron / n_greenwald) ** -0.174
1 | Convergence Parameter: 7.936E-01
/home/runner/work/PROCESS/PROCESS/process/models/physics/current_drive.py:2154: RuntimeWarning: invalid value encountered in scalar divide * (c_hcd_driven / p_hcd_injected)
2 | Convergence Parameter: 1.831E-01
3 | Convergence Parameter: 2.837E-02
4 | Convergence Parameter: 7.247E-02
5 | Convergence Parameter: 2.120E-02
6 | Convergence Parameter: 8.867E-03
7 | Convergence Parameter: 1.631E-02
8 | Convergence Parameter: 2.932E-03
9 | Convergence Parameter: 2.889E-03
10 | Convergence Parameter: 6.735E-05
11 | Convergence Parameter: 4.008E-04
12 | Convergence Parameter: 3.389E-03
13 | Convergence Parameter: 2.045E-02
14 | Convergence Parameter: 1.039E-03
15 | Convergence Parameter: 1.224E-07
16 | Convergence Parameter: 6.642E-10
17 | Convergence Parameter: 2.462E-09
************************************* PROCESS found a feasible solution **************************************
******************************************** Errors and Warnings ********************************************* (/home/runner/work/PROCESS/PROCESS/process/models/physics/physics.py:6017) 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/models/tfcoil/base.py:236) dr_tf_plasma_case too small to accommodate the WP, forced to minimum value ******************************************* End of PROCESS Output ********************************************
Plot summary¶
Create a summary of the generated MFILE.DAT using plot_proc.
You can also call plot_proc from the cli with python -m process.core.io.plot_proc
from process.core.io import plot_proc
# Pdf and png output are also available
plot_proc.main(
args=["-f", single_run.mfile_path.as_posix(), "--output-format", "none", "--show"]
)
View key output variables¶
Using the MFILE we generated by running the large tokamak scenario above,
we have set some values on the CostModel instance and can print them.
import process.data_structure
# Print some values on the CostModel instance
print(f"Heat transport system: {process.data_structure.cost_variables.c226:.3e} M$")
print(f"Electrical plant equipment: {process.data_structure.cost_variables.c24:.3e} M$")
Heat transport system: 3.547e+02 M$ Electrical plant equipment: 4.444e+01 M$
Convert to CSV format¶
This demonstrates how you would read from a PROCESS MFILE and write specified values into a csv using the mfile_to_csv function
from process.core.io import mfile_to_csv
# mfile_to_csv requires two inputs:
# - path to the MFILE
# - .json containing the variable names to include in the csv file
# This routine attempts to find every variable listed in the json file
# in the MFILE and writes the variable name, description and value
# to the output csv.
# Any listed variable that isn't in that MFILE will be skipped.
# The .csv file is saved to the directory of the input file
mfile_to_csv.main(
args=[
"-f",
(data_dir / "large_tokamak_1_MFILE.DAT").as_posix(),
"-v",
(data_dir / "mfile_to_csv_vars.json").as_posix(),
]
)
Fetching list of variables from /home/runner/work/PROCESS/PROCESS/process/../examples/data/mfile_to_csv_vars.json Reading from MFILE: /home/runner/work/PROCESS/PROCESS/process/../examples/data/large_tokamak_1_MFILE.DAT Variable 'p_plant_electric_net_required_mw' not in MFILE. Skipping and moving on... Writing to csv file: /home/runner/work/PROCESS/PROCESS/process/../examples/data/large_tokamak_1_MFILE.csv Complete.
# Clean up
temp_dir.cleanup()