|
7 | 7 | import numpy as np
|
8 | 8 | from scipy.spatial import cKDTree
|
9 | 9 |
|
10 |
| -from .utils.utils import * |
11 |
| - |
12 | 10 | parent_path = Path(__file__).parent
|
13 | 11 |
|
14 | 12 |
|
| 13 | +class _Utils: |
| 14 | + @staticmethod |
| 15 | + def heatcapacitywater(Twater): |
| 16 | + """Computationally efficient correlation for water specific heat capacity based on the GEOPHIRES. |
| 17 | +
|
| 18 | + Args: |
| 19 | + Twater (Union[ndarray, float]): water temperature in deg C |
| 20 | +
|
| 21 | + Returns: |
| 22 | + Union[ndarray, float]: water specific heat capacity in J/kg-K |
| 23 | + """ |
| 24 | + |
| 25 | + # Based on GEOPHIRES correlations (more stable XSTEAM) |
| 26 | + Twater = (Twater + 273.15) / 1000 |
| 27 | + A = -203.6060 |
| 28 | + B = 1523.290 |
| 29 | + C = -3196.413 |
| 30 | + D = 2474.455 |
| 31 | + E = 3.855326 |
| 32 | + cpwater = (A + B * Twater + C * Twater**2 + D * Twater**3 + E / (Twater**2)) / 18.02 * 1000 |
| 33 | + return cpwater |
| 34 | + |
| 35 | + @staticmethod |
| 36 | + def nonzero(x, thresh=1e-6): |
| 37 | + """Ensure input is nonzero |
| 38 | +
|
| 39 | + Args: |
| 40 | + x (ndarray): input numbers |
| 41 | + thresh (float, optional): threshold below which numbers are set to zero. Defaults to 1E-6. |
| 42 | +
|
| 43 | + Returns: |
| 44 | + ndarray: nonzero version of input array |
| 45 | + """ |
| 46 | + return np.maximum(thresh, x) |
| 47 | + |
| 48 | + |
15 | 49 | class CustomUnpickler(pickle.Unpickler):
|
16 | 50 |
|
17 | 51 | def find_class(self, module, name):
|
@@ -140,9 +174,13 @@ def step(
|
140 | 174 | if m_tes_out > 0:
|
141 | 175 | m_wh_to_turbine = m_turbine - m_tes_out
|
142 | 176 | self.T_mix = (
|
143 |
| - m_wh_to_turbine * heatcapacitywater(T_prd_wh) * T_prd_wh |
144 |
| - + m_tes_out * heatcapacitywater(T_tes_out) * T_tes_out |
145 |
| - ) / (m_wh_to_turbine * heatcapacitywater(T_prd_wh) + m_tes_out * heatcapacitywater(T_tes_out) + 1e-3) |
| 177 | + m_wh_to_turbine * _Utils.heatcapacitywater(T_prd_wh) * T_prd_wh |
| 178 | + + m_tes_out * _Utils.heatcapacitywater(T_tes_out) * T_tes_out |
| 179 | + ) / ( |
| 180 | + m_wh_to_turbine * _Utils.heatcapacitywater(T_prd_wh) |
| 181 | + + m_tes_out * _Utils.heatcapacitywater(T_tes_out) |
| 182 | + + 1e-3 |
| 183 | + ) |
146 | 184 | else:
|
147 | 185 | self.T_mix = T_prd_wh
|
148 | 186 |
|
@@ -553,7 +591,7 @@ def __init__(self, Tres, Tamb, m_prd, num_prd=None, ppc=None, cf=1.0, k=2):
|
553 | 591 | self.T_inj = np.clip(model_output[1], a_min=self.Tamb_design, a_max=self.Tres_design) # deg C
|
554 | 592 |
|
555 | 593 | if self.num_prd is None:
|
556 |
| - m_g = ppc / nonzero(self.power_output_MWh_kg) / 3600 # kg/s |
| 594 | + m_g = ppc / _Utils.nonzero(self.power_output_MWh_kg) / 3600 # kg/s |
557 | 595 | self.num_prd = np.ceil(m_g / m_prd).astype(int)
|
558 | 596 |
|
559 | 597 | def compute_cplant(self, MaxProducedTemperature, min_cost=0):
|
|
0 commit comments