diff --git a/src/geophires_x/AGSOutputs.py b/src/geophires_x/AGSOutputs.py index 01ad1e44..c06e06e8 100644 --- a/src/geophires_x/AGSOutputs.py +++ b/src/geophires_x/AGSOutputs.py @@ -5,13 +5,14 @@ import geophires_x -from .Parameter import ConvertUnitsBack, ConvertOutputUnits -from .OptionList import EndUseOptions, EconomicModel -from .Units import * +from geophires_x.OptionList import EndUseOptions, EconomicModel + import geophires_x.Model as Model import geophires_x.Outputs as Outputs import numpy as np +from geophires_x.Units import TemperatureUnit + NL = "\n" @@ -28,27 +29,8 @@ def PrintOutputs(self, model: Model): :return: None """ model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}') - # Deal with converting Units back to PreferredUnits, if required. - # before we write the outputs, we go thru all the parameters for all of the objects and set the values - # back to the units that the user entered the data in - # We do this because the value may be displayed in the output, and we want the user to recognize their value, - # not some converted value - for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: - for key in obj.ParameterDict: - param = obj.ParameterDict[key] - if not param.UnitsMatch: - ConvertUnitsBack(param, model) - - # now we need to loop thru all the output parameters to update their units to whatever units the user has specified. - # i.e., they may have specified that all LENGTH results must be in feet, so we need to convert - # those from whatever LENGTH unit they are to feet. - # same for all the other classes of units (TEMPERATURE, DENSITY, etc). - - for obj in [model.reserv, model.wellbores, model.surfaceplant, model.economics]: - for key in obj.OutputParameterDict: - if key in self.ParameterDict: - if self.ParameterDict[key] != obj.OutputParameterDict[key].CurrentUnits: - ConvertOutputUnits(obj.OutputParameterDict[key], self.ParameterDict[key], model) + + self._convert_units(model) # --------------------------------------- # write results to output file and screen diff --git a/src/geophires_x/GEOPHIRES3_newunits.txt b/src/geophires_x/GEOPHIRES3_newunits.txt index e8afe4c4..d5f52780 100644 --- a/src/geophires_x/GEOPHIRES3_newunits.txt +++ b/src/geophires_x/GEOPHIRES3_newunits.txt @@ -1,2 +1,4 @@ USD = [currency] cents = USD / 100 +KUSD = USD * 1000 +MMBTU = BTU * 1_000_000 diff --git a/src/geophires_x/Outputs.py b/src/geophires_x/Outputs.py index dd2c52e3..ddbd8021 100644 --- a/src/geophires_x/Outputs.py +++ b/src/geophires_x/Outputs.py @@ -744,15 +744,7 @@ def read_parameters(self, model: Model, default_output_path: Path = None) -> Non model.logger.info(f'Complete {__class__!s}: {__name__}') - def PrintOutputs(self, model: Model): - """ - PrintOutputs writes the standard outputs to the output file. - :param model: The container class of the application, giving access to everything else, including the logger - :type model: :class:`~geophires_x.Model.Model` - :return: None - """ - model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}') - + def _convert_units(self, model: Model): # Deal with converting Units back to PreferredUnits, if required. # before we write the outputs, we go thru all the parameters for all of the objects and set the values back # to the units that the user entered the data in @@ -779,6 +771,17 @@ def PrintOutputs(self, model: Model): elif not output_param.UnitsMatch: obj.OutputParameterDict[key] = output_param.with_preferred_units() + def PrintOutputs(self, model: Model): + """ + PrintOutputs writes the standard outputs to the output file. + :param model: The container class of the application, giving access to everything else, including the logger + :type model: :class:`~geophires_x.Model.Model` + :return: None + """ + model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}') + + self._convert_units(model) + #data structures and assignments for HTML and Improved Text Output formats simulation_metadata = [] summary = [] diff --git a/src/geophires_x/OutputsAddOns.py b/src/geophires_x/OutputsAddOns.py index e9364bac..bab710f8 100644 --- a/src/geophires_x/OutputsAddOns.py +++ b/src/geophires_x/OutputsAddOns.py @@ -20,6 +20,8 @@ def PrintOutputs(self, model) -> tuple: """ model.logger.info(f'Init {str(__class__)}: {__name__}') + self._convert_units(model) + # now do AddOn output, which will append to the original output # write results to output file and screen try: diff --git a/src/geophires_x/OutputsCCUS.py b/src/geophires_x/OutputsCCUS.py index 0cb2cd00..e187c5a4 100644 --- a/src/geophires_x/OutputsCCUS.py +++ b/src/geophires_x/OutputsCCUS.py @@ -16,7 +16,9 @@ def PrintOutputs(self, model): :type model: :class:`~geophires_x.Model.Model` :return: Nothing """ - model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name) + model.logger.info(f'Init {__class__!s}: sys._getframe().f_code.co_name') + + self._convert_units(model) if np.sum(model.ccuseconomics.CCUSRevenue.value) == 0: return # don't bother if we have nothing to report. diff --git a/src/geophires_x/OutputsS_DAC_GT.py b/src/geophires_x/OutputsS_DAC_GT.py index f9b20b31..b92d83e8 100644 --- a/src/geophires_x/OutputsS_DAC_GT.py +++ b/src/geophires_x/OutputsS_DAC_GT.py @@ -18,6 +18,8 @@ def PrintOutputs(self, model) -> tuple: """ model.logger.info(f'Init {str(__class__)}: {__name__}') + self._convert_units(model) + # now do S_DAC_GT output, which will append to the original output # write results to output file and screen try: diff --git a/src/geophires_x/SUTRAOutputs.py b/src/geophires_x/SUTRAOutputs.py index 4e644c21..7e98d6d8 100644 --- a/src/geophires_x/SUTRAOutputs.py +++ b/src/geophires_x/SUTRAOutputs.py @@ -3,10 +3,11 @@ import sys import geophires_x -import numpy as np import geophires_x.Model as Model from geophires_x.Outputs import Outputs -from .OptionList import EconomicModel +from geophires_x.OptionList import EconomicModel + +import numpy as np NL="\n" @@ -47,6 +48,7 @@ def PrintOutputs(self, model: Model): """ model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}') + self._convert_units(model) # write results to output file and screen try: @@ -83,7 +85,11 @@ def PrintOutputs(self, model: Model): f.write(f" Fixed Charge Rate (FCR): {model.economics.FCR.value*100.0:10.2f} " + model.economics.FCR.CurrentUnits.value + NL) elif model.economics.econmodel.value == EconomicModel.STANDARDIZED_LEVELIZED_COST: f.write(" Economic Model = " + model.economics.econmodel.value.value + NL) - f.write(f" Interest Rate: {model.economics.discountrate.value*100.0:10.2f} " + model.economics.discountrate.CurrentUnits.value + NL) + + # FIXME discountrate should not be multiplied by 100 here - + # it appears to be incorrectly claiming its units are percent when the actual value is in tenths. + f.write(f" Interest Rate: {model.economics.discountrate.value*100.0:10.2f} {model.economics.discountrate.CurrentUnits.value}\n") + elif model.economics.econmodel.value == EconomicModel.BICYCLE: f.write(" Economic Model = " + model.economics.econmodel.value.value + NL) f.write(f" Accrued financing during construction: {model.economics.inflrateconstruction.value*100:10.2f} " + model.economics.inflrateconstruction.PreferredUnits.value + NL) diff --git a/tests/examples/SUTRAExample1.out b/tests/examples/SUTRAExample1.out index 225bdd9b..dc2b4aff 100644 --- a/tests/examples/SUTRAExample1.out +++ b/tests/examples/SUTRAExample1.out @@ -6,8 +6,8 @@ Simulation Metadata ---------------------- GEOPHIRES Version: 3.6.0 Simulation Date: 2024-10-10 - Simulation Time: 11:54 - Calculation Time: 0.510 sec + Simulation Time: 12:23 + Calculation Time: 0.515 sec ***SUMMARY OF RESULTS*** @@ -17,7 +17,7 @@ Simulation Metadata Number of Production Wells: 1 Number of Injection Wells: 1 Lifetime Average Well Flow Rate: 16.2 kg/sec - Well depth: 600.0 meter + Well depth: 0.6 kilometer ***ECONOMIC PARAMETERS*** @@ -31,11 +31,11 @@ Simulation Metadata Number of Production Wells: 1 Number of Injection Wells: 1 - Well Depth: 600.0 meter + Well Depth: 0.6 kilometer Pump efficiency: 0.8 Lifetime Average Well Flow Rate: 16.2 kg/sec - Injection well casing ID: 0.198 meter - Production well casing ID: 0.198 meter + Injection well casing ID: 7.800 in + Production well casing ID: 7.800 in ***RESERVOIR SIMULATION RESULTS***