From 24396d5a4b096a6c9037321d1e8ae1c1fffc0ee1 Mon Sep 17 00:00:00 2001 From: Malcolm Ross Date: Tue, 23 Jan 2024 16:08:34 -0600 Subject: [PATCH] Fixes Issue 92: https://github.com/NREL/GEOPHIRES-X/issues/92 --- src/geophires_x/Outputs.py | 3 ++- src/geophires_x/Parameter.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/geophires_x/Outputs.py b/src/geophires_x/Outputs.py index fdd79643..56919e7c 100644 --- a/src/geophires_x/Outputs.py +++ b/src/geophires_x/Outputs.py @@ -94,7 +94,8 @@ def PrintOutputs(self, model: Model): 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) + if not param.UnitsMatch: + ConvertUnitsBack(param, model) # now we need to loop through all thw output parameters to update their units to # whatever units the user has specified. diff --git a/src/geophires_x/Parameter.py b/src/geophires_x/Parameter.py index 35c3ae41..c9687894 100644 --- a/src/geophires_x/Parameter.py +++ b/src/geophires_x/Parameter.py @@ -636,7 +636,8 @@ def ConvertUnitsBack(ParamToModify, model): try: # update The quantity back to the current units (the units that we started with) units # so the display will be in the right units - currQ = prefQ.to(currQ) + #currQ = prefQ.to(currQ) + currQ = currQ.to(prefQ) except BaseException as ex: print(str(ex)) print("Error: GEOPHIRES failed to convert your units for " + ParamToModify.Name + @@ -650,8 +651,10 @@ def ConvertUnitsBack(ParamToModify, model): " Exiting.") sys.exit() - # rest the value - ParamToModify.value = currQ.magnitude + # reset the values + if ParamToModify.value != currQ.magnitude: + ParamToModify.value = currQ.magnitude + ParamToModify.CurrentUnits = ParamToModify.PreferredUnits model.logger.info("Complete " + str(__name__) + ": " + sys._getframe().f_code.co_name)