K23 CC12 Gr08 Project2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY


···☼···

REPORT
DETERMINING THE MAGNETIC FIELD OF
A CIRCULAR CURENT
USING BIOT-SAVART’S LAW
……………………………………………………………………………………
…………………………………………………………………………………….

Lecturer: Nguyen Xuan Thanh Tram


Group No: 08 Class: CC12 Completion day: November 16, 2023

Student Name Student ID


Tran Nguyen Gia Thinh 2353143
Nguyen Tien 2353180
Nguyen Phung Bao Tran 2353207
Do Minh Triet 2353212
Chu Quang Trung 2353239
Phan Nguyen Thanh Trung 2353252
Tran Anh Tuan 2353276
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

Project 2 Report:
Determining the magnetic field of a circular current
using Biot-Savart's law

Group information
Group No: 08 Class: CC12 Completion day: November 16, 2023
1. Tran Nguyen Gia Thinh, Student ID: 2353143
2. Nguyen Tien, Student ID: 2353180
3. Nguyen Phung Bao Tran, Student ID: 2353207
4. Do Minh Triet, Student ID: 2353212
5. Chu Quang Trung, Student ID: 2353239
6. Phan Nguyen Thanh Trung, Student ID: 2353252
7. Tran Anh Tuan, Student ID: 2353276

1. Introduction
A magnetic field is an area in the space surrounding a conductor where magnetic
forces can be observed. It is created by an electric current running through the conductor or by
a moving electric charge. Based on the tests conducted in 1820 by the French scientists Jean-
Baptiste Biot and Félix Savart, the Biot-Savart law is a key quantitative relationship in
physics between an electric current I and the magnetic field B it produces. One might think of
the value of the magnetic field at a location in the surrounding area as the total of all the
contributions made by each little component, or section, of a conductor that carries current.
The value of the magnetic field at a particular place in space from a single brief current
segment is expressed by the Biot-Savart law. Every component that affects the field affects
the carrying conductor differently.

1/6
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

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

dl 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.
l is a point on path C.
r is the full displacement vector from the wire element ( ) at point to the point at
which the field is being computed ()
μ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.

2/6
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

3. MATLAB Code and Explanation


Compute magnetic field for a current loop using the Biot-Savart law:
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
%@ Compute components of the r vector (vector between segment on loop and observation point)
rx = xObs(j) - xc(k);
ry = yObs(i) - yc(k);
rz = -zc(k); % Observation points are in xy plane
%@ 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;

3/6
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

%@ 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

The result above show us the section in xy plane of the magnetic field of the circular.
The loop lies in the yz plane with the radius R of 3m and 2A 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.

4/6
Applied Physics Department, FAS, HCMUT Matlab Projects – Physics 1

To prove this, change the value of NGird to a higher number. Then we have the
magnetic field of the circular current when NGrid is 100:

Now we see that the magnetic field is approximately closed which is match the
theory. Moreover, the magnetic field remains constant regardless of the plane selected (slant
or yz, etc.).
A circular loop of wire with a current of 2A is surrounded by magnetic field lines,
displaying the circular currents in three dimensions and the magnetic field in two. This
circular current's simplified magnetic field in three dimensions demonstrates it. Whichever
plane is selected, the magnetic field remains constant.

5. Conclusion
With the aid of MATLAB, the project has been successful in charting the magnetic
field of a circular current at different current and radius values using the Biot-Savart law. We
may more precisely observe the magnetic field in intricate conditions with the help of this
equipment.

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-scientists-and-
engineers
[4] https://www.youtube.com/watch?v=kcuaUZv9u2w
[5] https://www.edn.com/estimating-wire-loop-inductance-rule-of-thumb-15/

5/6

You might also like