当前位置: 首页 > news >正文

fluent脱硝SCR相对标准偏差、氨氮比、截面速度计算

# -*- coding: utf-8 -*-
"""
Created on Wed Sep 20 20:40:30 2023
联系QQ:3123575367,专业SCR脱硝仿真。
该程序用来处理fluent通过export-solution-ASCII-Space导出的数据,可计算标准偏差SD、相对标准偏差RSD,适用于求解平面的相对均匀度
@author: PS
"""import chardet #识别文件的编码格式#确定文件编码格式
def check_code(text):#detect函数只需要一个 非unicode字符串参数,返回一个字典。该字典包括判断到的编码格式及判断的置信度。with open(text, 'rb') as f:    adchar = chardet.detect(f.read())  # adchar = chardet.detect(text)# 由于windows系统的编码有可能是Windows-1254,打印出来后还是乱码,所以不直接用adchar['encoding']编码if adchar['encoding'] == 'gbk' or adchar['encoding'] == 'GBK' or adchar['encoding'] == 'GB2312':return 'GB2312'else:return 'utf-8'#读取文件并进行计算 
def read_file_text(file_url):with open(file_url, 'r',encoding=check_code(file_url)) as f0:row_nul = 1for i in range(row_nul):next(f0)#跳行f0_word = f0.readlines()ls = []x=[]y=[]#将文本数据按照行整理到列表中for line in f0_word:line = line.strip('\n')#将每段的回车替换为空格line = line.replace(')','')words = line.split()#将字符串以空格分开ls.append(words)#将列表中的数据按照列提取出来for lin in ls:for l in range(len(lin)):lin[l] = lin[l].strip('(')#去掉左右的((while '' in lin:#将空格字符串删除lin.remove('')#最后一列为空值,需要跳过if lin == ls[-1]:breakx.append(float(lin[0]))#保存文本的第0列数据y.append(float(lin[4]))#保存文本的第4列数据#计算# print(y)#计算含0的数据mean = sum(y)/len(y)qh =[]for num in y:qh.append(pow(num-mean,2))qv = pow(sum(qh)/(len(qh)-1),0.5) #标准偏差 cv = qv/mean #相对标准偏差print('+++++++未操作数据 +++++++')print(f'平均值为:{round(mean,4)}')print(f'标准偏差(SD)为:{round(qv*100,4)} %\n相对标准偏差(RSD)为:{round(cv*100,4)} %')#计算去除0后的数据y_no_zero = [i for i in y if i!= 0] #去除0元素mean_no_zero = sum(y_no_zero)/len(y_no_zero)qh_no_zero = [pow(num-mean_no_zero,2) for num in y_no_zero]qv_no_zero = pow(sum(qh_no_zero)/(len(qh_no_zero)-1),0.5)cv_no_zero = qv_no_zero/mean_no_zeroprint('------------去除 0 数据------------')print(f'平均值为:{round(mean_no_zero,4)}')print(f'标准偏差(SD)为:{round(qv_no_zero*100,4)} %\n相对标准偏差(RSD)为:{round(cv_no_zero*100,4)} %')read_file_text(r'F:\1\t') #只需要更改此处输入 

与之前的区别在于一个是通过xyplot导出的,一个是export,两者计算差距较小(https://blog.csdn.net/weixin_43245453/article/details/133220734)。
截图输出如下
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

http://www.lryc.cn/news/299361.html

相关文章:

  • Codeforces Round 925 (Div. 3)(A~E)
  • @RequestBody、@RequestParam、@RequestPart使用方式和使用场景
  • LeetCode、1143. 最长公共子序列【中等,二维DP】
  • 162基于matlab的多尺度和谱峭度算法对振动信号进行降噪处理
  • Android Studio六大基本布局的概览和每个布局的关键特性以及实例分析
  • 【go语言】一个简单HTTP服务的例子
  • LeetCode Python - 15.三数之和
  • C#中implicit和explicit
  • 探讨java系统中全局唯一ID实现方案
  • 微信小程序(四十四)鉴权组件插槽-登入检测
  • 【ES】--ES集成热更新自定义词库(字典)
  • 能源管理师——为能源可持续发展护航
  • 设计模式理解:单例模式+工厂模式+建设者模式+原型模式
  • DataX源码分析 writer
  • 为自己的项目媒体资源添加固定高度
  • 家政小程序系统源码开发:引领智能生活新篇章
  • 多表查询
  • PHP开发日志 ━━ 深入理解三元操作与一般条件语句的不同
  • 多维时序 | Matlab实现RF-Adaboost随机森林结合Adaboost多变量时间序列预测
  • vue3-内置组件-Suspense
  • Rust入门:如何在windows + vscode中关闭程序codelldb.exe
  • git错误整理
  • 跟着cherno手搓游戏引擎【22】CameraController、Resize
  • 微信小程序(四十二)wechat-http拦截器
  • tomcat部署zrlog
  • Ubuntu Desktop 开机数字小键盘
  • 树莓派编程基础与硬件控制
  • autojs通过正则表达式获取带有数字的text内容
  • Android java基础_类的继承
  • nginx stream proxy 模块的ssl连接源码分析