Add cooldown telemetry, RHR cooldown path, and shutdown regression test

This commit is contained in:
Codex Agent
2025-11-28 23:38:20 +01:00
parent 12696b107f
commit e2fad87bfc
6 changed files with 115 additions and 13 deletions

View File

@@ -209,7 +209,7 @@ class Reactor:
)
decay_heat = decay_heat_fraction(state.core.burnup) * state.core.power_output_mw
total_power = prompt_power + decay_heat + decay_power
total_power = min(total_power, constants.TEST_MAX_POWER_MW * 0.98)
total_power = min(total_power, constants.TEST_MAX_POWER_MW * 0.98, self.control.setpoint_mw * 1.1)
state.core.power_output_mw = total_power
state.core.update_burnup(dt)
# Track fission products and emitted particles for diagnostics.
@@ -484,12 +484,20 @@ class Reactor:
env = constants.ENVIRONMENT_TEMPERATURE
primary_cooling = temperature_rise(transferred, state.primary_loop.mass_flow_rate)
if transferred <= 0.0 or state.secondary_loop.mass_flow_rate <= 1.0:
passive = 0.02 * max(0.0, state.primary_loop.temperature_out - env) * dt
passive = constants.PASSIVE_COOL_RATE_PRIMARY * max(0.0, state.primary_loop.temperature_out - env) * dt
primary_cooling = max(primary_cooling, passive)
state.primary_loop.temperature_in = max(env, state.primary_loop.temperature_out - primary_cooling)
if state.core.power_output_mw <= constants.RHR_CUTOFF_POWER_MW and not self.turbine_active:
bleed = constants.RHR_COOL_RATE * dt
state.primary_loop.temperature_out = max(env, state.primary_loop.temperature_out - bleed)
state.primary_loop.temperature_in = max(env, state.primary_loop.temperature_out - bleed)
if state.secondary_loop.mass_flow_rate <= 1.0:
target_temp = env
# Passive cooldown toward ambient when pumps off/low steam.
rhr = 0.0
if constants.RHR_ACTIVE and state.core.power_output_mw <= constants.RHR_CUTOFF_POWER_MW:
rhr = constants.RHR_COOL_RATE * dt
target_temp = max(env, state.secondary_loop.temperature_out - rhr)
state.secondary_loop.temperature_out = self._ramp_value(
state.secondary_loop.temperature_out, target_temp, dt, self.secondary_pump.spool_time
)
@@ -499,6 +507,10 @@ class Reactor:
excess = max(0.0, state.secondary_loop.temperature_out - env)
cooling_drop = min(40.0, max(10.0, 0.2 * excess))
state.secondary_loop.temperature_in = max(env, state.secondary_loop.temperature_out - cooling_drop)
if state.core.power_output_mw <= constants.RHR_CUTOFF_POWER_MW and not self.turbine_active:
bleed = constants.RHR_COOL_RATE * dt
state.secondary_loop.temperature_out = max(env, state.secondary_loop.temperature_out - bleed)
state.secondary_loop.temperature_in = max(env, state.secondary_loop.temperature_out - bleed)
# Keep stored energies consistent with updated temperatures/quality.
cp = constants.COOLANT_HEAT_CAPACITY
@@ -675,7 +687,7 @@ class Reactor:
if self.control.setpoint_mw <= 0.0:
return
error = (state.core.power_output_mw - self.control.setpoint_mw) / self.control.setpoint_mw
if abs(error) < 0.02:
if abs(error) < 0.005:
return
delta = constants.BORON_TRIM_RATE_PPM_PER_S * error * dt
state.boron_ppm = min(constants.CHEM_MAX_PPM, max(0.0, state.boron_ppm + delta))