计算机科学 ›› 2020, Vol. 47 ›› Issue (1): 17-23.doi: 10.11896/jsjkx.190500009

• 计算机体系结构 • 上一篇    下一篇

基于Python的大规模高性能LBM多相流模拟

徐传福,王曦,刘舒,陈世钊,林玉   

  1. (国防科技大学计算机学院 长沙410073)
  • 收稿日期:2019-05-05 发布日期:2020-01-19
  • 通讯作者: 徐传福(xuchuanfu@nudt.edu.cn)

Large-scale High-performance Lattice Boltzmann Multi-phase Flow Simulations Based on Python

XU Chuan-fu,WANG Xi,LIU Shu,CHEN Shi-zhao,LIN Yu   

  1. (College of Computer,National University of Defense Technology,Changsha 410073,China)
  • Received:2019-05-05 Published:2020-01-19
  • About author:XU Chuan-fu,born in 1980,Ph.D,associate professor,is member of China Computer Federation(CCF).His main research interests include parallel computing and applications.

摘要: Python由于具有丰富的第三方库、开发高效等优点,已成为数据科学、智能科学等应用领域最流行的编程语言之一。Python强调了对科学与工程计算的支持,目前已积累了丰富的科学与工程计算库和工具。例如,SciPy和NumPy等数学库提供了高效的多维数组操作及丰富的数值计算功能。以往,Python主要作为脚本语言,起到连接数值模拟前处理、求解器和后处理的“胶水”功能,以提升数值模拟的自动化处理水平。近年来,国外已有学者尝试采用Python代码实现求解计算功能,并在高性能计算机上开展了超大规模并行计算研究,取得了不错的效果。由于自身特点,高效大规模Python数值模拟的实现和性能优化与传统基于C/C++和Fortran的数值模拟等具有很大的不同。文中实现了国际上首个完全基于Python的大规模并行三维格子玻尔兹曼多相流模拟代码PyLBMFlow,探索了Python大规模高性能计算和性能优化方法。首先,利用NumPy多维数组和通用函数设计实现了LBM流场数据结构和典型计算内核,通过一系列性能优化并对LBM边界处理算法进行重构,大幅提升了Python的计算效率,相对于基准实现,优化后的串行性能提升了两个量级。在此基础上,采用三维流场区域分解方法,基于mpi4py和Cython实现了MPI+OpenMP混合并行;在天河二号超级计算机上成功模拟了基于D3Q19离散方法和Shan-Chen BGK碰撞模型的气液两相流,算例规模达百亿网格,并行规模达1024个结点,并行效率超过90%。

关键词: 并行计算, 多相流模拟, 高性能Python, 格子玻尔兹曼方法, 性能优化

Abstract: Due to the plenty of third-party libraries and development productivity,Python is becoming increasingly popular as a programming language in areas such as data science and artificial intelligence.Python has been providing fundamental support for scientific and engineering computing.For example,libraries such as NumPy and SciPy provide efficient data structures for multi-dimensional arrays and rich numerical functions.Traditionally,Python was used as a script language,gluing preprocessors,solvers and postprocessors and enhancing automation in numerical simulations.Recently,some foreign researchers implement their solvers using Python and parallelize their Python codes on high performance computers,with impressive results achieved.Because of its intrinsic features,implementation and optimization of high performance large-scale numerical simulations with Python are quite different with traditional language such as C/C++ and Fortran.This paper presented a large-scale parallel open source 3D Lattice Boltzmann multi-phase flow simulation code PyLBMFlow with Python,and investigated large-scale parallel computing and performance optimization for Python numerical applications.It designed LBM flow data structures and computational kernels with NumPy multi-dimensional arrays and universal functions.Through a range of optimization including reconstruction of boundary processing,it dramatically improves the efficiency of Python computing by about 100X,compared with the baseline version,on a CPU core.Furthermore,this paper designed a 3D decomposition method and implement hybrid MPI+OpenMP parallelization using mpi4py and Cython.Tests for 3D multi-phase(liquid and gases) problem(about 10 Billion lattices) simulating drop impact with gravity effect using D3Q19 Lattice Boltzmann discretization and Shan-Chen BGK single relaxation time collision model were presented,achieving a weak parallel efficiency of above 90% in going from 64 to 1024 compute nodes.

Key words: High performance Python, Lattice Boltzmann method, Multi-phase flow simulation, Parallel computing, Performance optimization

中图分类号: 

  • TP391
[1]ANDERSON J D.Computational Fluid Dynamics[M].McGraw-Hill,1995:1-30.
[2]SUCCI S,BENZI R,HIGUERA F.The lattice Boltzmann equation:A new tool for computational fluid dynamics[J].Physica D:Nonlinear Phenomena,1991,47(1):219-230.
[3]DAWSON S P,CHEN S,DOOLEN G D.Lattice Boltzmann computations for reaction-di_usion equations[J].The Journal of Chemical Physics,1993,98(2):1514-1523.
[4]SHAN X,CHEN H.Lattice Boltzmann model for simulating flows with multiple phases and components[J].Physics Review E,1993,47(3):1815-1819.
[5]ZHAO Y,WANG L,QIU F,et al.Melting and flowing in multiphase environment[J].Computers and Graphics,2006,30(4):519-528.
[6]BOSL W J,DVORKIN J,NUR A.A study of porosity and permeability using a lattice Boltzmann simulation[J].Geophysical Research Letters,1998,25(9):1475-1478.
[7]BAILEY P,MYRE J,WALSH S D,et al.Accelerating lattice Boltzmann fluid flow simulations using graphics processors[C]∥Internation al Conference on Parallel Processing.2009:550-557.
[8]BIFERALE L,MANTOVANI F,PIVANTI M,et al.Optimization of Multi-Phase Compressible Lattice Boltzmann Codes on Massively Parallel Multi-Core Systems[J].Procedia Computer Science,2011,4(4):994-1003.
[9]MOUNTRAKIS L,LORENZ E,MALASPINAS O,et al.Parallel performance of an IB-LBM suspension simulation framework[J].Journal of Computational Science,2015,9:45-50.
[10]WILLIAMS S,CARTER J,OLIKER L,et al.Optimization of a lattice boltzmann computation on state-of-the-art multicore platforms[J].Journal of Parallel and Distributed Computing,2009,69(9):762-777.
[11]PANANILATH I,ACHARYA A,VASISTA V,et al.An optimizing code generator for a class of lattice-boltzmann computations[J].ACM Transactions on Architecture and Code Optimization,2015,12(2):1-14.
[12]FEICHTINGER C,HABICH J,KESTLER H,et al.Perform- ance modeling and analysis of heterogeneous lattice boltzmann simulations on cpu-gpu clusters[J].Parallel Computing,2015,46(C):1-13.
[13]LI D,XU C,WANG Y,et al.Parallelizing and optimizing large-scale 3d multi-phase flow simulations on the tianhe-2 supercomputer[J].Concurrency and Computation:Practice and Expe-rience,2016,28:1678-1692.
[14]NumPy Official. http://www.numpy.org. Scipy Official. http://www.scipy.org.
[16]MORTENSEN M,LANGTANGEN H P.High performance Python for direct numerical simulations of turbulent flows[J].Computer Physics Communications,2016,203:53-65.
[17]VINCENT P,WITHERDENY F,VERMERIRE B,et al.Towards Green Aviation with Python at Petascale∥IEEE International Conference for High Performance Computing and Data analytic.2016:1-11.
[18]LIAO X,XIAO L,YANG C.Milkyway-2 supercomputer:system and application[J].Frontier of Computer Science,2004,8(3):345-356.
[1] 陈钧吾, 余华山.
面向无尺度图的Δ-stepping算法改进策略
Strategies for Improving Δ-stepping Algorithm on Scale-free Graphs
计算机科学, 2022, 49(6A): 594-600. https://doi.org/10.11896/jsjkx.210400062
[2] 陈鑫, 李芳, 丁海昕, 孙唯哲, 刘鑫, 陈德训, 叶跃进, 何香.
面向国产异构众核架构的CFD非结构网格计算并行优化方法
Parallel Optimization Method of Unstructured-grid Computing in CFD for DomesticHeterogeneous Many-core Architecture
计算机科学, 2022, 49(6): 99-107. https://doi.org/10.11896/jsjkx.210400157
[3] 傅天豪, 田鸿运, 金煜阳, 杨章, 翟季冬, 武林平, 徐小文.
一种面向构件化并行应用程序的性能骨架分析方法
Performance Skeleton Analysis Method Towards Component-based Parallel Applications
计算机科学, 2021, 48(6): 1-9. https://doi.org/10.11896/jsjkx.201200115
[4] 何亚茹, 庞建民, 徐金龙, 朱雨, 陶小涵.
基于神威平台的Floyd并行算法的实现和优化
Implementation and Optimization of Floyd Parallel Algorithm Based on Sunway Platform
计算机科学, 2021, 48(6): 34-40. https://doi.org/10.11896/jsjkx.201100051
[5] 冯凯, 马鑫玉.
(n,k)-冒泡排序网络的子网络可靠性
Subnetwork Reliability of (n,k)-bubble-sort Networks
计算机科学, 2021, 48(4): 43-48. https://doi.org/10.11896/jsjkx.201100139
[6] 鄂海红, 张田宇, 宋美娜.
基于Web的数据可视化图表渲染优化方法
Web-based Data Visualization Chart Rendering Optimization Method
计算机科学, 2021, 48(3): 119-123. https://doi.org/10.11896/jsjkx.200600038
[7] 张晓, 张思蒙, 石佳, 董聪, 李战怀.
Ceph分布式存储系统性能优化技术研究综述
Review on Performance Optimization of Ceph Distributed Storage System
计算机科学, 2021, 48(2): 1-12. https://doi.org/10.11896/jsjkx.201000149
[8] 胡蓉, 阳王东, 王昊天, 罗辉章, 李肯立.
基于GPU加速的并行WMD算法
Parallel WMD Algorithm Based on GPU Acceleration
计算机科学, 2021, 48(12): 24-28. https://doi.org/10.11896/jsjkx.210600213
[9] 马梦宇, 吴烨, 陈荦, 伍江江, 李军, 景宁.
显示导向型的大规模地理矢量实时可视化技术
Display-oriented Data Visualization Technique for Large-scale Geographic Vector Data
计算机科学, 2020, 47(9): 117-122. https://doi.org/10.11896/jsjkx.190800121
[10] 陈国良, 张玉杰.
并行计算学科发展历程
Development of Parallel Computing Subject
计算机科学, 2020, 47(8): 1-4. https://doi.org/10.11896/jsjkx.200600027
[11] 阳王东, 王昊天, 张宇峰, 林圣乐, 蔡沁耘.
异构混合并行计算综述
Survey of Heterogeneous Hybrid Parallel Computing
计算机科学, 2020, 47(8): 5-16. https://doi.org/10.11896/jsjkx.200600045
[12] 冯凯, 李婧.
k元n方体的子网络可靠性研究
Study on Subnetwork Reliability of k-ary n-cubes
计算机科学, 2020, 47(7): 31-36. https://doi.org/10.11896/jsjkx.190700170
[13] 徐江峰谭玉龙.
基于机器学习的HBase配置参数优化研究
Research on HBase Configuration Parameter Optimization Based on Machine Learning
计算机科学, 2020, 47(6A): 474-479. https://doi.org/10.11896/JsJkx.190900046
[14] 吕小敬, 刘钊, 褚学森, 石树鹏, 孟虹松, 黄震春.
面向超大规模并行模拟的LBM计算流体力学软件
Extreme-scale Simulation Based LBM Computing Fluid Dynamics Simulations
计算机科学, 2020, 47(4): 13-17. https://doi.org/10.11896/jsjkx.191000010
[15] 杨宗霖, 李天瑞, 刘胜久, 殷成凤, 贾真, 珠杰.
基于Spark Streaming的流式并行文本校对
Streaming Parallel Text Proofreading Based on Spark Streaming
计算机科学, 2020, 47(4): 36-41. https://doi.org/10.11896/jsjkx.190300070
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!