# Importance of Initialization of distribution function, f

Hi every body,
I want to know how much initialization of distibution function, f, is important, especially in thermal modeling.
For example in the MATLAB code below, if we initialize “g” with zero, we will get completely different result in comparison with initialization of “g” with 1.

``````
tic;
clc; clear;
nx=100; ny=100; tstep=400;
t_in=1;
alpha=0.25; omegaT=1/(3*alpha+0.5);
w1=4/9; w2=1/9; w3=1/36; g=zeros(nx,ny,9); g_eq=g; densityT=0;

for ii=1:tstep

% Propegate (This part of code [propegate] is always constant for all LBM
% problems.)
g(:,:,4)=g([2:nx 1],[ny 1:ny-1],4); g(:,:,3)=g(:,[ny 1:ny-1],3);
g(:,:,2)=g([nx 1:nx-1],[ny 1:ny-1],2); g(:,:,5)=g([2:nx 1],:,5);
g(:,:,1)=g([nx 1:nx-1],:,1); g(:,:,6)=g([2:nx 1],[2:ny 1],6);
g(:,:,7)=g(:,[2:ny 1],7); g(:,:,8)=g([nx 1:nx-1],[2:ny 1],8);

% Boundary Conditions
%At i=1, T=1
g(1,:,1)=2*w2*t_in-g(1,:,5); g(1,:,2)=2*w3*t_in-g(1,:,6); g(1,:,8)=2*w3*t_in-g(1,:,4);
%At i=nx, T=0
g(nx,:,4)=-g(nx,:,8); g(nx,:,5)=-g(nx,:,1); g(nx,:,6)=-g(nx,:,2);
%At j=1, T=0
g(:,1,1)=g(:,2,1); g(:,1,2)=g(:,2,2); g(:,1,3)=g(:,2,3); g(:,1,4)=g(:,2,4);
g(:,1,5)=g(:,2,5); g(:,1,6)=g(:,2,6); g(:,1,7)=g(:,2,7); g(:,1,8)=g(:,2,8);
%At j=ny, T=0
g(:,ny,7)=-g(:,ny,3); g(:,ny,6)=-g(:,ny,2); g(:,ny,8)=-g(:,ny,4);

densityT=sum(g,3);

g_eq(:,:,1)=w2*densityT;
g_eq(:,:,3)=w2*densityT;
g_eq(:,:,5)=w2*densityT;
g_eq(:,:,7)=w2*densityT;

g_eq(:,:,2)=w3*densityT;
g_eq(:,:,4)=w3*densityT;
g_eq(:,:,6)=w3*densityT;
g_eq(:,:,8)=w3*densityT;

g_eq(:,:,9)=w1*densityT;

g=omegaT*g_eq+(1-omegaT)*g;

end

contour(densityT',20); colorbar;
toc;

``````