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 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