Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc;
- clear;
- //coeficientes
- TD = 10;
- TE = 40;
- TINI = 25;
- L=1;
- alpha = 40*10^(-6);
- celulas = 200;
- dt = 20;
- dx = L/celulas;
- S = (alpha*dt)/(dx*dx);
- B=0.7;
- Tnova(1) = TE;
- Tnova(celulas) = TD;
- Tvelha(1)= TE;
- Tvelha(celulas)= TD;
- t=0;
- tmax=20;
- totalit=0;
- tolerancia=0.000000001;
- for i=2:(celulas-1)
- Tnova(i)=TINI;
- Tvelha(i)=TINI;
- end;
- while(t<tmax)
- for totalit=0:1
- erro=-1;
- for i=2:(celulas-1)
- Taux=((S*B*(Tnova(i-1)+Tnova(i+1))+S*(1-B)*(Tvelha(i+1)+Tvelha(i-1)+Tvelha(i)+2*S*(1-B)*Tvelha(i))))/(1+(2*S*B))
- disp (Taux)
- break;
- erro=max(erro,abs(Taux-Tnova(i)));
- Tnova(i) = Taux;
- end;
- if (erro<tolerancia) then
- break;
- end;
- for i=1:(celulas)
- Tvelha(i)=Tnova(i);
- end;
- end;
- t=t+dt;
- end;
- disp(Tnova);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement