diff --git a/documentation/source/cost-models/cost-models.md b/documentation/source/cost-models/cost-models.md
index 4b3f0221fa..d985b0c7c5 100644
--- a/documentation/source/cost-models/cost-models.md
+++ b/documentation/source/cost-models/cost-models.md
@@ -4,7 +4,7 @@ Two cost models are available, determined by the switch `cost_model`.
## 1990 cost model (`cost_model = 0`)
-This combines methods[^1] used in the TETRA code [^2] and the Generomak[^3] scheme. The costs are split into accounting categories[^4]. The best references for the algorithms used are[^5], and source file `costs.f90` in the code itself. The majority of the costed items have a unit cost associated with them. These values scale with (for example) power output, volume, component mass etc., and many are available to be changed via the input file. All costs and their algorithms correspond to 1990 dollars.
+This combines methods[^1] used in the TETRA code [^2] and the Generomak[^3] scheme. The costs are split into accounting categories[^4]. The best references for the algorithms used are[^5], and source file `costs.py` in the code itself. The majority of the costed items have a unit cost associated with them. These values scale with (for example) power output, volume, component mass etc., and many are available to be changed via the input file. All costs and their algorithms correspond to 1990 dollars.
The unit costs of the components of the fusion power core are relevant to "first-of-a-kind" items. That is to say, the items are assumed to be relatively expensive to build as they are effectively prototypes and specialised tools and machines have perhaps been made specially to create them. However, if a "production line" has been set up, and R & D progress has allowed more experience to be gained in constructing the power core components, the cost will be reduced as a result. Variable `fkind` may be used to multiply the raw unit costs of the fusion power core items (by a factor less than one) to simulate this cost reduction for an *Nth*-of-a-kind device. In other systems studies of fusion power plants[^6], values for this multiplier have ranged from 0.5 to 0.8.
diff --git a/documentation/source/development/add-vars.md b/documentation/source/development/add-vars.md
index 81ff1b49a1..8e6928f257 100644
--- a/documentation/source/development/add-vars.md
+++ b/documentation/source/development/add-vars.md
@@ -5,9 +5,6 @@ optimisation figure of merit and constraints to the `PROCESS` code.
**At all times the [`PROCESS` style guide](../development/standards.md) must be used.**
-!!! note
-
- As the code is quickly converging towards a wholly Python codebase the respective files may change in type from `.f90` to `.py`.
-----------------
@@ -15,29 +12,21 @@ optimisation figure of merit and constraints to the `PROCESS` code.
To add a `PROCESS` input, please follow below:
-1. Choose the most relevant module `XX` and add the variable in the `XX_variables` defined in `XX_variables.f90`.
+1. Choose the most relevant module `XX` and add the variable in the `XX_variables` defined in `XX_variables.py`.
-2. Add a description of the input variable below the declaration, using the FORD formatting described in the standards section specifying the units.
-
-3. Specify a sensible default value in the `init_XX_variables()` function within the corresponding model `.py` main file
+2. Add a description of the input variable below the declaration, using the formatting described in the standards section specifying the units.
+
+3. Assign a sensible default initial value, and a type.
4. Add the parameter to the `INPUT_VARIABLES` dictionary in `input.py`.
Here is an example of the code to add:
-Variable definition example in `tfcoil_variables.f90`:
-```fortran
- real(dp) :: rho_tf_joints
- !! TF joints surfacic resistivity [ohm.m]
- !! Feldmetal joints assumed.
-```
-
-Variable initialization example in `tf_coil.py`:
+Variable definition and initial value setting example in `tfcoil_variables.py`:
```python
- def init_tfcoil_variables():
- ...
- tfv.rho_tf_joints = 2.5e-10
+ e_tf_coil_magnetic_stored: float = 0.0
+ """Stored magnetic energy in a single TF coil (J)"""
```
Code example in the `input.py` file:
@@ -55,10 +44,10 @@ 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 `ipnvars` in module `numerics` of `numerics.py` 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`.
+4. Update the `lablxc` description in `numerics.py`.
It should be noted that iteration variables must not be reset elsewhere in the
code. That is, they may only be assigned new values when originally
@@ -115,28 +104,45 @@ After following the instruction to add an input variable, you can make the varia
`nsweep` comment example:
-```fortran
+```python
+ nsweep: int = None
+ """Switch denoting quantity to scan:
+ - 1 aspect
+
- 2 pflux_div_heat_load_max_mw
+
- 3 p_plant_electric_net_required_mw
+
- 4 hfact
+```
- integer :: nsweep = 1
- !! nsweep /1/ : switch denoting quantity to scan:
- !! - 1 aspect
- !!
- 2 pflux_div_heat_load_max_mw
- ...
- !!
- 54 GL_nbti upper critical field at 0 Kelvin
- !!
- 55 `dr_shld_inboard` : Inboard neutron shield thickness
+`nsweep_dict` example in `scans.py`
+```python
+nsweep_dict = {
+ 1: "aspect",
+ 2: "pflux_div_heat_load_max_mw",
+ 3: "p_plant_electric_net_mw",
+ 4: "hfact",
+ ...
+}
```
-`SCAN_VARIABLES` case example:
+
+`ScanVariables` case example:
```python
class ScanVariables(Enum):
- aspect: ScanVariable("aspect", "Aspect_ratio", 1),
- pflux_div_heat_load_max_mw: ScanVariable("pflux_div_heat_load_max_mw", "Div_heat_limit_(MW/m2)", 2),
+
...
- Bc2_0K: ScanVariable("Bc2(0K)", "GL_NbTi Bc2(0K)", 54),
- dr_shld_inboard : ScanVariable("dr_shld_inboard", "Inboard neutronic shield", 55),
+
+ aspect = ScanVariable("aspect", "Aspect_ratio", 1)
+ pflux_div_heat_load_max_mw = ScanVariable(
+ "pflux_div_heat_load_max_mw", "Div_heat_limit_(MW/m2)", 2
+ )
+ p_plant_electric_net_required_mw = ScanVariable(
+ "p_plant_electric_net_required_mw", "Net_electric_power_(MW)", 3
+ )
```
+
+
---------------
## Add a constraint equation
diff --git a/documentation/source/development/standards.md b/documentation/source/development/standards.md
index a265e36c32..0c86ba1ea2 100644
--- a/documentation/source/development/standards.md
+++ b/documentation/source/development/standards.md
@@ -37,7 +37,7 @@ Switches should start with the `i_` prefix in their name, be of integer type and
Use an uppercase single letter, word, or words. Separate words with underscores to improve readability.
-Refrain from declaring or typing known numerical constants directly in the code. Instead call the value from `constants.f90`
+Refrain from declaring or typing known numerical constants directly in the code. Instead call the value from `constants.py`
If the constants doesn't exist then add it with a source link and uncertainty value.
---------------------
@@ -524,13 +524,13 @@ Try to keep names to a sensible length while also keeping the name explicit and
The physical type of the variable should form the first part of the variable name, e.g. for plasma resistance the variable should be named:
-```fortran
+```python
res_plasma = 1.0
```
Another example would be pulse length
-```fortran
+```python
time_pulse_length = 7200.0
```
@@ -540,17 +540,17 @@ time_pulse_length = 7200.0
Inside PROCESS all variables should be in SI units unless otherwise stated. For example:
-```fortran
-! Fusion power [W]
-p_fusion_total = 1000.0d6
+```python
+p_fusion_total = 1e6
+"""Fusion power [W]"""
```
If a variable is not in SI units then its units should be put at the end of of the variable name.
Example:
-```fortran
-! Fusion power [MW]
-p_fusion_total_mw = 1000.0d0
+```python
+p_fusion_total_mw = 1000.0
+"""Fusion power [MW]"""
```
---------------------
@@ -559,22 +559,21 @@ p_fusion_total_mw = 1000.0d0
Coordinates should be defined as
-```fortran
-r_plasma_centre = 9.0d0
+```python
+r_plasma_centre = 9.0
-z_plasma_centre = 0.0d0
+z_plasma_centre = 0.0
-theta_ =
+theta_ = ...
```
For dimensions
-```fortran
-dr_cs =
+```python
+dr_cs = ...
-dz_cs =
+dz_cs = ...
-dtheta_description =
```
---------------------
diff --git a/documentation/source/fusion-devices/stellarator.md b/documentation/source/fusion-devices/stellarator.md
index 4687498df3..4ef2a252bb 100644
--- a/documentation/source/fusion-devices/stellarator.md
+++ b/documentation/source/fusion-devices/stellarator.md
@@ -82,7 +82,7 @@ ixc = 169 * Achievable Temperature of the ECRH at the ignition point
## Code specifics
-The stellarator model is largely contained within source file `stellarator.f90`.
+The stellarator model is largely contained within source file `stellarator.py`.
The model call is in the following order
diff --git a/documentation/source/physics-models/fusion_reactions/plasma_reactions.md b/documentation/source/physics-models/fusion_reactions/plasma_reactions.md
index 735f044401..bdfadce19f 100644
--- a/documentation/source/physics-models/fusion_reactions/plasma_reactions.md
+++ b/documentation/source/physics-models/fusion_reactions/plasma_reactions.md
@@ -125,8 +125,8 @@ There are 4 key functions for calculating the fusion reaction for the plasma. Th
#### Detailed Steps
1. **Initialize Bosch-Hale Constants**: Initializes the Bosch-Hale constants for the required reaction using predefined reaction constants stored in the BoschHaleConstants dataclass.
2. **Calculate Fusion Reaction Rate**: Uses Simpson's rule to integrate the fusion reaction rate over the plasma profile.
-3. **Calculate Fusion Power Density**: Compute the fusion power density produced by the given reaction. Using the reaction energy calculated and stored in `constants.f90`. The reactant density is given by $\mathtt{f\_deuterium, f\_tritium}$ or $\mathtt{f\_helium3}$ multiplied by the volume averaged ion density. For the D-D reactions the fusion reaction rate is scaled with the output of [`deuterium_branching()`](#deuterium-branching-fraction--deuterium_branching) to simulate the different branching ratios.
-4. **Calculate Specific Fusion Power Densities**: Compute the fusion power density for alpha particles, neutrons and other charged particles, depending on the reaction. Energy branching fractions used are calculated and called from `constants.f90`.
+3. **Calculate Fusion Power Density**: Compute the fusion power density produced by the given reaction. Using the reaction energy calculated and stored in `constants.py`. The reactant density is given by $\mathtt{f\_deuterium, f\_tritium}$ or $\mathtt{f\_helium3}$ multiplied by the volume averaged ion density. For the D-D reactions the fusion reaction rate is scaled with the output of [`deuterium_branching()`](#deuterium-branching-fraction--deuterium_branching) to simulate the different branching ratios.
+4. **Calculate Specific Fusion Power Densities**: Compute the fusion power density for alpha particles, neutrons and other charged particles, depending on the reaction. Energy branching fractions used are calculated and called from `constants.py`.
5. **Calculate Fusion Rate Densities**: Compute the total fusion rate density and fusion rates just for the alpha particles, neutrons and other charged particles, depending on the reaction.
6. **Update Reaction Power Density**: Updates the object attribute for the specific reaction power density.
7. **Sum Fusion Rates**: Call the [`sum_fusion_rates()`](#sum-the-fusion-rates--sum_fusion_rates) function to add the reaction to the global plasma power balance.
diff --git a/documentation/source/solver/solver-guide.md b/documentation/source/solver/solver-guide.md
index 361cd43017..2be4b6e1bb 100644
--- a/documentation/source/solver/solver-guide.md
+++ b/documentation/source/solver/solver-guide.md
@@ -94,7 +94,7 @@ variable values that maximises or minimises a certain function of them,
known as the figure of merit.
Several possible figures of merit are available, all of which are in the
-source file `evaluators.f90`.
+source file `evaluators.py`.
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
diff --git a/process/core/caller.py b/process/core/caller.py
index 01365d26ff..5ac162b3ff 100644
--- a/process/core/caller.py
+++ b/process/core/caller.py
@@ -249,8 +249,7 @@ def _call_models_once(self, xc: np.ndarray):
"""Call the physics and engineering models.
This method is the principal caller of all the physics and
- engineering models. Some are Fortran subroutines within modules, others
- will be methods on Python model objects.
+ engineering models.
Parameters
----------
diff --git a/process/core/input.py b/process/core/input.py
index bfc45f88c3..23ee61e170 100644
--- a/process/core/input.py
+++ b/process/core/input.py
@@ -47,7 +47,7 @@ class InputVariable:
"""A variable to be parsed from the input file."""
module: Any
- """The Fortran module that this variable should be set on."""
+ """The module that this variable should be set on."""
type: type
"""The expected type of the variable"""
range: tuple[NumberType, NumberType] | None = None
@@ -1156,7 +1156,6 @@ def parse_input_file(data_structure_obj: DataStructure):
continue
# matches (variable name, array index, value)
- # NOTE: array index is Fortran-based hence starts at 1.
line_match = re.match(
r"([a-zA-Z0-9_]+)(?:\(([0-9]+)\))?[ ]*=[ ]*([ +\-a-zA-Z0-9.,]+).*",
stripped_line,
@@ -1342,12 +1341,9 @@ def set_scalar_variable(name: str, value: ValidInputTypes, config: InputVariable
"""
current_value = getattr(config.module, name, ...)
- # use ... sentinel because None is probably a valid return from Fortran
- # and definately will be when moving to a Python data structure
+ # use ... sentinel because None is a valid initial/default value for variables
if current_value is ...:
- error_msg = (
- f"Fortran module '{config.module}' does not have a variable '{name}'."
- )
+ error_msg = f"Module '{config.module}' does not have a variable '{name}'."
raise ProcessValueError(error_msg)
setattr(config.module, name, value)
@@ -1356,9 +1352,6 @@ def set_scalar_variable(name: str, value: ValidInputTypes, config: InputVariable
def set_array_variable(name: str, value: str, array_index: int, config: InputVariable):
"""Set an array variable in the `config.module`.
- The way PROCESS input files are structured, each element of the array is provided on one line
- so this function just needs to set the `value` at `array_index` (-1) because of Fortran-based indexing.
-
Parameters
----------
name :
diff --git a/process/core/io/data_structure_dicts.py b/process/core/io/data_structure_dicts.py
index 1a5d0e51bb..418c605e09 100644
--- a/process/core/io/data_structure_dicts.py
+++ b/process/core/io/data_structure_dicts.py
@@ -59,7 +59,6 @@ def publish(self):
class SourceDictionary(Dictionary):
- # Dictionary created from Fortran source
def __init__(self, name, dict_creator_func):
Dictionary.__init__(self, name)
# Function that creates the dict
@@ -221,11 +220,8 @@ def remove_comments(line):
def dict_var_type():
"""Function to return a dictionary mapping variable name to variable type
- eg. 'real_variable' or 'int_array'. Looks in input.f90 at the process
- functions that read in variables from IN.DAT.
-
- Example of line we are looking for:
- call parse_real_variable('BETA', beta, 0.0D0, 1.0D0, &
+ eg. 'real_variable' or 'int_array'. Iterates over INPUT_VARIABLES to build
+ the mapping using the type and array properties of each variable config.
Example dictionary entry:
DICT_VAR_TYPE['beta'] = 'real_variable'
@@ -244,12 +240,9 @@ def dict_var_type():
def dict_input_bounds():
"""Returns a dictionary matching variable names to dictionary containing
- upper and lower bounds that PROCESS checks variable lies between when
- reading IN.DAT. Looks in input.f90 for parse_real_variable and
- parse_int_variable.
-
- Example of a line we are looking for:
- call parse_real_variable('BETA', beta, 0.0D0, 1.0D0, &
+ upper and lower bounds. Bounds are derived from the INPUT_VARIABLES config
+ objects, using either the explicit range property or min/max of choices
+ for numeric types.
Example dictionary entry:
DICT_INPUT_BOUNDS['beta'] = {'lb' : 0.0, 'ub' : 1.0}
diff --git a/process/core/io/in_dat/base.py b/process/core/io/in_dat/base.py
index 31989bc748..1fd2b2a9ee 100644
--- a/process/core/io/in_dat/base.py
+++ b/process/core/io/in_dat/base.py
@@ -1152,11 +1152,6 @@ def process_line(self, line_type, line):
line_commentless = line.split("*")[0]
array_name = line_commentless.split("(")[0]
empty_array = dicts["DICT_DEFAULT"][array_name]
- # empty_array is what the array is initialised to when it is
- # declared in the Fortran. If the array is declared but not
- # initialised until later in a separate "init" subroutine, then
- # empty_array will be None. This is a side-effect of the need to
- # re-initialise Fortran arrays in a separate subroutine.
if empty_array is None:
# Array is declared but not initialised at the same time;
@@ -1405,61 +1400,25 @@ def process_array(self, line, empty_array):
empty_array:
Default array for this array name
"""
- # TODO This is a mess after the Fortran module variable
- # re-initialisation work. It is hard to see how this can be improved
- # as the regex method of Fortran inspection (i.e. Python-Fortran
- # dictionaries) is increasingly untenable. An attempt is made here,
- # but with a view to the dictionaries method being dropped in future
- # in light of increasing Python f2py conversion.
-
line_commentless = line.split("*")[0] if "*" in line else line
name = line_commentless.split("(")[0]
index = int(line_commentless.split("(")[1].split(")")[0]) - 1
- # The -1 assumes all Fortran arrays begin at 1: they don't in Process!
- # This bug would cause a Fortran index of 0 to be interpreted as a
- # Python index of -1 (last element). This didn't cause any exceptions,
- # but would obviously set the wrong list index. This now throws
- # exceptions when trying to access [-1] of an empty list []. Hence it
- # must be guarded against with the following:
+
if index == -1:
index = 0
- # This will cause Fortran index 0 and 1 to overwrite the same Python
- # index of 0, which is clearly awful. However, it is equally bad to the
- # previous case above, where Fortran [0] would overwrite Python [-1].
- # There isn't a way of reconciling this without knowing whether the
- # Fortran array begins at 0 or 1.
- # TODO Either enforce Fortran arrays that start at 1 throughout, or
- # find a way of determining the starting index of the array
value = line_commentless.split("=")[-1].replace(",", "")
- # Many arrays are now declared but not initialised until the "init"
- # subroutine is run in each Fortran module, to allow re-initialisation
- # on demand for a new run etc.
- # In Fortran, we have a declared but uninitialised array of a given
- # length. This results in an empty list in the value attribute here.
- # However, we need to set the value for a given index. Therefore
- # make a list of Nones, so that we can set the value for a given
- # index. We don't know the length of the Fortran array (its value is
- # []), so we have to make the Python list as long as this Fortran index.
- # This way, at least the list is long enough for this Fortran index.
- # TODO Again, this requires a more robust solution
-
list_len = len(self.data[name].value)
# Length of Python list in self.data
max_list_index = list_len - 1
# The greatest index in that Python list
array_len = index + 1
- # The Fortran array must be at least this long
- # If the default array is an empty list, make a list of Nones of
- # matching length to the Fortran array
if len(empty_array) == 0:
empty_array = [None] * array_len
- # If the Pyhton list is an empty list, make a list of Nones of
- # matching length to the Fortran array
if list_len == 0:
self.data[name].value = [None] * array_len
# Check the Python list is long enough to store the new index
diff --git a/process/core/io/vary_run/tools.py b/process/core/io/vary_run/tools.py
index 641367f6c3..fe7571e429 100644
--- a/process/core/io/vary_run/tools.py
+++ b/process/core/io/vary_run/tools.py
@@ -350,7 +350,6 @@ def set_variable_in_indat(in_dat, varname, value):
elif "(" in varname:
name = varname.split("(")[0]
- # Fortran numbering converted to Python numbering!
identity = int((varname.split("("))[1].split(")")[0]) - 1
in_dat.change_array(name, identity, float(value))
diff --git a/process/core/output.py b/process/core/output.py
index 1368eaae7f..54f1698777 100644
--- a/process/core/output.py
+++ b/process/core/output.py
@@ -16,7 +16,6 @@ def write(models, data, _outfile):
models : process.main.Models
physics and engineering model objects
_outfile : int
- Fortran output unit identifier
"""
# ensure we are capturing warnings that occur in the 'output' stage as these are warnings
diff --git a/process/core/process_output.py b/process/core/process_output.py
index ff8956bd8b..26a23c9781 100644
--- a/process/core/process_output.py
+++ b/process/core/process_output.py
@@ -173,7 +173,6 @@ def ovarre(file, descr: str, varnam: str, value, output_flag: str = ""):
if isinstance(value, np.ndarray):
value = value.item()
if isinstance(value, bytes):
- # TODO: remove when Fortran is gone
value = value.decode().strip()
if isinstance(value, str):
# try and convert the value to a float
diff --git a/process/core/scan.py b/process/core/scan.py
index 7a33222c49..fd956cedbe 100644
--- a/process/core/scan.py
+++ b/process/core/scan.py
@@ -189,7 +189,7 @@ def _missing_(cls, var):
class Scan:
- """Perform a parameter scan using the Fortran scan module."""
+ """Perform a parameter scan using the scan module."""
def __init__(self, models: Model, solver: str, data: DataStructure):
"""Immediately run the run_scan() method.
diff --git a/process/core/solver/iteration_variables.py b/process/core/solver/iteration_variables.py
index a3add624a0..16cd1a6bba 100644
--- a/process/core/solver/iteration_variables.py
+++ b/process/core/solver/iteration_variables.py
@@ -15,7 +15,7 @@ class IterationVariable:
name: str
"""The name of the variable"""
module: str | Any
- """The Fortran module that this variable should be set on."""
+ """The module that this variable should be set on."""
lower_bound: float
"""The default lower bound of the iteration variable"""
upper_bound: float
@@ -28,7 +28,6 @@ class IterationVariable:
"""If `module.name` is an array, the iteration variable can only modify
`array_index` of that array.
- NOTE: The indexes start at 0 (despite indexing Fortran arrays).
"""
@@ -263,8 +262,6 @@ def load_iteration_variables(data):
variable_index = data_structure.numerics.ixc[i]
iteration_variable = ITERATION_VARIABLES[variable_index]
- # use ... as the default return value because None might be a valid return from Fortran?
-
module = (
getattr(data, iteration_variable.module)
if isinstance(iteration_variable.module, str)
diff --git a/process/core/solver/solver_handler.py b/process/core/solver/solver_handler.py
index 5094c5a9e2..fd46ca3883 100644
--- a/process/core/solver/solver_handler.py
+++ b/process/core/solver/solver_handler.py
@@ -30,13 +30,10 @@ def __init__(self, models, solver_name, data):
def run(self):
"""Run solver and retry if it fails in certain ways."""
- # Initialise iteration variables and bounds in Fortran
load_iteration_variables(self.data)
load_scaled_bounds()
- # Initialise iteration variables and bounds in Python: relies on Fortran
- # iteration variables being defined above
- # Trim maximum size arrays down to actually used size
+ # Initialise solver variables from numerics module
n = numerics.nvar
x = numerics.xcm[:n]
bndl = numerics.itv_scaled_lower_bounds[:n]
@@ -96,12 +93,10 @@ def run(self):
return ifail
def output(self):
- """Store results back in Fortran numerics module.
+ """Store results back in numerics module.
Objective function value, solution vector and constraints vector.
"""
numerics.norm_objf = self.solver.objf
- # Slicing required due to Fortran arrays being maximum possible, rather
- # than required, size
numerics.xcm[: self.solver.x.shape[0]] = self.solver.x
numerics.rcm[: self.solver.conf.shape[0]] = self.solver.conf
diff --git a/process/data_structure/numerics.py b/process/data_structure/numerics.py
index 8499302c80..e69a66c889 100644
--- a/process/data_structure/numerics.py
+++ b/process/data_structure/numerics.py
@@ -156,8 +156,6 @@ def description(self):
active_constraints: list[bool] = True
"""Logical array showing which constraints are active"""
-# TODO Do not change the comments for lablcc: they are used to create the
-# Python-Fortran dictionaries. This must be improved on.
lablcc: list[str] = None
"""Labels describing constraint equations (corresponding itvs)
@@ -444,7 +442,6 @@ def description(self):
* (174) NOT USED
* (175) NOT USED
"""
-# Issue 287 iteration variables are now defined in module define_iteration_variables in iteration variables.f90
name_xc: list[str] = None
diff --git a/process/data_structure/tfcoil_variables.py b/process/data_structure/tfcoil_variables.py
index c01a16cbb1..b459e3d760 100644
--- a/process/data_structure/tfcoil_variables.py
+++ b/process/data_structure/tfcoil_variables.py
@@ -333,7 +333,6 @@ class TFData:
n_tf_stress_layers: int = 0
"""Number of layers considered for the inboard TF stress calculations
- set in initial.f90 from i_tf_bucking and n_tf_graded_layers
"""
n_tf_wp_stress_layers: int = 5
diff --git a/process/main.py b/process/main.py
index 1c2a0f49ae..6b99b6aecc 100644
--- a/process/main.py
+++ b/process/main.py
@@ -1,13 +1,4 @@
-"""Run Process by calling into the Fortran.
-
-This uses a Python module called fortran.py, which uses an extension module
-called "_fortran.cpython... .so", which are both generated from
-process_module.f90. The process_module module contains the code to actually run
-Process.
-
-This file, process.py, is now analogous to process.f90, which contains the
-Fortran "program" statement. This Python module effectively acts as the Fortran
-"program".
+"""Run `PROCESS` by calling into the Python module.
Power Reactor Optimisation Code for Environmental and Safety Studies
@@ -24,9 +15,7 @@
The code was transferred to Culham Laboratory, Oxfordshire, UK, in
April 1992, and the physics models were updated by P.J.Knight to
include the findings of the Culham reactor studies documented in
-Culham Report AEA FUS 172 (1992). The standard of the Fortran has
-been thoroughly upgraded since that time, and a number of additional
-models have been added.
+Culham Report AEA FUS 172 (1992).
During 2012, PROCESS was upgraded from FORTRAN 77 to Fortran 95,
to facilitate the restructuring of the code into proper modules
@@ -34,6 +23,8 @@
aid the inclusion of more advanced physics and engineering models under
development as part of a number of EFDA-sponsored collaborations.
+The code is now fully Python based.
+
Box file F/RS/CIRE5523/PWF (up to 15/01/96)
Box file F/MI/PJK/PROCESS and F/PL/PJK/PROCESS (15/01/96 to 24/01/12)
Box file T&M/PKNIGHT/PROCESS (from 24/01/12)
@@ -346,7 +337,7 @@ def run(self):
@staticmethod
def init_module_vars():
- """Initialise all module variables in the Fortran.
+ """Initialise all module variables
This "resets" all module variables to their initialised values, so each
new run doesn't have any side-effects from previous runs.
@@ -388,13 +379,12 @@ def set_input(self):
"in the analysis folder",
)
- # Set the input file in the Fortran
data_structure.global_variables.fileprefix = self.input_path.resolve()
def set_output(self):
"""Set the output file name.
- Set Path object on the Process object, and set the prefix in the Fortran.
+ Set Path object on the Process object
"""
self.output_path = Path(self.filepath, self.filename_prefix.strip() + "OUT.DAT")
data_structure.global_variables.output_prefix = (
@@ -443,11 +433,7 @@ def show_errors(self):
show_errors(constants.NOUT)
def finish(self):
- """Run the finish subroutine to close files open in the Fortran.
-
- Files being handled by Fortran must be closed before attempting to
- write to them using Python, otherwise only parts are written.
- """
+ """Run the finish subroutine to close files that are open at the end of a run."""
oheadr(constants.NOUT, "End of PROCESS Output")
oheadr(constants.IOTTY, "End of PROCESS Output")
oheadr(constants.NOUT, "Copy of PROCESS Input Follows")
@@ -583,14 +569,14 @@ def validate_user_model(self):
class Models:
"""Creates instances of physics and engineering model classes.
- Creates objects to interface with corresponding Fortran physics and
+ Creates objects to interface with corresponding physics and
engineering modules.
"""
def __init__(self, data: DataStructure):
"""Create physics and engineering model objects.
- This also initialises module variables in the Fortran for that module.
+ This also initialises module variables for each model.
"""
self.data = data
diff --git a/process/models/blankets/dcll.py b/process/models/blankets/dcll.py
index 5fc1ebb0d6..fd885ec5b2 100644
--- a/process/models/blankets/dcll.py
+++ b/process/models/blankets/dcll.py
@@ -436,7 +436,7 @@ def dcll_masses(self, output: bool):
FW Armour
- Tungsten
- - Use den_tungsten form constants.f90
+ - Use DEN_TUNGSTEN from constants.py
FW and BB Structure Coolant
- Helium
- See primary_coolant_properties for denisty etc.
diff --git a/process/models/blankets/hcpb.py b/process/models/blankets/hcpb.py
index ab23d03291..eb4fde38a5 100644
--- a/process/models/blankets/hcpb.py
+++ b/process/models/blankets/hcpb.py
@@ -288,7 +288,6 @@ def component_masses(self):
# Mass of He coolant = volume * density at typical coolant temperatures and pressures (kg)
self.data.fwbs.m_fw_blkt_div_coolant_total = coolvol * 1.517
- # Average first wall coolant fraction, only used by old routines in fispact.f90, safety.f90
self.data.fwbs.fwclfr = (
self.data.first_wall.a_fw_inboard
* self.data.build.dr_fw_inboard
diff --git a/process/models/cs_fatigue.py b/process/models/cs_fatigue.py
index a4de377778..4b7f7599bf 100644
--- a/process/models/cs_fatigue.py
+++ b/process/models/cs_fatigue.py
@@ -100,7 +100,7 @@ def ncycle(
# run euler_method and find number of cycles needed to give crack increase
delta_n = delta / (cr * (k_max**self.data.cs_fatigue.paris_power_law))
- # update a and c, N (+= doesnt work for fortran (?) reasons)
+ # update a and c, N
a += delta * (k_a / k_max) ** self.data.cs_fatigue.paris_power_law
c += delta * (k_c / k_max) ** self.data.cs_fatigue.paris_power_law
n_pulse += delta_n
diff --git a/process/models/pfcoil.py b/process/models/pfcoil.py
index 774ad6974e..6591f90129 100644
--- a/process/models/pfcoil.py
+++ b/process/models/pfcoil.py
@@ -29,7 +29,7 @@ class PFCoil(Model):
"""Calculate poloidal field coil system parameters."""
def __init__(self, cs_fatigue, cs_coil):
- """Initialise Fortran module variables."""
+ """Initialise the PF coil model."""
self.outfile = constants.NOUT # output file unit
self.mfile = constants.MFILE # mfile file unit
self.cs_fatigue = cs_fatigue
@@ -1719,8 +1719,6 @@ def induct(self, output):
noh = min(noh, nohmax)
- # TODO In FNSF case, noh = -7! noh should always be positive. Fortran
- # array allocation with -ve bound previously coerced to 0
noh = max(noh, 0)
roh = np.zeros(noh)
@@ -2956,7 +2954,7 @@ class CSCoil(Model):
"""Calculate central solenoid coil system parameters."""
def __init__(self, cs_fatigue):
- """Initialise Fortran module variables."""
+ """Initialise the CS coil model."""
self.outfile = constants.NOUT # output file unit``
self.mfile = constants.MFILE # mfile file unit
self.cs_fatigue = cs_fatigue
diff --git a/process/models/physics/physics.py b/process/models/physics/physics.py
index 573ab73acf..43e162978c 100644
--- a/process/models/physics/physics.py
+++ b/process/models/physics/physics.py
@@ -459,10 +459,6 @@ def run(self):
self.data.times.t_plant_pulse_plasma_current_ramp_up
)
- # Reset second self.data.times.t_plant_pulse_burn value
- # (self.data.times.t_burn_0).
- # This is used to ensure that the burn time is used consistently;
- # see convergence loop in fcnvmc1, evaluators.f90
self.data.times.t_burn_0 = self.data.times.t_plant_pulse_burn
# Time during the pulse in which a plasma is present
@@ -1697,7 +1693,7 @@ def calculate_effective_charge_ionisation_profiles(self):
def outplas(self):
"""Subroutine to output the plasma physics information
- self.outfile : input integer : Fortran output unit identifier
+ self.outfile : file to write to
This routine writes the plasma physics information
to a file, in a tidy format.
"""
diff --git a/process/models/power.py b/process/models/power.py
index ede6e6f0ec..0e7f56b155 100644
--- a/process/models/power.py
+++ b/process/models/power.py
@@ -927,7 +927,7 @@ def component_thermal_powers(self):
+ self.data.heat_transport.p_div_coolant_pump_mw
)
- # Heat removal from first wall and divertor (MW) (only used in costs.f90)
+ # Heat removal from first wall and divertor (MW)
i_p_coolant_pumping = PumpingPowerModelTypes(self.data.fwbs.i_p_coolant_pumping)
if i_p_coolant_pumping != PumpingPowerModelTypes.MECHANICAL_WITH_PRESSURE_DROP:
self.data.heat_transport.p_fw_div_heat_deposited_mw = (
diff --git a/process/models/stellarator/coils/coils.py b/process/models/stellarator/coils/coils.py
index 95076a46bb..c0fd247429 100644
--- a/process/models/stellarator/coils/coils.py
+++ b/process/models/stellarator/coils/coils.py
@@ -31,7 +31,7 @@ def jcrit_from_material(
# of a cable conductor.
if i_tf_sc_mat == 1: # ITER Nb3Sn critical surface parameterization
- bc20m = 32.97 # these are values taken from sctfcoil.f90
+ bc20m = 32.97
tc0m = 16.06
# j_crit_sc returned by itersc is the critical current density in the
@@ -63,7 +63,6 @@ def jcrit_from_material(
jstrand = j_wp / (1 - f_he)
# jstrand = 0 # as far as I can tell this will always be 0
- # because jwp was never set in fortran (so 0)
j_crit_cable, tmarg = superconductors.bi2212(
b_max, jstrand, t_helium, f_hts
diff --git a/process/models/stellarator/stellarator.py b/process/models/stellarator/stellarator.py
index 4eaa3def11..cd5bb8fc00 100644
--- a/process/models/stellarator/stellarator.py
+++ b/process/models/stellarator/stellarator.py
@@ -1228,7 +1228,6 @@ def st_fwbs(self, output: bool):
)
# Average first wall coolant fraction, only used by old routines
- # in fispact.f90, safety.f90
self.data.fwbs.fwclfr = (
self.data.first_wall.a_fw_inboard
diff --git a/process/models/tfcoil/base.py b/process/models/tfcoil/base.py
index c3ace698bd..0ce3f15899 100644
--- a/process/models/tfcoil/base.py
+++ b/process/models/tfcoil/base.py
@@ -108,7 +108,7 @@ class TFCoil(Model):
"""
def __init__(self):
- """Initialise Fortran module variables."""
+ """Initialise the TF coil model."""
self.outfile = constants.NOUT # output file unit
def run(self):
@@ -2540,8 +2540,6 @@ def stresscl(
# Superconducting CS
if i_pf_conductor == 0:
# Getting the turn dimention from scratch
- # as the TF is called before CS in caller.f90
- # -#
# CS vertical cross-section area [m2]
if i_tf_inside_cs == 1:
diff --git a/process/models/tfcoil/superconducting.py b/process/models/tfcoil/superconducting.py
index e9ae183a21..b71333a36c 100644
--- a/process/models/tfcoil/superconducting.py
+++ b/process/models/tfcoil/superconducting.py
@@ -3380,11 +3380,6 @@ def tf_cable_in_conduit_averaged_turn_geometry(
# Area of inter-turn insulation: single turn [m2]
a_tf_turn_insulation = a_tf_turn - t_conductor**2
- # NOTE: Fortran has a_tf_turn_cable_space_no_void as an intent(out) variable
- # that was outputting into data.tfcoil.a_tf_turn_cable_space_no_void.
- # The local variable, however, appears to initially hold the value of
- # data.tfcoil.a_tf_turn_cable_space_no_void despite not being intent(in).
- # I have replicated this behaviour in Python for now.
a_tf_turn_cable_space_no_void = copy.copy(
data.tfcoil.a_tf_turn_cable_space_no_void
)
diff --git a/tests/integration/test_vmcon.py b/tests/integration/test_vmcon.py
index 1630840081..c8bbed1b2f 100644
--- a/tests/integration/test_vmcon.py
+++ b/tests/integration/test_vmcon.py
@@ -22,7 +22,7 @@
@pytest.fixture(autouse=True)
def reinit():
- """Re-initialise Fortran module variables before each test is run."""
+ """Re-initialise module variables before each test is run."""
init_all_module_vars()
diff --git a/tests/unit/models/physics/test_impurity_radiation.py b/tests/unit/models/physics/test_impurity_radiation.py
index 335736faaf..e3576eaa0c 100644
--- a/tests/unit/models/physics/test_impurity_radiation.py
+++ b/tests/unit/models/physics/test_impurity_radiation.py
@@ -1,4 +1,4 @@
-"""Unit tests for the impurity_radiation.f90.py module."""
+"""Unit tests for the impurity_radiation.py module."""
from typing import NamedTuple
diff --git a/tests/unit/models/physics/test_physics.py b/tests/unit/models/physics/test_physics.py
index b41e11b9b8..7ad8698dbd 100644
--- a/tests/unit/models/physics/test_physics.py
+++ b/tests/unit/models/physics/test_physics.py
@@ -1,4 +1,4 @@
-"""Unit tests for physics.f90."""
+"""Unit tests for physics.py module."""
from typing import Any, NamedTuple
diff --git a/tests/unit/models/physics/test_plasma_geom.py b/tests/unit/models/physics/test_plasma_geom.py
index 9c72edfbf3..cc7113781c 100644
--- a/tests/unit/models/physics/test_plasma_geom.py
+++ b/tests/unit/models/physics/test_plasma_geom.py
@@ -1,4 +1,4 @@
-"""Unit tests for plasma_geometry.f90."""
+"""Unit tests for plasma_geometry.py module."""
from typing import Any, NamedTuple
diff --git a/tests/unit/models/test_availability.py b/tests/unit/models/test_availability.py
index 61a7cd47d9..6891b64624 100644
--- a/tests/unit/models/test_availability.py
+++ b/tests/unit/models/test_availability.py
@@ -71,7 +71,7 @@ def test_avail_1(monkeypatch, availability):
:param availability: fixture containing an initialised `Availability` object
:type availability: tests.unit.test_availability.availability (functional fixture)
"""
- # Initialise fortran variables to keep test isolated from others
+
init_all_module_vars()
# Mock module vars
@@ -95,7 +95,6 @@ def test_avail_1(monkeypatch, availability):
cfactr_exp = 0.0006344554455445239
assert pytest.approx(cfactr_exp) == cfactr_obs
- # Initialise fortran variables again to reset for other tests
init_all_module_vars()
@@ -589,7 +588,7 @@ def test_avail_st(monkeypatch, availability):
:param availability: fixture containing an initialised `Availability` object
:type availability: tests.unit.test_availability.availability (functional fixture)
"""
- # Initialise fortran variables to keep test isolated from others
+
init_all_module_vars()
monkeypatch.setattr(availability.data.costs, "tmain", 1.0)
monkeypatch.setattr(availability.data.costs, "life_plant", 30.0)
diff --git a/tests/unit/models/test_divertor.py b/tests/unit/models/test_divertor.py
index 6184c6a864..0749346858 100644
--- a/tests/unit/models/test_divertor.py
+++ b/tests/unit/models/test_divertor.py
@@ -1,4 +1,4 @@
-"""Unit tests for divertor.f90 subroutines/functions"""
+"""Unit tests for divertor.py module."""
import pytest
diff --git a/tests/unit/models/test_pfcoil.py b/tests/unit/models/test_pfcoil.py
index 3b4d47d611..0215284475 100644
--- a/tests/unit/models/test_pfcoil.py
+++ b/tests/unit/models/test_pfcoil.py
@@ -50,7 +50,7 @@ def cs_coil(process_models):
def test_init_pfcoil(pfcoil):
- """Test initialisation of Fortran module variables.
+ """Test initialisation of module variables.
:param pfcoil: PFCoil object
:type pfcoil: process.pfcoil.PFCoil
@@ -2773,9 +2773,6 @@ def test_efc(pfcoil: PFCoil, monkeypatch: pytest.MonkeyPatch):
n_pf_coil_groups = 4
n_pf_coils_in_group = np.array([1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- # This 2D array argument discovered via gdb prints as a 1D array, therefore
- # needs to be reshaped into its original 2D. Fortran ordering is essential
- # when passing greater-than-1D arrays from Python to Fortran
r_pf_coil_middle_group_array = np.reshape(
[
6.7651653417201345,
diff --git a/tracking/tracking_data.py b/tracking/tracking_data.py
index ba6d05c0bb..8d4a5f800a 100644
--- a/tracking/tracking_data.py
+++ b/tracking/tracking_data.py
@@ -27,8 +27,6 @@
To add a variable to track:
Add the variable to ProcessTracker.tracking_variables (in this file).
-If the variable is not a fortran module variable, ensure to override its parent module name
-e.g. FOO.bar says `bar`'s parent module is `FOO`.
"""
import argparse
@@ -243,8 +241,6 @@ def _generate_data(self):
# tracking data
for var in self.tracking_variables:
if "." in var:
- # a dotted variable is for variables that no longer exist in Fortran module variables
- # see tracking_variables docstring
try:
_, var = var.split(".") # noqa: PLW2901
except (AttributeError, ValueError):