Download presentation

Presentation is loading. Please wait.

Published byOrion Lovell Modified about 1 year ago

1
Building an LBM Model The following is a mixture of MATLAB and C. Care must be taken, because array indexing begins at 1 in MATLAB and at 0 in C.

2
Define velocity vectors In MATLAB, can write ex(0+1)=0, ex(1+1)=1, etc. 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 D2Q9 e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 e7e7 e8e8 %define es ex(0)= 0; ey(0)= 0 ex(1)= 1; ey(1)= 0 ex(2)= 0; ey(2)= 1 ex(3)=-1; ey(3)= 0 ex(4)= 0; ey(4)=-1 ex(5)= 1; ey(5)= 1 ex(6)=-1; ey(6)= 1 ex(7)=-1; ey(7)=-1 ex(8)= 1; ey(8)=-1

3
Problem definition LY=10 LX=20 tau = 1 g=0.00001 %set solid nodes is_solid_node=zeros(LY,LX) for i=1:LX is_solid_node(1,i)=1 is_solid_node(LY,i)=1 end LX LY % if ~is_interior_solid_node(j,i)

4
Initialize density and fs (assuming zero velocity) %define initial density and fs rho=ones(LY,LX); f(:,:,1) = (4./9. ).*rho; f(:,:,2) = (1./9. ).*rho; f(:,:,3) = (1./9. ).*rho; f(:,:,4) = (1./9. ).*rho; f(:,:,5) = (1./9. ).*rho; f(:,:,6) = (1./36.).*rho; f(:,:,7) = (1./36.).*rho; f(:,:,8) = (1./36.).*rho; f(:,:,9) = (1./36.).*rho;

5
// Computing macroscopic density, rho, and velocity, u=(ux,uy). for( j=0; j

6

7
Periodic Boundaries On boundary, ‘neighboring’ point is on opposite boundary ip = ( i

8
// Compute the equilibrium distribution function, feq. f1=3.; f2=9./2.; f3=3./2.; for( j=0; j

9
feqij[0] = rt0*( 1. - f3*usq); feqij[1] = rt1*( 1. + f1*ueqxij + f2*uxsq - f3*usq); feqij[2] = rt1*( 1. + f1*ueqyij + f2*uysq - f3*usq); feqij[3] = rt1*( 1. - f1*ueqxij + f2*uxsq - f3*usq); feqij[4] = rt1*( 1. - f1*ueqyij + f2*uysq - f3*usq); feqij[5] = rt2*( 1. + f1*uxuy5 + f2*uxuy5*uxuy5 - f3*usq); feqij[6] = rt2*( 1. + f1*uxuy6 + f2*uxuy6*uxuy6 - f3*usq); feqij[7] = rt2*( 1. + f1*uxuy7 + f2*uxuy7*uxuy7 - f3*usq); feqij[8] = rt2*( 1. + f1*uxuy8 + f2*uxuy8*uxuy8 - f3*usq); }

10
// Collision step. for( j=0; j

11
Bounceback Boundaries Bounceback boundaries are particularly simple Played a major role in making LBM popular among modelers interested in simulating fluids in domains characterized by complex geometries such as those found in porous media Their beauty is that one simply needs to designate a particular node as a solid obstacle and no special programming treatment is required

12
Two type of solids:

13
Bounceback Boundaries

14
Collision (solid nodes): Bounceback // Standard bounceback. temp = fij[1]; fij[1] = fij[3]; fij[3] = temp; temp = fij[2]; fij[2] = fij[4]; fij[4] = temp; temp = fij[5]; fij[5] = fij[7]; fij[7] = temp; temp = fij[6]; fij[6] = fij[8]; fij[8] = temp;

15
// Streaming step. for( j=0; j

16
Incorporating Forcing (gravity) Gravitational acceleration is incorporated in a velocity term ueqxij = u_x(j,i)+tau*g; %add forcing

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google