import os from timer import timer # import tecplot as tp # import plt2pandas as p2p import numpy as np import pandas as pd import sys from glob import glob import variable_analysis as fv from triaxial_field import TriField as tf path = "/media/weibo/VID2/BFS_M1.7TS/" pathV = path + "Vortex/" flow = tf() dirs = glob(pathV + '*.h5') xloc = np.arange(0.125, 30.0 + 0.125, 0.125) tp_time = np.arange(900, 1000 + 5.0, 5.0) y = np.linspace(-3.0, 0.0, 151) z = np.linspace(-8.0, 8.0, 161) Xtilt1, Xtilt2, Xstret, Xdilate, Xtorque = np.zeros((5, np.size(xloc), 2)) Ytilt1, Ytilt2, Ystret, Ydilate, Ytorque = np.zeros((5, np.size(xloc), 2)) Ztilt1, Ztilt2, Zstret, Zdilate, Ztorque = np.zeros((5, np.size(xloc), 2)) nms1 = ['x', 'tilt1_p', 'tilt1_n', 'tilt2_p', 'tilt2_n', 'stretch_p', 'stretch_n', 'dilate_p', 'dilate_n', 'torque_p', 'torque_n'] enstro = False x_out = False y_out = True
ax.ticklabel_format(axis="z", style="sci", scilimits=(-2, 2)) ax.view_init(elev=50, azim=-20) ax.axes.xaxis.labelpad = 1 ax.axes.yaxis.labelpad = 6 ax.axes.zaxis.labelpad = 0.1 ax.tick_params(axis='x', which='major', pad=1) ax.tick_params(axis='y', which='major', pad=0.1) ax.tick_params(axis='z', which='major', pad=0.1) plt.tight_layout(pad=0.5, w_pad=0.5, h_pad=1) #plt.savefig(pathF + "3dContourFWPSD.svg") plt.show() """ save wall plane data and plot """ # %% plot Cf in x-z plane time_ave = tf() filename = glob(path + 'TP_data_1123.h5') time_ave.load_3data(pathT, FileList=filename, NameList='h5') # time_ave.load_3data(path+'TP_data_02087427/') # time_ave._data_field.to_hdf(path+'TP_data_1124.h5', 'w', format='fixed') time_ave.add_walldist(3.0) # filename = glob(pathT + 'MeanFlow_*') # time_ave.load_3data(pathT, FileList=filename, NameList='h5') df1 = time_ave.TriData.query("x>0 & walldist>0") df1a = df1.loc[df1['walldist'] == np.min( df1['walldist'])] # np.min(df1['walldist'])*2 df2 = time_ave.TriData.query("x<=0 & y>=0 & walldist>0") df2a = df2.loc[df2['walldist'] == np.min( df2['walldist'])] # on the wall=0.5*dy df = pd.concat([df1a, df2a]) df.to_hdf(pathT + 'WallValue.h5', 'w', format='fixed')
# %% Load Data for time-averaged results path4 = "/media/weibo/Data1/BFS_M1.7L/Slice/" MeanFlow = DataPost() MeanFlow.UserDataBin(pathF + "SolTime995.00.h5") # %% Preprocess the data in the xy plane (z=0.0) MeanFlowZ0 = MeanFlow.DataTab.loc[MeanFlow.DataTab["z"] == 0.0] MeanFlowZ1 = MeanFlow.DataTab.loc[MeanFlow.DataTab["z"] == 0.5] MeanFlowZ2 = MeanFlow.DataTab.loc[MeanFlow.DataTab["z"] == -0.5] MeanFlowZ3 = pd.concat((MeanFlowZ1, MeanFlowZ2)) MeanFlowZ4 = MeanFlowZ3.groupby(["x", "y"]).mean().reset_index() MeanFlowZ5 = MeanFlowZ4.loc[MeanFlowZ4["y"] > 3.0] MeanFlowZ0 = pd.concat((MeanFlowZ0, MeanFlowZ5), sort=False) MeanFlowZ0.to_hdf(pathF + "MeanFlowZ0.h5", "w", format="fixed") # %% Load data fluc_flow = tf() fluc_flow.load_3data( path, FileList=path+"/ZFluctuation_900.0.h5", NameList='h5' ) # %% Plot contour of the fluctuation flow field in the xy plane zslice = fluc_flow.TriData.loc[fluc_flow.TriData['z']==0.0] x, y = np.meshgrid(np.unique(zslice.x), np.unique(zslice.y)) omegaz = griddata((zslice.x, zslice.y), zslice.vorticity_3, (x, y)) corner = (x < 0.0) & (y < 0.0) omegaz[corner] = np.nan fig, ax = plt.subplots(figsize=(6.4, 3.2)) matplotlib.rc("font", size=textsize) plt.tick_params(labelsize=numsize) val1 = -0.2 val2 = 0.2 lev1 = np.linspace(val1, val2, 21)
ax.semilogx(freq1 * Lr1, psd1[:, ind1], "k-", linewidth=1.0) # ax.scatter(Fre1*Lr1, FPSD1, s=10, marker='o', # facecolors='w', edgecolors='C7', linewidths=0.8) ax.semilogx(freq3 * Lr3, psd3[:, ind3], "k:", linewidth=1.5) # ax.set_xscale('log') ax.yaxis.offsetText.set_fontsize(numsize) plt.tick_params(labelsize=numsize) plt.tight_layout(pad=0.5, w_pad=0.8, h_pad=1) plt.savefig(pathC + "VarFWPSD_com.svg", bbox_inches="tight", pad_inches=0.1) plt.show() # %%############################################################################ """ Development of variables with spanwise direction """ # %% load data TimeFlow0 = tf() TimeFlow0.load_3data(path0T, FileList=path0 + 'TP_912.plt') #, NameList='plt') TimeFlow1 = tf() TimeFlow1.load_3data(path1T, FileList=path1 + 'TP_912.plt') #, NameList='plt') # %% save data xyloc = [[-0.1875, 0.03125], [0.203125, 0.0390625], [0.59375, -0.171875], [2.0, 0.46875]] for i in range(np.shape(xyloc)[0]): file = path0P + 'spanwise_' + str(xyloc[i][0]) + '.dat' var0 = TimeFlow0.TriData df = var0.loc[(var0['x'] == xyloc[i][0]) & (var0['y'] == xyloc[i][1])] val0 = df.drop_duplicates(subset='z', keep='first') val0.to_csv(file, sep=' ', index=False, float_format='%1.8e') file = path1P + 'spanwise_' + str(xyloc[i][0]) + '.dat' var1 = TimeFlow1.TriData