a new title
For this projest , we have solved the steadu and unsteady state using both explicit and implicit schemes.
The implicit schemes are unconditionally stable and tend to give the same solution even eith the change in CFL number.
The explicit schemes on the other hand are conditionally stable and tend to become unstable at higher value of CFL number. The CFL number increases with decrease in grid size or with incrase in the step size dt.
Stable solution:-
Case 1 :-
This figure represents a stable solution for the parametres.
C=0.050
dt = 0.01
Case 2:-
This figure represents a stable solution for the parametres.
C=0.50
dt = 1
Unstable Solution:-
Case 1 :-
This figure represents an unstable solution for the parametres.
C=0.5050
dt = 1.01
Case 2 :-
This figure represents an unstable solution for the parametres.
C=1.0050
dt = 2.01
It can be inferred from the above plots that the solution tends to become unstable for a value of C> 0.5 . The solution is stable within the mentioned limits.
So in order to make the stable we need to use a coarse mesh or we could also use smaller timesteps.
clear all;close all;clc;l=1;N=51;dx=(l)/(N-1);dy=(l)/(N-1);x=linspace(0,l,N);y=linspace(0,l,N);dt=1.01;tol=1e-4;alpha=1e-4;t=1;% Defining the temperaturesT_r=800;T_l=400;T_b=900;T_t=600;T=298*ones(N,N);T(:,N)=T_r;T(:,1)=T_l;T(N,:)=T_t;T(1,:)=T_b;% Temperature at cornersT(1,1) = 0.5*(T_b+T_l);T(1,end) = 0.5*(T_b+T_r);T(end,1) = 0.5*(T_l+T_t);T(end,end) = 0.5*(T_r+T_t);a=(alpha*dt)/dx^2;b=(alpha*dt)/dy^2;C=a+b;T_old=T;iter=1;tic;for k=1:20000; for i=2:N-1 for j=2:N-1 T(i,j)=T_old(i,j)+a*(T_old(i+1,j)-2*T_old(i,j)+T_old(i-1,j))+b*(T_old(i,j+1)-2*T_old(i,j)+T_old(i,j-1)); end end T_old=T; iter=iter+1;endtime_taken=toc;[X,Y]=meshgrid(x,y);contourf(X,Y,T,'ShowText','on');colorbar;colormap(jet);xlabel('x');ylabel('y');title('Temperature distribution using explicit method');