﻿{"id":3159,"date":"2023-12-16T20:42:15","date_gmt":"2023-12-16T12:42:15","guid":{"rendered":"http:\/\/81.70.49.155\/?p=3159"},"modified":"2023-12-16T20:45:32","modified_gmt":"2023-12-16T12:45:32","slug":"3%e5%9c%a8%e9%80%9a%e9%81%93%e6%b5%81%e5%9f%ba%e7%a1%80%e4%b8%8a%e6%94%b9%e6%88%90%e5%9c%86%e6%9f%b1%e7%bb%95%e6%b5%81matlab%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"http:\/\/81.70.49.155\/?p=3159","title":{"rendered":"[LBM-3]\u5728\u901a\u9053\u6d41\u57fa\u7840\u4e0a\u6539\u6210\u5706\u67f1\u7ed5\u6d41MATLAB\u4ee3\u7801"},"content":{"rendered":"<p>\n\t<br \/>\n%<span style=\"color:#E53333;\">\u7ea2\u8272<\/span>\u4ee3\u7801\u4e3a\u589e\u52a0\u4ee3\u7801\uff1b<strong><span style=\"background-color:#99BB00;\">\u7eff\u5e95<\/span><\/strong>\u4e3a\u5c4f\u853d\u7684\u4ee3\u7801\n<\/p>\n<p>\n\t%\u521d\u59cb\u5316\n<\/p>\n<p><span>clc; clear; close;&nbsp;&nbsp;<\/span><br \/>\n<span style=\"background-color:#99BB00;\">% lx=25;&nbsp; ly=9;&nbsp; &nbsp;<\/span><br \/>\n<span style=\"background-color:#99BB00;\">% Re=1.25;<\/span><br \/>\n<span style=\"background-color:#99BB00;\">% yu=0.1;<\/span><br \/>\n<span style=\"background-color:#99BB00;\">% fx0=Re*8*yu^2\/(ly-1)^3;&nbsp; &nbsp;<\/span><\/p>\n<p>lx=400;&nbsp; ly=81;&nbsp;<\/p>\n<p><span style=\"color:#E53333;\">%\u6784\u5efa\u58c1\u9762\u53ca\u5706\u67f1\u533a\u57df<\/span><br \/>\n<span style=\"color:#E53333;\">Bound=zeros(lx,ly);<\/span><br \/>\n<span style=\"color:#E53333;\">Bound(:,[1,ly])=1;<\/span><br \/>\n<span style=\"color:#E53333;\">xc=lx\/4;&nbsp; yc=ly\/2;&nbsp; &nbsp;Rc=6;<\/span><br \/>\n<span style=\"color:#E53333;\">for i=floor(xc)-7:floor(xc)+7<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; for j=floor(yc)-7:floor(yc)+7<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ((i-xc)^2+(j-yc)^2)^0.5&lt;=Rc<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Bound(i,j)=1;<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; end<\/span><br \/>\n<span style=\"color:#E53333;\">end<\/span><\/p>\n<p><span style=\"color:#E53333;\">Bin=[]; BFin0=[]; BFin=[];<\/span><br \/>\n<span style=\"color:#E53333;\">opposite=[1,4,5,2,3,8,9,6,7];<\/span><br \/>\n<span style=\"color:#E53333;\">for i=1:lx<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; for j=1:ly<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp;if Bound(i,j)==1<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Bin=[Bin,i+lx*(j-1)];<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for k=1:9<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BFin=[BFin,(i+lx*(j-1))+(opposite(k)-1)*lx*ly];<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BFin0=[BFin0,(i+lx*(j-1))+(k-1)*lx*ly];<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end&nbsp;<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; &nbsp; &nbsp; end<\/span><br \/>\n<span style=\"color:#E53333;\">&nbsp; &nbsp; end<\/span><br \/>\n<span style=\"color:#E53333;\">end<\/span><\/p>\n<p><span style=\"color:#E53333;\">Re=100;<\/span><br \/>\n<span style=\"color:#E53333;\">Uin=0.1;<\/span><br \/>\n<span style=\"color:#E53333;\">yu=2*Rc*Uin\/Re;<\/span><br \/>\n<span style=\"color:#E53333;\">fx0=0;&nbsp; &nbsp;<\/span><br \/>\nW=[4\/9,1\/9,1\/9,1\/9,1\/9,1\/36,1\/36,1\/36,1\/36];<br \/>\nex=[0, 1, 0, -1, 0&nbsp; 1,-1, -1, 1];<br \/>\ney=[0, 0, 1, 0, -1, 1, 1, -1,-1];<br \/>\ncs=1\/sqrt(3);<\/p>\n<p>rho=ones(lx,ly);<br \/>\nu=zeros(lx,ly);<br \/>\nv=zeros(lx,ly);<br \/>\nfx=zeros(lx,ly)+fx0;<br \/>\nfy=zeros(lx,ly);<br \/>\nM1=W(1)*rho; M2=W(2)*rho; M3=W(6)*rho;<br \/>\nF= cat(3,M1,M2,M2,M2,M2,M3,M3,M3,M3);<br \/>\nFeq=F;<\/p>\n<p>%\u8fc1\u79fb\u4e0b\u6807<br \/>\nD2x=[lx,1:lx-1]; D2y=[1:ly];<br \/>\nD3x=[1:lx];&nbsp; &nbsp; &nbsp; D3y=[ly,1:ly-1];<br \/>\nD4x=[2:lx,1];&nbsp; &nbsp; D4y=[1:ly];<br \/>\nD5x=[1:lx];&nbsp; &nbsp; &nbsp; D5y=[2:ly,1];<br \/>\nD6x=[lx,1:lx-1]; D6y=[ly,1:ly-1];<br \/>\nD7x=[2:lx,1];&nbsp; &nbsp; D7y=[ly,1:ly-1];<br \/>\nD8x=[2:lx,1];&nbsp; &nbsp; D8y=[2:ly,1];<br \/>\nD9x=[lx,1:lx-1]; D9y=[2:ly,1];<\/p>\n<p>%% \u4e3b\u5faa\u73af===========================================<br \/>\nfor tStep=1:15000<br \/>\n% \u8fc1\u79fb<br \/>\nF0(:,:,1)=F(:,:,1);<br \/>\nF0(:,:,2)=F(D2x,D2y,2);<br \/>\nF0(:,:,3)=F(D3x,D3y,3);<br \/>\nF0(:,:,4)=F(D4x,D4y,4);<br \/>\nF0(:,:,5)=F(D5x,D5y,5);<br \/>\nF0(:,:,6)=F(D6x,D6y,6);<br \/>\nF0(:,:,7)=F(D7x,D7y,7);<br \/>\nF0(:,:,8)=F(D8x,D8y,8);<br \/>\nF0(:,:,9)=F(D9x,D9y,9);<br \/>\nF=F0;<\/p>\n<p>%\u8ba1\u7b97\u5b8f\u89c2\u91cf<br \/>\nrho=sum(F,3);<br \/>\nu=(sum(F(:,:,[2,6,9]),3)-sum(F(:,:,[4,7,8]),3)).\/rho+fx\/2.\/rho;<br \/>\nv=(sum(F(:,:,[3,6,7]),3)-sum(F(:,:,[5,8,9]),3)).\/rho+fy\/2.\/rho;<\/p>\n<p>%\u8bbe\u7f6e\u5b8f\u89c2\u8fb9\u754c<br \/>\nrho(:,1)=rho(:,2);&nbsp; &nbsp; &nbsp; &nbsp;%\u4e0b\u58c1\u9762<br \/>\nrho(:,ly)=rho(:,ly-1);&nbsp; &nbsp;%\u4e0a\u58c1\u9762<br \/>\n<span style=\"color:#E53333;\">u(Bin)=0;&nbsp; v(Bin)=0;&nbsp; &nbsp; &nbsp;%\u6240\u6709\u56fa\u4f53<\/span><\/p>\n<p><span style=\"color:#E53333;\">rho(1,:)=rho(2,:);&nbsp; &nbsp; &nbsp; &nbsp; %\u5165\u53e3<\/span><br \/>\n<span style=\"color:#E53333;\">u(1,:)=Uin;&nbsp; v(1,:)=0;&nbsp; &nbsp; %<\/span><\/p>\n<p><span style=\"color:#E53333;\">rho(lx,:)=rho(lx-1,:);&nbsp; &nbsp; %\u51fa\u53e3<\/span><br \/>\n<span style=\"color:#E53333;\">u(lx,:)=u(lx-1,:);&nbsp; v(lx,:)=v(lx-1,:);<\/span><\/p>\n<p>%\u8ba1\u7b97\u5e73\u8861\u6001\u51fd\u6570<br \/>\nfor i=1:9<br \/>\n&nbsp; &nbsp; &nbsp;M1=(ex(i)*u+ey(i)*v)\/cs^2;<br \/>\n&nbsp; &nbsp; &nbsp;M2=M1.^2\/2;<br \/>\n&nbsp; &nbsp; &nbsp;M3=(u.^2+v.^2)\/2\/cs^2;<br \/>\n&nbsp; &nbsp; &nbsp;Feq(:,:,i)=rho.*W(i).*(1+M1+M2-M3);<br \/>\nend<\/p>\n<p>%\u78b0\u649e<br \/>\nfor i=1:9<br \/>\n&nbsp; &nbsp; M1=3*(ex(i)-u).*fx+(ey(i)-v).*fy;<br \/>\n&nbsp; &nbsp; M2=9*(ex(i)*u+ey(i)*v).*(ex(i).*fx+ey(i).*fy);<br \/>\n&nbsp; &nbsp; force(:,:,i)=W(i)*(1-0.5\/(0.5+3*yu))*(M1+M2);<br \/>\nend<br \/>\n&nbsp; &nbsp; F=F-1\/(0.5+3*yu)*(F-Feq)+force;<br \/>\n&nbsp; &nbsp;&nbsp;<br \/>\n%\u5fae\u89c2\u8fb9\u754c\u8bbe\u7f6e<br \/>\n<span style=\"color:#E53333;\">F(BFin0)=F(BFin); %\u534a\u6b65\u53cd\u5f39\u64cd\u4f5c<\/span><br \/>\n<span style=\"color:#E53333;\">F(1,:,:)=Feq(1,:,:)+(F(2,:,:)-Feq(2,:,:));<\/span><br \/>\n<span style=\"color:#E53333;\">F(lx,:,:)=Feq(lx,:,:)+(F(lx-1,:,:)-Feq(lx-1,:,:));<\/span><br \/>\n<span style=\"background-color:#99BB00;\">% F(:,[1,ly],:)=F(:,[1,ly],opposite);<\/span><br \/>\n% F(:,1,:)=Feq(:,1,:)+(F(:,2,:)-Feq(:,2,:));<br \/>\n% F(:,ly,:)=Feq(:,ly,:)+(F(:,ly-1,:)-Feq(:,ly-1,:));<\/p>\n<p>%\u540e\u5904\u7406<br \/>\nif mod(tStep,100)==0<br \/>\nclc;clf<br \/>\ntStep<br \/>\nU=(u.^2+v.^2).^0.5;<br \/>\nsubplot(1,2,1),imagesc(U');<br \/>\ncolormap jet<br \/>\naxis equal<br \/>\ncy=(ly-1)\/2;<br \/>\ny0=fx0\/2\/yu*(cy.^2-([0:ly-1]-cy).^2);<br \/>\nNi=floor(lx\/2);<br \/>\nsubplot(1,2,2),hold on,plot(y0,'k'),plot(u(Ni,:),'r'); hold off<br \/>\ndrawnow<br \/>\nend<\/p>\n<p>end&nbsp; % \u4e3b\u5faa\u73af\u7ed3\u675f============================<\/p>\n","protected":false},"excerpt":{"rendered":"<p>%\u7ea2\u8272\u4ee3\u7801\u4e3a\u589e\u52a0\u4ee3\u7801\uff1b\u7eff\u5e95\u4e3a\u5c4f\u853d\u7684\u4ee3\u7801 %\u521d\u59cb\u5316 clc; clear; close;&nbsp;&nbsp; &hellip; <a href=\"http:\/\/81.70.49.155\/?p=3159\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c[LBM-3]\u5728\u901a\u9053\u6d41\u57fa\u7840\u4e0a\u6539\u6210\u5706\u67f1\u7ed5\u6d41MATLAB\u4ee3\u7801\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"views":1599,"_links":{"self":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/3159"}],"collection":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3159"}],"version-history":[{"count":3,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/3159\/revisions"}],"predecessor-version":[{"id":3166,"href":"http:\/\/81.70.49.155\/index.php?rest_route=\/wp\/v2\/posts\/3159\/revisions\/3166"}],"wp:attachment":[{"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3159"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/81.70.49.155\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}