Análise de métodos númericos
(Figure 1 – Application of the code shown in Question 1)
(Figure 2 – Periodic advection using scheme (a))
(Figure 3 – Periodic advection using scheme (b))
(Figure 4 – Periodic advection using scheme (c))
(Figure 5 – Eigenvalues for the schemes (a), (b) and (c))
(Figure 6 – Periodic Burger’s Equation using scheme (a))
(Figure 7 – Periodic Burger’s Equation using scheme (b))
(Figure 8 – Periodic Burger’s Equation using scheme (c))
(Figure 9 – Periodic heat equation using scheme (a))
(Figure 10 – Periodic heat equation using scheme (b))
(Figure 11 – Periodic heat equation using scheme (c))
(Figure 12 – Eigenvalues for the schemes (a), (b) and (c) for second derivative)
(Figure 13 – Periodic backwards heat equation using scheme (a))
(Figure 14 – Periodic backwards heat equation using scheme (b))
(Figure 15 – Periodic backwards heat equation using scheme (c))
* CODES:
* General codes:
- Second Order Central Scheme
function C = Central2(Nx,dx,PeriodicFlag)
%
% [C] = Central2(Nx,dx,PriodicFlag)
%
% Return the matrix for the 1-2-1 Central second order FD scheme on a grid
% of Nx points with equal spacing dx.
%
% INPUTS:
%
% PeriodicFlag = 1 = TRUE;
% PeriodicFlag = 0 = FALSE;
%
% OUTPUTS:
% C = B fprintf(1,'Using 2nd-order central '); V1 = ones([1,Nx-1]);
V2 = ones([1,Nx-2]);
V3 = ones([1,Nx-3]); B = (-diag(V1,-1)+diag(V1,1))/(2*dx); if (PeriodicFlag == 0) % boundary terms fprintf(1,'bounded.\n'); B(1,:) = [-1 1 0*V2]/dx; B(Nx,:) = [0*V2 -1 1]/dx; else fprintf(1,'periodic.\n'); B(1,:) = [0 1 0*V3 -1]/(2*dx); B(Nx,:) = [1 0*V3 -1 0]/(2*dx); end C = B; return;
- Fourth Order Central Scheme:
function C = Central4(Nx,dx,PeriodicFlag)
%
% [C] = Central4(Nx,dx,PriodicFlag)
%
% Return the matrix for the Central fourth order FD scheme on a grid
% of Nx points with equal spacing dx.
%
% INPUTS:
%
%