5
5
import pandas as pd
6
6
from scipy .special import erf , erfc , jv , yv , exp1
7
7
from scipy .interpolate import interp1d
8
+ from scipy .integrate import trapezoid
8
9
import scipy .io as sio
9
10
import matplotlib .pyplot as plt
10
11
12
+ import CoolProp .CoolProp as CP
13
+
11
14
import geophires_x .Model as Model
12
15
from .CylindricalReservoir import CylindricalReservoir
13
16
from .OptionList import FlowrateModel , InjectionTemperatureModel , Configuration
14
17
from .Parameter import intParameter , floatParameter , OutputParameter , ReadParameter , strParameter , boolParameter
15
18
from .Reservoir import Reservoir
16
19
from .Units import *
17
- import sys
18
20
from functools import lru_cache
19
21
20
22
@@ -378,6 +380,8 @@ def Calculate_Coaxial(self, model):
378
380
"""
379
381
model .logger .info (f'Init { str (__class__ )} : { sys ._getframe ().f_code .co_name } ' )
380
382
383
+ raise NotImplementedError ('SBT with coaxial configuration is not implemented at this time.' )
384
+
381
385
# Clear all equivalent: Initialize variables and import necessary libraries
382
386
383
387
# SBT v2 for co-axial heat exchanger with high-temperature capability
@@ -458,28 +462,30 @@ def Calculate_Coaxial(self, model):
458
462
eps_annulus = Dh_annulus * piperoughness # Relative roughness annulus [-]
459
463
eps_centerpipe = 2 * radiuscenterpipe * piperoughness # Relative roughness inner pipe [-]
460
464
465
+ # These variables are set but never used, and sio.loadmat is causing a "No such file" error.
466
+ # (see https://github.com/NREL/GEOPHIRES-X/issues/373)
461
467
# Variable fluid properties logic
462
- if variablefluidproperties == 0 :
463
- Pvector = [1 , 1e9 ]
464
- Tvector = [1 , 1e4 ]
465
- density = np .full ((2 , 2 ), rho_f )
466
- heatcapacity = np .full ((2 , 2 ), cp_f )
467
- thermalconductivity = np .full ((2 , 2 ), k_f )
468
- viscosity = np .full ((2 , 2 ), mu_f )
469
- thermalexpansion = np .zeros ((2 , 2 ))
470
- else :
471
- print ('Loading fluid properties ...' )
472
- if fluid == 1 :
473
- # Load properties for water from pre-generated CoolProp data
474
- properties = sio .loadmat ('properties_H2O_HT_v3.mat' )
475
- print ('Fluid properties for water loaded successfully' )
476
- elif fluid == 2 :
477
- # Load properties for CO2 from pre-generated CoolProp data
478
- properties = sio .loadmat ('properties_CO2.mat' )
479
- print ('Fluid properties for CO2 loaded successfully' )
480
- else :
481
- print ('No valid fluid selected' )
482
- exit ()
468
+ # if variablefluidproperties == 0:
469
+ # Pvector = [1, 1e9]
470
+ # Tvector = [1, 1e4]
471
+ # density = np.full((2, 2), rho_f)
472
+ # heatcapacity = np.full((2, 2), cp_f)
473
+ # thermalconductivity = np.full((2, 2), k_f)
474
+ # viscosity = np.full((2, 2), mu_f)
475
+ # thermalexpansion = np.zeros((2, 2))
476
+ # else:
477
+ # print('Loading fluid properties ...')
478
+ # if fluid == 1:
479
+ # # Load properties for water from pre-generated CoolProp data
480
+ # properties = sio.loadmat('properties_H2O_HT_v3.mat')
481
+ # print('Fluid properties for water loaded successfully')
482
+ # elif fluid == 2:
483
+ # # Load properties for CO2 from pre-generated CoolProp data
484
+ # properties = sio.loadmat('properties_CO2.mat')
485
+ # print('Fluid properties for CO2 loaded successfully')
486
+ # else:
487
+ # print('No valid fluid selected')
488
+ # exit()
483
489
484
490
# Length of each segment [m]
485
491
Deltaz = np .sqrt (np .diff (x ) ** 2 + np .diff (y ) ** 2 + np .diff (z ) ** 2 )
@@ -645,9 +651,10 @@ def Calculate_Coaxial(self, model):
645
651
# MIR N = len(x) - 1
646
652
N = len (x ) - 1
647
653
Nboiler = len (boilerelements )
648
- # MIR Nreg = N - Nboiler
649
- Nreg = 1 + N - Nboiler
654
+ Nreg = N - Nboiler
655
+ # Nreg = 1 + N - Nboiler
650
656
self .krock .value_vector = np .full (N , self .krock .value )
657
+ k_m_vector = np .zeros (N )
651
658
k_m_vector [Nreg :] = k_m_boiler
652
659
alpha_m_vector = k_m_vector / self .rhorock .value / self .cprock .value
653
660
@@ -662,24 +669,26 @@ def Calculate_Coaxial(self, model):
662
669
SoverLSorted = SMatrixSorted / (np .ones ((N , 1 )) * Deltaz )
663
670
mindexNPCP = np .argmax (np .min (SoverLSorted , axis = 1 ) < LimitSoverL )
664
671
665
- # MIR midpointsx = 0.5 * x[1:] + 0.5 * x[:-1]
666
- # MIR midpointsy = 0.5 * y[1:] + 0.5 * y[:-1]
667
- # MIR midpointsz = 0.5 * z[1:] + 0.5 * z[:-1]
668
- midpointsx = 0.5 * x + 0.5 * x
669
- midpointsy = 0.5 * y + 0.5 * y
670
- midpointsz = 0.5 * z + 0.5 * z
672
+ midpointsx = 0.5 * x [1 :] + 0.5 * x [:- 1 ]
673
+ midpointsy = 0.5 * y [1 :] + 0.5 * y [:- 1 ]
674
+ midpointsz = 0.5 * z [1 :] + 0.5 * z [:- 1 ]
675
+ # midpointsx = 0.5 * x + 0.5 * x
676
+ # midpointsy = 0.5 * y + 0.5 * y
677
+ # midpointsz = 0.5 * z + 0.5 * z
671
678
verticalchange = np .diff (z )
672
679
# MIR
673
- verticalchange = np .append (verticalchange , verticalchange [- 1 ])
680
+ # verticalchange = np.append(verticalchange, verticalchange[-1])
674
681
675
682
if initialtemperatureprofile == 0 :
676
683
BBinitial = Tsurf - GeoGradient * midpointsz
677
684
Tfluidupnodes = Tsurf - GeoGradient * z
678
685
Tfluiddownnodes = Tsurf - GeoGradient * z
679
686
elif initialtemperatureprofile == 1 :
680
687
BBinitial = np .interp (midpointsz , initialtemperaturedata [:, 0 ], initialtemperaturedata [:, 1 ])
681
- Tfluidupnodes = np .interp (z , initialtemperaturedata [:, 0 ], initialtemperaturedata [:, 1 ])
682
- Tfluiddownnodes = np .interp (z , initialtemperaturedata [:, 0 ], initialtemperaturedata [:, 1 ])
688
+ #Tfluidupnodes = np.interp(z, initialtemperaturedata[:, 0], initialtemperaturedata[:, 1])
689
+ #Tfluiddownnodes = np.interp(z, initialtemperaturedata[:, 0], initialtemperaturedata[:, 1])
690
+ Tfluidupnodes = np .interp (z [:- 1 ], initialtemperaturedata [:, 0 ], initialtemperaturedata [:, 1 ])
691
+ Tfluiddownnodes = np .interp (z [:- 1 ], initialtemperaturedata [:, 0 ], initialtemperaturedata [:, 1 ])
683
692
684
693
# MIR Tfluiddownmidpoints = 0.5 * Tfluiddownnodes[1:] + 0.5 * Tfluiddownnodes[:-1]
685
694
# MIR Tfluidupmidpoints = 0.5 * Tfluidupnodes[1:] + 0.5 * Tfluidupnodes[:-1]
@@ -806,26 +815,38 @@ def Calculate_Coaxial(self, model):
806
815
self .Tresoutput .value [0 ] = Tsurf
807
816
Poutput [0 ] = Pin * 1e5
808
817
809
- Tfluidupnodesstore = np .zeros ((N + 1 , len (times )))
810
- Tfluiddownnodesstore = np .zeros ((N + 1 , len (times )))
811
- # MIR Tfluidupmidpointsstore = np.zeros((N, len(times)))
812
- Tfluidupmidpointsstore = np .zeros ((N + 1 , len (times )))
813
- # MIR Tfluiddownmidpointsstore = np.zeros((N, len(times)))
814
- Tfluiddownmidpointsstore = np .zeros ((N + 1 , len (times )))
815
- Pfluidupnodesstore = np .zeros ((N + 1 , len (times )))
816
- Pfluiddownnodesstore = np .zeros ((N + 1 , len (times )))
817
- # MIR Pfluidupmidpointsstore = np.zeros((N, len(times)))
818
- # MIR Pfluiddownmidpointsstore = np.zeros((N, len(times)))
819
- Pfluidupmidpointsstore = np .zeros ((N + 1 , len (times )))
820
- Pfluiddownmidpointsstore = np .zeros ((N + 1 , len (times )))
821
- Qfluidupnodesstore = np .zeros ((N + 1 , len (times )))
822
- Qfluiddownnodesstore = np .zeros ((N + 1 , len (times )))
823
- Phasefluidupnodesstore = np .zeros ((N + 1 , len (times )))
824
- Phasefluiddownnodesstore = np .zeros ((N + 1 , len (times )))
825
- Hfluidupnodesstore = np .zeros ((N + 1 , len (times )))
826
- Hfluiddownnodesstore = np .zeros ((N + 1 , len (times )))
818
+ #Tfluidupnodesstore = np.zeros((N + 1, len(times)))
819
+ #Tfluiddownnodesstore = np.zeros((N + 1, len(times)))
820
+ Tfluidupnodesstore = np .zeros ((N , len (times )))
821
+ Tfluiddownnodesstore = np .zeros ((N , len (times )))
822
+ Tfluidupmidpointsstore = np .zeros ((N , len (times )))
823
+ #Tfluidupmidpointsstore = np.zeros((N + 1, len(times)))
824
+ Tfluiddownmidpointsstore = np .zeros ((N , len (times )))
825
+ #Tfluiddownmidpointsstore = np.zeros((N + 1, len(times)))
826
+ #Pfluidupnodesstore = np.zeros((N + 1, len(times)))
827
+ #Pfluiddownnodesstore = np.zeros((N + 1, len(times)))
828
+ Pfluidupnodesstore = np .zeros ((N , len (times )))
829
+ Pfluiddownnodesstore = np .zeros ((N , len (times )))
830
+ Pfluidupmidpointsstore = np .zeros ((N , len (times )))
831
+ Pfluiddownmidpointsstore = np .zeros ((N , len (times )))
832
+ #Pfluidupmidpointsstore = np.zeros((N + 1, len(times)))
833
+ #Pfluiddownmidpointsstore = np.zeros((N + 1, len(times)))
834
+ #Qfluidupnodesstore = np.zeros((N + 1, len(times)))
835
+ #Qfluiddownnodesstore = np.zeros((N + 1, len(times)))
836
+ #Phasefluidupnodesstore = np.zeros((N + 1, len(times)))
837
+ #Phasefluiddownnodesstore = np.zeros((N + 1, len(times)))
838
+ #Hfluidupnodesstore = np.zeros((N + 1, len(times)))
839
+ #Hfluiddownnodesstore = np.zeros((N + 1, len(times)))
840
+ Qfluidupnodesstore = np .zeros ((N , len (times )))
841
+ Qfluiddownnodesstore = np .zeros ((N , len (times )))
842
+ Phasefluidupnodesstore = np .zeros ((N , len (times )))
843
+ Phasefluiddownnodesstore = np .zeros ((N , len (times )))
844
+ Hfluidupnodesstore = np .zeros ((N , len (times )))
845
+ Hfluiddownnodesstore = np .zeros ((N , len (times )))
827
846
Qinterexchangestore = np .zeros ((N , len (times )))
828
847
QinterexchangeUp = np .zeros (N )
848
+ velocityfluiddownmidpointsstore = np .zeros ((N , len (times )))
849
+ heatcapacityfluidupmidpointsstore = np .zeros ((N , len (times )))
829
850
830
851
# Store initial values
831
852
Tfluidupnodesstore [:, 0 ] = Tfluidupnodes
@@ -841,6 +862,8 @@ def Calculate_Coaxial(self, model):
841
862
Phasefluidupnodesstore [:, 0 ] = Phasefluidupnodes
842
863
Phasefluiddownnodesstore [:, 0 ] = Phasefluiddownnodes
843
864
Qinterexchangestore [:, 0 ] = np .zeros (N )
865
+ velocityfluiddownmidpointsstore [:, 0 ] = velocityfluiddownmidpoints
866
+ heatcapacityfluidupmidpointsstore [:, 0 ] = heatcapacityfluidupmidpoints
844
867
845
868
print ('Pre-processing completed successfully. Starting simulation ...' )
846
869
@@ -937,7 +960,8 @@ def Calculate_Coaxial(self, model):
937
960
else :
938
961
maxindextoconsider = np .where (maxspacingtest > 1 )[0 ][- 1 ]
939
962
940
- if mindexNPCP < maxindextoconsider + 1 :
963
+ #if mindexNPCP < maxindextoconsider + 1:
964
+ if mindexNPCP < maxindextoconsider :
941
965
indicestocalculate = SortedIndices [:, mindexNPCP + 1 :maxindextoconsider + 1 ]
942
966
NPCP [range (N ), indicestocalculate ] = Deltaz [indicestocalculate ] / (
943
967
4 * np .pi * k_m_vector [indicestocalculate ] * SMatrix [range (N ), indicestocalculate ]) * erfc (
@@ -1022,40 +1046,53 @@ def Calculate_Coaxial(self, model):
1022
1046
1023
1047
Q [:, i ] = BB
1024
1048
1025
- R [0 :N ] = Vvector * Tfluiddownmidpointsstore [:, i - 1 ] / Deltat
1026
- R [0 :N ] += Q [:, i ]
1027
- R [N :2 * N ] = Vvector * Tfluidupmidpointsstore [:, i - 1 ] / Deltat
1028
- R [N :2 * N ] += Q [:, i ]
1029
-
1030
- R [2 * N :3 * N ] = Pfluidupmidpointsstore [:, i - 1 ] - Pfluiddownmidpointsstore [:,
1049
+ #R[0:N] = Vvector * Tfluiddownmidpointsstore[:, i - 1] / Deltat
1050
+ #R[0:N] += Q[:, i]
1051
+ #R[N:2 * N] = Vvector * Tfluidupmidpointsstore[:, i - 1] / Deltat
1052
+ #R[N:2 * N] += Q[:, i]
1053
+ R [0 :N , 0 ] = Vvector * Tfluiddownmidpointsstore [:, i - 1 ] / Deltat
1054
+ R [0 :N , 0 ] += Q [:, i ]
1055
+ R [N :2 * N , 0 ] = Vvector * Tfluidupmidpointsstore [:, i - 1 ] / Deltat
1056
+ R [N :2 * N , 0 ] += Q [:, i ]
1057
+
1058
+ #R[2 * N:3 * N] = Pfluidupmidpointsstore[:, i - 1] - Pfluiddownmidpointsstore[:,
1059
+ # i - 1] + velocityfluiddownmidpointsstore[:,
1060
+ # i - 1] * Pfluiddownmidpointsstore[:,
1061
+ # i - 1] * Deltat
1062
+ R [2 * N :3 * N , 0 ] = Pfluidupmidpointsstore [:, i - 1 ] - Pfluiddownmidpointsstore [:,
1031
1063
i - 1 ] + velocityfluiddownmidpointsstore [:,
1032
1064
i - 1 ] * Pfluiddownmidpointsstore [:,
1033
1065
i - 1 ] * Deltat
1034
1066
1035
- R [3 * N :4 * N ] = heatcapacityfluidupmidpointsstore [:, i - 1 ] * Tfluidupmidpointsstore [:, i - 1 ]
1067
+ #R[3 * N:4 * N] = heatcapacityfluidupmidpointsstore[:, i - 1] * Tfluidupmidpointsstore[:, i - 1]
1068
+ R [3 * N :4 * N , 0 ] = heatcapacityfluidupmidpointsstore [:, i - 1 ] * Tfluidupmidpointsstore [:, i - 1 ]
1036
1069
1037
1070
try :
1038
1071
solutions = np .linalg .solve (L , R )
1039
1072
except np .linalg .LinAlgError :
1040
1073
print (f'Simulation terminated prematurely due to linear algebra error at time step { i } .' )
1041
1074
break
1042
1075
1043
- BB = solutions [0 :N ]
1076
+ #BB = solutions[0:N]
1077
+ BB = solutions [0 :N , 0 ]
1044
1078
Tfluidupmidpointsstore [:, i ] = BB
1045
1079
Tfluidupmidpoints = BB
1046
1080
Tfluidupmidpoints = Tfluidupmidpoints
1047
1081
1048
- BB = solutions [N :2 * N ]
1082
+ #BB = solutions[N:2 * N]
1083
+ BB = solutions [N :2 * N , 0 ]
1049
1084
Tfluiddownmidpointsstore [:, i ] = BB
1050
1085
Tfluiddownmidpoints = BB
1051
1086
Tfluiddownmidpoints = Tfluiddownmidpoints
1052
1087
1053
- BB = solutions [2 * N :3 * N ]
1088
+ #BB = solutions[2 * N:3 * N]
1089
+ BB = solutions [2 * N :3 * N , 0 ]
1054
1090
Pfluidupmidpointsstore [:, i ] = BB
1055
1091
Pfluidupmidpoints = BB
1056
1092
Pfluidupmidpoints = Pfluidupmidpoints
1057
1093
1058
- BB = solutions [3 * N :4 * N ]
1094
+ #BB = solutions[3 * N:4 * N]
1095
+ BB = solutions [3 * N :4 * N , 0 ]
1059
1096
Pfluiddownmidpointsstore [:, i ] = BB
1060
1097
Pfluiddownmidpoints = BB
1061
1098
Pfluiddownmidpoints = Pfluiddownmidpoints
0 commit comments