Assignment correction
22.2MB1
Dr Yvan Petillot
Sinusoidal EM
22.3MB1
3.1
Introduction
Use MATLAB to determine the distribution of magnetic flux density B(T) in the region of free space surrounding a straight current-carrying conductor of finite length. Apply the Biot-Savart Law to evaluate B(T). Assume that the conductor is 5m long and that it carries a direct current of 1A. Compute the magnetic field at grid points over an area of 20m x 15m, with the conductor at the centre of the grid, lying along the 20m direction. Your report should contain the following detail, as a minimum. 1. A description of the mathematics involved, referring to an appropriate textbook. 2. A printout of your MATLAB code, with descriptive comments beside each line of code. A group of four subplots 3.
Sinusoidal EM 22.3MB1 3.2
Analysis of the problem
15m wire
i dl r dB = 0 4 r 3
M(x,y)
20m
i
dl r Problems: - Which resolution to use? - How to do that with matlab?
Sinusoidal EM
22.3MB1
3.3
Matlab program
Initiliasation
current = 1; % Fixes the current amplitude to 1 A mu_0 = 4*pi*1e-7; % Value of mu_0 step = 0.5; % Resolution of the grid nbx = 15/step; % number of points in x direction nby = 20/step; % number of points in y direction % creates equally spaced points from -7.5 to 7.5 x = linspace(-7.5,7.5,nbx); % creates equally spaced points from -10 to 10 y = linspace(-10,10,nby); % Creates a grid of points [X,Y] = meshgrid(x,y); % number of elements of current nb_dl = 10/step; CurrentLine = linspace(-2.5,2.5,nb_dl); % Line of current B = zeros(nby,nbx,3); Btot = zeros(nby,nbx,3);
Sinusoidal EM
% Initiliases the B vector field % Initiliases the total B vector field
22.3MB1 3.4
Matlab program
Calculus
for i = 1 : nb_dl % For each small element of current dl = [0;step;0]; % Creates the dl vector for k = 1 : nby % For each y coordinates for l = 1 : nbx % For each x coordinates %Creates R vector over the grid R = [X(k,l) ; Y(k,l)- CurrentLine(i); 0]; % Caclulates the B value due to dl over the grid B(k,l,:) = mu_0/(4*pi)*current*cross(R,dl)/norm(R)^3; %Calc end end % Initialises z Value for the origin of B (always 0) z = zeros(nby,nbx); figure(1); % Create a figure quiver3(X,Y,z,B(:,:,1),B(:,:,2),B(:,:,3)); %Plots B drawnow; % Ask for a redraw; Btot = Btot + B; % Generated the overall Fields to date figure(2); % Create a figure quiver3(X,Y,z,Btot(:,:,1),Btot(:,:,2),Btot(:,:,3)); %Plots Btot drawnow; end
Sinusoidal EM 22.3MB1 3.5
Matlab program
Display
% Calculation is now finished figure(3); %Plots the z value of B as Bx and By are null surfl(X,Y,Btot(:,:,3)); shading interp; % Make it nicer colormap(pink); % idem figure(4); contour(X,Y,Btot(:,:,3)); % Now get the contours of B BzdB = 20*log(abs(Btot(:,:,3))/1e-9); % Get Bz in dB % Same as for B figure(5); surfl(X,Y,BzdB); shading interp; colormap(pink); figure(6); contour(X,Y,BzdB);
Sinusoidal EM 22.3MB1 3.6
Results
0.5
-0.5
-1 20 10 0 -10 -20 -10 -5 5 0 10
Sinusoidal EM
22.3MB1
3.7
Results
Sinusoidal EM
22.3MB1
3.8
Results
10 8 6 4 2 0 -2 -4 -6 -8 -10 -6 -4 -2 0 2 4 6
Sinusoidal EM
22.3MB1
3.9
Results
Sinusoidal EM
22.3MB1
3.10
Results
10 8 6 4 2 0 -2 -4 -6 -8 -10 -6 -4 -2 0 2 4 6
Sinusoidal EM
22.3MB1
3.11