Commit b63cfd4c authored by Jakob Randow's avatar Jakob Randow Committed by HBShaoUFZ
Browse files

test case for server communication


keep false in test input file. 


Update Tests

Update Tests

Update Tests and delete ogs.exe
parent a1cc159a
......@@ -99,6 +99,38 @@ if("${Python3_VERSION}" VERSION_LESS 3.9)
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE2 temperature_BHE2 1e-10 1e-13
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE3 temperature_BHE3 1e-10 1e-13
)
AddTest(
NAME HeatTransportBHE_1U_3D_beier_sandbox_server_communication
PATH Parabolic/T/3D_Beier_sandbox_SimX
EXECUTABLE ogs
EXECUTABLE_ARGS beier_sandbox.prj
WRAPPER time
TESTER vtkdiff
REQUIREMENTS OGS_USE_PYTHON AND NOT OGS_USE_MPI
RUNTIME 50
PYTHON_PACKAGES "pandas"
DIFF_DATA
beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 0 5e-15
beier_sandbox_ts_10_t_600.000000.vtu beier_sandbox_ts_10_t_600.000000.vtu temperature_soil temperature_soil 0 1e-13
)
AddTest(
NAME HeatTransportBHE_3D_3BHEs_array_server_communication
PATH Parabolic/T/3D_3BHEs_array_SimX
RUNTIME 50
EXECUTABLE ogs
EXECUTABLE_ARGS 3bhes_1U.prj
WRAPPER time
TESTER vtkdiff
REQUIREMENTS OGS_USE_PYTHON AND NOT OGS_USE_MPI
PYTHON_PACKAGES "TESPy=0.3.2"
DIFF_DATA
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_soil temperature_soil 1e-12 1e-13
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE1 temperature_BHE1 1e-9 1e-12
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE2 temperature_BHE2 1e-9 1e-12
3bhes_1U_ts_10_t_600.000000.vtu 3bhes_1U_ts_10_t_600.000000.vtu temperature_BHE3 temperature_BHE3 1e-9 1e-12
)
endif()
AddTest(
......
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="OpenGeoSysGLI.xsl"?>
<OpenGeoSysGLI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.opengeosys.org/images/xsd/OpenGeoSysGLI.xsd" xmlns:ogs="http://www.opengeosys.org">
<name>3bhes_1U</name>
<points>
<point id="0" x="-25.0" y="0.0" z="0.0" name="TOP_left_down"/>
<point id="1" x="-25.0" y="50.0" z="0.0" name="TOP_left_upper"/>
<point id="2" x="25.0" y="50.0" z="0.0" name="TOP_right_upper"/>
<point id="3" x="25.0" y="0.0" z="0.0" name="TOP_right_down"/>
<point id="4" x="-25.0" y="0.0" z="-72.0" name="bottom_left_down"/>
<point id="5" x="-25.0" y="50.0" z="-72.0" name="bottom_left_upper"/>
<point id="6" x="25.0" y="50.0" z="-72.0" name="bottom_right_uppert"/>
<point id="7" x="25.0" y="0.0" z="-72.0" name="bottom_right_down"/>
<point id="8" x="0.0" y="25.0" z="-52.0" name="BHE1_BOTTOM"/>
<point id="9" x="0.0" y="25.0" z="-2.0" name="BHE1_TOP"/>
<point id="10" x="-6.0" y="25.0" z="-52.0" name="BHE2_BOTTOM"/>
<point id="11" x="-6.0" y="25.0" z="-2.0" name="BHE2_TOP"/>
<point id="12" x="0.0" y="25.0" z="-52.0" name="BHE3_BOTTOM"/>
<point id="13" x="0.0" y="25.0" z="-2.0" name="BHE3_TOP"/>
</points>
<polylines>
<polyline id="0" name="BHE_1">
<pnt>9</pnt>
<pnt>8</pnt>
</polyline>
<polyline id="1" name="BHE_2">
<pnt>11</pnt>
<pnt>10</pnt>
</polyline>
<polyline id="2" name="BHE_3">
<pnt>13</pnt>
<pnt>12</pnt>
</polyline>
</polylines>
<surfaces>
<surface id="0" name="top">
<element p1="0" p2="1" p3="2"/>
<element p1="0" p2="3" p3="2"/>
</surface>
</surfaces>
</OpenGeoSysGLI>
<?xml version="1.0" encoding="ISO-8859-1"?>
<OpenGeoSysProject>
<mesh>3bhes_1U.vtu</mesh>
<geometry>3bhes_1U.gml</geometry>
<python_script>bcs_tespy_and_serverCommunication.py</python_script>
<processes>
<process>
<name>HeatTransportBHE</name>
<type>HEAT_TRANSPORT_BHE</type>
<integration_order>2</integration_order>
<process_variables>
<process_variable>temperature_soil</process_variable>
<process_variable>temperature_BHE1</process_variable>
<process_variable>temperature_BHE2</process_variable>
<process_variable>temperature_BHE3</process_variable>
</process_variables>
<use_server_communication>true</use_server_communication>
<borehole_heat_exchangers>
<borehole_heat_exchanger>
<type>1U</type>
<use_bhe_pipe_network>true</use_bhe_pipe_network>
<flow_and_temperature_control>
<type>TemperatureCurveConstantFlow</type>
<flow_rate>2.0e-4</flow_rate>
<temperature_curve>inflow_temperature</temperature_curve>
</flow_and_temperature_control>
<borehole>
<length>50.0</length>
<diameter>0.126</diameter>
</borehole>
<grout>
<density>2190.0</density>
<porosity>0.0</porosity>
<specific_heat_capacity>1735.160</specific_heat_capacity>
<thermal_conductivity>0.806</thermal_conductivity>
</grout>
<pipes>
<inlet>
<diameter> 0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</inlet>
<outlet>
<diameter>0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</outlet>
<distance_between_pipes>0.053</distance_between_pipes>
<longitudinal_dispersion_length>0.001</longitudinal_dispersion_length>
</pipes>
<refrigerant>
<density>992.92</density>
<viscosity>0.00067418</viscosity>
<specific_heat_capacity>4198</specific_heat_capacity>
<thermal_conductivity>0.62863</thermal_conductivity>
<reference_temperature>298.15</reference_temperature>
</refrigerant>
</borehole_heat_exchanger>
<borehole_heat_exchanger>
<type>1U</type>
<use_bhe_pipe_network>true</use_bhe_pipe_network>
<flow_and_temperature_control>
<type>TemperatureCurveConstantFlow</type>
<flow_rate>2.0e-4</flow_rate>
<temperature_curve>inflow_temperature</temperature_curve>
</flow_and_temperature_control>
<borehole>
<length>50.0</length>
<diameter>0.126</diameter>
</borehole>
<grout>
<density>2190.0</density>
<porosity>0.0</porosity>
<specific_heat_capacity>1735.160</specific_heat_capacity>
<thermal_conductivity>0.806</thermal_conductivity>
</grout>
<pipes>
<inlet>
<diameter> 0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</inlet>
<outlet>
<diameter>0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</outlet>
<distance_between_pipes>0.053</distance_between_pipes>
<longitudinal_dispersion_length>0.001</longitudinal_dispersion_length>
</pipes>
<refrigerant>
<density>992.92</density>
<viscosity>0.00067418</viscosity>
<specific_heat_capacity>4198</specific_heat_capacity>
<thermal_conductivity>0.62863</thermal_conductivity>
<reference_temperature>298.15</reference_temperature>
</refrigerant>
</borehole_heat_exchanger>
<borehole_heat_exchanger>
<type>1U</type>
<use_bhe_pipe_network>true</use_bhe_pipe_network>
<flow_and_temperature_control>
<type>TemperatureCurveConstantFlow</type>
<flow_rate>2.0e-4</flow_rate>
<temperature_curve>inflow_temperature</temperature_curve>
</flow_and_temperature_control>
<borehole>
<length>50.0</length>
<diameter>0.126</diameter>
</borehole>
<grout>
<density>2190.0</density>
<porosity>0.0</porosity>
<specific_heat_capacity>1735.160</specific_heat_capacity>
<thermal_conductivity>0.806</thermal_conductivity>
</grout>
<pipes>
<inlet>
<diameter> 0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</inlet>
<outlet>
<diameter>0.013665</diameter>
<wall_thickness>0.003035</wall_thickness>
<wall_thermal_conductivity>0.39</wall_thermal_conductivity>
</outlet>
<distance_between_pipes>0.053</distance_between_pipes>
<longitudinal_dispersion_length>0.001</longitudinal_dispersion_length>
</pipes>
<refrigerant>
<density>992.92</density>
<viscosity>0.00067418</viscosity>
<specific_heat_capacity>4198</specific_heat_capacity>
<thermal_conductivity>0.62863</thermal_conductivity>
<reference_temperature>298.15</reference_temperature>
</refrigerant>
</borehole_heat_exchanger>
</borehole_heat_exchangers>
</process>
</processes>
<media>
<medium id="0">
<phases>
<phase>
<type>AqueousLiquid</type>
<properties>
<property>
<name>phase_velocity</name>
<type>Constant</type>
<value>0 0 0</value>
</property>
<property>
<name>specific_heat_capacity</name>
<type>Constant</type>
<value>4068</value>
</property>
<property>
<name>density</name>
<type>Constant</type>
<value>992.92</value>
</property>
</properties>
</phase>
<phase>
<type>Solid</type>
<properties>
<property>
<name>specific_heat_capacity</name>
<type>Constant</type>
<value>1780</value>
</property>
<property>
<name>density</name>
<type>Constant</type>
<value>1120</value>
</property>
</properties>
</phase>
<phase>
<type>Gas</type>
<properties>
<property>
<name>specific_heat_capacity</name>
<type>Constant</type>
<value>1000</value>
</property>
<property>
<name>density</name>
<type>Constant</type>
<value>2500</value>
</property>
</properties>
</phase>
</phases>
<properties>
<property>
<name>porosity</name>
<type>Constant</type>
<value>0</value>
</property>
<property>
<name>thermal_conductivity</name>
<type>Constant</type>
<value>2.4</value>
</property>
<property>
<name>thermal_longitudinal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
<property>
<name>thermal_transversal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
</properties>
</medium>
</media>
<time_loop>
<processes>
<process ref="HeatTransportBHE">
<nonlinear_solver>basic_picard</nonlinear_solver>
<convergence_criterion>
<type>DeltaX</type>
<norm_type>NORM2</norm_type>
<reltol>1.e-5</reltol>
</convergence_criterion>
<time_discretization>
<type>BackwardEuler</type>
</time_discretization>
<time_stepping>
<type>FixedTimeStepping</type>
<t_initial> 0.0 </t_initial>
<t_end> 600 </t_end>
<!-- use the following for full simulation -->
<!-- <t_end> 15552000 </t_end> -->
<timesteps>
<pair>
<repeat>10</repeat>
<delta_t>60</delta_t>
</pair>
<!-- use the following for full simulation -->
<!-- <pair><repeat>10</repeat><delta_t>60</delta_t></pair> -->
<!-- <pair><repeat>1</repeat><delta_t>3000</delta_t></pair> -->
<!-- <pair><repeat>5</repeat><delta_t>3600</delta_t></pair> -->
<!-- <pair><repeat>1</repeat><delta_t>10800</delta_t></pair> -->
</timesteps>
</time_stepping>
</process>
</processes>
<output>
<type>VTK</type>
<prefix>3bhes_1U</prefix>
<timesteps>
<pair>
<repeat> 10</repeat>
<each_steps> 1 </each_steps>
</pair>
<!-- use the following for full simulation -->
<!-- <pair><repeat> 1</repeat><each_steps> 94 </each_steps></pair> -->
<!-- <pair><repeat> 1</repeat><each_steps> 80 </each_steps></pair> -->
</timesteps>
<variables>
<variable>temperature_soil</variable>
<variable>temperature_BHE1</variable>
<variable>temperature_BHE2</variable>
<variable>temperature_BHE3</variable>
</variables>
<suffix>_ts_{:timestep}_t_{:time}</suffix>
</output>
</time_loop>
<parameters>
<parameter>
<name>T0</name>
<type>Constant</type>
<value>315.15</value>
</parameter>
<parameter>
<name>T0_BHE</name>
<type>Constant</type>
<values>305.36 305.13 305.23 305.115</values>
</parameter>
</parameters>
<process_variables>
<process_variable>
<name>temperature_soil</name>
<components>1</components>
<order>1</order>
<initial_condition>T0</initial_condition>
<boundary_conditions>
<boundary_condition>
<geometrical_set>3bhes_1U</geometrical_set>
<geometry>top</geometry>
<type>Dirichlet</type>
<parameter>T0</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
<process_variable>
<name>temperature_BHE1</name>
<components>4</components>
<order>1</order>
<initial_condition>T0_BHE</initial_condition>
</process_variable>
<process_variable>
<name>temperature_BHE2</name>
<components>4</components>
<order>1</order>
<initial_condition>T0_BHE</initial_condition>
</process_variable>
<process_variable>
<name>temperature_BHE3</name>
<components>4</components>
<order>1</order>
<initial_condition>T0_BHE</initial_condition>
</process_variable>
</process_variables>
<nonlinear_solvers>
<nonlinear_solver>
<name>basic_picard</name>
<type>Picard</type>
<max_iter>100</max_iter>
<linear_solver>general_linear_solver</linear_solver>
</nonlinear_solver>
</nonlinear_solvers>
<linear_solvers>
<linear_solver>
<name>general_linear_solver</name>
<lis>-i cg -p jacobi -tol 1e-16 -maxiter 10000</lis>
<eigen>
<solver_type>BiCGSTAB</solver_type>
<precon_type>ILUT</precon_type>
<max_iteration_step>1000</max_iteration_step>
<error_tolerance>1e-16</error_tolerance>
</eigen>
<petsc>
<prefix>gw</prefix>
<parameters>-gw_ksp_type cg -gw_pc_type bjacobi -gw_ksp_rtol 1e-16 -gw_ksp_max_it 10000</parameters>
</petsc>
</linear_solver>
</linear_solvers>
<curves>
<curve>
<name>inflow_temperature</name>
<coords>0 933120000
</coords>
<values>295.3611111 295.3611111
</values>
</curve>
</curves>
</OpenGeoSysProject>
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
# How to run
You need to install the modules used in the python script and build OGS with `OGS_USE_PYTHON=ON`.
###
# Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
# Distributed under a Modified BSD License.
# See accompanying file LICENSE.txt or
# http://www.opengeosys.org/project/license
###
import sys
print(sys.version)
import os
import numpy as np
from pandas import read_csv
import OpenGeoSys
from tespy.networks import load_network
# User setting ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# parameters
# refrigerant density
rho_f = 992.92 # kg/m3
# switch for special boundary conditions
# switch of the function for manually specified dynamic flowrate
switch_dyn_frate = "off" # 'on','off'
# switch of the function for manually specified dynamic thermal demand
switch_dyn_demand = "on" # 'on','off'
# network status setting
def network_status(t):
nw_status = "on"
# month for closed network
timerange_nw_off_month = [] # No month for closed network
# t-1 to avoid the calculation problem at special time point,
# e.g. t = 2592000.
t_trans = int((t - 1) / 86400 / 30) + 1
t_trans_month = t_trans
if t_trans_month > 12:
t_trans_month = t_trans - 12 * (int(t_trans / 12))
if t_trans_month in timerange_nw_off_month:
nw_status = "off"
return nw_status
# dynamic consumer thermal load
def consumer_demand(t): # dynamic thermal demand from consumer
# time conversion
t_trans = int((t - 1) / 86400 / 30) + 1
if t_trans > 12:
t_trans = t_trans - 12 * (int(t_trans / 12))
# thermal demand in each month (assumed specific heat extraction rate*
# length of BHE* number of BHE)
month_demand = [
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
-25 * 50 * 3,
]
return month_demand[t_trans - 1]
# dynamic hydraulic flow rate at the network inlet
def dyn_frate(t):
# time conversion
t_trans = int((t - 1) / 86400 / 30) + 1
if t_trans > 12:
t_trans = t_trans - 12 * (int(t_trans / 12))
# flow rate in kg / s time curve in month
month_frate = []
return month_frate[t_trans - 1]
# End User setting +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# create network dataframe
def create_dataframe():
# return dataframe
df_nw = read_csv(
"./pre/bhe_network.csv", delimiter=";", index_col=[0], dtype={"data_index": str}
)
return df_nw
# TESPy calculation process
def get_tespy_results(t):
# bhe network boundary conditions re parametrization
# if network exist dynamic flowrate
if switch_dyn_frate == "on":
cur_frate = dyn_frate(t)
localVars["inlet_name"].set_attr(m=cur_frate)
# if network exist dynamic thermal demand
if switch_dyn_demand == "on":
# consumer thermal load:
cur_month_demand = consumer_demand(t)
nw.busses[bus_name].set_attr(P=cur_month_demand)
# T_out re parametrization:
for i in range(n_BHE):
localVars["outlet_BHE" + str(i + 1)].set_attr(
T=df.loc[data_index[i], "Tout_val"]
)
# solving network
nw.solve(mode="design")
# get Tin_val and flow rate
for i in range(n_BHE):
# get Tin_val
df.loc[df.index[i], "Tin_val"] = (
localVars["inlet_BHE" + str(i + 1)].get_attr("T").val
)
# get flowrate
df.loc[df.index[i], "flowrate"] = (
localVars["inlet_BHE" + str(i + 1)].get_attr("m").val / rho_f
)
return df["Tin_val"].tolist(), df["flowrate"].tolist()
# OGS setting
# Dirichlet BCs
class BC(OpenGeoSys.BHENetwork):
def initializeDataContainer(self):
# initialize network and get data from the network
nw.solve(mode="design")
get_tespy_results(0)
# convert dataframe to column list
t = 0 # 'initial time'
data_col_1 = df["Tin_val"].tolist() # 'Tin_val'
data_col_2 = df["Tout_val"].tolist() # 'Tout_val'
data_col_3 = df["Tout_node_id"].astype(int).tolist() # 'Tout_node_id'
data_col_4 = df["flowrate"].tolist() # 'BHE flow rate'
return (t, data_col_1, data_col_2, data_col_3, data_col_4)
def tespySolver(self, t, Tin_val, Tout_val):
# network status:
nw_status = network_status(t)
# if network closed:
if nw_status == "off":
df.loc[:, "flowrate"] = 0