Matlab Report OF Project 2 PDF

Title Matlab Report OF Project 2
Author Mina San
Course Operation Research 1
Institution Trường Đại học Công nghệ Thành phố Hồ Chí Minh
Pages 7
File Size 596 KB
File Type PDF
Total Downloads 19
Total Views 144

Summary

Matlab report...


Description

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

Determining the magnetic field of a circular current using Biot-Savart law 1. Introduction An electric current flowing in a conductor, or a moving electric charge, produces a magnetic field, or a region in the space around the conductor in which magnetic forces may be detected. The value of the magnetic field at a point in the surrounding space may be considered the sum of all the contributions from each small element, or segment, of a current-carrying conductor. The Biot-Savart law states how the value of the magnetic field at a specific point in space from one short segment of currentcarrying conductor depends on each factor that influences the field.

2. Theory The Biot–Savart law is used for computing the resultant magnetic field B at position r in 3D-space generated by a flexible current I (for example due to a wire). A steady (or stationary) current is a continual flow of charges which does not change with time and the charge neither accumulates nor depletes at any point. The equation in SI units is

Where is a vector along the path C whose magnitude is the length of the differential element of the wire in the direction of conventional current. is a point on path C. is the full displacement vector from the wire element ( ) at point to the point at which the field is being computed (), and μ0 is the magnetic constant. Alternatively :

Using symbolic calculation of MATLAB, we can calculate the magnetic field of a circular current by dividing the circle into small current segments and adding the magnetic field values created by each of the segments above at a certain position. Then, use the calculated magnetic field values to plot the field lines of mentioned magnetic field in MATLAB. 3. MATLAB Code and Explanation Compute magnetic field for a current loop using the Biot-Savart law: Page 1 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

clear all; help biotsav; % Clear memory; print header clc % Initialize variables (e.g., Loop radius, current, graphics) mu0 = 4*pi*1e-7; % Permeability of free space (T*m/A) I_current = input('Enter the current : '); % Current in the loop (A) Radius = input('Enter radius of the loop (m): '); Constant = mu0/(4*pi) * I_current; % Useful constant NGrid = 10; % Number of grid points for plots xMax = 5; % Limits for graphics yMax = xMax; % Limits for graphics fprintf('Field plotted from x = %g m to x = %g m\n',-xMax,xMax); fprintf('Field plotted from y = %g m to y = %g m\n',-yMax,yMax); for i=1:NGrid xObs(i) = -xMax + (i-1)/(NGrid-1)*(2*xMax); % x values to plot yObs(i) = -yMax + (i-1)/(NGrid-1)*(2*yMax); % y values to plot end %@ Loop over the segments in the current loop in yz plane NSegments = 20; for k=1:NSegments %@ Compute location of the endpoints of a segment theta1 = 2*pi*(k-1)/NSegments; x1 = 0; y1 = Radius*cos(theta1); z1 = Radius*sin(theta1); theta2 = 2*pi*k/NSegments; x2 = 0; y2 = Radius*cos(theta2); z2 = Radius*sin(theta2); %@ Compute components of segment vector dl dlx(k) = x2-x1; dly(k) = y2-y1; dlz(k) = z2-z1; %@ Compute the location of the midpoint of a segment xc(k) = (x2+x1)/2; yc(k) = (y2+y1)/2; zc(k) = (z2+z1)/2; end %@ Loop over all grid points and evaluate B(x,y) on grid for i=1:NGrid for j=1:NGrid Bx = 0; By = 0; % Initialize B to zero %@ Loop over the segments in the loop for k=1:NSegments

Page 2 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

%@ Compute components of the r vector (vector between segment on loop and observation point) rx = xObs(j) - xc(k); ry = yObs(i) - yc(k); % Observation points are in xy plane rz = -zc(k); %@ Compute r^3 from r vector r3 = sqrt(rx^2 + ry^2 + rz^2)^3; %@ Compute x and y components of cross product dl X r dlXr_x = dly(k)*rz - dlz(k)*ry; dlXr_y = dlz(k)*rx - dlx(k)*rz; %@ Increment sum of x and y components of magnetic field Bx = Bx + Constant*dlXr_x/r3; By = By + Constant*dlXr_y/r3; end %@ Compute normalized vectors of magnetic field direction BMag = sqrt(Bx^2 + By^2); BDirx(i,j) = Bx/BMag; BDiry(i,j) = By/BMag; end end %@ Plot magnetic field direction as a quiver (arrow) plot clf; figure(gcf); % Clear figure; bring figure window forward quiver(xObs,yObs,BDirx,BDiry); % Draw arrows for B field hold on; plot(0,Radius,'bo'); % Mark the location of the current plot(0,-Radius,'rx'); % loop on the plot title('Magnetic field direction for loop in yz plane'); xlabel('x'); ylabel('y'); hold off;

4. Results and discussion :

Page 3 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

The result above show us the section in xy plane of the magnetic field of the circular loop lies in yz plane with the radius R of 1.2m and 1A as its current I . Theoretically, the magnetic field must be closed but it seems to not be the case above. In fact, the magnetic field of the circular loop above is closed but because the arrows are straight and quite large as the number of them is small.

To prove this, change the value of NGird to a higher number. Then we have :

Page 4 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

And the magnetic field of the circular current when NGrid is 50 and 100, respectively :

Now we see that the magnetic field is approximately closed which is match the theory. Page 5 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

Moreover, the magnetic field is the same with every plane chosen (slant or yz, etc.)

Magnetic field lines around a circular loop of wire with 1A of current which shows the circular currents in 3D with the magnetic field in 2D plane.

The simplified magnetic field of circular current in 3D proves that this circular current’s magnetic field is the same whichever plane chosen. 5. Conclusion Page 6 of 7

Applied Physics Department, FAS, HCMUT

Matlab Projects – Physics 1

The project has succeed in graphing the magnetic field of a circular current with various values of the current and the radius of the current using Biot-Savart law with the help of MATLAB . With this tool we can observe the magnetic field of complex situations more accurate . 6. References: [1] https://www.britannica.com/science/Biot-Savart-law [2] https://en.wikipedia.org/wiki/Biot%E2%80%93Savart_law [3] A. L. Garcia and C. Penland, MATLAB Projects for Scientists and Engineers, Prentice Hall, Upper Saddle River, NJ, 1996. https://www.mathworks.com/matlabcentral/fileexchange/2268-projects-for-scientistsand-engineers [4] https://www.youtube.com/watch?v=kcuaUZv9u2w [5] https://www.edn.com/estimating-wire-loop-inductance-rule-of-thumb-15/

Page 7 of 7...


Similar Free PDFs