Skip to content

Commit

Permalink
Merge pull request NREL#46 from malcolm-dsider/main
Browse files Browse the repository at this point in the history
Update SUTRA Docstrings to standard
  • Loading branch information
malcolm-dsider authored Nov 10, 2023
2 parents c8f948b + fdd2ca2 commit eb48f64
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 145 deletions.
52 changes: 26 additions & 26 deletions src/geophires_x/AGSWellBores.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,23 @@ def interp_kWt_avg(self, point):
def pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp, t):
"""
point source/sink solution functions
:param yy: y coordinate of the point source/sink
:param yy: y coordinate of the point source/sink (m) (yy = 0) for coaxial wellbore and (yy = 0.078) for U-loop wellbore (m)
:type yy: float
:param zz: z coordinate of the point source/sink
:param zz: z coordinate of the point source/sink (m) (zz = 0) for coaxial wellbore and (zz = 0.078) for U-loop wellbore (m)
:type zz: float
:param yt: y coordinate of the point source/sink
:param yt: y coordinate of the point source/sink (m) (yt = 0) for coaxial wellbore and (yt = 0.078) for U-loop wellbore (m)
:type yt: float
:param zt: z coordinate of the point source/sink
:param zt: z coordinate of the point source/sink (m) (zt = 0) for coaxial wellbore and (zt = 0.078) for U-loop wellbore (m)
:type zt: float
:param ye: y coordinate of the point source/sink
:param ye: y coordinate of the point source/sink (m) (ye = 0) for coaxial wellbore and (ye = 0.078) for U-loop wellbore (m)
:type ye: float
:param ze: z coordinate of the point source/sink
:param ze: z coordinate of the point source/sink (m) (ze = 0) for coaxial wellbore and (ze = 0.078) for U-loop wellbore (m)
:type ze: float
:param alpha: thermal diffusivity
:param alpha: thermal diffusivity (m2/s)
:type alpha: float
:param sp: Laplace variable
:param sp: Laplace variable (1/s)
:type sp: float
:param t: time
:param t: time (s)
:type t: float
:return: z
:rtype: float
Expand All @@ -202,23 +202,23 @@ def pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp, t):
def chebeve_pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp) -> float:
"""
Chebyshev approximation for numerical Laplace transformation integration from 1e-8 to 1e30
:param yy: y coordinate of the point source/sink
:param yy: y coordinate of the point source/sink (m) (yy = 0) for coaxial wellbore and (yy = 0.078) for U-loop wellbore (m)
:type yy: float
:param zz: z coordinate of the point source/sink
:param zz: z coordinate of the point source/sink (m) (zz = 0) for coaxial wellbore and (zz = 0.078) for U-loop wellbore (m)
:type zz: float
:param yt: y coordinate of the point source/sink
:param yt: y coordinate of the point source/sink (m) (yt = 0) for coaxial wellbore and (yt = 0.078) for U-loop wellbore (m)
:type yt: float
:param zt: z coordinate of the point source/sink
:param zt: z coordinate of the point source/sink (m) (zt = 0) for coaxial wellbore and (zt = 0.078) for U-loop wellbore (m)
:type zt: float
:param ye: y coordinate of the point source/sink
:param ye: y coordinate of the point source/sink (m) (ye = 0) for coaxial wellbore and (ye = 0.078) for U-loop wellbore (m)
:type ye: float
:param ze: z coordinate of the point source/sink
:param ze: z coordinate of the point source/sink (m) (ze = 0) for coaxial wellbore and (ze = 0.078) for U-loop wellbore (m)
:type ze: float
:param alpha: thermal diffusivity
:param alpha: thermal diffusivity (m2/s)
:type alpha: float
:param sp: Laplace variable
:param sp: Laplace variable (1/s)
:type sp: float
:return: ????
:return: ???? (need to check)
:rtype: float
"""
m = 32
Expand All @@ -238,7 +238,7 @@ def chebeve_pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp) -> float:
def laplace_solution(self, sp) -> float:
"""
Duhamel convolution method for closed-loop system
:param sp: Laplace variable
:param sp: Laplace variable (1/s)
:type sp: float
:return: Toutletl
:rtype: float
Expand Down Expand Up @@ -385,11 +385,11 @@ def Chebyshev(self, a, b, n, yy, zz, yt, zt, ye, ze, alpha, sp, func):
:type ye: float
:param ze: z coordinate of the point source/sink
:type ze: float
:param alpha: thermal diffusivity
:param alpha: thermal diffusivity (m2/s)
:type alpha: float
:param sp: Laplace variable
:param sp: Laplace variable (1/s)
:type sp: float
:param func: function
:param func: function to be integrated (pointsource)
:type func: function
:return: y * d - dd + 0.5 * cint[0]
:rtype: float
Expand Down Expand Up @@ -844,13 +844,13 @@ def CalculateNonverticalPressureDrop(self, model, time_operation: float, time_ma
Calculate nonvertical pressure drops - it will vary as the temperature varies
:param model: The container class of the application, giving access to everything else, including the logger
:type model: :class:`~geophires_x.Model.Model`
:param time_operation: time of operation
:param time_operation: time of operation in years (0.01)
:type time_operation: float
:param time_max: maximum time of operation
:param time_max: maximum time of operation in years (100) - this is the time of the last year of operation
:type time_max: float
:param al: time step
:param al: time step in years (0.01) - this is the time step of the simulation (not the time step of the CLGS model)
:type al: float
:return: NonverticalPressureDrop, friction
:return: NonverticalPressureDrop, friction - pressure drop and friction factor for the nonvertical section of the wellbore
:rtype: tuple
"""
friction = 0.0
Expand Down
20 changes: 10 additions & 10 deletions src/geophires_x/SUTRAEconomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .Parameter import intParameter, floatParameter, OutputParameter, ReadParameter, boolParameter
from .Units import *


class SUTRAEconomics:
"""
Class to support the default economic calculations in GEOPHIRES
Expand All @@ -18,13 +19,10 @@ def __init__(self, model: Model):
It initializes the attributes of an object, and sets default values for certain arguments that can be overridden
by user input.
The __init__ function is used to set up all the parameters in Economics.
:param self: Store data that will be used by the 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)

# Set up all the Parameters that will be predefined by this class using the different types of parameter classes.
Expand Down Expand Up @@ -301,10 +299,13 @@ def __init__(self, model: Model):

def read_parameters(self, model: Model) -> None:
"""
read_parameters read and update the Economics parameters and handle the special cases
Args:
model (Model): The container class of the application, giving access to everything else, including the logger
read_parameters read and update the Economics parameters and handle the special cases that need to be taken care of after a
value has been read in and checked. This is called from the main Model class. It is not called from the __init__
function because the user may not want to read in the parameters from the input file, but may want to set them
in the user interface.
:param model: The container class of the application, giving access to everything else, including the logger
:type model: :class:`~geophires_x.Model.Model`
:return: Nothing, but it does make calculations and set values in the model
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down Expand Up @@ -363,10 +364,9 @@ def Calculate(self, model: Model) -> None:
"""
The Calculate function is where all the calculations are done.
This function can be called multiple times, and will only recalculate what has changed each time it is called.
:param self: Access variables that belongs to the 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: Nothing, but it does make calculations and set values in the model
:doc-author: Malcolm Ross
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down
29 changes: 13 additions & 16 deletions src/geophires_x/SUTRAOutputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import sys
import numpy as np
import geophires_x.Model as Model
from .Parameter import ConvertUnitsBack, ConvertOutputUnits, LookupUnits
from .OptionList import EndUseOptions, EconomicModel, ReservoirModel, FractureShape, ReservoirVolume
from matplotlib import pyplot as plt
from .Units import *
from .Parameter import LookupUnits
from .OptionList import EconomicModel

NL="\n"

Expand All @@ -17,10 +15,9 @@ def __init__(self, model:Model):
It initializes the attributes of an object, and sets default values for certain arguments that can be
overridden by user input.
The __init__ function is used to set up all the parameters in the Outputs.
:param self: Store data that will be used by the 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)
Expand All @@ -40,18 +37,17 @@ 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
:return: None
:doc-author: Malcolm Ross
#Deal with all the parameter values that the user has provided. They should really only provide values that
Deals with all the parameter values that the user has provided. They should really only provide values that
they want to change from the default values, but they can provide a value that is already set because it is a
default value set in __init__. It will ignore those.
#This also deals with all the special cases that need to be taken care of after a value has been read in
This also deals with all the special cases that need to be taken care of 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),
If you choose to subclass this master class, you can also choose to override this method (or not),
and if you do, do it before or after you call you own version of this method. If you do, you can also choose
to call this method from you class, which can effectively modify all these superclass parameters in your 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
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand All @@ -74,11 +70,12 @@ def read_parameters(self, model:Model) -> None:

model.logger.info("Complete "+ str(__class__) + ": " + sys._getframe().f_code.co_name)

def PrintOutputs(self, model:Model):
def PrintOutputs(self, model: Model):
"""
PrintOutputs writes the standard outputs to the output file.
Args:
model (Model): The container class of the application, giving access to everything else, including the logger
: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("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)

Expand Down
43 changes: 25 additions & 18 deletions src/geophires_x/SUTRAReservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@

class SUTRAReservoir(Reservoir):
"""
This class reads in the output of a simulation with SUTRA.
This class reads in the output of a simulation with SUTRA. It then uses the output to calculate the heat stored, heat
supplied and efficiency for each year of the simulation. It also calculates the target heat and simulated heat for
each SUTRA time step over the lifetime of the simulation. Finally, it calculates the well flow rate and temperature
for each SUTRA time step over the lifetime of the simulation. It then stores all these values in the appropriate arrays
in the reservoir class. It also creates plots of the SUTRA output data.
"""
def __init__(self, model: Model):
"""
The __init__ function is called automatically when a class is instantiated.
It initializes the attributes of an object, and sets default values for certain arguments that can be overridden
by user input.
:param self: Store data that will be used by the class
Set up all the Parameters that will be predefined by this class using the different types of parameter classes.
Setting up includes giving it a name, a default value, The Unit Type (length, volume, temperature, etc.) and
Unit Name of that value, sets it as required (or not), sets allowable range, the error message if that range
is exceeded, the ToolTip Text, and the name of teh class that created it.
This includes setting up temporary variables that will be available to all the class but noy read in by user,
or used for Output
This also includes all Parameters that are calculated and then published using the Printouts function.
If you choose to subclass this master class, you can do so before or after you create your own parameters.
If you do, you can also choose to call this method from you class, which will effectively add and set all
these parameters to your 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().__init__(model) # initialize the parent parameters and variables
sclass = str(__class__).replace("<class \'", "")
self.MyClass = sclass.replace("\'>","")

# Set up all the Parameters that will be predefined by this class using the different types of parameter classes.
# Setting up includes giving it a name, a default value, The Unit Type (length, volume, temperature, etc.) and
# Unit Name of that value, sets it as required (or not), sets allowable range, the error message if that range
# is exceeded, the ToolTip Text, and the name of teh class that created it.
# This includes setting up temporary variables that will be available to all the class but noy read in by user,
# or used for Output
# This also includes all Parameters that are calculated and then published using the Printouts function.
# If you choose to subclass this master class, you can do so before or after you create your own parameters.
# If you do, you can also choose to call this method from you class, which will effectively add and set all
# these parameters to your class.
# specific to this class:

self.sutraannualheatfilename = self.ParameterDict[self.sutraannualheatfilename.Name] = strParameter(
"SUTRA Annual Heat File Name",
value='annual_heat.csv',
Expand Down Expand Up @@ -152,25 +154,30 @@ def read_parameters(self, model:Model) -> None:
"""
The read_parameters function reads in the parameters from a dictionary created by reading the user-provided file
and updates the parameter values for this object.
The function reads in all the parameters that relate to this object, including those that are inherited from
other objects. It then updates any of these parameter values that have been changed by the user.
It also handles any special cases.
:param self: Reference the class instance (such as it is) from within the 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 parameters for the parent.
# if we call super, we don't need to deal with setting the parameters here, just deal with the special cases
# for the variables in this class
# because the call to the super.readparameters will set all the variables, including the ones that are specific
# to this class
super().read_parameters(model) # read the parameters for the parent.

model.logger.info("Complete " + str(__class__) + ": " + sys._getframe().f_code.co_name)

def Calculate(self, model: Model):
"""
The Calculate function reads in the SUTRA output files and stores the data in the appropriate reservoir arrays.
It also creates plots of the SUTRA output data. It then calls the Calculate function of the parent 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
"""
model.logger.info("Init " + str(__class__) + ": " + sys._getframe().f_code.co_name)
super().Calculate(model) # run calculations for the parent.

Expand Down
Loading

0 comments on commit eb48f64

Please sign in to comment.