Contents
clc;
clear all;
close all;
Nz=51;
Ny=51;
S=12;
N=(S+1)*4;
N4=N/4;
a=S/2;
I=3;
u0=1;
Xc(1:N4)=-a:1:a;
Xc(N4+1:2*N4)=a;
Xc(2*N4+1:3*N4)=a:-1:-a;
Xc(3*N4+1:N)=-a;
Yc(1:13)=-a;
Yc(14:26)=-a:1:a;
Yc(27:39)=a;
Yc(40:52)=a:-1:-a;
yp(1:51)=-25:1:25;
zp(1:51)=0:1:50;
Y(1:Ny,1:Nz)=0;
Z(1:Ny,1:Nz)=0;
for i=1:Ny
Y(i,:)=yp(i);
end
for i=1:Nz
Z(:,i)=zp(i);
end
calculate R-vector from the loop(X-Y plane)to Y-Z plane.
for A=1:Ny
for B=1:Nz
for i=1:N-1
Rx(i)=-0.5*(Xc(i)+Xc(i+1));
Ry(i)=(Y(A,B)-(0.5*(Yc(i)+Yc(i+1))));
Rz(i)=Z(A,B);
dlx(i)=Xc(i+1)-Xc(i);
dly(i)=Yc(i+1)-Yc(i);
end
Rx(N)=-0.5*(Xc(N)+Xc(1));
Ry(N)=(Y(A,B)-(0.5*(Yc(N)+Yc(1))));
Rz(N)=Z(A,B);
dlx(N)=-Xc(N)+Xc(1);
dly(N)=-Yc(N)+Yc(1);
for i=1:N
Xcross(i)=dly(i).*Rz(i);
Ycross(i)=-dlx(i).*Rz(i);
Zcross(i)=(dlx(i).*Ry(i))-(dly(i).*Rx(i));
R(i)=sqrt(Rx(i).^2+Ry(i).^2+Rz(i).^2);
end
Bx1=(I*u0./(4*pi*(R.^3))).*Xcross;
By1=(I*u0./(4*pi*(R.^3))).*Ycross;
Bz1=(I*u0./(4*pi*(R.^3))).*Zcross;
BX(A,B)=0;
BY(A,B)=0;
BZ(A,B)=0;
for i=1:N
BX(A,B)=BX(A,B)+Bx1(i);
BY(A,B)=BY(A,B)+By1(i);
BZ(A,B)=BZ(A,B)+Bz1(i);
end
end
end
figure(1);
plot(Xc,Yc,'linewidth',3);
axis([-20 20 -20 20]);
xlabel('X-axis','fontsize',14);
ylabel('Y-axis','fontsize',14);
title('square loop co-ordinates','fontsize',14);
h=gca;
get(h,'FontSize');
set(h,'FontSize',14);
h = get(gca, 'ylabel');
fh = figure(1);
set(fh, 'color', 'white');
grid on;
figure(2);
lim1=min(min(BZ));
lim2=max(max(BZ));
steps=(lim2-lim1)/100;
contour(zp,yp,BZ,lim1:steps:lim2);
axis([1 50 -25 25]);
xlabel('Z-axis','fontsize',14);
ylabel('Y-axis','fontsize',14);
title('BZ component','fontsize',14);
colorbar('location','eastoutside','fontsize',14);
h=gca;
get(h,'FontSize');
set(h,'FontSize',14);
h = get(gca, 'ylabel');
fh = figure(2);
set(fh, 'color', 'white');
figure(3);
lim1=min(min(BY));
lim2=max(max(BY));
steps=(lim2-lim1)/100;
contour(zp,yp,BY,lim1:steps:lim2)
axis([1 50 -25 25])
xlabel('Z-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('BY component','fontsize',14)
colorbar('location','eastoutside','fontsize',14);
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(3);
set(fh, 'color', 'white');
figure(4);
quiver(zp,yp,BZ,BY,2);
axis([1 50 -25 25]);
xlabel('Z-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('B-field Vector flow','fontsize',14)
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(4);
set(fh, 'color', 'white');
Nz=51;
Ny=51;
N=25;
Ra=6;
I=3;
u0=1;
phi=-pi/2:2*pi/(N-1):3*pi/2;
Xc=Ra*cos(phi);
Yc=Ra*sin(phi);
yp(1:51)=-25:1:25;
zp(1:51)=0:1:50;
Y(1:Ny,1:Nz)=0;
Z(1:Ny,1:Nz)=0;
for i=1:Ny
Y(i,:)=yp(i);
end
for i=1:Nz
Z(:,i)=zp(i);
end
for a=1:Ny
for b=1:Nz
for i=1:N-1
Rx(i)=-0.5*(Xc(i)+Xc(i+1));
Ry(i)=(Y(a,b)-(0.5*(Yc(i)+Yc(i+1))));
Rz(i)=Z(a,b);
dlx(i)=Xc(i+1)-Xc(i);
dly(i)=Yc(i+1)-Yc(i);
end
Rx(N)=-0.5*(Xc(N)+Xc(1));
Ry(N)=(Y(a,b)-(0.5*(Yc(N)+Yc(1))));
Rz(N)=Z(a,b);
dlx(N)=-Xc(N)+Xc(1);
dly(N)=-Yc(N)+Yc(1);
for i=1:N
Xcross(i)=dly(i).*Rz(i);
Ycross(i)=-dlx(i).*Rz(i);
Zcross(i)=(dlx(i).*Ry(i))-(dly(i).*Rx(i));
R(i)=sqrt(Rx(i).^2+Ry(i).^2+Rz(i).^2);
end
Bx1=(I*u0./(4*pi*(R.^3))).*Xcross;
By1=(I*u0./(4*pi*(R.^3))).*Ycross;
Bz1=(I*u0./(4*pi*(R.^3))).*Zcross;
BX(a,b)=0;
BY(a,b)=0;
BZ(a,b)=0;
for i=1:N
BX(a,b)=BX(a,b)+Bx1(i);
BY(a,b)=BY(a,b)+By1(i);
BZ(a,b)=BZ(a,b)+Bz1(i);
end
end
end
figure(5)
plot(Xc,Yc,'linewidth',3)
axis([-20 20 -20 20])
xlabel('X-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('square loop co-ordinates','fontsize',14)
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(5);
set(fh, 'color', 'white');
grid on
figure(6)
lim1=min(min(BZ));
lim2=max(max(BZ));
steps=(lim2-lim1)/100;
contour(zp,yp,BZ,lim1:steps:lim2)
axis([1 50 -25 25])
xlabel('Z-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('BZ component','fontsize',14)
colorbar('location','eastoutside','fontsize',14);
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(6);
set(fh, 'color', 'white');
figure(7)
lim1=min(min(BY));
lim2=max(max(BY));
steps=(lim2-lim1)/100;
contour(zp,yp,BY,lim1:steps:lim2)
axis([1 50 -25 25])
xlabel('Z-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('BY component','fontsize',14)
colorbar('location','eastoutside','fontsize',14);
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(7);
set(fh, 'color', 'white');
figure(8)
quiver(zp,yp,BZ,BY,2)
axis([1 50 -25 25])
xlabel('Z-axis','fontsize',14)
ylabel('Y-axis','fontsize',14)
title('B-field Vector flow','fontsize',14)
h=gca;
get(h,'FontSize')
set(h,'FontSize',14)
h = get(gca, 'ylabel');
fh = figure(8);
set(fh, 'color', 'white');
ans =
10
ans =
10
ans =
10
ans =
10
ans =
10
ans =
10
No comments:
Post a Comment