fluent使用DPM模型计算出的颗粒沉积(trap)数据(.dpm格式)后处理python实现

下图所示为二维圆柱绕流时颗粒的沉积情况,这里二维展示效果不明显,若是三维圆柱绕流的话,沉积效果会更明显,也可以使用第四个变量为颗粒着色,比如颗粒粒径,颗粒质量,颗粒速度,颗粒湿度等等。

在这里插入图片描述
下图为二维圆柱绕流模型
在这里插入图片描述

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
path=r"E:\DESKTOP\case_xu\test\dpm"#将.dpm文件放到dpm文件夹下
file_list=os.listdir(path)#列举出文件路径下的所有.dpm文件
for file in file_list:
	fn = os.path.splitext(file)    # 将文件名与后缀名分开
	old_name=os.path.join(path,file)
    if fn[1] == '.dpm':                    # 文件名:ext[0]
        new_name = fn[0] + '.csv'         # 文件后缀:ext[1]
        new_name=os.path.join(path,new_name)
        os.rename(old_name, new_name)    
 for file in file_list:     
		 data=pd.read_csv(os.path.join(path,file))
        data=np.array(data)
        print(data.shape)
        data=data[1:]
        xyz=[]
        for i in range(len(data)):
            for i in list(data[i])[0][3:39].split("   "):##提取前三个数据,即(x,y,z),并使用空格对提取出的数据分割
                xyz.append(float(i))
		xyz=np.array(xyz)
		xyz=xyz.reshape((-1,3))#reshape为3列数据
		from mpl_toolkits.mplot3d import Axes3D
		fig = plt.figure()
		ax1 = plt.axes(projection='3d')
		#ax = fig.add_subplot(111,projection='3d')  #这种方法可以画多个子图
		ax1.scatter3D(xyz[:,0],xyz[:,1],xyz[:,2], cmap='Blues')  	
		plt.show()

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值