diff --git a/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy.py b/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy.py index fb824f82b09c0adee252cafd53f8f38ffe9eab95..fe2245525081f953812e84291529f61c2262d13b 100644 --- a/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy.py +++ b/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy.py @@ -5,19 +5,19 @@ # http://www.opengeosys.org/project/license ### -import sys - -print(sys.version) import os +import sys import numpy as np +from pandas import read_csv +from tespy.networks import load_network try: import ogs.callbacks as OpenGeoSys except ModuleNotFoundError: import OpenGeoSys -from pandas import read_csv -from tespy.networks import load_network + +print(sys.version) # User setting ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # parameters @@ -148,36 +148,34 @@ class BC(OpenGeoSys.BHENetwork): df.loc[:, "flowrate"] = 0 cur_flowrate = df["flowrate"].tolist() return (True, True, Tout_val, cur_flowrate) - else: - # read Tout_val to dataframe - for i in range(n_BHE): - df.loc[df.index[i], "Tout_val"] = Tout_val[i] - # TESPy solver - cur_Tin_val, cur_flowrate = get_tespy_results(t) - # check norm if network achieves the converge - if_success = False - pre_Tin_val = Tin_val - norm = np.linalg.norm( - abs(np.asarray(pre_Tin_val) - np.asarray(cur_Tin_val)) - ) - if norm < 10e-6: - if_success = True - # return to OGS - return (True, if_success, cur_Tin_val, cur_flowrate) + + # read Tout_val to dataframe + for i in range(n_BHE): + df.loc[df.index[i], "Tout_val"] = Tout_val[i] + # TESPy solver + cur_Tin_val, cur_flowrate = get_tespy_results(t) + # check norm if network achieves the converge + if_success = False + pre_Tin_val = Tin_val + norm = np.linalg.norm(abs(np.asarray(pre_Tin_val) - np.asarray(cur_Tin_val))) + if norm < 10e-6: + if_success = True + # return to OGS + return (True, if_success, cur_Tin_val, cur_flowrate) # main # initialize the tespy model of the bhe network # load path of network model: # loading the TESPy model -if ogs_prj_directory != "": - os.chdir(ogs_prj_directory) +if ogs_prj_directory != "": # noqa: F821 + os.chdir(ogs_prj_directory) # noqa: F821 nw = load_network("./pre/tespy_nw") # set if print the network iteration info nw.set_attr(iterinfo=False) # create bhe dataframe of the network system from bhe_network.csv -df = create_dataframe() +df = create_dataframe() # noqa: PD901 n_BHE = np.size(df.iloc[:, 0]) # create local variables of the components label and connections label in diff --git a/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy_closedloop.py b/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy_closedloop.py index 630700f288adea3b16b1fffd350eb786231229f5..56aa85fa05d36550f029993d2b7dbf8b49c16981 100644 --- a/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy_closedloop.py +++ b/Tests/Data/Parabolic/T/3D_3BHEs_array/bcs_tespy_closedloop.py @@ -6,18 +6,19 @@ ### import sys - -print(sys.version) -import os +from pathlib import Path import numpy as np +from pandas import read_csv +from tespy.networks import load_network try: import ogs.callbacks as OpenGeoSys except ModuleNotFoundError: import OpenGeoSys -from pandas import read_csv -from tespy.networks import load_network + + +print(sys.version) # User setting ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # parameters @@ -151,37 +152,35 @@ class BC(OpenGeoSys.BHENetwork): df.loc[:, "flowrate"] = 0 cur_flowrate = df["flowrate"].tolist() return (True, True, Tout_val, cur_flowrate) - else: - # read Tout_val to dataframe - for i in range(n_BHE): - df.loc[df.index[i], "Tout_val"] = Tout_val[i] - # TESPy solver - cur_Tin_val, cur_flowrate = get_tespy_results(t) - # check norm if network achieves the converge - if_success = False - pre_Tin_val = Tin_val - norm_dx = np.linalg.norm( - abs(np.asarray(pre_Tin_val) - np.asarray(cur_Tin_val)) - ) - norm_x = np.linalg.norm(np.asarray(cur_Tin_val)) - if norm_dx / norm_x < 1e-6: - if_success = True - # return to OGS - return (True, if_success, cur_Tin_val, cur_flowrate) + + # read Tout_val to dataframe + for i in range(n_BHE): + df.loc[df.index[i], "Tout_val"] = Tout_val[i] + # TESPy solver + cur_Tin_val, cur_flowrate = get_tespy_results(t) + # check norm if network achieves the converge + if_success = False + pre_Tin_val = Tin_val + norm_dx = np.linalg.norm(abs(np.asarray(pre_Tin_val) - np.asarray(cur_Tin_val))) + norm_x = np.linalg.norm(np.asarray(cur_Tin_val)) + if norm_dx / norm_x < 1e-6: + if_success = True + # return to OGS + return (True, if_success, cur_Tin_val, cur_flowrate) # main # initialize the tespy model of the bhe network # load path of network model: # loading the TESPy model -project_dir = os.getcwd() +project_dir = Path.cwd() print("Project dir is: ", project_dir) nw = load_network("./pre/tespy_nw_closedloop") # set if print the network iteration info nw.set_attr(iterinfo=False) # create bhe dataframe of the network system from bhe_network.csv -df = create_dataframe() +df = create_dataframe() # noqa: PD901 n_BHE = np.size(df.iloc[:, 0]) # create local variables of the components label and connections label in