Report
Report
𝑚+1 𝑚 𝐶𝑖,𝑗 −𝐶𝑖−−1,𝑗 𝐶𝑖,𝑗 −𝐶𝑖,,𝑗−1 𝐶𝑖,+1,𝑗 −𝐶𝑖,𝑗 +𝐶𝑖−1,𝑗 𝐶𝑖,,𝑗+1 −𝐶𝑖,𝑗 +𝐶𝑖,𝑗−1
𝐶𝑖,𝑗 = 𝐶𝑖,𝑗 + ∆𝑡 (𝑢 +𝑣 +𝛤( + ))
∆𝑥 ∆𝑦 ∆𝑥 2 ∆𝑦 2
Where
• 𝑚+1
𝐶𝑖,𝑗 is the concentration at node (I,j) and time tn+1
• 𝑚
𝐶𝑖,𝑗 is the concentration at node (I,j) and time tn
• Δx and Δy are the grid spacings in the x and y directions respectively.
• Δt is the time step size.
• u and v are the velocities in the x and y directions respectively.
• Γ is the diffusion coefficient.
Handling Convective Term:
For the Convective term, we use a hybrid scheme:
𝑢∆𝑡 𝑣∆𝑡
• If the Peclet number Pex and Pey (defined as 𝑎𝑛𝑑 respectively) are both less than
∆𝑥 ∆𝑦
2, we use a central difference scheme.
• Otherwise, we use an upwind scheme.
Only perform the first iteration
Given advection diffusive equation
𝜕𝐶 𝜕𝐶 𝜕𝐶 𝜕2𝐶 𝜕2𝐶
+𝑢 +𝑣 = 𝛤 ( 2 + 2)
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦
Parameters
u=1.5; v=0; 𝛤=0.001
Step 1: Compute Convective term
We will compute |pe| and determine
𝑢∆𝑡
|pe| =
∆𝑥
Ly=1m; Lx=50m
𝐿𝑥 𝐿𝑦
∆𝑥 = ; ∆𝑦 =
𝑁𝑥 −1 𝑁𝑦 −1
Assume that
No. of grid along x =Nx=100
No. of grid along y=Ny=20
Time Step = ∆𝑡 = 0.1
50
∆𝑥 = = 0.5051
100 − 1
1
∆𝑥 = = 0.0526
20 − 1
Now
(1.5)(0.1)
|Pe| = = 0.297
0.5051
Since |Pe| < 2 we will use the central difference scheme for convective term
𝐶3,2 −𝐶1,2 𝐶2,3 −𝐶2,1
Convective term = 𝑢 +𝑣
2∆𝑥 2∆𝑦
MATLAB Code
function [C_final] = solve_advection_diffusion_task1(D, u, v, dx, dy, dt, Nx, Ny, Nt, cw0, cnL)
% Initialize concentration matrix
C = zeros(Nx, Ny, Nt);
% Time-stepping loop
for n = 1:Nt-1
% Internal nodes update (excluding boundary nodes)
C_temp = C(:,:,n);
for i = 2:Nx-1
for j = 2:Ny-1
% Convective term (hybrid scheme)
if abs(u) < 2 && abs(v) < 2
convective_x = u * (C_temp(i,j) - C_temp(i-1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j-1)) / dy;
else
convective_x = u * (C_temp(i,j) - C_temp(i+1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j+1)) / dy;
end
𝐶3,2 −𝐶1,2 𝐶 −𝐶
Convective term = (1.5) ( ) + (0) ( 2,3 2,1 )
2(0.5051) 2(0.0526)
1.5
= (𝐶3,2 − 𝐶1,2 )
1.0102
𝐶3,2 −2𝐶2,2 +𝐶1,2 𝐶2,3 −2𝐶2,2 +𝐶2,1
Diffusive term = 𝛤 ( + )
∆𝑥 2 ∆𝑦 2
1 1.5 𝐶3,2
𝐶2,2 =(0.1) ( (𝐶3,2 ) + 0.001 ( ))
1.0102 0.2552
1
𝐶2,2 =(0.1)((1.4848)(𝐶3,2 ) + 0.003915𝐶3,2 )
1
𝐶2,2 =(0.14848)(𝐶3,2 )
This is the complete first iteration with the provided boundary condition.
MATLAB Code
function [C_final] = solve_advection_diffusion_task2(D, u, v, dx, dy, dt, Nx, Ny, Nt, cw0, cnL)
% Initialize concentration matrix
C = zeros(Nx, Ny, Nt);
% Time-stepping loop
for n = 1:Nt-1
% Internal nodes update (excluding boundary nodes)
C_temp = C(:,:,n);
for i = 2:Nx-1
for j = 2:Ny-1
% Convective term (hybrid scheme)
if abs(Pe_x) < 2 && abs(Pe_y) < 2
convective_x = u * (C_temp(i,j) - C_temp(i-1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j-1)) / dy;
else
convective_x = u * (C_temp(i,j) - C_temp(i+1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j+1)) / dy;
end
% East Boundary (x = L)
% Neumann boundary condition: dC/dx = 0
C(Nx,:,n+1) = C(Nx-1,:,n+1);
% South Boundary (y = 0)
% Neumann boundary condition: dC/dy = 0 (implicit)
C(:,1,n+1) = C(:,2,n+1);
% North Boundary (y = H)
C(:,Ny,n+1) = cnL(1:Nx);
end
% Return final concentration
C_final = C(:,:,Nt);
end
% Define parameters
D = 0.01; % Diffusion coefficient
u = 1.5; % x-velocity
v = 0; % y-velocity
dx = 0.5051; % x-direction mesh size
dy = 0.0526; % y-direction mesh size
dt = 0.1; % time step size
Nx = 100; % Number of grid points in x-direction
Ny = 20; % Number of grid points in y-direction
Nt = 100; % Number of time steps
Results of TASK 2:
Task3: MATLAB Implementation
function [C_final] = solve_advection_diffusion_task3(dx, dy, dt, u, v, D)
% Define parameters
Lx = 50; % Length of the domain in the x-direction (m)
Ly = 1; % Length of the domain in the y-direction (m)
Nx = round(Lx / dx) + 1; % Number of grid points in x-direction
Ny = round(Ly / dy) + 1; % Number of grid points in y-direction
Nt = 100; % Number of time steps
% Initialize concentration matrix
C = zeros(Nx, Ny, Nt);
% Set initial condition
C(:,:,1) = zeros(Nx, Ny);
% Define boundary conditions
cw0 = @(y) zeros(size(y)); % West boundary condition function
cnL = @(x) 0.1 * (x / Lx); % North boundary condition function
% East Boundary (x = L)
% Neumann boundary condition: dC/dx = 0
C(Nx,:,n+1) = C(Nx-1,:,n+1);
% South Boundary (y = 0)
% Neumann boundary condition: dC/dy = 0 (implicit)
C(:,1,n+1) = C(:,2,n+1);
% Time-stepping loop
for n = 1:Nt-1
% Internal nodes update (excluding boundary nodes)
C_temp = C(:,:,n);
for i = 2:Nx-1
for j = 2:Ny-1
% Convective term (hybrid scheme)
if abs(Pe_x) < 2 && abs(Pe_y) < 2
convective_x = u * (C_temp(i,j) - C_temp(i-1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j-1)) / dy;
else
convective_x = u * (C_temp(i,j) - C_temp(i+1,j)) / dx;
convective_y = v * (C_temp(i,j) - C_temp(i,j+1)) / dy;
end
% East Boundary (x = L)
% Neumann boundary condition: dC/dx = 0
C(Nx,:,n+1) = C(Nx-1,:,n+1);
% South Boundary (y = 0)
% Neumann boundary condition: dC/dy = 0 (implicit)
C(:,1,n+1) = C(:,2,n+1);
% North Boundary (y = H)
C(:,Ny,n+1) = cnL(1:Nx);
end
• Mesh Size Sensitivity: We varied the mesh sizes (Δx and Δy) and observed their impact on the
concentration distribution at a specific time instant (e.g., t=50s). Changes in mesh sizes can affect
the spatial resolution of the solution and potentially influence the accuracy of the results.
• Time Step Size Sensitivity: Similarly, we varied the time step size (Δt) and analyzed its effect on
the concentration distribution at t=50s. Adjusting the time step size can influence the temporal
resolution of the solution and affect the stability and accuracy of the numerical simulation.
Discussion:
By analyzing the sensitivity of the results to changes in mesh sizes and time step sizes, we gain insights
into the numerical solution's robustness and accuracy. The discussion includes observations on how
different parameter settings impact the concentration distribution and recommendations for selecting
appropriate mesh and time step sizes to achieve accurate and efficient simulations. Additionally, we may
discuss potential limitations or challenges encountered during the sensitivity analysis and propose strategies
to address them.
During the sensitivity analysis of the advection-diffusion problem, we may encounter several limitations
and challenges:
• Computational Resources: Performing sensitivity analysis for different mesh sizes and time step
sizes can be computationally intensive, especially for large domains or fine resolutions. This may
require significant computational resources and time.
• Accuracy vs. Efficiency Trade-off: Using smaller mesh sizes and time step sizes generally
improves the accuracy of the numerical solution but increases computational cost. Finding the
optimal balance between accuracy and computational efficiency is crucial.
• Numerical Stability: As we vary the mesh sizes and time step sizes, the numerical scheme's
stability may be affected. Certain combinations of mesh sizes and time step sizes could lead to
unstable solutions, such as numerical oscillations or divergence. Ensuring numerical stability is
essential for obtaining reliable results.
• Convergence Issues: The iterative solver used to solve the discretized equations may encounter
convergence issues for certain combinations of mesh sizes and time step sizes. Convergence
problems can arise due to rapid changes in the solution or insufficient iterations.
To address these limitations and challenges, we can employ the following strategies:
Conclusion
In conclusion, the problem of advection-diffusion provides valuable insights into the behavior of a scalar
quantity transported by fluid flow and diffusive processes. Throughout the analysis, we tackled four main
tasks: