Skip to content

Commit

Permalink
Merge pull request NREL#45 from malcolm-dsider/main
Browse files Browse the repository at this point in the history
No functional changes. Only Docstring changes and formatting. removed…
  • Loading branch information
malcolm-dsider authored Nov 10, 2023
2 parents e2b134d + 2a5e4ea commit c8f948b
Show file tree
Hide file tree
Showing 31 changed files with 2,013 additions and 1,344 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ docs/reference/parameters.rst
docs/geophires-request.json
docs/parameters.rst
_site/
/docs/geophires_x.rstx
/docs/temperature.txt
/geophires_x.rst
/modules.rst
/Useful sites for Sphinx docstrings.txt
/.github/workflows/workflows.7z

# Mypy Cache
.mypy_cache/

#CLG Simulator
/src/geophires_x/CLG Simulator/clg_tea_module_laptop_auto.py
/src/geophires_x/CLG Simulator/clg_tea_v3.py
/src/geophires_x/CLG Simulator/clg_tea_v3_coaxial_water_elec.py
/src/geophires_x/CLG Simulator/clg_tea_v3_SCO2_elec.py
/src/geophires_x/CLG Simulator/clgs_v2.py
52 changes: 8 additions & 44 deletions src/geophires_x/AGSEconomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,16 @@
class AGSEconomics(Economics.Economics):
"""
AGSEconomics Child class of Economics; it is the same, but has advanced AGS closed-loop functionality
.. list-table:: **Parameters**
:widths: 100 25 25 50 25 25 25
:header-rows: 1
* - Name
- Type
- Default Value
- Units
- Min
- Max
- Required
* - Operation & Maintenance Cost of Surface Plant
- float
- 0.015
- PercentUnit.TENTH
- 0.0
- 0.2
- True
* - Capital Cost for Surface Plant for Direct-use System
- float
- 100.0
- EnergyCostUnit.DOLLARSPERKW
- 0.0,
- 10000.0
- False
"""

def __init__(self, model: Model):
"""
The __init__ function is the constructor for a class. It is called whenever an instance of the class is created.
The __init__ function can take arguments, but self is always the first one. Self refers to the instance of the
object that has already been created, and it's used to access variables that belong to that object."
:param self: Reference the class object itself
object that has already been created, and it's used to access variables that belong to that object
:param model: The container class of the application, giving access to everything else, including the logger
:type model: Model
:return: Nothing, and is used to initialize the class
:doc-author: Malcolm Ross
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down Expand Up @@ -92,7 +64,8 @@ def __init__(self, model: Model):
Required=True,
ErrMessage="assume default Operation & Maintenance cost of surface plant expressed as fraction of total surface plant capital cost (0.015)"
)
self.Direct_use_heat_cost_per_kWth = self.ParameterDict[self.Direct_use_heat_cost_per_kWth.Name] = floatParameter(
self.Direct_use_heat_cost_per_kWth = self.ParameterDict[
self.Direct_use_heat_cost_per_kWth.Name] = floatParameter(
"Capital Cost for Surface Plant for Direct-use System",
value=100.0,
DefaultValue=100.0,
Expand Down Expand Up @@ -128,12 +101,9 @@ def read_parameters(self, model: Model) -> None:
The read_parameters function reads in the parameters from a dictionary and stores them in the parameters.
It also handles special cases that need to be handled after a value has been read in and checked.
If you choose to subclass this master class, you can also choose to override this method (or not), and if you do
:param self: Access variables that belong to a class
: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
:doc-author: Malcolm Ross
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
super().read_parameters(model) # read the default parameters
Expand All @@ -152,12 +122,9 @@ def verify(self, model: Model) -> int:
"""
The validate function checks that all values provided are within the range expected by AGS modeling system.
These values in within a smaller range than the value ranges available to GEOPHIRES-X
:param self: Access variables that belong to a class
:param model: The container class of the application, giving access to everything else, including the logger
:type model: :class:`~geophires_x.Model.Model`
:return: 0 if all OK, 1 if error.
:doc-author: Koenraad Beckers
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down Expand Up @@ -220,12 +187,9 @@ def verify(self, model: Model) -> int:
def Calculate(self, model: Model) -> None:
"""
The calculate function verifies, initializes, and calculate the values for the AGS model
:param self: Access variables that belong to a class
: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
:doc-author: Koenraad Beckers
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down Expand Up @@ -279,7 +243,7 @@ def Calculate(self, model: Model) -> None:
model.surfaceplant.error_codes = np.append(model.surfaceplant.error_codes, 6000)
else:
self.LCOE.value = (self.TotalCAPEX + np.sum(self.OPEX_Plant * Discount_vector)) * 1e6 / np.sum((
model.surfaceplant.Annual_electricity_production - model.surfaceplant.Annual_pumping_power) / 1e3 * Discount_vector) # $/MWh
model.surfaceplant.Annual_electricity_production - model.surfaceplant.Annual_pumping_power) / 1e3 * Discount_vector) # $/MWh
if self.LCOE.value < 0:
self.LCOE.value = 9999
model.surfaceplant.error_codes = np.append(model.surfaceplant.error_codes, 7000)
Expand Down
19 changes: 15 additions & 4 deletions src/geophires_x/AGSOutputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,32 @@


class AGSOutputs(Outputs.Outputs):
"""description of class"""
"""
Handles the display of AGS data
"""

def PrintOutputs(self, model: Model):
"""
Print the outputs to the screen and to the output file
:param model: the model object
:type model: :class:`~geophires_x.Model.Model`
:return: None
"""
model.logger.info("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
# 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 thw 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.
# 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]:
Expand Down
Loading

0 comments on commit c8f948b

Please sign in to comment.