目录

某区域流体数据处理(只会写操作,不知道具体意义)

目录

前言

帮舍友整的,不知道具体实际意义。

代码

1
2
3
4
5
import numpy as np
import pandas as pd


data = pd.read_excel(r'C:\Users\祈LHL\Desktop\data.xlsx')
1
data.head()
cellnumber x-coordinate y-coordinate z-coordinate density z-velocity relative-z-velocity x-coordinate.1 y-coordinate z-face-area boundary-cell-dist boundary-normal-dist
0 1 -12.597898 -2.404495 -6.320497 1.226 -22.205814 -22.205814 -12.597899 -2.404528 -0.006824 1 0.010276
1 2 -12.597898 -2.321485 -6.320487 1.226 -23.532957 -23.532957 -12.597899 -2.321584 -0.006824 1 0.020553
2 3 -12.515688 -2.404495 -6.320500 1.226 -23.167622 -23.167622 -12.515688 -2.404528 -0.006824 1 0.020636
3 4 -12.515688 -2.321485 -6.320500 1.226 -24.882029 -24.882029 -12.515688 -2.321584 -0.006824 1 0.051111
4 5 -12.433477 -2.404495 -6.320500 1.226 -23.488083 -23.488083 -12.433478 -2.404528 -0.006824 1 0.020719
1
y = data.sort_values(by="y-coordinate" , ascending=False)
1
2
3
4
5
6

step = 4.892/6
i = 0
y_list = []
section = []
#y6  x3
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#分y
while i < 6:
    step_y = float("%.8f"%(i*step))
    a_y = step_y-2.446
    y_min = y.loc[y['y-coordinate'] >= a_y]
    i +=1
    step_y = float("%.8f"%(i*step))
    b_y = step_y-2.446
    y_max = y_min.loc[y_min['y-coordinate'] < b_y]
    y_list.append(y_max)
    section_y = (a_y,b_y)
    section.append(section_y)
#section[5]
1
2
3
4
5
j = 0
step = 1.562/3
x_list = []
section_x_list = []
section_y_list = []
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#在y中分x
while j <= 5:
    temp = y_list[j]
    m = 0
    while m <= 2:
        step_x = float("%.8f"%(m*step))
        a_x = step_x-12.639
        x_min = temp.loc[temp['x-coordinate'] >= a_x]
        m +=1
        step_x = float("%.8f"%(m*step))
        b_x = step_x-12.639
        x_max = x_min.loc[temp['x-coordinate'] < b_x]
        x_list.append(x_max)
        section_x = (a_x,b_x)
        section_x_list.append(section_x)
        section_y_list.append(section[j])
    j += 1
#18个块
1
2
3
section_list = []
Q_list = []
i = 0
1
2
3
4
5
while i <= 17:
    temp_l = x_list[i]
    Q = (temp_l["density"]*temp_l["z-velocity"]*temp_l["z-face-area"]).sum()
    i +=1
    Q_list.append(Q)
1
section_x_list
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[(-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077),
 (-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077),
 (-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077),
 (-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077),
 (-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077),
 (-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077)]
1
section_y_list
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[(-2.446, -1.63066667),
 (-2.446, -1.63066667),
 (-2.446, -1.63066667),
 (-1.63066667, -0.8153333300000001),
 (-1.63066667, -0.8153333300000001),
 (-1.63066667, -0.8153333300000001),
 (-0.8153333300000001, 0.0),
 (-0.8153333300000001, 0.0),
 (-0.8153333300000001, 0.0),
 (0.0, 0.8153333299999996),
 (0.0, 0.8153333299999996),
 (0.0, 0.8153333299999996),
 (0.8153333299999996, 1.6306666699999997),
 (0.8153333299999996, 1.6306666699999997),
 (0.8153333299999996, 1.6306666699999997),
 (1.6306666699999997, 2.446),
 (1.6306666699999997, 2.446),
 (1.6306666699999997, 2.446)]
1
2
3
4
5
6
index = []
i = 0
while i <= 2:
    index.append(section_x_list[i])
    i+=1
index
1
2
3
[(-12.639, -12.118333329999999),
 (-12.118333329999999, -11.597666669999999),
 (-11.597666669999999, -11.077)]
1
2
3
4
5
6
cols = []
i = 0
while i <= 17:
    cols.append(section_y_list[i])
    i+=3
cols
1
2
3
4
5
6
[(-2.446, -1.63066667),
 (-1.63066667, -0.8153333300000001),
 (-0.8153333300000001, 0.0),
 (0.0, 0.8153333299999996),
 (0.8153333299999996, 1.6306666699999997),
 (1.6306666699999997, 2.446)]
1
2
3
4
5
6
7
j = 0
data = {}
while j <=5:
    col = cols[j]
    data[col]= 1
    j += 1
data
1
2
3
4
5
6
{(-2.446, -1.63066667): 1,
 (-1.63066667, -0.8153333300000001): 1,
 (-0.8153333300000001, 0.0): 1,
 (0.0, 0.8153333299999996): 1,
 (0.8153333299999996, 1.6306666699999997): 1,
 (1.6306666699999997, 2.446): 1}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
temp_list = Q_list.copy()
r = 0
l = 0
for i in data:
    content = []
    for j in range(3):
        content.append(Q_list[l])
        l+=1
    data[i] = content
data
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{(-2.446, -1.63066667): [12.427282344087539,
  12.86438295520224,
  8.104732674789329],
 (-1.63066667, -0.8153333300000001): [14.059159859218617,
  14.0170078290342,
  6.50613023081204],
 (-0.8153333300000001, 0.0): [13.851341644545903,
  14.102576555137208,
  6.549793869809068],
 (0.0, 0.8153333299999996): [13.873905539737082,
  14.100577509379482,
  6.539991338980014],
 (0.8153333299999996, 1.6306666699999997): [14.030126072372612,
  13.966730831575635,
  6.467075694188603],
 (1.6306666699999997, 2.446): [11.644887356127308,
  12.004108151505823,
  7.422577844039829]}
1
2
df = pd.DataFrame(data=data, index=index)
df
-2.446000 -1.630667 -0.815333 0.000000 0.815333 1.630667
-1.630667 -0.815333 0.000000 0.815333 1.630667 2.446000
(-12.639, -12.118333329999999) 12.427282 14.059160 13.851342 13.873906 14.030126 11.644887
(-12.118333329999999, -11.597666669999999) 12.864383 14.017008 14.102577 14.100578 13.966731 12.004108
(-11.597666669999999, -11.077) 8.104733 6.506130 6.549794 6.539991 6.467076 7.422578

相关资料:数据集链接点此下载