@@ -127,6 +127,54 @@ def test_core_profiles_negative_values_check(self):
127127 self .assertFalse (new_core_profiles .negative_temperature_or_density ())
128128
129129
130+ class CoreProfilesTemperatureCheckTest (parameterized .TestCase ):
131+ """Tests for the below_minimum_temperature method in CoreProfiles."""
132+
133+ def setUp (self ):
134+ super ().setUp ()
135+ self .geo = circular_geometry .CircularConfig (n_rho = 5 ).build_geometry ()
136+ self .base_profiles = core_profile_helpers .make_zero_core_profiles (self .geo )
137+
138+ @parameterized .named_parameters (
139+ ('all_above' , 0.2 , 0.2 , 100.0 , False ), # 0.2 keV = 200 eV > 100 eV
140+ ('te_below' , 0.05 , 0.2 , 100.0 , True ), # 0.05 keV = 50 eV < 100 eV
141+ ('ti_below' , 0.2 , 0.05 , 100.0 , True ),
142+ ('both_below' , 0.05 , 0.05 , 100.0 , True ),
143+ # 0.1 keV = 100 eV. Logic is strictly <, so this should pass (False).
144+ ('exact_boundary' , 0.1 , 0.1 , 100.0 , False ),
145+ )
146+ def test_below_minimum_temperature (
147+ self , te_val , ti_val , threshold_ev , expected
148+ ):
149+ """Verifies below_minimum_temperature returns correct boolean flag."""
150+ # Create profiles with constant values across the radius
151+ core_profiles = dataclasses .replace (
152+ self .base_profiles ,
153+ T_e = core_profile_helpers .make_constant_core_profile (self .geo , te_val ),
154+ T_i = core_profile_helpers .make_constant_core_profile (self .geo , ti_val ),
155+ )
156+
157+ result = core_profiles .below_minimum_temperature (threshold_ev )
158+
159+ self .assertIsInstance (result , bool )
160+ self .assertEqual (result , expected )
161+
162+ def test_below_minimum_temperature_mixed_profile (self ):
163+ """Tests detection when only part of the profile is below threshold."""
164+ threshold_ev = 100.0 # 0.1 keV
165+
166+ te_values = jnp .array ([0.2 , 0.2 , 0.05 , 0.2 , 0.2 ]) # 0.05 is below threshold
167+ ti_values = jnp .array ([0.2 , 0.2 , 0.2 , 0.2 , 0.2 ])
168+
169+ core_profiles = dataclasses .replace (
170+ self .base_profiles ,
171+ T_e = dataclasses .replace (self .base_profiles .T_e , value = te_values ),
172+ T_i = dataclasses .replace (self .base_profiles .T_i , value = ti_values ),
173+ )
174+
175+ self .assertTrue (core_profiles .below_minimum_temperature (threshold_ev ))
176+
177+
130178class ImpurityFractionsTest (parameterized .TestCase ):
131179 """Tests for the impurity_fractions attribute in CoreProfiles."""
132180
0 commit comments