美文网首页
用Python对OpenFOAM计算结果log文件数据的提取

用Python对OpenFOAM计算结果log文件数据的提取

作者: 平平又无奇 | 来源:发表于2017-12-21 14:36 被阅读201次
  • 一个时间步的log文件显示如下
Time = 1000


Solving 3-D cloud sprayCloud

Cloud: sprayCloud injector: model1
    Added 20000 new parcels

Cloud: sprayCloud
    Current number of parcels       = 104523
    Current mass in system          = 2.44025e+06
    Linear momentum                 = (448.443 3.07731e+07 -4.0631e+06)
   |Linear momentum|                = 3.10402e+07
    Linear kinetic energy           = 2.67875e+08
    model1:
        number of parcels added     = 79980000
        mass introduced             = 1.86726e+09
    Parcel fate (number, mass)
      - escape                      = 390717, 0
      - stick                       = 0, 0
    Temperature min/max             = 301, 301
    Mass transfer phase change      = 0
    D10, D32, Dmax (mu)             = 400, 400, 400
    Liquid penetration 95% mass (m) = 31.2189

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
PIMPLE: iteration 1
GAMG:  Solving for Ux, Initial residual = 0.180739, Final residual = 0.000179812, No Iterations 1
GAMG:  Solving for Uy, Initial residual = 0.000644012, Final residual = 1.31311e-06, No Iterations 1
GAMG:  Solving for Uz, Initial residual = 0.000924792, Final residual = 1.35269e-06, No Iterations 1
DILUPBiCG:  Solving for H2O, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for N2, Initial residual = 0.00133494, Final residual = 8.04592e-09, No Iterations 4
DILUPBiCG:  Solving for h, Initial residual = 0.00114968, Final residual = 6.95384e-05, No Iterations 1
T gas min/max   = 296.882, 301.877
GAMG:  Solving for p, Initial residual = 0.00656675, Final residual = 1.67482e-05, No Iterations 3
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 5.64318e-07, global = -1.53357e-08, cumulative = 0.00182297
rho max/min : 1.20053 1.12852
GAMG:  Solving for p, Initial residual = 0.00133588, Final residual = 6.08234e-06, No Iterations 3
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 2.04937e-07, global = 2.23063e-09, cumulative = 0.00182298
rho max/min : 1.20033 1.12852
PIMPLE: iteration 2
GAMG:  Solving for Ux, Initial residual = 0.0441852, Final residual = 3.2553e-07, No Iterations 2
GAMG:  Solving for Uy, Initial residual = 8.23501e-05, Final residual = 1.02875e-07, No Iterations 1
GAMG:  Solving for Uz, Initial residual = 0.000119312, Final residual = 1.05676e-07, No Iterations 1
DILUPBiCG:  Solving for H2O, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for N2, Initial residual = 0.00392789, Final residual = 1.48488e-07, No Iterations 4
DILUPBiCG:  Solving for h, Initial residual = 0.00132034, Final residual = 3.51496e-07, No Iterations 3
T gas min/max   = 296.882, 301.876
GAMG:  Solving for p, Initial residual = 0.000637544, Final residual = 2.7269e-06, No Iterations 3
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 9.18747e-08, global = -4.31392e-09, cumulative = 0.00182297
rho max/min : 1.20028 1.12852
GAMG:  Solving for p, Initial residual = 0.000161301, Final residual = 3.80677e-08, No Iterations 5
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
time step continuity errors : sum local = 1.28259e-09, global = 2.30985e-11, cumulative = 0.00182297
rho max/min : 1.2003 1.12852
GAMG:  Solving for k, Initial residual = 0.00180064, Final residual = 7.61412e-09, No Iterations 2
ExecutionTime = 21472.9 s  ClockTime = 21611 s
  • 如上面的运行结果所示,提取每个时间步的Current number of parcels行信息,并写入新的文件
my_file=open('F:/data/1221/test_1.txt','w')
for line in open("F:/data/1221/log_43"):  
    if 'Current number of parcels' in line:       
        my_file.write(line) 
my_file.close()
  • 则test_1中部分显示如下

Current number of parcels = 104388
Current number of parcels = 104335
Current number of parcels = 104363
Current number of parcels = 104465
Current number of parcels = 104542
Current number of parcels = 104409
Current number of parcels = 104656
Current number of parcels = 104463
Current number of parcels = 104424
Current number of parcels = 104503
Current number of parcels = 104535
Current number of parcels = 104530
Current number of parcels = 104502
Current number of parcels = 104652
Current number of parcels = 104655
Current number of parcels = 104633
Current number of parcels = 104623
Current number of parcels = 104489
Current number of parcels = 104681
Current number of parcels = 104712
Current number of parcels = 104784
Current number of parcels = 104763
Current number of parcels = 104379
Current number of parcels = 104523
......

  • 接下来就可以导入MATLAB画图了:
    数据结果图.png

相关文章

  • 用Python对OpenFOAM计算结果log文件数据的提取

    一个时间步的log文件显示如下 如上面的运行结果所示,提取每个时间步的Current number of parc...

  • 用python获取当前文件夹下的所有csv文件

    昨天我们用python将所有csv文件写入数据库,进行数据保存供后续提取分析用,程序中有段代码是获取当前文件夹下的...

  • 2018-07-03

    BeautifulSoup是一个可以从HTML或者XML文件中提取数据的Python库。 软件:python 3....

  • 读取log日志并最后合成在视频中

    开始拿到的书log日志是这样的 首先按行对他们进行提取因为每个数据后边都有个-所以用这个符号把这些数据行分割 因为...

  • Python | 数据结构常用方法

    python 有什么用?或者说 python 对我有什么用? 我试着写了一个提取基因序列小脚本,几个数据结构的应用...

  • HTML解析大法-Beautiful soup

    Beautiful soup是一个可以从HTML或XML文件中提取数据的python库。在python爬虫开发中,...

  • 提取 genecode的gtf注释信息

    读入数据 提取gene信息 获取想要的信息 写在最后的话 很多大神用perl和python来提取,对于文本提取这两...

  • scrapy框架总结

    #scrapy框架是什么: #####scrapy是用纯Python实现的一个为了爬去网站数据,提取结构数据而编写...

  • 2019-03-07

    对web服务的日志文件进行保护,只允许忘文件里添加数据,不能删除数据chattr +a /var/log/http...

  • Scrapy

    Scrapy简介和历史 Scrapy是用纯Python实现一个为了爬取网站数据、提取结构性数据而编写的应用框架,用...

网友评论

      本文标题:用Python对OpenFOAM计算结果log文件数据的提取

      本文链接:https://www.haomeiwen.com/subject/pdlawxtx.html