注册 登录
流体中文网 返回首页

子沫筝的个人空间 http://www.cfluid.com/?147932 [收藏] [复制] [分享] [RSS]

日志

LBM多孔介质python代码

已有 349 次阅读2018-10-25 20:25 |个人分类:LBM|系统分类:学术

#!/usr/bin/python
from palabos import *
nx, ny, nz = 100, 50, 50
tau  = 0.6
lattice = Block3D(nx,ny,nz, D3Q19, BGK(omega=1/tau))
pout.display( lattice[10,10,10].getPopulations() )
lattice[10,10,10].initializeAtEquilibrium(1.1, [0.,0.,0.])
lattice.collideAndStream()
for i in range(1,100):
  lattice.collideAndStream()
imShow(lattice[:,:,nz/2].velocityNorm())
lattice[10:30,10:30,10:30].defineDynamics(BounceBack(1.))
dir(lattice)
help(lattice.defineDynamics)
for i in range(1,100):
  lattice.collideAndStream()
imShow(lattice[:,:,nz/2].velocityNorm())
lattice.defineDynamics(BGK(omega=1./tau))
x,y,z = lattice.meshGrid()
media = (x−10)**2 + (y−10)**2 + (z−10)**2 < 10**2
pout.isoSurface(media, [1.])
nobst = 30
r  = 8
for cx,cy,cz in zip(rand_int(nobst,nx), rand_int(nobst,ny), rand_int(nobst,nz)):
  pout.display(’Sphere at position’, cx, cy, cz)
  media += (x−cx)**2 + (y−cy)**2 + (z−cz)**2 < r**2
pout.isoSurface(media>0, [1.])
boundary.regularized().definePressureBC(lattice[0,:,:])
lattice[0,:,:].setBoundaryDensity(1.02)
boundary.regularized().definePressureBC(lattice[nx−1,:,:])
lattice[nx−1,:,:].setBoundaryDensity(1.)
lattice[media>0].defineDynamics(BounceBack(1.))
for i in range(1,200):
  lattice.collideAndStream()
imShow(lattice[:,:,20].velocityNorm())
pout.display( lattice[media==0][nx/2,:,:].velocityComponent(0).average() )
pout.imagesc( [ lattice.velocity().strainRate().symmetricTensorNorm()[:,:,20],
  lattice.strainRateFromStress().symmetricTensorNorm()[:,:,20] ] )

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

返回顶部