[m10_1_1]Explicit form solution of T.

%This program complished the process of 2D Eulerian advection with method
%of allocating memory temporarily.
clear all;clf;
% Set parameters
Nt = 1;
output_interval = 1;
Lx = 1000000; 
Ly = 1500000;
x_midd = Lx/2;
y_midd = Ly/2;
Nx = 51; 
Ny = 31; 
k = 3;%W/(m*K)
den = 3200;%Kg/m^3
Cp = 1000;%J/(Kg*K)
bt = 1000;%K,background temperature
wt = 1300;%K,wave temperature
Nx1 = Nx+1;
Ny1 = Ny+1;
dx = Lx / (Nx-1);
dy = Ly / (Ny-1);
% Basic E-nodes.
x = 0:dx:Lx;
y = 0:dy:Ly;
[X,Y] = meshgrid(0:dx:Lx,0:dy:Ly);
T = zeros(Ny,Nx);
% Initialize temperature matrix.
for j=1:1:Nx
    for i=1:1:Ny
        T(i,j) = bt;
        if ( x(j)<=x_midd+100000 && x(j)>=x_midd-100000 && y(i)<=y_midd+150000 && y(i)>=y_midd-150000)
            T(i,j) = wt;
        end
    end
end
td = k/(den*Cp);
dt = min(dx^2,dy^2)/(4*td);

figure(1);
colormap('Jet');
mesh(X,Y,T);
xlabel('Horizontal(m)')
ylabel('Vertical(m)')
set(gca,'xaxislocation','top');
set (gca,'YDir','reverse')
shading interp;
colorbar
title(['T after 0 deltat'])
pause(0.01);

for t = 1:Nt
    % Explicit
    for j = 2:Nx-1
        for i = 2:Ny-1
            T(i,j) = T(i,j) + td*dt*( ( T(i,j-1)-2*T(i,j)+T(i,j+1) )/(dx^2)+...
                              ( T(i-1,j)-2*T(i,j)+T(i+1,j) )/(dy^2)  );
        end
    end
    % Constant temperature boundary condition.
    % T_bc = constant = 1000
    T(1,:) = 1000;
    T(Ny,:) = 1000;
    T(:,1) = 1000;
    T(:,Nx) = 1000;
    
    figure(2);
    colormap('Jet');
    mesh(X,Y,T);
    xlabel('Horizontal(m)')
    ylabel('Vertical(m)')
    set(gca,'xaxislocation','top');
    set (gca,'YDir','reverse')
    shading interp;
    colorbar
    title(['Explicit form solution of T after ',num2str(t-1),' deltat(CTbc)'])
    pause(0.01);
    % Insulating boundary condition.
    % T1(boundary) = T2(internal)
    T(1,:) = T(2,:);
    T(Ny,:) = T(Ny-1,:);
    T(:,1) = T(:,2);
    T(:,Nx) = T(:,Nx-1);
    
    figure(3);
    colormap('Jet');
    mesh(X,Y,T);
    xlabel('Horizontal(m)')
    ylabel('Vertical(m)')
    set(gca,'xaxislocation','top');
    set (gca,'YDir','reverse')
    shading interp;
    colorbar
    title(['Explicit form solution of T after ',num2str(t-1),' deltat(Ibc)'])
    pause(0.01);    
end

[m10_1_1]Explicit form solution of T._第1张图片

 [m10_1_1]Explicit form solution of T._第2张图片

 [m10_1_1]Explicit form solution of T._第3张图片

 

你可能感兴趣的:(2D-stokes,Possion,Explicit,form)