Skip to content

Commit c8136a2

Browse files
committed
raise NotImplementedError in SBTReservoir::Calculate_Coaxial (issue 373)
1 parent 139bfd2 commit c8136a2

File tree

2 files changed

+85
-41
lines changed

2 files changed

+85
-41
lines changed

src/geophires_x/SBTReservoir.py

Lines changed: 73 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ def Calculate_Coaxial(self, model):
380380
"""
381381
model.logger.info(f'Init {str(__class__)}: {sys._getframe().f_code.co_name}')
382382

383+
raise NotImplementedError('SBT with coaxial configuration is not implemented at this time.')
384+
383385
# Clear all equivalent: Initialize variables and import necessary libraries
384386

385387
# SBT v2 for co-axial heat exchanger with high-temperature capability
@@ -649,8 +651,8 @@ def Calculate_Coaxial(self, model):
649651
# MIR N = len(x) - 1
650652
N = len(x) - 1
651653
Nboiler = len(boilerelements)
652-
# MIR Nreg = N - Nboiler
653-
Nreg = 1 + N - Nboiler
654+
Nreg = N - Nboiler
655+
#Nreg = 1 + N - Nboiler
654656
self.krock.value_vector = np.full(N, self.krock.value)
655657
k_m_vector = np.zeros(N)
656658
k_m_vector[Nreg:] = k_m_boiler
@@ -667,24 +669,26 @@ def Calculate_Coaxial(self, model):
667669
SoverLSorted = SMatrixSorted / (np.ones((N, 1)) * Deltaz)
668670
mindexNPCP = np.argmax(np.min(SoverLSorted, axis=1) < LimitSoverL)
669671

670-
# MIR midpointsx = 0.5 * x[1:] + 0.5 * x[:-1]
671-
# MIR midpointsy = 0.5 * y[1:] + 0.5 * y[:-1]
672-
# MIR midpointsz = 0.5 * z[1:] + 0.5 * z[:-1]
673-
midpointsx = 0.5 * x + 0.5 * x
674-
midpointsy = 0.5 * y + 0.5 * y
675-
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
676678
verticalchange = np.diff(z)
677679
# MIR
678-
verticalchange = np.append(verticalchange, verticalchange[-1])
680+
#verticalchange = np.append(verticalchange, verticalchange[-1])
679681

680682
if initialtemperatureprofile == 0:
681683
BBinitial = Tsurf - GeoGradient * midpointsz
682684
Tfluidupnodes = Tsurf - GeoGradient * z
683685
Tfluiddownnodes = Tsurf - GeoGradient * z
684686
elif initialtemperatureprofile == 1:
685687
BBinitial = np.interp(midpointsz, initialtemperaturedata[:, 0], initialtemperaturedata[:, 1])
686-
Tfluidupnodes = np.interp(z, initialtemperaturedata[:, 0], initialtemperaturedata[:, 1])
687-
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])
688692

689693
# MIR Tfluiddownmidpoints = 0.5 * Tfluiddownnodes[1:] + 0.5 * Tfluiddownnodes[:-1]
690694
# MIR Tfluidupmidpoints = 0.5 * Tfluidupnodes[1:] + 0.5 * Tfluidupnodes[:-1]
@@ -811,26 +815,38 @@ def Calculate_Coaxial(self, model):
811815
self.Tresoutput.value[0] = Tsurf
812816
Poutput[0] = Pin * 1e5
813817

814-
Tfluidupnodesstore = np.zeros((N + 1, len(times)))
815-
Tfluiddownnodesstore = np.zeros((N + 1, len(times)))
816-
# MIR Tfluidupmidpointsstore = np.zeros((N, len(times)))
817-
Tfluidupmidpointsstore = np.zeros((N + 1, len(times)))
818-
# MIR Tfluiddownmidpointsstore = np.zeros((N, len(times)))
819-
Tfluiddownmidpointsstore = np.zeros((N + 1, len(times)))
820-
Pfluidupnodesstore = np.zeros((N + 1, len(times)))
821-
Pfluiddownnodesstore = np.zeros((N + 1, len(times)))
822-
# MIR Pfluidupmidpointsstore = np.zeros((N, len(times)))
823-
# MIR Pfluiddownmidpointsstore = np.zeros((N, len(times)))
824-
Pfluidupmidpointsstore = np.zeros((N + 1, len(times)))
825-
Pfluiddownmidpointsstore = np.zeros((N + 1, len(times)))
826-
Qfluidupnodesstore = np.zeros((N + 1, len(times)))
827-
Qfluiddownnodesstore = np.zeros((N + 1, len(times)))
828-
Phasefluidupnodesstore = np.zeros((N + 1, len(times)))
829-
Phasefluiddownnodesstore = np.zeros((N + 1, len(times)))
830-
Hfluidupnodesstore = np.zeros((N + 1, len(times)))
831-
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)))
832846
Qinterexchangestore = np.zeros((N, len(times)))
833847
QinterexchangeUp = np.zeros(N)
848+
velocityfluiddownmidpointsstore = np.zeros((N, len(times)))
849+
heatcapacityfluidupmidpointsstore = np.zeros((N, len(times)))
834850

835851
# Store initial values
836852
Tfluidupnodesstore[:, 0] = Tfluidupnodes
@@ -846,6 +862,8 @@ def Calculate_Coaxial(self, model):
846862
Phasefluidupnodesstore[:, 0] = Phasefluidupnodes
847863
Phasefluiddownnodesstore[:, 0] = Phasefluiddownnodes
848864
Qinterexchangestore[:, 0] = np.zeros(N)
865+
velocityfluiddownmidpointsstore[:, 0] = velocityfluiddownmidpoints
866+
heatcapacityfluidupmidpointsstore[:, 0] = heatcapacityfluidupmidpoints
849867

850868
print('Pre-processing completed successfully. Starting simulation ...')
851869

@@ -942,7 +960,8 @@ def Calculate_Coaxial(self, model):
942960
else:
943961
maxindextoconsider = np.where(maxspacingtest > 1)[0][-1]
944962

945-
if mindexNPCP < maxindextoconsider + 1:
963+
#if mindexNPCP < maxindextoconsider + 1:
964+
if mindexNPCP < maxindextoconsider:
946965
indicestocalculate = SortedIndices[:, mindexNPCP + 1:maxindextoconsider + 1]
947966
NPCP[range(N), indicestocalculate] = Deltaz[indicestocalculate] / (
948967
4 * np.pi * k_m_vector[indicestocalculate] * SMatrix[range(N), indicestocalculate]) * erfc(
@@ -1027,40 +1046,53 @@ def Calculate_Coaxial(self, model):
10271046

10281047
Q[:, i] = BB
10291048

1030-
R[0:N] = Vvector * Tfluiddownmidpointsstore[:, i - 1] / Deltat
1031-
R[0:N] += Q[:, i]
1032-
R[N:2 * N] = Vvector * Tfluidupmidpointsstore[:, i - 1] / Deltat
1033-
R[N:2 * N] += Q[:, i]
1034-
1035-
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[:,
10361063
i - 1] + velocityfluiddownmidpointsstore[:,
10371064
i - 1] * Pfluiddownmidpointsstore[:,
10381065
i - 1] * Deltat
10391066

1040-
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]
10411069

10421070
try:
10431071
solutions = np.linalg.solve(L, R)
10441072
except np.linalg.LinAlgError:
10451073
print(f'Simulation terminated prematurely due to linear algebra error at time step {i}.')
10461074
break
10471075

1048-
BB = solutions[0:N]
1076+
#BB = solutions[0:N]
1077+
BB = solutions[0:N, 0]
10491078
Tfluidupmidpointsstore[:, i] = BB
10501079
Tfluidupmidpoints = BB
10511080
Tfluidupmidpoints = Tfluidupmidpoints
10521081

1053-
BB = solutions[N:2 * N]
1082+
#BB = solutions[N:2 * N]
1083+
BB = solutions[N:2 * N, 0]
10541084
Tfluiddownmidpointsstore[:, i] = BB
10551085
Tfluiddownmidpoints = BB
10561086
Tfluiddownmidpoints = Tfluiddownmidpoints
10571087

1058-
BB = solutions[2 * N:3 * N]
1088+
#BB = solutions[2 * N:3 * N]
1089+
BB = solutions[2 * N:3 * N, 0]
10591090
Pfluidupmidpointsstore[:, i] = BB
10601091
Pfluidupmidpoints = BB
10611092
Pfluidupmidpoints = Pfluidupmidpoints
10621093

1063-
BB = solutions[3 * N:4 * N]
1094+
#BB = solutions[3 * N:4 * N]
1095+
BB = solutions[3 * N:4 * N, 0]
10641096
Pfluiddownmidpointsstore[:, i] = BB
10651097
Pfluiddownmidpoints = BB
10661098
Pfluiddownmidpoints = Pfluiddownmidpoints

tests/test_geophires_x.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,15 @@ def test_negative_electricity_production_raises_error(self):
900900
)
901901
client.get_geophires_result(params)
902902
self.assertIn('Electricity production calculated as negative', str(e.exception))
903+
904+
def test_sbt_coaxial_raises_error(self):
905+
client = GeophiresXClient()
906+
with self.assertRaises(RuntimeError) as e:
907+
params = GeophiresInputParameters(
908+
{
909+
'Reservoir Model': 8,
910+
'Well Geometry Configuration': 2,
911+
}
912+
)
913+
client.get_geophires_result(params)
914+
self.assertIn('SBT with coaxial configuration is not implemented', str(e.exception))

0 commit comments

Comments
 (0)