5
5
import geophires_x
6
6
import numpy as np
7
7
import geophires_x .Model as Model
8
- from .Parameter import LookupUnits
8
+ from .Parameter import ConvertUnitsBack , ConvertOutputUnits , LookupUnits
9
9
from .OptionList import EconomicModel
10
10
11
11
NL = "\n "
@@ -89,22 +89,25 @@ def PrintOutputs(self, model: Model):
89
89
# to the units that the user entered the data in
90
90
# We do this because the value may be displayed in the output, and we want the user to recognize their value,
91
91
# not some converted value
92
- # for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
93
- # for key in obj.ParameterDict:
94
- # param = obj.ParameterDict[key]
95
- # if not param.UnitsMatch: ConvertUnitsBack(param, model)
92
+ for obj in [model .reserv , model .wellbores , model .surfaceplant , model .economics ]:
93
+ for key in obj .ParameterDict :
94
+ param = obj .ParameterDict [key ]
95
+ if not param .UnitsMatch : ConvertUnitsBack (param , model )
96
96
97
97
# now we need to loop through all thw output parameters to update their units to
98
98
# whatever units the user has specified.
99
99
# i.e., they may have specified that all LENGTH results must be in feet, so we need to convert those
100
100
# from whatever LENGTH unit they are to feet.
101
101
# same for all the other classes of units (TEMPERATURE, DENSITY, etc).
102
102
103
- #for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]:
104
- # for key in obj.OutputParameterDict:
105
- # if key in self.ParameterDict:
106
- # if self.ParameterDict[key] != obj.OutputParameterDict[key].CurrentUnits:
107
- # ConvertOutputUnits(obj.OutputParameterDict[key], self.ParameterDict[key], model)
103
+ for obj in [model .reserv , model .wellbores , model .surfaceplant , model .economics ]:
104
+ for key in obj .OutputParameterDict :
105
+ output_param :OutputParameter = obj .OutputParameterDict [key ]
106
+ if key in self .ParameterDict :
107
+ if self .ParameterDict [key ] != output_param .CurrentUnits :
108
+ ConvertOutputUnits (output_param , self .ParameterDict [key ], model )
109
+ elif not output_param .UnitsMatch :
110
+ obj .OutputParameterDict [key ] = output_param .with_preferred_units ()
108
111
109
112
# write results to output file and screen
110
113
@@ -142,7 +145,7 @@ def PrintOutputs(self, model: Model):
142
145
f .write (f" Fixed Charge Rate (FCR): { model .economics .FCR .value * 100.0 :10.2f} " + model .economics .FCR .CurrentUnits .value + NL )
143
146
elif model .economics .econmodel .value == EconomicModel .STANDARDIZED_LEVELIZED_COST :
144
147
f .write (" Economic Model = " + model .economics .econmodel .value .value + NL )
145
- f .write (f" Interest Rate: { model .economics .discountrate .value * 100.0 :10.2f} " + model .economics .discountrate .PreferredUnits .value + NL )
148
+ f .write (f" Interest Rate: { model .economics .discountrate .value :10.2f} " + model .economics .discountrate .PreferredUnits .value + NL )
146
149
elif model .economics .econmodel .value == EconomicModel .BICYCLE :
147
150
f .write (" Economic Model = " + model .economics .econmodel .value .value + NL )
148
151
f .write (f" Accrued financing during construction: { model .economics .inflrateconstruction .value * 100 :10.2f} " + model .economics .inflrateconstruction .PreferredUnits .value + NL )
@@ -156,7 +159,7 @@ def PrintOutputs(self, model: Model):
156
159
f .write (f" Well Depth: { model .reserv .depth .value :10.1f} " + model .reserv .depth .CurrentUnits .value + NL )
157
160
158
161
pump_efficiency_display_unit = model .surfaceplant .pump_efficiency .CurrentUnits .value
159
- pump_efficiency_display = f'{ model .surfaceplant .pump_efficiency .value * 100 :10.1f} { pump_efficiency_display_unit } '
162
+ pump_efficiency_display = f'{ model .surfaceplant .pump_efficiency .value :10.1f} { pump_efficiency_display_unit } '
160
163
f .write (f' Pump efficiency: { pump_efficiency_display } { NL } ' )
161
164
162
165
f .write (f" Lifetime Average Well Flow Rate: { np .average (abs (model .wellbores .ProductionWellFlowRates .value )):10.1f} " + model .wellbores .ProductionWellFlowRates .CurrentUnits .value + NL )
0 commit comments