Advertisement
Guest User

tpo élec

a guest
Mar 19th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.87 KB | None | 0 0
  1. % Programme sphere : calcule
  2. % le champ electrique cree par la matiere
  3. % polarisee.
  4.  
  5. % Universite Paul Sabatier
  6. % Licence de Physique UL5, TD numeriques, 2003-2004
  7. % Version 08/02/2004 LK
  8.  
  9. % -------------- Initialisation ------------------
  10. clear all;
  11. clf reset
  12.  
  13. nom='DOMENECH FOURCAULT';
  14.  
  15. % -------------- constantes ----------------------
  16. C = 299792458;                  % Vitesse de la lumi�re
  17. us4pe0 = C*C*1E-7;               % 1 sur (4 PI epsilon0) = C^2 10^-7
  18.  
  19. r0= 0.5E-9;             % Rayon de la sphere
  20. a=  0.5*10^(-10);          % Decalage entre les pseudo sph�res
  21. borne = 2*10^(-9);           % limite (en m) de la zone de calcul
  22.  
  23. q = 5 * 1.6E-19;        % Charge
  24. q1=  q;
  25. q2= -q;
  26.  
  27. % ------ Definition de la grille de travail ------
  28. ymin= -borne;
  29. ymax=  borne;
  30. ny=500;
  31. ypas=(ymax-ymin)/(ny-1);
  32.  
  33. zmin= -borne;
  34. zmax=  borne;
  35. nz=500;
  36. zpas=(zmax-zmin)/(nz-1);
  37.  
  38. % -------------- Calcul du potentiel -------------
  39. for ly=1:ny
  40. for lz=1:nz
  41.     y(ly)=ymin+(ly-1)*ypas;
  42.     z(lz)=zmin+(lz-1)*zpas;
  43.  
  44.     % --------- calcul "spheres decalees" --------
  45.     r1=sqrt(y(ly).^2 + (z(lz)-a/2).^2);
  46.     if r1 > r0
  47.         V1(lz,ly)= -q*us4pe0/(r1);
  48.     elseif r1 <= r0
  49.         V1(lz, ly)= -q*us4pe0*(r1^2)/(r0^3);
  50.     end
  51.  
  52.     r2=sqrt(y(ly).^2 + (z(lz)+a/2).^2);
  53.     if r2 > r0  
  54.         V2(lz, ly)= q*us4pe0/(r2);
  55.     elseif r2 <= r0
  56.         V2(lz, ly)= q*us4pe0*(r2^2)/(r0^3);
  57.     end
  58.     V(lz, ly) = V1(lz,ly) + V2(lz,ly);
  59.  
  60.     % --------- calcul "approche dipole" ---------
  61.     r = sqrt(y(ly)^2+z(lz)^2);
  62.     if r > r0
  63.         Vap(lz,ly)= q*us4pe0*(1/r1 - 1/r2);
  64.         elseif r<= r0
  65.         Vap(lz,ly)= q*us4pe0*a*z(lz)/(r0^3);
  66.     end
  67. end
  68. end
  69.  
  70. % --------------- Partie graphique  --------------
  71. hold on
  72. mini= min(V)*100;
  73. maxi= max(V)*100;
  74. pas= abs((maxi-mini)/40);
  75.  
  76. v = mini:pas:maxi;
  77.  
  78. C=contour(y,z,V,v);
  79. C=contour(y,z,Vap,v,'--');
  80. xlabel('y')
  81. ylabel('z')
  82. title=[nom]
  83. clabel(C, 'manual');
  84. hold off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement