Advertisement
fellpz

Exemplo 1. Equação de Laplace

Nov 30th, 2017
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.21 KB | None | 0 0
  1. %IFPB 30/11/2017 - METODO DAS DIFERENÇAS FINITAS
  2. %EQUACAO DE LAPLACE COM CONDICOES DE CONTORNO DE DIRICHLET
  3.  
  4. close all, clear all, clc;
  5. % malha computacional bidimensional
  6. p = 100; q = 100; %linhaXcoluna
  7. %condicoes de contorno
  8. V = zeros (p,q);
  9. V(1,:) = 100; V(q,:) = 100;
  10. %equacao de diferencas
  11. for iter = 1:1000
  12.     for i = 2:p-1
  13.         for j = 2:q-1
  14.             V(i,j) = 0.25*(V(i+1,j)+V(i-1,j)+V(i,j+1)+V(i,j-1));
  15.         end
  16.     end
  17. end
  18.  
  19. %saida grafica
  20. ss = get(0,  'ScreenSize');
  21. fig1 = figure(1); ax = axes;
  22. set(fig1, 'Position',ss,'Color',[1 1 1]);
  23. set(ax, 'FontName', 'Verdana', 'FontSize', 16)
  24. mesh(V)
  25. label(1) = xlabel('x');
  26. label(2) = ylabel('y');
  27. label(3) = zlabel('V(x,y)');
  28. label(4) = title('Equacao de Laplace: Vxx - Vyy = 0');
  29. label(5) = legend('Diferencas Finitas',1);
  30. set(label,'FontSize',16);
  31. drawnow,pause(1)
  32.  
  33. fig2 = figure(2); %linhas equipotenciais
  34. set(fig2,'Position',ss,'Color',[1 1 1]);
  35. [cs,h] = contour(V);
  36. clabel(cs,h,'FontSize',15,'Color','k','Rotation',0)
  37. label(1) = xlabel('x');
  38. label(2) = ylabel('y');
  39. label(3) = zlabel('u(x,y)');
  40. label(4) = title('Equacao de Laplace: Vxx - Vyy = 0');
  41. label(5) = legend('Diferencas Finitas',1);
  42. set(label,'FontSize',16);
  43. drawnow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement