Skip to content

Commit

Permalink
Start of effort to upgrade docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolm-dsider committed Nov 6, 2023
1 parent d3d0aaf commit ce807e8
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 81 deletions.
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,18 @@ nosetests.xml
output/*.html
output/*/index.html

# Sphinx
docs/_build
# Sphinx - ignore all the work I did on Sphinx
docs/*
/geophires_x.rst
/modules.rst
/Useful sites for Sphinx docstrings.txt

# Mypy Cache
.mypy_cache/

#CLGS Simulator files
/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
120 changes: 107 additions & 13 deletions src/geophires_x/AGSWellBores.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# copyright, 2023, Malcolm I Ross
# except for code from Wanju Yuan based on: "Closed-Loop Geothermal Energy Recovery from Deep High Enthalpy Systems"
# ref: Yuan, Wanju, et al. "Closed-loop geothermal energy recovery from deep high enthalpy systems."
# Renewable Energy 177 (2021): 976-991.
# and CLGScode from Koenraad
# ref Beckers, Koenraad, et al. Tabulated Database of Closed-Loop Geothermal Systems Performance for Cloud-Based
# Technical and Economic Modeling of Heat Production and Electricity Generation. No. NREL/CP-5700-84979.
# National Renewable Energy Lab.(NREL), Golden, CO (United States), 2023.
"""
contains code from Wanju Yuan based on: "Closed-Loop Geothermal Energy Recovery from Deep High Enthalpy Systems"
ref: Yuan, Wanju, et al. "Closed-loop geothermal energy recovery from deep high enthalpy systems."
Renewable Energy 177 (2021): 976-991.
and CLGScode from Koenraad
ref Beckers, Koenraad, et al. Tabulated Database of Closed-Loop Geothermal Systems Performance for Cloud-Based
Technical and Economic Modeling of Heat Production and Electricity Generation. No. NREL/CP-5700-84979.
National Renewable Energy Lab.(NREL), Golden, CO (United States), 2023.
:doc-author: Malcolm Ross
"""
import sys
import os
import math
Expand Down Expand Up @@ -107,6 +109,12 @@ def __uncompress(self, file, output_loc, state):
return np.reshape(M_k_full.T, shape)

def interp_outlet_states(self, point):
"""
Interpolate the outlet states for a given point
param: point: tuple of (mdot, L2, L1, grad, D, Tinj, k)
:return: Tout, Pout
:doc-author: Malcolm Ross
"""
points = list(itern.product(
(point[0],),
(point[1],),
Expand All @@ -128,17 +136,42 @@ def interp_outlet_states(self, point):
return Tout, Pout

def interp_kWe_avg(self, point):
"""
Interpolate the average heat extraction rate for a given point
:return: kWe_avg
:doc-author: Malcolm Ross
"""
ivars = self.ivars[:-1]
return self.GWhr * interpn(ivars, self.We, point) / (1000. * self.time[-1] * 86400. * 365.)

def interp_kWt_avg(self, point):
"""
Interpolate the average heat extraction rate for a given point
:return: kWt_avg
:doc-author: Malcolm Ross
"""
ivars = self.ivars[:-1]
return self.GWhr * interpn(ivars, self.Wt, point) / (1000. * self.time[-1] * 86400. * 365.)


# #############################point source/sink solution functions################################

def pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp, t):
"""
point source/sink solution functions
:param self: Reference the class object itself
:param yy: y coordinate of the point source/sink
:param zz: z coordinate of the point source/sink
:param yt: y coordinate of the point source/sink
:param zt: z coordinate of the point source/sink
:param ye: y coordinate of the point source/sink
:param ze: z coordinate of the point source/sink
:param alpha: thermal diffusivity
:param sp: Laplace variable
:param t: time
:return: z
:doc-author: Malcolm Ross
"""
rhorock_cprock_4 = self.rhorock * self.cprock * 4.0
theta_yt_minus_yy = thetaY(yt - yy, ye, alpha, t)
theta_yt_plus_yy = thetaY(yt + yy, ye, alpha, t)
Expand All @@ -154,6 +187,20 @@ def pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp, t):
# #####Chebyshev approximation for numerical Laplace transformation integration from 1e-8 to 1e30###################

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 self: Reference the class object itself
:param yy: y coordinate of the point source/sink
:param zz: z coordinate of the point source/sink
:param yt: y coordinate of the point source/sink
:param zt: z coordinate of the point source/sink
:param ye: y coordinate of the point source/sink
:param ze: z coordinate of the point source/sink
:param alpha: thermal diffusivity
:param sp: Laplace variable
:return: ????
:doc-author: Malcolm Ross
"""
m = 32
t_1 = 1.0e-8
n = int(math.log10(1.0e4 / 1.0e-8) + 1)
Expand All @@ -169,6 +216,14 @@ def chebeve_pointsource(self, yy, zz, yt, zt, ye, ze, alpha, sp) -> float:

# ############################Duhamerl convolution method for closed-loop system######################################
def laplace_solution(self, sp) -> float:
"""
Duhamel convolution method for closed-loop system
:param self: Reference the class object itself
:param sp: Laplace variable
:return: Toutletl
:doc-author: Malcolm Ross
"""

Toutletl = 0.0
ss = 1.0 / sp / chebeve_pointsource(self, self.y_well, self.z_well, self.y_well, self.z_well - 0.078,
self.y_boundary, self.z_boundary, self.alpha_rock, sp)
Expand All @@ -182,6 +237,14 @@ def laplace_solution(self, sp) -> float:

# ###############################Numerical Laplace transformation algorithm#########################
def inverselaplace(self, NL, MM):
"""
Numerical Laplace transformation algorithm
:param self: Reference the class object itself
:param NL: NL
:param MM: MM
:return: Toutlet
:doc-author: Malcolm Ross
"""
V = np.zeros(50)
Gi = np.zeros(50)
H = np.zeros(25)
Expand Down Expand Up @@ -281,6 +344,24 @@ def thetaZ(zt, ze, alpha, t):


def Chebyshev(self, a, b, n, yy, zz, yt, zt, ye, ze, alpha, sp, func):
"""
Chebyshev approximation for numerical Laplace transformation integration from 1e-8 to 1e30
:param self: Reference the class object itself
:param a: a
:param b: b
:param n: n
:param yy: y coordinate of the point source/sink
:param zz: z coordinate of the point source/sink
:param yt: y coordinate of the point source/sink
:param zt: z coordinate of the point source/sink
:param ye: y coordinate of the point source/sink
:param ze: z coordinate of the point source/sink
:param alpha: thermal diffusivity
:param sp: Laplace variable
:param func: function
:return: y * d - dd + 0.5 * cint[0]
:doc-author: Malcolm Ross
"""
bma = 0.5 * (b - a)
bpa = 0.5 * (b + a)
cos_vals = [math.cos(math.pi * (k + 0.5) / n) for k in range(n)]
Expand Down Expand Up @@ -588,7 +669,13 @@ def read_parameters(self, model: Model) -> None:

# code from Koenraad
def calculatedrillinglengths(self, model) -> tuple:
# returns the total length, vertical length, and horizontal lengths, depending on the configuration
"""
returns the total length, vertical length, and horizontal lengths, depending on the configuration
: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: total length, vertical length, and horizontal lengths
:doc-author: Malcolm Ross
"""
if self.Configuration.value == Configuration.ULOOP:
# Total drilling depth of both wells and laterals in U-loop [m]
return ((self.numnonverticalsections.value * self.Nonvertical_length.value) + 2 * model.reserv.InputDepth.value * 1000.0), \
Expand Down Expand Up @@ -687,7 +774,7 @@ def getTandP(self, model: Model) -> None:

def verify(self, model: Model) -> int:
"""
The validate function checks that all values provided are within the range expected by CLGS modeling system.
The verify function checks that all values provided are within the range expected by CLGS 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
Expand Down Expand Up @@ -722,9 +809,16 @@ def verify(self, model: Model) -> int:
# Multilateral code

def CalculateNonverticalPressureDrop(self, model, time_operation: float, time_max: float, al: float):
# ------------------------------------------
# Calculate nonvertical pressure drops - it will vary as the temperature varies
# ------------------------------------------
"""
Calculate nonvertical pressure drops - it will vary as the temperature varies
: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
:param time_operation: time of operation
:param time_max: maximum time of operation
:param al: time step
:return: NonverticalPressureDrop, friction
:doc-author: Koenraad Beckers
"""
friction = 0.0
NonverticalPressureDrop = [0.0] * model.surfaceplant.plantlifetime.value # initialize the array
while time_operation <= time_max:
Expand Down
66 changes: 0 additions & 66 deletions src/geophires_x/CylindricalReservoir.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,6 @@ class CylindricalReservoir(Reservoir):
It inherits from the primary Reservoir model but offers new parameters and calculations.
.. list-table:: Input Parameters
:widths: 25 50 10 10 10 10 25
:header-rows: 1
* - Name
- Description
- Default Value Type
- Default Value
- Min
- Max
- Preferred Units
* - Cylindrical Reservoir Input Depth
- Depth of the inflow end of a cylindrical reservoir.
- float
- 3.0
- 0.1
- 15
- LengthUnit.KILOMETERS
* - Cylindrical Reservoir Output Depth
- Depth of the outflow end of a cylindrical reservoir
- float
- Input Depth
- 0.1
- 15
- LengthUnit.KILOMETERS
* - Reservoir Length
- Length of cylindrical reservoir
- float
- 4.0
- 0.1
- 10.0
- LengthUnit.KILOMETERS
* - Cylindrical Reservoir Radius of Effect
- The radius of effect - the distance into the rock from the center of the cylinder that will be perturbed by at least 1 C
- float
- 30.0
- 0
- 1000.0
- LengthUnit.METERS
* - Cylindrical Reservoir Radius of Effect Factor
- The radius of effect reduction factor accounts for the fact that we cannot extract 100% of the heat in the cylinder.
- float
- 1.0
- 0.0
- 10.0
- PercentUnit.TENTH
.. list-table:: Output Parameters
:widths: 25 20 20
:header-rows: 1
* - Name
- Default Value Type
- Preferred Units
* - Cylindrical Reservoir Surface Area
- float
- METERS2
* - Average Gradient
- float
- dEGC/KM
* - Time Vector
- float array
- YEAR
* - Reservoir Temperature History
- float array
- CELSIUS
:doc-author: Malcolm Ross
Expand Down

0 comments on commit ce807e8

Please sign in to comment.