• 青锋
    了解作者
  • matlab
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 25
    下载次数
  • 2017-01-07 16:44
    上传日期
求解二维Couette流动的LBM方法,速度模型是D2Q9
Couette_flow.rar
  • Couette_flow.m
    1.5KB
内容介绍
%Couette_flow clear;clc;close all global cx cy w m n cx=[0,1,0,-1,0,1,-1,-1,1]; cy=[0,0,1,0,-1,1,1,-1,-1]; w=[4/9,1/9,1/9,1/9,1/9,1/36,1/36,1/36,1/36]; lx=81;ly=51; m=lx;n=ly; nu = 1; % kinematic viscosity omega = 1. / (3*nu+1./2.); % relaxation parameter maxT = 30000; % total number of iterations u=zeros(m,n);v=zeros(m,n);rho=ones(m,n); U=-0.1; u(:,n)=U; fin=eqdf(u,v,rho); acc=0.0002; tic for cycle=1:maxT f_eq=eqdf(u,v,rho); % Collesion fout=omega*f_eq+(1-omega)*fin; for i=1:9; %fout(:,:,i)=fout(:,:,i)+ 3*w(i)*(cx(i)*acc*rho); % LGA方式 Fi=((cx(i)-u)*acc+(cy(i)-v)*0).*f_eq(:,:,i)*(1-omega/2)*3; % He_Shan_Doolen方式 fout(:,2:n-1,i)=fout(:,2:n-1,i)+Fi(:,2:n-1); end % Streaming for k=1:9 fin(:,:,k)=circshift(fout(:,:,k),[cx(k),cy(k)]); end % top 速度边界上(2:m-1,n) v_top=0.0;u_top=U; rho_top=(sum(fin(2:m-1,n,[1 2 4]),3)+2*sum(fin(2:m-1,n,[3 6 7]),3))./(1+v_top); fin(2:m-1,n,5)=fin(2:m-1,n,3)-2*rho_top.*v_top; fin(2:m-1,n,8)=fin(2:m-1,n,6)+0.5*(fin(2:m-1,n,2)-fin(2:m-1,n,4))-rho_top*v_top/6-rho_top*u_top/2; fin(2:m-1,n,9)=fin(2:m-1,n,7)-0.5*(fin(2:m-1,n,2)-fin(2:m-1,n,4))-rho_top*v_top/6+rho_top*u_top/2; fin(:,1,[ 3 6 7])=fin(:,1,[5 8 9]); % Macro Var rho=sum(fin,3); u=reshape(cx*(reshape(fin,[m*n 9]))',m,n)./rho+0.5*acc; v=reshape(cy*(reshape(fin,[m*n 9]))',m,n)./rho; u(:,n)=U; if mod(cycle,10)==0 plot(u'); drawnow toc end end
评论
  • TYP.R 2020-08-20 23:37:22
    未定义函数或变量 'eqdf'。
相关推荐