From fe04cbc6d88af1c384aa346e2faf8920d0e54158 Mon Sep 17 00:00:00 2001 From: Tridip Das Date: Wed, 6 May 2015 10:09:02 -0400 Subject: [PATCH] LBGK code for 2D pipe flow and pipe flow with a cylinder --- 2Dpipeflow_block.m | 117 +++++++++++++++++++++++++++++++++++++++++++++ pipe_flow_final.m | 106 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 223 insertions(+) create mode 100644 2Dpipeflow_block.m create mode 100644 pipe_flow_final.m diff --git a/2Dpipeflow_block.m b/2Dpipeflow_block.m new file mode 100644 index 0000000..f781e3d --- /dev/null +++ b/2Dpipeflow_block.m @@ -0,0 +1,117 @@ +% D2Q9 Lattice Boltzmann Bhatnagar-Gross-Krook (LBGK) +% Code developed by Tridip Das +clear all; +close all; +clc; +% assuming the flowing fluid as WATER +rho=1.0; % gm/cc density +mu = 1.0; % dynamic viscosity (cP) +mu = mu * 0.01; % g/(cm.s) +nu = mu/rho; % kinematic viscosity (cm^2/s) +del_x = 1; % grid spacing (cm) +del_t = 1; % time step (s) +b = 6; % vel of sound +D = 2; +d0 = 1/2; +tau = (1 + b*nu*(del_t/del_x)^2)/2; +w1=4/9; % weight factor for central component +w2=1/9; % weight factor for edge component +w3=1/36; % weight factor for diagonal component +c_squ=1/3; +% +nx=101; % grid points in x-direction +ny=61; % grid points in y-direction +% +F=repmat(rho/9,[nx ny 9]); % Initialize lattice +FEQ=F; % Initialize equilibriation point +meshsize=nx*ny; +CI=[0:meshsize:meshsize*7]; % Repeated for each 8 components +a=repmat(-30:30,[61 1]); % Define lattice points for cylinder +BOUND=(a.^2+a'.^2)<68; % Define cylinder as block +BOUND(1:nx,[1 ny])=1; % Block the wall boundary +ON=find(BOUND); %matrix offset of each Occupied Node +TO_REFLECT=[ON+CI(1) ON+CI(2) ON+CI(3) ON+CI(4) ... + ON+CI(5) ON+CI(6) ON+CI(7) ON+CI(8)]; +% No slip boundary condition +REFLECTED= [ON+CI(5) ON+CI(6) ON+CI(7) ON+CI(8) ... + ON+CI(1) ON+CI(2) ON+CI(3) ON+CI(4)]; +% Slip boundary condition +% REFLECTED= [ON+CI(3) ON+CI(4) ON+CI(5) ON+CI(6) ... +% ON+CI(7) ON+CI(8) ON+CI(1) ON+CI(2)]; +% +avg_u=1; +prev_avg_u=1; +time_steps=0; +deltaU=1e-4; % Velocity increament +num_active_nodes=sum(sum(1-BOUND)); +%% Time steps iteration loop +while (time_steps<10000 & 1e-5