matlab lbm 代码,Matlab实现格子玻尔兹曼方法(Lattice Boltzmann Method,LBM)模拟
%LBM的matlab代码
%Matlab实现格子玻尔兹曼方法(Lattice Boltzmann Method,LBM)模拟
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% cylinder.m: Flow around a cyliner, using LBM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
% You should have received a copy of the GNU General Public
% License along with this program; if not, write to the Free
% Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
% Boston, MA 02110-1301, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear
% GENERAL FLOW CONSTANTS
lx = 250;
ly = 51;
obst_x = lx/5+1; % position of the cylinder; (exact
obst_y = ly/2+1; % y-symmetry is avoided)
obst_r = ly/10+1; % radius of the cylinder
uMax = 0.02; % maximum velocity of Poiseuille inflow
Re = 100; % Reynolds number
nu = uMax * 2.*obst_r / Re; % kinematic viscosity
omega = 1. / (3*nu+1./2.); % relaxation parameter
maxT = 400000; % total number of iterations
tPlot = 5; % cycles
% D2Q9 LATTICE CONSTANTS
t = [4/9, 1/9,1/9,1/9,1/9, 1/36,1/36,1/36,1/36];
cx = [ 0, 1, 0, -1, 0, 1, -1, -1, 1];
cy = [ 0, 0, 1, 0, -1, 1, 1, -1, -1];
opp = [ 1, 4, 5, 2, 3, 8, 9, 6, 7];
col = [2:(ly-1)];
[y,x] = meshgrid(1:ly,1:lx);
obst = (x-obst_x).^2 + (y-obst_y).^2 <= obst_r.^2;
obst(:,[1,ly]) = 1;
bbRegion = find(obst);
% INITIAL CONDITION: (rho=0, u=0) ==> fIn(i) = t(i)
fIn = reshape( t' * ones(1,lx*ly), 9, lx, ly);
% MAIN LOOP (TIME CYCLES)
for cycle = 1:maxT
% MACROSCOPIC VARIABLES
rho = sum(fIn);
ux = reshape ( ...
(cx * reshape(fIn,9,lx*ly)), 1,lx,ly) ./rho;
uy = reshape ( ...
(cy * reshape(fIn,9,lx*ly)), 1,lx,ly) ./rho;
% MACROSCOPIC (DIRICHLET) BOUNDARY CONDITIONS
% Inlet: Poiseuille profile
L = ly-2; y = col-1.5;
ux(:,1,col) = 4 * uMax / (L*L) * (y.*L-y.*y);
uy(:,1,col) = 0;
rho(:,1,col) = 1 ./ (1-ux(:,1,col)) .* ( ...
sum(fIn([1,3,5],1,col)) + ...
2*sum(fIn([4,7,8],1,col)) );
% Outlet: Zero gradient on rho/ux
rho(:,lx,col) = rho(:,lx-1,col);
uy(:,lx,col) = 0;
ux(:,lx,col) = ux(:,lx-1,col);
% COLLISION STEP
for i=1:9
cu = 3*(cx(i)*ux+cy(i)*uy);
fEq(i,:,:) = rho .* t(i) .* ...
( 1 + cu + 1/2*(cu.*cu) ...
- 3/2*(ux.^2+uy.^2) );
fOut(i,:,:) = fIn(i,:,:) - ...
omega .* (fIn(i,:,:)-fEq(i,:,:));
end
% MICROSCOPIC BOUNDARY CONDITIONS
for i=1:9
% Left boundary
fOut(i,1,col) = fEq(i,1,col) + ...
18*t(i)*cx(i)*cy(i)* ( fIn(8,1,col) - ...
fIn(7,1,col)-fEq(8,1,col)+fEq(7,1,col) );
% Right boundary
fOut(i,lx,col) = fEq(i,lx,col) + ...
18*t(i)*cx(i)*cy(i)* ( fIn(6,lx,col) - ...
fIn(9,lx,col)-fEq(6,lx,col)+fEq(9,lx,col) );
% Bounce back region
fOut(i,bbRegion) = fIn(opp(i),bbRegion);
end
% STREAMING STEP
for i=1:9
fIn(i,:,:) = ...
circshift(fOut(i,:,:), [0,cx(i),cy(i)]);
end
% VISUALIZATION
if (mod(cycle,tPlot)==0)
u = reshape(sqrt(ux.^2+uy.^2),lx,ly);
u(bbRegion) = nan;
imagesc(u');
axis equal off; drawnow
end
end
matlab lbm 代码,Matlab实现格子玻尔兹曼方法(Lattice Boltzmann Method,LBM)模拟相关推荐
- matlab boltzmann函数,Matlab实现格子玻尔兹曼方法(Lattice Boltzmann Method,LBM)模拟
Matlab实现格子玻尔兹曼方法(Lattice Boltzmann Method,LBM)模拟 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % cylinder.m: Flow ...
- 格子玻尔兹曼流体代码_格子玻尔兹曼方法(LBM)学习:对流-扩散问题(附MATLAB代码)...
(๑❛ᴗ❛๑) 麻烦各位读者收藏之余点个喜欢或赞呢,咱也更有干劲了~ OrzSunspot:格子玻尔兹曼方法(LBM)学习:等温不可压缩流体流动问题(附MATLAB代码)zhuanlan.zhihu ...
- python可以应用lbm_格子玻尔兹曼方法(LBM)python程序提速
研究生开学已经两周了,一直在学习跟LBM相关的编程知识.由于自己数值传热学的基础不是太好,为了能够快速地融入到现有的工作当中我将工作重心侧重在了编程方面,而不是相关模型和边界条件等的学习.我的主要参考 ...
- 格子玻尔兹曼方法(LBM)的学习笔记1(附Couette流源代码及解析)
笔记目录 关于学习的教材及说明 在学习之前大致将流体力学学了一下包括一些概念的理解和重要的公式,在看这本<The Lattice Boltzmann Method Principles and ...
- [LBM方法学习笔记1】格子玻尔兹曼方法介绍
本人LBM方法小白,记录一下自己的学习过程,因为LBM方法的公式比较多,所以为手写贴图,后面会考虑整理. [参考书]: 1.<The Lattice Boltzmann Method>,之 ...
- python可以应用lbm_格子玻尔兹曼方法(LBM)Python 程序提速
众所周知,python是一门解释型语言,相比于C/C++等编译型语言程序运行的运行速度慢.在我使用python的日常中多半是编写数值模拟程序,程序主要结构就是一个for循环下面跟着各种各样的计算公式. ...
- 格子玻尔兹曼方法(LBM)计算中的无量纲化转化(将物理参数转化为格子参数)
说明:方法来自外文资料,主要通过无量纲方法进行LBM仿真计算中由实际物理量到格子物理量的转化,保证其一致性 已知量 物理长度尺寸HHH : 格子长度尺寸 (自定义)H~\tilde{H}H~: 密度ρ ...
- 格子玻尔兹曼在多孔介质孔隙尺度气泡输运调控中的应用和MATLAB仿真『需要数据和代码请先私信』
引言 格子玻尔兹曼方法(Lattice Boltzmann Method, LBM)是一种基于介观(mesoscopic)模拟尺度的计算流体力学方法.该方法相比于其他传统CFD计算方法,具有介于微观分 ...
- 格子玻尔兹曼法学习记录(附MATLAB画图源程序)
感谢群里的朋友们提供帮助!还是老样子,有啥问题Feel free to tell us~毕竟群众力量大嘛~格子玻尔兹曼救星QQ群:293267908. 流体计算领域中,LBM还是个比较新的思想,最近宝 ...
最新文章
- 150亿参数大杀器!Facebook开源机器翻译新模型,同传人员或失业
- zzz KVC/KVO原理详解及编程指南
- C#实验室常用软件-Windows Live Writer
- 2021湖南l高考成绩查询入口,湘潭2021高考成绩查询入口
- java servletlis_Java学习(六)servlet 的引入
- 校内网脱胎“人人”能成大器
- R语言重抽样与自助法
- 定制C/C++缩进风格
- 计算机论文研究思路怎么写,论文的研究思路怎么写
- 淘宝数据魔方技术架构解析【转】
- 【程序设计基础与实验】地铁售票查询系统
- 2021年P气瓶充装新版试题及P气瓶充装证考试
- 解决Spring文件下载时文件损毁问题
- STM32F7--->FMC(可变存储控制器) Flexible Memory Controller
- Android 将文本和图片写入到pdf文件以及读取手机里的pdf文件
- Linux 进行yum 安装是出现文件 conflicts 解决方法
- FXTZ 1.10 小爱使用
- 利用nid更改数据库的名称(OCM---OCP)
- 老衲与你一起走过。。。
- Golang基础链表