<jupyter_start><jupyter_text>validate the obstacle center temperature<jupyter_code>center_T_ref=[4.248,6.193,7.132,7.715,7.571]
center_T_ref=[T/100 for T in center_T_ref]
center_T_ref
Tfin=300
q=100
ladalf=2
H=0.02

with open(f"{probe_folder}/T","r") as fp:
    lines = fp.readlines()
    data=lines[-1]
center_T_dbs=data.strip("\n").split()
center_T_dbs.pop(0)
center_T_dbs=[(float(T)-Tfin)/(q*H/ladalf) for T in center_T_dbs]
center_T_dbs
relative_error_center_T=0
for i in np.arange(0,5):
    error=(center_T_dbs[i]-center_T_ref[i])/center_T_ref[i]
    relative_error_center_T+=pow(error,2)
relative_error_center_T=math.sqrt(relative_error_center_T)/len(center_T_dbs)
print(f"relative_error_center_T: {relative_error_center_T*100}%")
indexs=np.arange(1,6)
fig, ax = plot.subplots( aspect=(4, 3), axwidth=4)
ax.scatter(indexs,center_T_ref, c='none',marker='o', edgecolors='b',label="Benchmark" )
ax.scatter(indexs,center_T_dbs, c='none',marker='^', edgecolors='r',label="Micro-continuum model" )
ax.set_xticks(indexs)
ax.set_ylim([0.04,0.08])
ax.set_xlabel("Obstacle Index")
ax.set_ylabel("Normalized Temperature")
# ax.set_title("Obstacle centered Temperature Validations")
ax.text(1.1,0.07,"Relative error: {:.3f}%".format(relative_error_center_T*100))
ax.legend(loc="ul", ncol=1, fancybox=True)
fig.savefig("Obstacle centered Temperature Validations.jpg",bbox_inches='tight',dpi=600)<jupyter_output><empty_output><jupyter_text>validate  surface temperature of obstacles (Index1 & Index2)<jupyter_code>w=0.005
L=4*w
def read_obstacle_surface_temperature(obstacle_index):
    df_obstacle=pd.DataFrame({"distance":[],"T":[]})
    for i in np.arange(1,4):
        df=pd.read_csv(f"{sampling_folder}/obstacle{str(obstacle_index)}_{str(i)}_T.csv")
        df["distance"]=(df["distance"]+(i-1)*w)/L
        df["T"]=(df["T"]-Tfin)/(q*H/ladalf)
        df_obstacle=df_obstacle.append(df)
    df_obstacle.reset_index(drop=True) 
    return df_obstacle
df_obstacle_1=read_obstacle_surface_temperature(1)
df_obstacle_2=read_obstacle_surface_temperature(2)

def read_benchmark_data(obstacle_index,prefix):
    with open(f"{lb_folder}/{prefix}{obstacle_index}-paper.txt","r") as fp:
        lines=fp.readlines()
    distances=[]
    results=[]
    for line in lines:
        data=line.split()
        distances.append(float(data[0]))
        results.append(float(data[1]))
    df=pd.DataFrame({"distance":distances,prefix:results})
    return df
df_obstacle_benmark_1=read_benchmark_data(1,"T")
df_obstacle_benmark_2=read_benchmark_data(2,"T")
interp_f1=interpolate.interp1d(df_obstacle_1["distance"],df_obstacle_1["T"],kind="linear")
df_obstacle_dbs_1_interpolated=interp_f1(df_obstacle_benmark_1["distance"])

relative_error_surface_temperature1=0.0
for i in df_obstacle_benmark_1.index:
    benmark=df_obstacle_benmark_1["T"][i]
    dbs=df_obstacle_dbs_1_interpolated[i]
    error=(dbs-benmark)/benmark   
    relative_error_surface_temperature1+=pow(error,2)

relative_error_surface_temperature1=math.sqrt(relative_error_surface_temperature1)/df_obstacle_benmark_1.index.size
print(f"relative_error_surface_temperature1: {relative_error_surface_temperature1*100}%")

interp_f2=interpolate.interp1d(df_obstacle_2["distance"],df_obstacle_2["T"],kind="linear")
df_obstacle_dbs_2_interpolated=interp_f2(df_obstacle_benmark_2["distance"])
relative_error_surface_temperature2=0.0
for i in df_obstacle_benmark_2.index:
    benmark=df_obstacle_benmark_2["T"][i]
    dbs=df_obstacle_dbs_2_interpolated[i]
    error=(dbs-benmark)/benmark   
    relative_error_surface_temperature2+=pow(error,2)

relative_error_surface_temperature2=math.sqrt(relative_error_surface_temperature2)/df_obstacle_benmark_2.index.size
print(f"relative_error_surface_temperature2: {relative_error_surface_temperature2*100}%")

fig, ax = plt.subplots()
ax.plot(df_obstacle_benmark_2["distance"],df_obstacle_benmark_2["T"],color='b',label="Benchmark: obstacle1")
ax.plot(df_obstacle_benmark_1["distance"],df_obstacle_benmark_1["T"],color='b',linestyle="--",label="Benchmark: obstacle2")

samplingRate=3
df_obstacle_2_sampling=df_obstacle_2[df_obstacle_2.index%samplingRate==0]
df_obstacle_2_sampling=df_obstacle_2_sampling[df_obstacle_2_sampling["T"]>df_obstacle_2_sampling["T"].min()]
df_obstacle_1_sampling=df_obstacle_1[df_obstacle_1.index%samplingRate==0]
df_obstacle_1_sampling=df_obstacle_1_sampling[df_obstacle_1_sampling["T"]>df_obstacle_1_sampling["T"].min()]

ax.scatter(df_obstacle_2_sampling["distance"],df_obstacle_2_sampling["T"],color='r',marker="o",label="Micro-continuum : obstacle1")
ax.scatter(df_obstacle_1_sampling["distance"],df_obstacle_1_sampling["T"],color='',marker="o",edgecolors='r',label="Micro-continuum : obstacle2")
ax.set_ylim([0,0.08])
ax.legend(loc="lower right",fancybox=True)
ax.set_xlabel("Peripheral Distance")
ax.set_ylabel("Normalized Temperature")
ax.text(0.08,0.015,"Relative error of obstacle 1: {:.3f}%".format(relative_error_surface_temperature1*100))
ax.text(0.08,0.01,"Relative error of obstacle 2: {:.3f}%".format(relative_error_surface_temperature2*100))
# ax.set_title("Obstacle Surface Temperature Validation")
fig.savefig("Obstacle Surface Temperature Validation.jpg",bbox_inches='tight',dpi=600)<jupyter_output><ipython-input-86-877be2c6c19e>:12: MatplotlibDeprecationWarning: Using a string of single character colors as a color sequence is deprecated since 3.2 and will be removed two minor releases later. Use an explicit list instead.
  ax.scatter(df_obstacle_1_sampling["distance"],df_obstacle_1_sampling["T"],color='',marker="o",edgecolors='r',label="Micro-continuum : obstacle2")<jupyter_text>validate  surface Nu of obstacles (Index1 & Index2)<jupyter_code>def read_obstacle_surface_temperature_cell(obstacle_index,suffix):
    df_obstacle=pd.DataFrame({"distance":[],"T":[]})
    for i in np.arange(1,4):
        df=pd.read_csv(f"{sampling_folder}/obstacle{str(obstacle_index)}_{str(i)}_{suffix}.csv")
        df=df.rename( columns = {'y':'distance','x':'distance'})
        df["distance"]=(df["distance"]+(i-1)*w)/L
        df["T"]=(df["T"]-Tfin)/(q*H/ladalf)
        df_obstacle=df_obstacle.append(df)
    df_obstacle=df_obstacle.reset_index(drop=True) 
    return df_obstacle

def calculate_Nu(obstacle_index,deltax_2):
    df_cell_adj=read_obstacle_surface_temperature_cell(obstacle_index,"cell_adj_T")
    df_cell=read_obstacle_surface_temperature_cell(obstacle_index,"cell_T")
    df_nu_cell=df_cell
    df_nu_cell["nu"]=((df_cell["T"]-df_cell_adj["T"])/deltax_2)/df_cell["T"]

    return df_nu_cell


D=2*H #characteristic length
mesh_num=50
deltax_2=w/mesh_num/2/D
df_nu_obstacle1=calculate_Nu(1,deltax_2)
df_nu_obstacle2=calculate_Nu(2,deltax_2)
df_nu_obstacle2.tail()
df_obstacle_benmark_Nu_1=read_benchmark_data(1,"Nu")
df_obstacle_benmark_Nu_2=read_benchmark_data(2,"Nu")
interp_Nu_f1=interpolate.interp1d(df_nu_obstacle1["distance"],df_nu_obstacle1["nu"],kind="linear")
df_nu_obstacle_dbs_1_interpolated=interp_Nu_f1(df_obstacle_benmark_Nu_1["distance"])

relative_error_Nu1=0.0
for i in df_obstacle_benmark_Nu_1.index:
    benmark=df_obstacle_benmark_Nu_1["Nu"][i]
    dbs=df_nu_obstacle_dbs_1_interpolated[i]
    error=(dbs-benmark)/benmark   
    relative_error_Nu1+=pow(error,2)

relative_error_Nu1=math.sqrt(relative_error_Nu1)/df_obstacle_benmark_Nu_1.index.size
print(f"relative_error_Nu1: {relative_error_Nu1*100}%")

interp_Nu_f2=interpolate.interp1d(df_nu_obstacle2["distance"],df_nu_obstacle2["nu"],kind="linear")
df_nu_obstacle_dbs_2_interpolated=interp_Nu_f2(df_obstacle_benmark_Nu_2["distance"])

relative_error_Nu2=0.0
for i in df_obstacle_benmark_Nu_2.index:
    benmark=df_obstacle_benmark_Nu_2["Nu"][i]
    dbs=df_nu_obstacle_dbs_2_interpolated[i]
    error=(dbs-benmark)/benmark   
    relative_error_Nu2+=pow(error,2)

relative_error_Nu2=math.sqrt(relative_error_Nu2)/df_obstacle_benmark_Nu_2.index.size
print(f"relative_error_Nu2: {relative_error_Nu2*100}%")

fig, ax = plt.subplots()
ax.plot(df_nu_obstacle1["distance"],df_nu_obstacle1["nu"],)
ax.scatter(df_obstacle_benmark_Nu_1["distance"],df_obstacle_benmark_Nu_1["Nu"])

ax.plot(df_nu_obstacle1["distance"],df_nu_obstacle1["nu"],label="DBS: obstacle1")
ax.plot(df_nu_obstacle2["distance"],df_nu_obstacle2["nu"],label="DBS: obstacle2")
ax.scatter(df_obstacle_benmark_Nu_1["distance"],df_obstacle_benmark_Nu_1["Nu"],label="Benchmark: obstacle1")
ax.scatter(df_obstacle_benmark_Nu_2["distance"],df_obstacle_benmark_Nu_2["Nu"],label="Benchmark: obstacle2")
ax.set_ylim([0,50])
ax.set_xlim([-0.02,0.5])
ax.legend()
ax.set_xlabel("Peripheral Distance")
ax.set_ylabel("Local Nusselt Number")
ax.text(0.0,40,"relative error of obstacle 1: {:.3f}%".format(relative_error_Nu1*100))
ax.text(0.0,36,"relative error of obstacle 2: {:.3f}%".format(relative_error_Nu2*100))
ax.set_title("Obstacle Nusselt Number Validation")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14757062146892655, 'fraction_numerical': 0.03638418079096045, 'mean_word_length': 9.807081807081808, 'pattern_counts': {'":': 5, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '46866', 'license': 'Apache-2.0', 'n_tokens_mistral': 3818, 'n_tokens_neox': 3584, 'n_words': 325, 'path': 'applications/test/dbsConjugateHeatTransfer/conjugateHeatTransfer/validateWithLB/validateWithLB.ipynb', 'repo_name': 'anoldfriend0718/openfoam', 'size': '8850'}