Skip to content

Commit da5d42d

Browse files
Convert efficiency into its CurrentUnits instead of hardcoding tenth to percent multiplication
1 parent 5aa60a7 commit da5d42d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/geophires_x/Outputs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
PlantType
2424
from geophires_x.GeoPHIRESUtils import UpgradeSymbologyOfUnits, render_default, InsertImagesIntoHTML
2525
from geophires_x.Parameter import Parameter
26-
from geophires_x.Units import convertible_unit, Units, PercentUnit
2726

2827
NL = '\n'
2928
validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits)

src/geophires_x/SurfacePlant.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import numpy as np
44

5+
from .GeoPHIRESUtils import quantity
56
from .OptionList import EndUseOptions, PlantType
67
from .Parameter import floatParameter, intParameter, strParameter, OutputParameter, ReadParameter, \
78
coerce_int_params_to_enum_values
@@ -486,7 +487,7 @@ def __init__(self, model: Model):
486487
Name="First Law Efficiency",
487488
UnitType=Units.PERCENT,
488489
PreferredUnits=PercentUnit.PERCENT,
489-
CurrentUnits=PercentUnit.PERCENT,
490+
CurrentUnits=PercentUnit.PERCENT, # FIXME default values are actually in tenths, not percent.
490491
ToolTipText='Net electricity produced divided by heat extracted towards electricity'
491492
)
492493
self.heat_to_power_conversion_efficiency = self.OutputParameterDict[self.heat_to_power_conversion_efficiency.Name] = OutputParameter(
@@ -657,6 +658,8 @@ def _calculate_derived_outputs(self, model: Model) -> None:
657658
"""
658659

659660
if self.FirstLawEfficiency is not None:
660-
avg_efficiency = np.average(model.surfaceplant.FirstLawEfficiency.value) * 100 # TODO proper unit conversion
661+
fle_unit = PercentUnit.TENTH # See FIXME on self.FirstLawEfficiency re: CurrentUnit being incorrect.
662+
avg_efficiency = quantity(np.average(model.surfaceplant.FirstLawEfficiency.value), fle_unit).to(
663+
convertible_unit(self.heat_to_power_conversion_efficiency.CurrentUnits)).magnitude
661664
if avg_efficiency > 0: # 0 is presumed to mean N/A
662665
self.heat_to_power_conversion_efficiency.value = avg_efficiency

0 commit comments

Comments
 (0)