From 2497da6ce31311ee52b4e6adda4de3648e883b0d Mon Sep 17 00:00:00 2001 From: Jonathan Maddock <78556175+jonmaddock@users.noreply.github.com> Date: Fri, 1 May 2026 15:18:23 +0100 Subject: [PATCH 1/2] Add exception for znfuel < 0 --- process/models/physics/physics.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/process/models/physics/physics.py b/process/models/physics/physics.py index 1c3b0c628..90a026a3a 100644 --- a/process/models/physics/physics.py +++ b/process/models/physics/physics.py @@ -1161,6 +1161,12 @@ def plasma_composition(): - znimp ) + # Negative znfuel can occur during solution and is always fatal, + # frequently resulting in a confusing bootstrap current error later. + # Catch early and explicitly instead + if znfuel < 0.0: + raise ValueError(f"znfuel is negative: {znfuel}") + # ====================================================================== # Fuel ion density, nd_plasma_fuel_ions_vol_avg From 83985efe88205c2a2841608b82acc44430b57c81 Mon Sep 17 00:00:00 2001 From: Jonathan Maddock <78556175+jonmaddock@users.noreply.github.com> Date: Fri, 1 May 2026 15:25:19 +0100 Subject: [PATCH 2/2] Exception for negative profile temperature --- process/models/physics/bootstrap_current.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/process/models/physics/bootstrap_current.py b/process/models/physics/bootstrap_current.py index 0282f2b23..9524cd99a 100644 --- a/process/models/physics/bootstrap_current.py +++ b/process/models/physics/bootstrap_current.py @@ -1470,6 +1470,10 @@ def bootstrap_fraction_sauter(self, plasma_profile: float) -> float: # Calculate electron and ion temperature profiles tempe = plasma_profile.teprofile.profile_y + # Check for any negative temperature in profile: always fatal eventually, + # report explicitly at source + if (tempe < 0).any(): + raise ValueError("Negative temperature in plasma profile") tempi = ( physics_variables.temp_plasma_ion_vol_avg_kev / physics_variables.temp_plasma_electron_vol_avg_kev