-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeamwarming.m
45 lines (40 loc) · 1.45 KB
/
beamwarming.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function [y5] = beamwarming(deltaT,tempo,aux,deltaX,cinj,cini,newVet,oldVet,u,divEspaco,vetorEspaco,deltaTMAX)
tic
TempoProcessamento = 0;
%Courant = u*(deltaT/deltaX);
%Courant = 0.9;
while aux < tempo
if (aux>tempo/2)
cini = cinj;
end
newVet(1) = oldVet(1) - ((deltaT/deltaX)*(u*2*(oldVet(1)-cini)));
newVet(2) = oldVet(2) - ((deltaT/deltaX)*(u*2*(oldVet(2)-cini)));
for j = 3:divEspaco-1
newVet(j) = oldVet(j) - u*(deltaT/(2*deltaX))*(3*oldVet(j) - 4*oldVet(j-1)+ oldVet(j-2)) + ((u^2)*(deltaT^2))/(2*deltaX^2)*(oldVet(j)-2*oldVet(j-1)+oldVet(j-2))
end
oldVet=newVet;
aux = aux + deltaT;
newVet(divEspaco) = oldVet(divEspaco) - (deltaT/deltaX) *(u*(oldVet(divEspaco) - oldVet(divEspaco-1))); %Contorno Direito
end
for k =1:divEspaco
y5(k) = newVet(k);
end
plot(vetorEspaco, newVet,'g');
title("Equação de Advecção-Difusão BEAMWARMING");
grid on
hold on
texto_anotacao = sprintf('DeltaT: %.3f\nDeltaTMAX: %.3f', deltaT, deltaTMAX);
annotation('textbox',[0.63,0.2,0.2,0.7] ,'String',texto_anotacao,'FitBoxToText','on');
xlabel("Lx");
ylabel("Concentração");
%Plot sem anotacao para varios graficos (Necessario ir mudando a cor
%manualmente e os parametros no arquivo novaEntradaDados.m manualmente
%e comentar o plot de cima
% plot(vetorEspaco, newVet,'g');
% title("Equação de Advecção-Difusão BEAMWARMING");
% grid on
% hold on
% xlabel("Lx");
% ylabel("Concentração");
TempoProcessamento = toc
end