the code print -inf in TT matrix. Please anyone helps
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
clear all
close all
clc
%Geometry definition
L=0.3;                      %Length of the The rectangular bar in meter 
W=0.4;                      %Width of the The rectangular bar in meter
%Material properties 
alpha=11.234E-05;            %theraml diffusivity
% computional details
i_max=31;                   %max divisions in x-direction        
j_max=41;                   %max divisions in y-direction 
req_error=0.01;             %total variation condition in temp           
delta_t=1;                  %time step 
delta_x=L/(i_max-1);        %Divisons in x-direction  
delta_y=W/(j_max-1);        %Divisons in y-direction  
d=alpha*delta_t/(delta_x)^2;%Defining stability condition 
%Solution initializing 
T=zeros(i_max,j_max);
% Boundary conditions
T(:,1)=40;
T(:,j_max)=10;
TT=T;
%processing 
error_mag=1;
iterations=0;
while error_mag > req_error
 for i=2:(i_max-1)
        for j=(2:j_max-1)
            TT(i,j)=T(i,j)+d*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1)-4*T(i,j));
        end
 end 
    iterations=iterations+1;
    error_mag = 0;
    for i=2:(i_max-1)
          for j=2:(j_max-1)
              error_mag =error_mag +abs(T(i,j)-TT(i,j)); %defining the total variance to calcualte the  difference  in temperature from one time level to the next 
              error_track(iterations)= error_mag;
          end 
    end 
    if rem(iterations,1000)==0
        iterations
        error_mag
    end 
    T=TT;
end 
%plottting the solution
solution_x=linspace(0,0.3,7);
solution_y=linspace(0,0.4,41);
T_final = T(1:5:i_max,:);
[X,Y] = meshgrid(solution_x,solution_y);
T_1_ss=T(11,:);
%figure(1);
%contourf(X,Y,T_final.')
%colorbar
%colormap(jet)
title('Steady state Solution of FTCS Explicit scheme ')
xlabel('L')
ylabel('W')
figure(2);
plot(solution_y,T_1_ss)
title('Steady stateSolution of FTCS Explicit scheme')
xlabel('Y')
ylabel('Temperature')
0 comentarios
Respuestas (1)
  Torsten
      
      
 el 3 de Dic. de 2022
        Your value of 1 for delta_t violates the CFL condition for stability of the explicit Euler scheme.
Choose a value that satisfies CFL.
0 comentarios
Ver también
Categorías
				Más información sobre Annotations en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!