0% found this document useful (0 votes)
48 views11 pages

EDP Parabolica e Hiperbolica

This document contains 4 numerical problems solved using MATLAB to discretize and solve partial differential equations. The first problem solves a 1D parabolic PDE using an explicit finite difference method. The second problem solves a 1D hyperbolic PDE for different values of a parameter. The third problem extends this to 2D using an implicit method. The fourth problem solves the 1D wave equation. Discretization details and code are provided for each problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views11 pages

EDP Parabolica e Hiperbolica

This document contains 4 numerical problems solved using MATLAB to discretize and solve partial differential equations. The first problem solves a 1D parabolic PDE using an explicit finite difference method. The second problem solves a 1D hyperbolic PDE for different values of a parameter. The third problem extends this to 2D using an implicit method. The fourth problem solves the 1D wave equation. Discretization details and code are provided for each problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

UNIVERSIDAD NACIONAL MAYOR DE SAN

MARCOS

FACULTAD DE CIENCIAS FÍSICAS

ESCUELA ACADÉMICO PROFESIONAL DE


INGENIERÍA MECÁNICA DE FLUIDOS

Métodos Numéricos II

Tema: EDP Parabólica e Hiperbólica

Alumno: Guevara Loayza Victor Luis

Docente: Ing. William Wilfredo Chauca Nolasco

Fecha: 26 de Julio del 2020


%Problema 4
clear all; close all; clc;
%Datos de Entrada
L = 10; dx = 1; Tmax = 100; dt = 0.005;
k = 0.15; D = 100; U = 1;
%Grillado
nx = L/dx + 1; X = 0:dx:L;
nt = Tmax/dt + 1;
%Condiciones Iniciales
C(1:nx,1:nt) = 0;
C(1,:) = 100;
A = D*(dt/(dx^2));
B = U*(dt/(2*dx));
%Discretizacion
AA = zeros(nx-2,nx-2);
BB = zeros(nx-2,1);
for t = 1:nt-1
for i = 1:nx-2
AA(i,i) = 2*A + 1;
if i<nx-2
AA(i,i+1) = -(A-B);
AA(i+1,i) = -(A+B);
end
BB(i,1) = (1-k)*C(i+1,t);
end
BB(1,1) = BB(1,1) +(A+B)*C(1,t);
BB(nx-2,1) = BB(nx-2,1);
m = AA;
n = BB;
[x]=gauss(m,n);
C(2:nx-1,t+1) = x';
if t+1==nt
break
end
end
%Grafica
plot(X,C(:,t-1))
title('Problema 1')
xlabel('X')
ylabel('C')
Codigo MATLAB:
%Problema 2
clear all; close all; clc;
%Datos de Entrada
L = 1; nx = 10; Tmax = 0.1; nt = 11;
b = 4;%[4 2 0 -2 -4];%se puede poner solo 1 valor a la vez
nb = length(b);
%Grillado
dx = L/(nx-1); X = 0:dx:L;
dt = Tmax/(nt-1);
%Condiciones Iniciales
U(1:nx,1:nt) = 0;
U(1,:) = 0; U(nx,:) = 1; U(2:nx-1,1)=0;
for j = 1:nb
K = b(j)*(dt/dx); c = dt/(dx^2);
%Discretizacion
AA = zeros(nx-2,nx-2);
BB = zeros(nx-2,1);
for t =1:nt-1
for i = 1:nx-2
AA(i,i) = 2*(c+1);
AA(i,i+1) = -c;
AA(i+1,i) = -c;
BB(i,1) = (c - K)*U(i,t) + 2*(1-c)*U(i+1,t) + (c +
K)*U(i+2,t);
end
BB(1,1) = BB(1,1) + c*U(1,t+1);
BB(nx-2,1) = BB(nx-2,1) + c*U(nx,t+1);
m = AA;
n = BB;
[x]=gauss(m,n);
U(2:nx-1,t+1) = x';
if t+1==nt
break
end
end
%Grafica
plot(X,U(:,t))
hold on
title('Problema 2')
xlabel('X')
ylabel('U')
end
legend('b = 4','b = 2','b = 0','b = -2','b = -4')
Codigo MATLAB:
%Problema 3
clear all; close all; clc;
%Datos de Entrada
X = 40; dx = 10; Y = 40; dy = 10;
Tmax = 1*60*60; dt = 10; k = 0.8357;
%Grillado
nx = X/dx + 1; ny = Y/dy + 1; nt = Tmax/dt +1;
h = k*(dt/(dx^2));
%Condiciones Iniciales
T(1:nx,1:ny,1:nt) = 0; T(:,1,:) = 5; T(:,ny,:) = 200;
T(1,:,:) = 30; T(nx,:,:) = 80; Q(:,:,:) = T(:,:,:);
%Discretizacion
AA = zeros(nx-2,nx-2);
BB = zeros(nx-2,1);
for t = 1:nt
for i = 1:nx-2
for j = 1:nx-2
AA(j,j) = 2*(1+h);
if j<nx-2
AA(j,j+1) = -h;
AA(j+1,j) = -h;
end
BB(j,1) = h*T(i,j+1,t) + 2*(1-h)*T(i+1,j+1,t) +
h*T(i+2,j+1,t);
end
BB(1,1) = BB(1,1) + h*T(i+1,1,t);
BB(nx-2,1) = BB(nx-2,1) + h*T(i+1,ny,t);
m = AA;
n = BB;
[x]=gauss(m,n);
Q(i+1,2:ny-1,t+1) = x';
if t+1==nt
break
end

end
for j = 1:ny-2
for i = 1:nx-2
AA(i,i) = 2*(1+h);
if j<nx-2
AA(j,j+1) = -h;
AA(j+1,j) = -h;
end
BB(i,1) = h*Q(i+1,j,t) + 2*(1-h)*Q(i+1,j+1,t) +
h*Q(i+1,j+2,t);
end
BB(1,1) = BB(1,1) + h*Q(1,j+1,t+1);
BB(nx-2,1) = BB(nx-2,1) + h*Q(nx,j+1,t+1);
m = AA;
n = BB;
[x]=gauss(m,n);
T(2:nx-1,j+1,t+1) = x';
if t+1==nt
break
end

end
end
disp(T(:,:,t-1))
Codigo MATLAB
%Problema 4
clear all; close all; clc;
%Datos de Entrada
L = 1; nx = 11; Tmax = 1; nt = 101;
c = 1; %c^2= 1;
%Grillado
dx = L/(nx-1); x = 0:dx:L;
dt = Tmax/(nt-1);
K = c*((dt^2)/(dx^2));
%Condiciones Iniciales
y(1:nx,1:nt) = 0;
for i = 2:nx-1
y(i,1) = sin(pi*(i-1)*dx);
y(i,2) = y(i,1) + dt*2*pi*sin(2*pi*(i-1)*dx);
end
y(1,:) = 0; y(nx,:) = 0;
%Discretizacion
for t = 2:nt
for i = 2:nx-1
y(i,t) = 2*y(i,t) - y(i,t-1) + K*(y(i+1,t) + y(i-1,t) -
2*y(i+1,t));
end
end
%Grafica
plot(x,y(:,t))
title('Problema 4')
xlabel('X')
ylabel('Temperatura')

You might also like