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.

Slides:



Advertisements
Similar presentations
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Advertisements

A Few More LBM Boundary Conditions. Key paper: Zou, Q. and X. He, 1997, On pressure and velocity boundary conditions for the lattice Boltzmann BGK model,
Vector: Data Layout Vector: x[n] P processors Assume n = r * p
Dynamics of a four-bar linkage
Main Index Contents 11 Main Index Contents Week 6 – Binary Trees.
Conservation Vector Review Mass Balance General Statement Simplifications The Control Volume A Useable Form Problems.
1 AC Nodal and Mesh Analysis Discussion D11.1 Chapter 4 4/10/2006.
2D case: If or then 2 or 3D cases: Several dimensions: U(x,y,z) Compact notation using vector del, or nabla: Another notation: Partial derivative is.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
Hw: All Chapter 4 problems and exercises Chapter 5: Pr. 1-4; Ex. 1,2 Reading: Chapter 4.
Approximation of u
Impulse Momentum 1 Conservation. Impulse Momentum 2 The simplicity of momentum The astronaut has greater mass and slower velocity The wrench has less.
MA/CS471 Lecture 8 Fall 2003 Prof. Tim Warburton
computer
EE421, Fall 1998 Michigan Technological University Timothy J. Schulz 24-Sept, 1998EE421, Lecture 51 Lecture 5: Block Processing for FIR Filters l Block.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Lab 4 – Accelerated Motion Lab
Multicomponent Multiphase LB Models Multi- Component Multiphase Miscible Fluids/Diffusion (No Interaction) Immiscible Fluids Single Component Multiphase.
1 Discretizing the Boundary Conditions of the Gulf of Mexico Project Rich Affalter Math 1110 February 18, 2001.
Working with Arrays in MATLAB
Духовні символи Голосіївського району
Chapter 2 Matter. Chemical Change: – Produce gas – Produce heat/light – Produce precipitate Physical Properties – Density – BP – FP.
Midterm-Review GLY Basic Fluid Dynamics Momentum p = mv F = dp/dt = m dv/dt.
Motion Detection Frame 1Frame 2 Anomalous activity.
13.1 Sequences. Definition of a Sequence 2, 5, 8, 11, 14, …, 3n-1, … A sequence is a list. A sequence is a function whose domain is the set of natural.
Arrays (Chapter 5)‏ Definition Applications One-Dimensional –Declaration –Initialization –Use Multidimensional.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Acceleration. Definition Any change in velocity is acceleration What are the possible causes of acceleration? Speeding up Slowing down Changing direction.
Magnetic Helicity in Emerging Active Regions: A Statistical Study
PRODUCT MOMENTS OF BIVARIATE RANDOM VARIABLES
A Few More LBM Boundary Conditions
Sisgbee2b / Data Release
Physics definitions.
Even/Odd Functions 5.5.
Computing the velocity field
محاسبات عددی و برنامه نویسی
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.
Implementing our backward order final equation
FINITE ELEMENT METHOD (INTRODUCTION)
Chapter2 Creating Arrays
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
FINITE ELEMENT METHOD (INTRODUCTION)

Physics Chapter 6 Equilibrium.
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Presentation transcript:

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.

Define velocity vectors 1 2 3 4 5 6 7 8 D2Q9 e1 e2 e3 e4 e5 e6 e7 e8 %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 In MATLAB, can write ex(0+1)=0, ex(1+1)=1, etc.

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 LY LX % if ~is_interior_solid_node(j,i)

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;

// Computing macroscopic density, rho, and velocity, u=(ux,uy). for( j=0; j<LY; j++) { for( i=0; i<LX; i++) u_x[j][i] = 0.0; u_y[j][i] = 0.0; rho[j][i] = 0.0; if( !is_solid_node[j][i]) for( a=0; a<9; a++) rho[j][i] += f[j][i][a]; u_x[j][i] += ex[a]*f[j][i][a]; u_y[j][i] += ey[a]*f[j][i][a]; } u_x[j][i] /= rho[j][i]; u_y[j][i] /= rho[j][i];

Periodic Boundaries On boundary, ‘neighboring’ point is on opposite boundary ip = ( i<LX-1)?( i+1):( 0 ); in = ( i>0 )?( i-1):( LX-1); jp = ( j<LY-1)?( j+1):( 0 ); jn = ( j>0 )?( j-1):( LY-1); where LHS = (COND)?(TRUE_RHS):(FALSE_RHS); means if( COND) { LHS=TRUE_RHS;} else{ LHS=FALSE_RHS;}

// Compute the equilibrium distribution function, feq. for( j=0; j<LY; j++) { for( i=0; i<LX; i++) if( !is_solid_node[j][i]) rt0 = (4./9. )*rhoij; rt1 = (1./9. )*rhoij; rt2 = (1./36.)*rhoij; ueqxij = uxij; //Can add forcing here; see MATLAB code ueqyij = uyij; uxsq = ueqxij * ueqxij; uysq = ueqyij * ueqyij; uxuy5 = ueqxij + ueqyij; uxuy6 = -ueqxij + ueqyij; uxuy7 = -ueqxij + -ueqyij; uxuy8 = ueqxij + -ueqyij; usq = uxsq + uysq;

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); }

Collide // Collision step. for( j=0; j<LY; j++) for( i=0; i<LX; i++) if( !is_solid_node[j][i]) for( a=0; a<9; a++) { fij[a] = fij[a] + ( fij[a] - feqij[a])/tau; }

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

Two type of solids:

Bounceback Boundaries

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;

// Streaming step. for( j=0; j<LY; j++) { jn = (j>0 )?(j-1):(LY-1) jp = (j<LY-1)?(j+1):(0 ) for( i=0; i<LX; i++) if( !is_interior_solid_node[j][i]) in = (i>0 )?(i-1):(LX-1) ip = (i<LX-1)?(i+1):(0 ) ftemp[j ][i ][0] = f[j][i][0]; ftemp[j ][ip][1] = f[j][i][1]; ftemp[jp][i ][2] = f[j][i][2]; ftemp[j ][in][3] = f[j][i][3]; ftemp[jn][i ][4] = f[j][i][4]; ftemp[jp][ip][5] = f[j][i][5]; ftemp[jp][in][6] = f[j][i][6]; ftemp[jn][in][7] = f[j][i][7]; ftemp[jn][ip][8] = f[j][i][8]; }

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