Laboratory #4
EE Science II Laboratory #04
Charge Distributions and Electric Field Visualization in 3D
Laboratory Assignment
The purpose of this lab is to perform various calculations related to electric fields, e.g. charge distributions and particle
movement inside electric fields. This lab is linked to the special lecture in the Advanced Visualization Center (AVC).
You will also need to refer to the MATLAB tutorial posted on Canvas for some fundamental aspects of the activities
presented below.
Part I: Theory - Warm Up
Answer the following questions 1.
If you bring a negative charge (Q2) near to a positive charge (Q1) what happens to the orientation of the
resultant total electric field? Also, what happens to the electric field direction when a positive charge is near
Q1?
2.
A continuous charge density function describes how a certain amount of charge is spread out over some
region. Depending on the distribution of the electric charges in a region of space, we have three different
βcategoriesβ of density functions - linear, surface and volumetric charge density. Provide brief descriptions
of these categories in your own words.
3.
In a uniform charge distribution, the charge density has the same value at every point within the region.
However, in a non-uniform distribution, the density does not have a fixed value - it varies as a function of
position. Answer the following:
a)
Assume that you know the total charge and total volume occupied by a non-uniform charge
distribution. Can you calculate the charge density at any point in the object? Explain
Part II: Electric Field of Point Charges
The magnitude of an electric field represents the Coulomb force per unit of charge on any electric charge within the
field. The convention sets out the direction of the electric field vector towards the direction of movement of an
infinitesimal positive charge immersed in the electric field.
The following figures are some examples of electric field direction β the figure on the left is the electric field due to a
dipole and the figure on the right is the electric field within an infinitely large parallel plate capacitor.
University of South Florida
2
EE204-exp.docx
Laboratory #4
The equation describing the electric field of a point charge is:
πΈπΈοΏ½β(π
π
) =
πΈπΈοΏ½β(π₯π₯,π¦π¦) = ππ οΏ½
ππ
π
π
οΏ½ (π π π π βππππππππππππ πππππππππππππππππππππ π )
(4ππππ)π
π
2
1
1
ππ
ππ
οΏ½οΏ½
οΏ½ β οΏ½π₯π₯οΏ½
+ π¦π¦οΏ½
οΏ½ (πππππππππππ π ππππππ πππππππππππππππππππππ π ππππ π§π§ = 0)
2
(4ππππππ ππ0 ) οΏ½βππ 2 + ππ 2 οΏ½
βππ 2 + ππ 2
βππ 2 + ππ 2
1
Then, using οΏ½ππ = (4ππππ
ππ ππ0 )
οΏ½ you can express πΈπΈοΏ½β(π₯π₯,π¦π¦) as:
οΏ½β(π±π±,π²π²) = οΏ½π±π±οΏ½πππ±π± + π²π²οΏ½πππ²π² οΏ½ = οΏ½π±π±οΏ½
ππ
ππβπ€π€βππ
οΏ½οΏ½ππ ππ +ππ ππ οΏ½
ππ
+ π²π²οΏ½
ππβπ€π€βππ
ππ
οΏ½οΏ½ππ ππ +ππ ππ οΏ½
ππβπ€π€βππ
οΏ½ = οΏ½π±π±οΏ½
οΏ½ππ (π±π±,π²π²) οΏ½
ππ
+ π²π²οΏ½
ππβπ€π€βππ
ππ
οΏ½ (1)
οΏ½ππ (π±π±,π²π²) οΏ½
The activities in this section are designed to give you practice in visualizing electric fields and the use of the field
concept to solve problems. You are asked to use MATLAB to compute the electric field produced by the particle A.
As necessary you should refer to the lecture notes and the MATLAB tutorial posted on Canvas.
1. The Problem - Read the situation described in the following paragraph.
Suppose a charged particle, A is present at (x, y) = (ax, ay) in free space. The electric charge of this particle
has a value of Q. You are required to compute the electric field produced by the particle A. Assume that no
other fields are present in this region of space. A brief representation is shown in the following image.
Table 1- Equations describing the position vector πποΏ½β
for particle A and its electric charge value Q
Z
X
οΏ½οΏ½β
π·π·(ax,ay)
Y
οΏ½οΏ½β
π·π·(ππππ, ππππ)
[ (π€π€ + 2) , (π€π€ β 1) ]
Q
(π€π€)(10β3 )
(W = Group number - It will be assigned by the TA)
Q
2. Compute the position vector and electric charge value - open a spreadsheet or use a calculator to calculate Q
and the position of A in space by using the equations in Table 1 and complete Table 2 below. Note: to complete
this step you need to substitute your assigned group number in for w in the equations.
University of South Florida
3
EE204-exp.docx
Laboratory #4
Table 2 β Particle A position and charge value
P (ax, ay)
[
,
]
Q
3. Validate the results using MATLAB - Create a new script in the MATLAB script editor. Copy the template
code below into MATLABβs script editor. Make sure to type the equations / values for P (ax, ay), Q, e0, and
er. Save the script using the name βEE204_your_last_names_IIβ and press the run button. Fill in Table 3 and
compare against Table 2.
%-------------------------------------------------------------------------%
%
This script computes the Electric Fields due to point charge
%
in a 2-D plane using the Coulomb's Law
%-------------------------------------------------------------------------%
clear;
clc;
%-------------------------------------------------------------------------%
%
SYMBOLS USED IN THIS CODE
%-------------------------------------------------------------------------%
% W = Group number (Assigned by TA)
% P = [ax,ay] = coordinates for the position of particle A
% e0 = free space permittivity
% er = Relative permittivity
% Q = charge value is stored here
% k = (Coulomb's constant)*(er)
% Nx = Number of grid points in X-Direction
% Ny = Number of grid points in Y-Direction
% L = Distance coverture
% X,Y = coordinate system
% R = distance between a selected point and the location of charge
% Ex = X-Component of Electric-Field
% Ey = Y-Component of Electric-Field
%-------------------------------------------------------------------------%
%
INITIALIZATION OF INPUT PARAMETERS
%
Here, all the input constants are defined
%-------------------------------------------------------------------------%
W = 1; %Use your group number here. Remember to modify before running the code!
P = [,] %complete the equation for position vector
e0 = 8.854*10^-12
er = 1
Q =
%complete the equation for Charge value
L = 15;
Nx = 15;
Ny = 15;
k = 1/(4*pi*e0*er)
Table 3 β Particle A: position and charge value (MATLAB)
P(ax, ay)
Q
4. Generate the Meshgrid β append the next template to your script.
%-------------------------------------------------------------------------%
%
X Y SYSTEM CALCULATION
%-------------------------------------------------------------------------%
x=-L:2*L/(Nx-1):L;
y=-L:2*L/(Ny-1):L;
[X,Y]= meshgrid(x,y);
R = sqrt(((X-P(1)).^2)+((Y-P(2)).^2)); %Calculating the distance from source
University of South Florida
4
EE204-exp.docx
Laboratory #4
What is the purpose of the above code lines? Hint: Look for plotting functions in the MATLAB Tutorial
5. Compute the electric field - append the next template to your script. Complete the code by entering the
parameters for the quiver function. Run the code and change the title of the figure to display your group number
and last names. Save your figure and submit it with your postlab report.
%-------------------------------------------------------------------------%
%
CALCULATION OF THE x AND y COMPONENTS OF THE ELECTRIC FIELD
%-------------------------------------------------------------------------%
Ex = (Q*k.*(X-P(1)))./(R.^3);
Ey = (Q*k.*(Y-P(2)))./(R.^3);
%-------------------------------------------------------------------------%
%
PLOTTING THE ELECTRIC FIELD
%-------------------------------------------------------------------------%
% The following lines are intended to normalize and visualize the electric field
%
-------------------------------------Ex1 = Ex.*R.^1.5;
Ey1 = Ey.*R.^1.5;
figure
contourf(X,Y,1./R.^0.5,10) %Plotting equipotential lines
title('Change the title to your group number and last names')
xlabel('x')
ylabel('y')
colormap(jet)
colorbar
hold on
% ----------------End of field normalization
--------------------q = quiver(X,Y, , ); %complete the parameters for quiver function
q.Color='w'; % defining the color of the electric field arrows
hold off
Observations:
The arrows in your MATLAB plot represent the electric field due to the charge and the colored contours
represent equipotential surfaces around the charge.
Comment on the direction of the electric field. How does the strength of the field vary with respect to distance?
What are equipotential surfaces? From theory, what will be the shape of equipotential surfaces around a single
charge? Do you see this in your MATLAB plot? Why/why not?
Obtain your TAβs signature here after completing Part II on the first page
Part III: Electric Field of a Dipole
1. Read the situation described below Two charged particles, A and B are separated by a distance d in free space. Particles A and B have
an electric charge of Q1 and Q2 respectively. Compute the net electric field due to these two charged
particles by assuming a coordinate system centered at the midpoint of the line connecting A and B.
A brief representation is shown in the following image.
University of South Florida
5
EE204-exp.docx
Laboratory #4
Table 4- Equations describing the charge and
position of A and B
Z
(β1)ππ (ππ β 10β3 )
Q1 (Particle A Charge)
Q2 (Particle B Charge)
β(ππ)(1.5 β 10β2 )
d
10(ππ)
(W = Group number assigned by the TA)
οΏ½οΏ½β
π©π©(bx,by)
X
οΏ½οΏ½β(ax,ay)
π¨π¨
Y
2. Compute the position vector and charge values - open a spreadsheet or use a calculator to calculate Q1, Q2,
and their positions. Complete Table 5 below using the equations described in Table 4.
Table 5 β Parameters describing the charge and position for particle A and particle B
Q1
Q2
π
π
- distance between A and B
οΏ½οΏ½β(x,y) - position of particle A
π¨π¨
[ d/2 , 0 ] = [
, 0 ]
οΏ½οΏ½β
π©π©(x,y) - position of particle B
[ -d/2 , 0 ] = [
, 0 ]
3. Validate the results using MATLAB - Create a new script in the MATLAB script editor and copy the template
below. Make sure to type the equations for the values of Q1, Q2, d, A and B. Save the script using the name
βEE204_your_last_names_IIIβ and press the run button. Fill Table 6 and compare against Table 5.
%-------------------------------------------------------------------------%
%
This simple program computes the Electric Fields due to dipole
%
in a 2-D plane using the Coulomb's Law
%-------------------------------------------------------------------------%
clear;
clc;
%-------------------------------------------------------------------------%
%
SYMBOLS USED IN THIS CODE
%-------------------------------------------------------------------------%
% W = Group number (Assigned by TA)
% e0 = free space permittivity
% er = Relative permittivity
% Q1 = charge I value is stored here
% Q2 = charge II value is stored here
% Pi = ?
% k = (Coulomb's constant)*(er)
% Nx = Number of grid points in X-Direction
% Ny = Number of grid points in Y-Direction
% L = Distance coverture
% X,Y = coordinate system
% ax,ay = coordinates for the position of Particle A
% bx,by = coordinates for the position of particle B
% Ra = distance between a selected point and the location of particle A
% Rb = distance between a selected point and the location of particle B
% Ea = [Eax,Eay] Electric-Field produced by Particle A
% Eb = [Ebx,Eby] Electric-Field produced by Particle B
%-------------------------------------------------------------------------%
%
INITIALIZATION OF INPUT PARAMETERS
%
Here, all the input constants are defined
%-------------------------------------------------------------------------%
W = 3; %Use your group number here. Remember to modify before running the code!
e0 = 8.85*10^-12;
er = 1;
Q1 = ; %complete the equation
Q2 = ; %complete the equation
d = 10*W;
A = [
,0]; %complete the equation for x component of position vector (Particle A)
University of South Florida
6
EE204-exp.docx
Laboratory #4
B = [
,0]; %complete the equation for x component of position vector (Particle B)
k = 1/(4*pi*e0*er);
Table 6 β Computed values for charge and position of particles A and B (MATLAB)
Q1
Q2
π·π· - distance between A and B
A(x,y) - position of particle
A
B(x,y) - position of particle
B
4. Plot the electric field - append the next template to your script. Make sure to code the lines for Rb, Eby and
the quiver function parameters. Run the code and change the title of the figure to your group number and
last names. Save a copy of the figure.
%-------------------------------------------------------------------------%
%
X Y SYSTEM CALCULATION
%-------------------------------------------------------------------------%
L = 50;
Nx = 20;
Ny = 20;
x=-L:2*L/(Nx-1):L;
y=-L:2*L/(Ny-1):L;
[X,Y]= meshgrid(x,y);
Ra = sqrt(((X-A(1)).^2)+((Y-A(2)).^2));
Rb =
; %complete the equation to calculate the distance for B
%-------------------------------------------------------------------------%
%
CALCULATION OF THE x AND y COMPONENTS OF THE ELECTRIC FIELD
%-------------------------------------------------------------------------%
Eax = (Q1*k.*(X-A(1)))./(Ra.^3);
Eay = (Q1*k.*(Y-A(2)))./(Ra.^3);
Ebx = (Q2*k.*(X-B(1)))./(Rb.^3);
Eby = ; %complete the equation to calculate Y component of B field
%-------------------------------------------------------------------------%
%
PLOTTING THE ELECTRIC FIELD
%-------------------------------------------------------------------------%
% The following lines are intended to normalize and visualize the electric field
%
-------------------------------------Eax1 = Eax.*Ra.^1.5;
Eay1 = Eay.*Ra.^1.5;
Ebx1 = Ebx.*Rb.^1.5;
Eby1 = Eby.*Rb.^1.5;
figure
contourf(X,Y,(1./Ra.^0.5)+(1./Rb.^0.5),10);
colormap(jet);
colorbar;
title('Change this title to your group number and last names')
xlabel('x')
ylabel('y')
hold on
% ----------------End of field normalization
--------------------q = quiver(X,Y , + , + ); %complete (Apply superposition on normalized fields)
q.Color='w';
hold off
Observations:
The arrows in your MATLAB plot represent the electric field due to the charges and the colored contours
represent equipotential surfaces.
Identify A and B in the MATLAB figure. Comment on the field distribution and the equipotential surfaces.
University of South Florida
7
EE204-exp.docx
Laboratory #4
Obtain your TAβs signature here after completing Part III on the first page
Part IV: Linear Charge distribution
Sometimes, the distances between charges are much smaller than the space from the charges to some point of interest.
Under such situations, the system of electric charges is called continuous. That is, the system is equivalent to a total
electric charge distribution along a line, surface or volume.
The procedure to develop the equations describing this scenario for a line charge is as follow:
β’
We start by considering the electric charge distribution as a set of small elements, each of which contains a
small charge ΞQ. Here the [X, Y] is the position vector of the evaluation point and [π₯π₯0 , π¦π¦0 ] is the position of
the ππππ element of the rod. The electric field produced by a differential portion of the rod is as follow
ππππ β π€π€ β (ππ β π±π±π±π±)
οΏ½β(π±π±,π²π²) = οΏ½π±π±οΏ½πππππ±π± + π²π²οΏ½πππππ²π² οΏ½ = οΏ½π±π±οΏ½
π«π«ππ
οΏ½οΏ½(ππ β π±π±π±π±)ππ + (ππ β π²π²π±π±)ππ οΏ½
β’
+ π²π²οΏ½
ππππ β π€π€ β (ππ β π²π²π±π±)
οΏ½οΏ½(ππ β π±π±π±π±)ππ + (ππ β π²π²π±π±)ππ οΏ½
ππ
οΏ½
Next, we substitute the differential charge element by the following equation ππππ = πππ±π± β ππ, where dx is a
infinitesimal portion of the rod, Ξ» is the lineal charge density and ππππ is the electric charge of the infinitesimal
portion of the rod.
οΏ½β(π±π±,π²π²) = οΏ½π±π±οΏ½
π«π«ππ
ππ β π«π«π«π« β π€π€ β (ππ β π±π±π±π±)
οΏ½οΏ½(ππ β π±π±π±π±)ππ + (ππ β π²π²π±π±)ππ οΏ½
β’
ππ
ππ
+ π²π²οΏ½
ππ β π«π«π«π« β π€π€ β (ππ β π²π²π±π±)
οΏ½οΏ½(ππ β π±π±π±π±)ππ + (ππ β π²π²π±π±)ππ οΏ½
ππ
οΏ½
Finally, we evaluate the total field at P(x,y,z) due to the charge distribution. Adding the contributions of all
the infinitesimal charge elements (that is, by applying the superposition principle - integration).
ππ/ππ
οΏ½β(π±π±,π²π²) = οΏ½π±π±οΏ½πππ±π± + π²π²οΏ½πππ²π² οΏ½ = οΏ½π±π±οΏ½ β«ππ/ππ
ππ
πππππ±π± + π²π²οΏ½ β«πππ±π±=βππ/ππ πππππ²π²οΏ½ (2)
πππ±π±=βππ/ππ
1. Read the situation described below Consider a charged cylinder, C with a length l and negligible width (i.e., approximate the charged
cylinder as a line charge distribution with charge density of value ππβππ).
Table 7- Equations describing the charge density and
length of the charged cylinder
ππππππ - Charge
density (C/m)
(π€π€)(10β9 )
l β length of the
cylinder
(π€π€ + 15)
(W = Group number assigned by the TA)
Use MATLAB to calculate the total electric field produced by the charged cylinder C by following the steps
below:
University of South Florida
8
EE204-exp.docx
Laboratory #4
2. Compute the charge density and length values - open a spreadsheet or use a calculator to calculate rho and l.
Complete Table 8 below using the equations in Table 7.
Table 8 - Parameters describing the charge density and length of C
ππβππ
l
3. Validate the results using MATLAB - Create a new script in the script editor and copy the template below.
Make sure to type the equations for rho and l. Save the script using the name βEE204_your_last_names_IVβ
and press the run button. Fill Table 9 and compare against Table 8.
%-------------------------------------------------------------------------%
%
This program computes the Electric Fields due to a charged rod
%
in a 2-D plane using the Coulomb's Law
%-------------------------------------------------------------------------%
clear;
clc;
%-------------------------------------------------------------------------%
%
SYMBOLS USED IN THIS CODE
%-------------------------------------------------------------------------%
% W = Group number (Assigned by TA)
% rho = Charge density [C/m]
% l = length of C
% e0 = free space permittivity
% er = Relative permittivity
% d = charge density for linear rod
% X,Y = coordinate system
% R = distance between a selected point and the location of infinitesimal charge
% dE = Electric-Field due to infinitesimal charge element
% E = Electric-Field
% x0,y0 = coordinates for the location of infinitesimal charge (Integration variable)
% Pi = ?
% k = (Coulomb's constant)*(er)
% Nx = Number of grid points in X-Direction
% Ny = Number of grid points in Y-Direction
% L = Distance coverture
%-------------------------------------------------------------------------%
%
INITIALIZATION OF INPUT PARAMETERS
...

Purchase answer to see full
attachment