diff --git a/src/reactor_sim/reactor.py b/src/reactor_sim/reactor.py index c7ab3bb..6dd3ab4 100644 --- a/src/reactor_sim/reactor.py +++ b/src/reactor_sim/reactor.py @@ -203,8 +203,8 @@ class Reactor: for idx in range(2) ] any_units = any(primary_units_active) or any(secondary_units_active) or any(self.turbine_unit_active) - any_generators = any(getattr(g, "running", False) or getattr(g, "starting", False) for g in state.generators) - aux_base = 0.0 if (self.shutdown and not any_units and not any_generators) else constants.BASE_AUX_LOAD_MW + load_present = any_units or (self.consumer and self.consumer.online) + aux_base = constants.BASE_AUX_LOAD_MW if not self.shutdown or load_present else 0.0 aux_pump_primary = constants.PUMP_POWER_MW * sum(primary_units_active) aux_pump_secondary = constants.PUMP_POWER_MW * sum(secondary_units_active) aux_demand = aux_base + aux_pump_primary + aux_pump_secondary @@ -566,6 +566,11 @@ class Reactor: GeneratorState(running=False, starting=False, spool_remaining=0.0, power_output_mw=0.0, battery_charge=1.0) ) deficit = max(0.0, aux_demand - turbine_electric) + if self.generator_auto and aux_demand <= 0.0: + for idx, gen_state in enumerate(state.generators): + if gen_state.running or gen_state.starting: + self.generators[idx].stop(gen_state) + return 0.0 if self.generator_auto: if deficit > 0.0: for idx, gen_state in enumerate(state.generators):