Skip to content

Commit 06d6275

Browse files
author
Frederik
committed
Addressing latest comments by Gen
1 parent 93df2f7 commit 06d6275

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

‎hercules/plant_components/thermal_component_base.py‎

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def __init__(self, h_dict, component_name):
125125
self.min_down_time = component_dict["min_down_time"] # s
126126

127127
# Extract optional parameters for startup and shutdown fuel fractions
128-
self.startup_fuel_fraction = component_dict.get("startup_fuel_fraction", 0)
129-
self.shutdown_fuel_fraction = component_dict.get("shutdown_fuel_fraction", 0)
128+
self.startup_fuel_fraction = component_dict.get("startup_fuel_fraction", None)
129+
self.shutdown_fuel_fraction = component_dict.get("shutdown_fuel_fraction", None)
130130

131131
# Check all required parameters are numbers
132132
if not isinstance(self.rated_capacity, (int, float, hercules_float_type)):
@@ -577,7 +577,23 @@ def _apply_on_constraints(self, power_setpoint):
577577
return P_constrained
578578

579579
def calculate_efficiency(self, power_output):
580-
"""Calculate HHV net efficiency based on current power output.
580+
"""Calculate HHV net efficiency based on current power output and state.
581+
582+
Args:
583+
power_output (float): Current power output in kW.
584+
585+
Returns:
586+
float: HHV net efficiency as a fraction (0-1).
587+
"""
588+
fuel_consumption_rate = self.calculate_fuel_volume_rate(power_output) # m³/s
589+
590+
if fuel_consumption_rate == 0:
591+
return np.nan # Efficiency is undefined when fuel consumption is zero
592+
593+
return (power_output * 1000.0) / (fuel_consumption_rate * self.hhv)
594+
595+
def interpolate_efficiency(self, power_output):
596+
"""Interpolate HHV net efficiency based on current power output.
581597
582598
Uses linear interpolation from the efficiency table. Values outside the
583599
table range are clamped to the nearest endpoint.
@@ -588,10 +604,6 @@ def calculate_efficiency(self, power_output):
588604
Returns:
589605
float: HHV net efficiency as a fraction (0-1).
590606
"""
591-
if power_output <= 0:
592-
# Return efficiency at lowest power fraction when off
593-
return self.efficiency_values[0]
594-
595607
# Calculate power fraction
596608
power_fraction = power_output / self.rated_capacity
597609

@@ -612,31 +624,31 @@ def calculate_fuel_volume_rate(self, power_output):
612624
float: Fuel volume flow rate in m³/s.
613625
"""
614626
rated_fuel_consumption_rate = (self.rated_capacity * 1000.0) / (
615-
self.hhv * self.calculate_efficiency(self.rated_capacity)
627+
self.hhv * self.interpolate_efficiency(self.rated_capacity)
616628
) # m³/s at rated capacity
617629

618630
if self.state == self.STATES.OFF:
619631
# When off, fuel flow is zero
620632
return 0.0
621-
elif self.state == self.STATES.STOPPING:
633+
elif self.state == self.STATES.STOPPING and self.shutdown_fuel_fraction is not None:
622634
# When stopping, use shutdown fuel fraction if provided
623635
return self.shutdown_fuel_fraction * rated_fuel_consumption_rate
624-
elif self.state in [
625-
self.STATES.HOT_STARTING,
626-
self.STATES.WARM_STARTING,
627-
self.STATES.COLD_STARTING,
628-
]:
636+
elif (
637+
self.state
638+
in [
639+
self.STATES.HOT_STARTING,
640+
self.STATES.WARM_STARTING,
641+
self.STATES.COLD_STARTING,
642+
]
643+
and self.startup_fuel_fraction is not None
644+
):
629645
# During startup (HOT_STARTING, WARM_STARTING, COLD_STARTING), use startup fuel fraction
630646
return self.startup_fuel_fraction * rated_fuel_consumption_rate
631647

632648
# When on, calculate fuel rate based on current HHV net efficiency
633-
efficiency = self.calculate_efficiency(power_output)
649+
efficiency = self.interpolate_efficiency(power_output)
634650

635651
# Calculate fuel volume rate using HHV net efficiency
636652
# fuel_volume_rate (m³/s) = power (W) / (efficiency * hhv (J/m³))
637653
# Convert power from kW to W (multiply by 1000)
638-
# Ensure fuel rate is at least the startup fuel fraction when on
639-
return max(
640-
(power_output * 1000.0) / (efficiency * self.hhv),
641-
rated_fuel_consumption_rate * self.startup_fuel_fraction,
642-
)
654+
return (power_output * 1000.0) / (efficiency * self.hhv)

0 commit comments

Comments
 (0)