Code Implimentation
Code Implimentation
DTy=DTx;
Length (m)
Y=ymax;
dt1=1/(U/dx+2*DTx/(dx^2));
dt2=(1/U)*(2*DTx+dx);
dt4=(1/V)*(2*DTy+dy);
Courant number
Crx=U*(dt/dx)
Cry=V*(dt/dy)
Diffusive parameter
deltay=DTy*(dt/(dy)^2)
Peclet number
Pex=Crx/deltax;
Pey=Cry/deltay;
Ini al concentra on
C0=1; % g/L
C=zeros(nx,ny,nt);
1:(nx0-1) will iterate for the x form 1 up to the last node which means xCo/dx+1
1:(ny0-1) will iterate for the y form 1 up to the last node which means yCo/dx+1
C(1,1,1)=1
C(2,1,1)=1
C(3,1,1)=1
C(4,1,1)=1
Sets all the matrix where the loop points out to Co=1
plot(y,C(1,:,1)) % Concentra on only along y Plots the concentra on values along the
y-axis at the first x-axis loca on and at the first me step.
tle("Concentra on along y for ini al condi on at t=0s") Sets the tle of the plot
xlim([0 xmax])
xlabel("x (m)")
ylim([0 C0])
ylabel("C (g/L)")
A=deltax(δx);
B=deltay(δy);
D=deltax(δx)+Crx;
E=deltay(δy)+Cry;
F=1-2*deltax-2*deltay-Crx-Cry;
Temporal loop
for k = 1:(nt-1)
end
In the above code when we get to the func on calling the func on carries the arguments or parameters
and will be jumping or going to the func on created.
color
colorbar it provides a key for interpre ng the colors in terms of the data
values they represent.
subplot(4,1,2)
contourf(C(:,:,44)')
tle('t=15s')
colorbar
clim([0 C0])
subplot(4,1,3)
contourf(C(:,:,87)')
tle('t=30s')
colorbar
clim([0 C0])
subplot(4,1,4)
contourf(C(:,:,145)')
tle('t=50s')
xlabel("along x")
ylabel("along y")
colorbar
clim([0 C0])
figure(4)
contourf(C(:,:,nt)')
tle('t=70s')
xlabel("along x")
ylabel("along y")
colorbar
clim([0 C0])
figure (5)
xlim([0 xmax])
xlabel("x (m)")
ylim([0 C0])
ylabel("C (g/L)")
Fr=U/sqrt(9.81*Y);
Define the specific y-coordinate
Extract concentra on data for all x and t at y = 10, and all y and t at x = 10
end
checks if the number of rows in concentra onSliceY is equal to the number of elements in x. Similarly,
size(concentra onSliceY, 2) ~= length(t) checks if the number of columns in concentra onSliceY equals
the number of elements in t.
Transposing concentra onSliceY swaps its rows and columns, ensuring the first dimension aligns with x
and the second with t.
end
% Contour plot for y = 10 (all x over me)
figure(9);
colorbar;
xlabel('x-coordinate');
ylabel('Time');
clim([0 C0])
figure(10);
colorbar;
xlabel('Time');
ylabel('y-coordinate');
clim([0 C0])
% Func on to update the concentra on matrix
for i = 2:(nx-1)
for j = 2:(ny-1)
E * C(i,j-1) + F * C(i,j);
End
end
End