注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mr.Right

不顾一切的去想,于是我们有了梦想。脚踏实地的去做,于是梦想成了现实。

 
 
 

日志

 
 
关于我

人生一年又一年,只要每年都有所积累,有所成长,都有那么一次自己认为满意的花开时刻就好。即使一时不顺,也要敞开胸怀。生命的荣枯并不是简单的重复,一时的得失不是成败的尺度。花开不是荣耀,而是一个美丽的结束,花谢也不是耻辱,而是一个低调的开始。

网易考拉推荐

Matlab program for plotting some static electric fields and potentials  

2012-09-17 21:02:46|  分类: 编程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
% cylinder streamlines from Smythe formulas
% in uniform electric field
% K is the relative dielectric constant
clear
a=.5;  % inner radius
b=1;  % outer radius
E=1;  % field strength
dx=.025;
x=[-2:dx:2];
y=x;
[X,Y]=meshgrid(x,y);
rho=sqrt(X.^2+Y.^2)+1e-6;
phi=atan2(Y,X+1e-6);
% coordinates of the cylinders
pc=[0:1:360]*pi/180;
xa=a*cos(pc); ya=a*sin(pc);
xb=b*cos(pc); yb=b*sin(pc);
% case 1: CONDUCTING CYLINDER of radius b, K=1
K=1;
den=(K+1)*b^2+(K-1)*a^2;
A1=E*b^2*((K+1)*a^2+(K-1)*b^2)/den;  
B1=2*E*b^2/den;
C1=-2*E*a^2*b^2/den;
for ix=1:length(x)
  for iy=1:length(y)
     V(ix,iy)=0;
     if rho(ix,iy) > b
      V(ix,iy)=E*(rho(ix,iy)-a^2/rho(ix,iy))*cos(phi(ix,iy)); 
     end
  end
end
Vdb=20*log10(abs(V)+1e-6);
figure(1),clf
subplot(121)
plot(xb,yb,'r-'),hold on
axis([min(x),max(x),min(y),max(y)])
contour(X,Y,Vdb,[0,-10,-20,-30,-40,-50])
xlabel('x'),ylabel('y')
axis square
title('Potential (dB contours)')
hold off
subplot(122)
plot(xb,yb,'r-'),hold on
[Ex,Ey]=gradient(V);
Lines=[min(y):.5:max(y)];
Start=min(x)*ones(size(Lines));
h=streamline((stream2(X,Y,Ex,Ey,Start,Lines))); hold on
h=streamline((stream2(X,Y,-Ex,-Ey,-Start,Lines)));
set(h, 'Color', 'blue');
axis([min(x),max(x),min(y),max(y)])
axis square
title('Electric Field Lines')
xlabel('x'),ylabel('y')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% case 2: DIELECTRIC CYLINDER of radius b, K=5
K=5;
A1=-E*b^2*(K-1)/(K+1);  
B1=2*E/(K+1);
C1=0;
for ix=1:length(x)
  for iy=1:length(y)
     rr=rho(ix,iy);
     if rr>b
         V(ix,iy)=E*(rr+A1/rr)*cos(phi(ix,iy));
     end
     if rho(ix,iy)<=b
        % V(ix,iy)=(B1*rr+C1/rr)*cos(phi(ix,iy));
         V(ix,iy)=2*E*rr*cos(phi(ix,iy))/(K+1);
     end
  end
end
Vdb=20*log10(abs(V)+1e-6);
figure(2),clf
subplot(121)
plot(xb,yb,'r-'),hold on
axis([min(x),max(x),min(y),max(y)])
contour(X,Y,Vdb,[0,-10,-20,-30,-40,-50])
xlabel('x'),ylabel('y')
axis square
title('Potential (dB contours)')
hold off
subplot(122)
plot(xb,yb,'r-'),hold on
[Ex,Ey]=gradient(V);
Lines=[min(y):.5:max(y)];
Start=min(x)*ones(size(Lines));
%h=streamline(X,Y,Ex,Ey,Start,Lines);
h=streamline(stream2(X,Y,Ex,Ey,Start,Lines));
set(h, 'Color', 'blue');
axis([min(x),max(x),min(y),max(y)])
axis square
title('Electric Field Lines')
xlabel('x'),ylabel('y')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% case 3: DIELECTRIC COATED CONDUCTNING CYLINDER, K=5
a=.5;
b=1;
den=(K+1)*b^2+(K-1)*a^2;
A1=-E*b^2*((K+1)*a^2+(K-1)*b^2)/den;  
B1=2*E*b^2/den;
C1=-2*E*a^2*b^2/den;
for ix=1:length(x)
  for iy=1:length(y)
     rr=rho(ix,iy); 
     V(ix,iy)=0;
     if rr>b 
         V(ix,iy)=E*(rr+A1/rr)*cos(phi(ix,iy));
     end
     if rho(ix,iy)<=b & rr>a
        V(ix,iy)=(B1*rr+C1/rr)*cos(phi(ix,iy));
     end
  end
end
Vdb=20*log10(abs(V)+1e-6);
figure(3),clf
subplot(121)
plot(xb,yb,'r-',xa,ya,'r-'),hold on
axis([min(x),max(x),min(y),max(y)])
contour(X,Y,Vdb,[0,-10,-20,-30,-40,-50])
xlabel('x'),ylabel('y')
axis square
title('Potential (dB contours)')
hold off
subplot(122)
plot(xb,yb,'r-',xa,ya,'r-'),hold on
[Ex,Ey]=gradient(V);
Lines=[min(y):.5:max(y)];
Start=min(x)*ones(size(Lines));
h=streamline((stream2(X,Y,Ex,Ey,Start,Lines))); hold on
h=streamline((stream2(X,Y,-Ex,-Ey,-Start,Lines)));
set(h, 'Color', 'blue');
axis([min(x),max(x),min(y),max(y)])
axis square
title('Electric Field Lines')
xlabel('x'),ylabel('y')

  评论这张
 
阅读(394)| 评论(1)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016