Let auto rod control clear shutdown and adjust rods
This commit is contained in:
@@ -171,6 +171,8 @@ class Reactor:
|
|||||||
if command:
|
if command:
|
||||||
overrides = self._apply_command(command, state)
|
overrides = self._apply_command(command, state)
|
||||||
rod_fraction = overrides.get("rod_fraction", rod_fraction)
|
rod_fraction = overrides.get("rod_fraction", rod_fraction)
|
||||||
|
if not self.shutdown and not self.control.manual_control:
|
||||||
|
rod_fraction = self.control.update_rods(state.core, dt)
|
||||||
|
|
||||||
decay_power, decay_neutron_source, decay_products, decay_particles = self.fuel.decay_reaction_effects(
|
decay_power, decay_neutron_source, decay_products, decay_particles = self.fuel.decay_reaction_effects(
|
||||||
state.core
|
state.core
|
||||||
@@ -476,6 +478,8 @@ class Reactor:
|
|||||||
self.control.set_power_setpoint(command.power_setpoint)
|
self.control.set_power_setpoint(command.power_setpoint)
|
||||||
if command.rod_manual is not None:
|
if command.rod_manual is not None:
|
||||||
self.control.set_manual_mode(command.rod_manual)
|
self.control.set_manual_mode(command.rod_manual)
|
||||||
|
if command.rod_manual is False and not self.meltdown:
|
||||||
|
self.shutdown = False
|
||||||
if command.rod_position is not None:
|
if command.rod_position is not None:
|
||||||
self.control.set_manual_mode(True)
|
self.control.set_manual_mode(True)
|
||||||
overrides["rod_fraction"] = self.control.set_rods(command.rod_position)
|
overrides["rod_fraction"] = self.control.set_rods(command.rod_position)
|
||||||
@@ -505,6 +509,10 @@ class Reactor:
|
|||||||
overrides["coolant_demand"] = max(0.0, min(1.0, command.coolant_demand))
|
overrides["coolant_demand"] = max(0.0, min(1.0, command.coolant_demand))
|
||||||
for component in command.maintenance_components:
|
for component in command.maintenance_components:
|
||||||
self._toggle_maintenance(component)
|
self._toggle_maintenance(component)
|
||||||
|
if not self.meltdown and not command.scram:
|
||||||
|
rod_target = overrides.get("rod_fraction", self.control.rod_fraction)
|
||||||
|
if rod_target < 0.95:
|
||||||
|
self.shutdown = False
|
||||||
return overrides
|
return overrides
|
||||||
|
|
||||||
def _set_primary_pump(self, active: bool) -> None:
|
def _set_primary_pump(self, active: bool) -> None:
|
||||||
|
|||||||
@@ -253,3 +253,17 @@ def test_meltdown_triggers_shutdown():
|
|||||||
|
|
||||||
assert reactor.shutdown is True
|
assert reactor.shutdown is True
|
||||||
assert reactor.meltdown is True
|
assert reactor.meltdown is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_auto_control_resets_shutdown_and_moves_rods():
|
||||||
|
reactor = Reactor.default()
|
||||||
|
state = reactor.initial_state()
|
||||||
|
reactor.shutdown = True
|
||||||
|
reactor.control.manual_control = True
|
||||||
|
reactor.control.rod_fraction = 0.95
|
||||||
|
|
||||||
|
reactor.step(state, dt=1.0, command=ReactorCommand(rod_manual=False))
|
||||||
|
|
||||||
|
assert reactor.shutdown is False
|
||||||
|
assert reactor.control.manual_control is False
|
||||||
|
assert reactor.control.rod_fraction < 0.95
|
||||||
|
|||||||
Reference in New Issue
Block a user