Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % IFPB 07/12/2017 - MÉTODO DAS DIFERENÇAS FINITAS
- % EXEMPLO 03: EQUAÇÕES DE LAPLACE COM CONDIÇÕES DE CONTORNO DE DIRICHLET
- % LINHA DE MICROFITA SOBRE SUBSTRATO DIELÉTRICO
- close all, clear all, clc;
- n=100; r=10; a=40; b=60; V=100;
- p=n; q=n; x=1:n; y=x; h=1; e1=1; e2=12;
- %condicoes de contorno
- u=zeros(p,q);
- u(r,a:b)=V;
- for iter=1:1000
- for i=2:p-1
- for j=2:q-1
- if i==r & j>=a & j<=b, u(r,j)=V;
- elseif i==r
- u(i,j)=(e1/(2*(e1+e2)))*u(i+1,j)+(e2/(2*(e1+e2)))*u(i-1,j)+0.25*(u(i,j-1)+u(i,j+1));
- else
- u(i,j)=0.25*(u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1));
- end
- end
- end
- end
- %SAIDA GRAFICA
- %DISTRIBUICAO DE POTENCIAL 3D
- ss=get(0,'ScreenSize');
- fig1=figure(1)
- set(fig1,'Position',ss,'Color',[1 1 1]);
- mesh(u), colormap(jet), colorbar
- label(1)=xlabel('x');
- label(2)=ylabel('y');
- label(3)=zlabel('u(x,y)');
- label(4)=title('Equacao de Laplace: uxx - uyy = 0');
- label(5)=legend('Diferencas Finitas',1);
- set(label,'FontSize',16);
- drawnow,pause(1)
- %LINHAS EQUIPOTENCIAIS E DISTRIBUICAO DO CAMPO ELETRICO
- fig2=figure(2);set(fig2,'Position',ss,'Color',[1 1 1]);
- [x1,y1]=meshgrid(x,y);
- [px,py]=gradient(u,h,h/2);
- [c,h]=contour(x1,y1,u,[0.1:0.1:0.7]*V),cl=clabel(c,h);set(cl,'FontSize',14);
- colorbar; set(h,'Linewidth',2.5);
- hold on, s=1:2:n;
- g=quiver(x(s),y(s),-px(s,s),-py(s,s),0.7,'k-');
- hold off, set(g,'ShowArrowHead','on')
- label(1)=xlabel('x');
- label(2)=ylabel('y');
- label(3)=title('Equacao de Laplace: uxx + uyy = 0');
- label(4)=legend('Diferencas Finitas',1);
- set(label,'FontSize',16); axis([30 70 0 20])
- l(1)=line([40 60],[10 10]);
- l(2)=line([0 100],[0 0]);
- set(l,'Linewidth',5);
- drawnow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement