Skip to content

Commit de28e0b

Browse files
Define 'Heat to Power Conversion Efficiency' as a separate output that is calculated in _calculate_derived_outputs.
1 parent 1520f0a commit de28e0b

13 files changed

+43
-13
lines changed

src/geophires_x/Outputs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,12 +1912,10 @@ def PrintOutputs(self, model: Model):
19121912

19131913
f.write(f' Average Pumping Power: {np.average(model.wellbores.PumpingPower.value):10.2f} {model.wellbores.PumpingPower.CurrentUnits.value}{NL}')
19141914

1915-
if model.surfaceplant.FirstLawEfficiency is not None:
1916-
avg_efficiency = np.average(model.surfaceplant.FirstLawEfficiency.value) * 100
1917-
first_law_efficiency_output_name = 'Heat to power conversion efficiency'
1918-
if avg_efficiency > 0: # 0 is presumed to mean N/A
1919-
f.write(
1920-
f' {Outputs._field_label(first_law_efficiency_output_name, 50)}{avg_efficiency:10.2f} {model.surfaceplant.FirstLawEfficiency.CurrentUnits.value}\n')
1915+
if model.surfaceplant.heat_to_power_conversion_efficiency.value is not None:
1916+
hpce = model.surfaceplant.heat_to_power_conversion_efficiency
1917+
f.write(f' {Outputs._field_label(hpce.Name, 50)}'
1918+
f'{hpce.value:10.2f} {model.surfaceplant.heat_to_power_conversion_efficiency.CurrentUnits.value}\n')
19211919

19221920
f.write(NL)
19231921
f.write(' ************************************************************\n')

src/geophires_x/SurfacePlant.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,14 @@ def __init__(self, model: Model):
487487
UnitType=Units.PERCENT,
488488
PreferredUnits=PercentUnit.PERCENT,
489489
CurrentUnits=PercentUnit.PERCENT,
490-
ToolTipText='Heat to power conversion efficiency'
490+
ToolTipText='Net electricity produced divided by heat extracted towards electricity'
491+
)
492+
self.heat_to_power_conversion_efficiency = self.OutputParameterDict[self.heat_to_power_conversion_efficiency.Name] = OutputParameter(
493+
Name='Heat to Power Conversion Efficiency',
494+
UnitType=Units.PERCENT,
495+
PreferredUnits=PercentUnit.PERCENT,
496+
CurrentUnits=PercentUnit.PERCENT,
497+
ToolTipText='First law efficiency average over project lifetime'
491498
)
492499
self.HeatExtracted = self.OutputParameterDict[self.HeatExtracted.Name] = OutputParameter(
493500
Name="Heat Extracted",
@@ -637,4 +644,18 @@ def Calculate(self, model: Model) -> None:
637644

638645
# All calculations are handled in subclasses of this class, so this function is empty.
639646

647+
# Subclasses should call _calculate_derived_outputs at the end of their Calculate methods.
648+
self._calculate_derived_outputs(model)
649+
640650
model.logger.info(f'Complete {self.__class__.__name__}: {__name__}')
651+
652+
def _calculate_derived_outputs(self, model: Model) -> None:
653+
"""
654+
Subclasses should call _calculate_derived_outputs at the end of their Calculate methods to populate output
655+
values that are derived from subclass-calculated outputs.
656+
"""
657+
658+
if self.FirstLawEfficiency is not None:
659+
avg_efficiency = np.average(model.surfaceplant.FirstLawEfficiency.value) * 100 # TODO proper unit conversion
660+
if avg_efficiency > 0: # 0 is presumed to mean N/A
661+
self.heat_to_power_conversion_efficiency.value = avg_efficiency

src/geophires_x/SurfacePlantAGS.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,4 +783,5 @@ def Calculate(self, model: Model) -> None:
783783
print(f'Error: {class_file_info_msg}. Exiting....')
784784
raise RuntimeError(base_msg)
785785

786+
self._calculate_derived_outputs(model)
786787
model.logger.info(f"complete {str(__class__)}: {sys._getframe().f_code.co_name}")

src/geophires_x/SurfacePlantAbsorptionChiller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,6 @@ def Calculate(self, model: Model) -> None:
141141
# calculate reservoir heat content
142142
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
143143
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
144+
145+
self._calculate_derived_outputs(model)
144146
model.logger.info(f"complete {self.__class__.__name__}: {__name__}")

src/geophires_x/SurfacePlantDistrictHeating.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def Calculate(self, model: Model) -> None:
249249
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
250250
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
251251

252+
self._calculate_derived_outputs(model)
252253
model.logger.info(f"Complete {self.__class__.__name__}: {__name__}")
253254

254255
# district heating routines below

src/geophires_x/SurfacePlantDoubleFlash.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ def Calculate(self, model: Model) -> None:
133133
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
134134
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
135135

136+
self._calculate_derived_outputs(model)
136137
model.logger.info(f'complete {self.__class__.__name__}: {__name__}')

src/geophires_x/SurfacePlantHeatPump.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ def Calculate(self, model: Model) -> None:
131131
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
132132
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
133133

134-
model.logger.info("complete " + str(__class__) + ": " + inspect.currentframe().f_code.co_name)
134+
self._calculate_derived_outputs(model)
135+
model.logger.info(f"complete {str(__class__)}: {inspect.currentframe().f_code.co_name}")

src/geophires_x/SurfacePlantIndustrialHeat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,5 @@ def Calculate(self, model: Model) -> None:
9898
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
9999
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
100100

101-
model.logger.info("complete " + self.__class__.__name__ + ": " + __name__)
101+
self._calculate_derived_outputs(model)
102+
model.logger.info(f"complete {self.__class__.__name__}: {__name__}")

src/geophires_x/SurfacePlantSUTRA.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,6 @@ def Calculate(self, model: Model) -> None:
204204
# calculate maximum auxiliary boiler demand
205205
self.max_peaking_boiler_demand.value = max(self.AnnualAuxiliaryHeatProduced.value)
206206

207+
self._calculate_derived_outputs(model)
207208
model.logger.info(f"complete {self.__class__.__name__}: {self.__init__.__name__}")
208209

src/geophires_x/SurfacePlantSingleFlash.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,5 @@ def Calculate(self, model: Model) -> None:
133133
self.RemainingReservoirHeatContent.value = SurfacePlant.remaining_reservoir_heat_content(
134134
self, model.reserv.InitialReservoirHeatContent.value, self.HeatkWhExtracted.value)
135135

136-
model.logger.info("complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)
136+
self._calculate_derived_outputs(model)
137+
model.logger.info(f"complete {str(__class__)}: {sys._getframe().f_code.co_name}")

0 commit comments

Comments
 (0)