Exemple #1
0
yarr = yval.values.reshape(-1, 1)
zarr = zval.values.reshape(-1, 1)
names = ['x', 'y', 'z', var0, var1, var2, var3, var4,
         'u`', 'v`', 'w`', 'p`', 'T`']
path3 = path + 'plt/'
for ii in range(np.size(phase)):
    # ind = 10
    fluc = modeflow[:, ii].reshape((m, o), order='F')
    newflow = fluc.real
    data = np.hstack((xarr, yarr, zarr, base, newflow))
    df = pd.DataFrame(data, columns=names)
    filename = str(np.round(freq[num], 3)) + "DMD" + '{:03}'.format(ii)
    with timer('save plt of t=' + str(phase[ii])):
        df1 = df.query("x<=0.0 & y>=0.0")
        filename1 = filename + "A"
        p2p.frame2tec3d(df1, path3D, filename1, zname=1, stime=ii)
        p2p.tec2plt(path3D, filename1, filename1)
        df2 = df.query("x>=0.0")
        filename2 = filename + "B"
        p2p.frame2tec3d(df2, path3D, filename2, zname=2, stime=ii)
        p2p.tec2plt(path3D, filename2, filename2)

# %%      
def dmd_plt(df, path, ind):
    matplotlib.rc('font', size=textsize)   
    fig, ax = plt.subplots(figsize=(3.6, 2.0))
    ax.set_xlabel(r'$x/\delta_0$', fontdict=font)
    ax.set_ylabel(r'$y/\delta_0$', fontdict=font)

#    p = griddata((xval, yval), p_new, (x, y))
#    gradyx = np.gradient(p, y_coord, x_coord)
Exemple #2
0
]

start = time.time()

volume = [(-100.0, 80.0), (0.0, 40.0), (-8, 8)]
dxyz = [0.25, 0.125, 0.125]
df0, stime = p2p.ReadINCAResults(pathin, VarList, SubZone=volume)
xval = np.arange(volume[0][0], volume[0][1] + dxyz[0], dxyz[0])
yval = np.arange(volume[1][0], volume[1][1] + dxyz[1], dxyz[1])
zval = np.arange(volume[2][0], volume[2][1] + dxyz[2], dxyz[2])

df1 = df0[df0.x.isin(xval)]
df2 = df1[df1.y.isin(yval)]
df3 = df2[df2.z.isin(zval)]

stime = np.around(stime, decimals=2)
filename = "TP_data_" + str(stime)
df3.to_hdf(pathout + filename + ".h5", 'w', format='fixed')
# %% save to tecplot format
# in front of the step
df1 = df3.query("x<=0.0 & y>=0.0")
p2p.frame2tec3d(df1, pathout, filename + 'A', zname=1, stime=time)
p2p.tec2plt(pathout, filename + 'A')
# behind the step
df2 = df3.query("x>=0.0")
p2p.frame2tec3d(df2, pathout, filename + 'B', zname=2, stime=time)
p2p.tec2plt(pathout, filename + 'B')

end = time.time() - start
print(filename + ' took ' + str(end) + 's')
Exemple #3
0
    if (file['nz'] != len(np.unique(cube['z']))):
        # remove dismatch grid point on the z boundary of the block (boundary grid may be finer)
        zlist = np.linspace(file['z1'], file['z2'], int(file['nz']))
        blk1 = cube[cube['z'].isin(zlist)].reset_index(drop=True)
    else:
        blk1 = cube

    blk0 = base.query("x>={0} & x<={1} & y>={2} & y<={3}".format(
        file['x1'], file['x2'], file['y1'], file['y2']))
    new = blk0.loc[blk0.index.repeat(int(file['nz']))]
    new = new.reset_index(drop=True)
    new = new.sort_values(by=['x', 'y', 'z'])
    flc = blk1.sort_values(by=['x', 'y', 'z']).reset_index(drop=True)
    flc[varname] = flc[varname] - new[varname]
    # flc.update(flc[varname] - new[varname])
    if (file['nx'] != len(np.unique(flc['x']))):
        # remove dismatch grid point on the x boundary of the block
        xlist = np.unique(flc['x'])[0::2]
        flc = flc[flc['x'].isin(xlist)]
    if (file['ny'] != len(np.unique(flc['y']))):
        # remove dismatch grid point on the y boundary of the block
        ylist = np.unique(flc['y'])[0::2]
        flc = flc[flc['y'].isin(ylist)]
    p2p.frame2tec3d(flc, pathA, 'fluc' + str(i), zname=i, stime=899.5)

# %%
grouped = orig.groupby(['x', 'y'])
count = grouped.size().reset_index(name='count')
base_exts = base['u'].repeat(count['count'].values)
Exemple #4
0
               method='cubic')
p = griddata((df0.x, df0.y), df0['p'], (x, y), fill_value=0, method='cubic')
T = griddata((df0.x, df0.y), df0['T'], (x, y), fill_value=0, method='cubic')

xx = x.reshape(-1, 1)
yy = y.reshape(-1, 1)
zz = z.reshape(-1, 1)
uu = u.reshape(-1, 1)
vv = v.reshape(-1, 1)
ww = w.reshape(-1, 1)
rhorho = rho.reshape(-1, 1)
pp = p.reshape(-1, 1)
TT = T.reshape(-1, 1)

var1 = np.column_stack((xx, yy, zz, uu, vv, ww, rhorho, pp, TT))
var2 = np.copy(var1)
var1[:, 2] = -8.0
var2[:, 2] = 8.0
var = np.row_stack((var1, var2))
df = pd.DataFrame(var, columns=name)

filename = "initial_data"
df1 = df.query("x<=0.0 & y>=0.0")
p2p.frame2tec3d(df1, path, filename + 'A', zname=1, stime=0.0)
p2p.tec2plt(path, filename + 'A')

# behind the step
df2 = df.query("x>=0.0 & y>=3.0")
p2p.frame2tec3d(df2, path, filename + 'B', zname=2, stime=0.0)
p2p.tec2plt(path, filename + 'B')
Exemple #5
0
xval = np.arange(np.min(meanflow['x']), np.max(meanflow['x']) + 0.25, 0.25)
yval = np.arange(np.min(meanflow['y']), np.max(meanflow['y']) + 0.125, 0.125)
zval = np.arange(np.min(meanflow['z']), np.max(meanflow['z']) + 0.125, 0.125)
for ind in mode_id:
    # ind = 10
    modeflow = phi[:, ind - 1] * coeff[ind - 1, 0]
    newflow = modeflow.reshape((m, o), order='F')

    data = np.hstack((xarr, yarr, zarr, base, newflow))
    df = pd.DataFrame(data, columns=names)
    filename = "POD_Mode" + str(ind)
    with timer("save plt"):

        df1 = df.query("x<=0.0 & y>=0.0 & y<=1.0")
        filename1 = filename + "A"
        p2p.frame2tec3d(df1, path3P, filename1, zname=1, stime=ind)
        p2p.tec2plt(path3P, filename1, filename1)

        df2 = df.query("x>=0.0 & y<=0.0")
        filename2 = filename + "B"
        p2p.frame2tec3d(df2, path3P, filename2, zname=1, stime=ind)
        p2p.tec2plt(path3P, filename2, filename2)

        df0 = df[df.x.isin(xval)]
        df0 = df0[df0.y.isin(yval)]
        df0 = df0[df0.z.isin(zval)]

        df3 = df0.query("x<=0.0 & y>=1.0 & y<=2.0")
        filename3 = filename + "C"
        p2p.frame2tec3d(df3, path3P, filename3, zname=1, stime=ind)
        p2p.tec2plt(path3P, filename3, filename3)
Exemple #6
0
        # remove dismatch grid point on the z boundary of the block
        # since the boundary grid may be finer
        zlist = np.linspace(file['z1'], file['z2'], int(file['nz']))
        blk1 = cube[cube['z'].isin(zlist)].reset_index(drop=True)
    else:
        blk1 = cube

    blk0 = base.query("x>={0} & x<={1} & y>={2} & y<={3}".format(
        file['x1'], file['x2'], file['y1'], file['y2']))
    new = blk0.loc[blk0.index.repeat(int(file['nz']))]
    new = new.reset_index(drop=True)
    new = new.sort_values(by=['x', 'y', 'z'])
    flc = blk1.sort_values(by=['x', 'y', 'z']).reset_index(drop=True)
    flc[VarList[3:]] = flc[VarList[3:]] - new[VarList[3:]]
    # flc.update(flc[varname] - new[varname])
    if (file['nx'] != len(np.unique(flc['x']))):
        # remove dismatch grid point on the x boundary of the block
        xlist = np.unique(flc['x'])[0::2]
        flc = flc[flc['x'].isin(xlist)]
    if (file['ny'] != len(np.unique(flc['y']))):
        # remove dismatch grid point on the y boundary of the block
        ylist = np.unique(flc['y'])[0::2]
        flc = flc[flc['y'].isin(ylist)]
    p2p.frame2tec3d(flc, path3, 'fluc_base' + str(i), zname=i, stime=time)

# %% convert .dat to .plt
filelist = glob(path3 + '*.dat')
dataset = tp.data.load_tecplot(filelist, read_data_option=2)
tp.data.save_tecplot_plt(path2 + "fluc_base" + str(time) + '.plt',
                         dataset=dataset)
Exemple #7
0
zflc = pd.read_hdf(path2 + "ZFluctuation_" + str(time) + ".h5")[VarList]

path3 = path2 + str(time) + '/'
if (os.path.isdir(path3) is False):
    os.mkdir(path3)
for i in range(np.shape(df_zone)[0]):
    file = df_zone.iloc[i]
    cube = zflc.query("x>={0} & x<={1} & y>={2} & y<={3}".format(
        file['x1'], file['x2'], file['y1'], file['y2']))
    if (file['nz'] != len(np.unique(cube['z']))):
        # remove dismatch grid point on the z boundary of the block
        # since boundary grid may be finer
        zlist = np.linspace(file['z1'], file['z2'], int(file['nz']))
        blk1 = cube[cube['z'].isin(zlist)].reset_index(drop=True)
    else:
        blk1 = cube
    if (file['nx'] != len(np.unique(blk1['x']))):
        # remove dismatch grid point on the x boundary of the block
        xlist = np.unique(blk1['x'])[0::2]
        blk1 = blk1[blk1['x'].isin(xlist)]
    if (file['ny'] != len(np.unique(blk1['y']))):
        # remove dismatch grid point on the y boundary of the block
        ylist = np.unique(blk1['y'])[0::2]
        blk1 = blk1[blk1['y'].isin(ylist)]
    p2p.frame2tec3d(blk1, path3, 'Zfluc' + str(i), zname=i, stime=time)

# %% convert .dat to .plt
filelist = glob(path3 + '*.dat')
dataset = tp.data.load_tecplot(filelist, read_data_option=2)
tp.data.save_tecplot_plt(path2 + "zfluc" + str(time) + '.plt', dataset=dataset)