0% found this document useful (0 votes)
43 views

2024 Lab 1 Fields Visualization

This document provides instructions for a laboratory on visualizing vector fields. Students are asked to complete two tasks by performing coordinate transformations and vector operations, presenting results in figures and tables with descriptions, and summarizing outcomes in conclusions. The document also includes a rubric for evaluation.

Uploaded by

ireshn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

2024 Lab 1 Fields Visualization

This document provides instructions for a laboratory on visualizing vector fields. Students are asked to complete two tasks by performing coordinate transformations and vector operations, presenting results in figures and tables with descriptions, and summarizing outcomes in conclusions. The document also includes a rubric for evaluation.

Uploaded by

ireshn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

ELEN3002/6017 Lab 1 Prepared by M.

Kovaleva

Laboratory 1 “Vector Fields Visualization”


Instructions to perform the Laboratory:
The aim of this self-paced computer laboratory is to practice the operations with vector fields
through their visual interpretations. Vector operations and plotting can be easily performed
with MATLAB but the use of Python or another programming language instead of MATLAB
to perform this Laboratory is allowed.
The laboratory report should contain the front page (with laboratory title, your name and
student ID) and completion of the following sections including each Task (one report for both
tasks):
 Section I. Introduction (up to 300 words)
Introduce the topic of vector fields, formulate the objective of the laboratory and
provide a brief description of existing applications of vector fields in industry.
 Section II. Method
Should contain description of the process of coordinate transformation and vector
operations, numbered equations that have been used, short description of the
workflow of programming codes and analytical solutions.
 Section III. Results and Discussion (obtained results, presented using figures and
tables and accompanied by relevant descriptions)
 Section IV. Conclusion (one paragraph per Task summarising the achieved
outcomes)
 Make use of Appendices to comply with the page limit of 10 pages.
Report Formatting Requirements
1. Figures and Tables
All figures should be centered on the page and include a figure number and a caption
beneath the figure. Each axis should be labelled. All tables should be numbered and
have a caption above the table. The font of the report should be Times New Roman,
Arial or Georgia size 12.
In the Results section, before providing a figure/table, write a short paragraph
describing what information you are about to present.
Example 1: “The following table/figure compares/shows the values/distribution of …
at a given point/in an interval … .”
Example 2: “Fig. 1/Table 1 shows/presents calculated values of …, which were obtained
using Eq. (4).”

2. Report Length
Professional reports have page numbers. The length of the report is counted from
Introduction to Conclusion. References and Appendices do not contribute to the page
count.

3. IEEE Referencing Style Guide:


https://ieeeauthorcenter.ieee.org/wp-content/uploads/IEEE-Reference-Guide.pdf
https://ieee-
dataport.org/sites/default/files/analysis/27/IEEE%20Citation%20Guidelines.pdf
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

Marking rubric
Marking rubric
Criterion Poor Needs improvement Good Excellent
0% 50% 80% 100%

Introduction Very little background Certain major Good introduction but A cohesive well-written
(10%) information is provided introductory points are fails to provide context introduction to the
and/or information is missing (background, or background for some background material
incorrect. No references theory, context), or parts of the experiment, pertinent to the
are provided. explanations are unclear. or certain information is experiment with
References are used not cohesive. appropriate references.
properly. Places the purpose of the
experiment in context.
Method Several important details Missing several design Includes most of the Contains the details how
(25%) are missing. Narrative is and experimental details important design and calculations and the
incorrect, illogical, or or contains some experimental details but experiment was
copied directly from the incorrect statements. missing one or more performed. Written in
lab manual. Written in relevant pieces of the correct tense and
incorrect tense. information. omits information that
can be assumed by peers.
Results and Discussions Figures, graphs and tables Some of the results are Most of the results are Results are correct. All
(40%) are poorly constructed, correct. Most figures, correct, only minor figures, graphs and
have missing numbers, graphs and tables are errors exist. All figures, tables are numbered and
captions or numbers. shown but some required graphs and tables are have appropriate
Important discussions are features are missing. correctly shown and captions and explicitly
missing. Certain reported Certain data reported are explicitly mentioned in mentioned in the text.
results are not mentioned not mentioned in the text the text but there are Relevant data are
in the text. or missing. Captions are some minor problems presented and used in the
not descriptive or that can be improved. discussion.
incorrect. Most relevant data are
presented and used in
the discussion but some
comparisons are omitted.
Conclusion No or unsatisfactory A satisfactory review of A good review of the Excellent review of the
(10%) review of the results. The the results. The results. Student results with
conclusion is too short and conclusion is presented demonstrates demonstrated
below the expected quality. but not in sufficient understanding of the understanding of the
detail. topic. Result topic. Result
discrepancies are not discrepancies are
explained correctly. explained correctly.
Presentation The level of presentation is A satisfactory A commendable Exemplary presentation
(15%) clearly below the presentation of the report presentation of the report
of the report with
professional engineering with acceptable standard with good organization, excellent organization, in
reports. Poor order of of organization, format, format, language, expected format,
presentation. Format is not language, illustrations, sufficiently clear professional language,
followed at most places. numbering etc. Quality illustrations, section attractive illustrations,
Below acceptable level of needs to be improved in numbering etc. Quality proper numbering of
language, illustrations etc. most places. Brevity is can be further improved. sections etc. The
Brevity is not displayed. not displayed. Page limit not exceeded. paragraphs are justified
(text aligned with both
margins). Page limit not
exceeded.
Total = (mark for Introduction)*0.1 + (mark for Method)*0.25 + (mark for Results and Discussions)*0.4 + (mark for
(100%) Conclusion)*0.1 + (mark for Presentation)*0.15
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

Theory and Matlab Functions


1. In the Cartesian coordinate system (coordinates 𝑥𝑥, 𝑦𝑦, 𝑧𝑧),
divergence and curl of a vector field 𝐴𝐴⃗ = 𝑥𝑥�𝐴𝐴𝑥𝑥 + 𝑦𝑦�𝐴𝐴𝑦𝑦 + 𝑧𝑧̂ 𝐴𝐴𝑧𝑧 can be calculated as
𝜕𝜕𝐴𝐴𝑥𝑥 𝜕𝜕𝐴𝐴𝑦𝑦 𝜕𝜕𝐴𝐴𝑧𝑧
𝑑𝑑𝑑𝑑𝑑𝑑 𝐴𝐴⃗ = �∇⃗ ∙ 𝐴𝐴⃗ = + +
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝑥𝑥� 𝑦𝑦� 𝑧𝑧̂
𝜕𝜕 𝜕𝜕 𝜕𝜕 𝜕𝜕𝐴𝐴𝑧𝑧 𝜕𝜕𝐴𝐴𝑦𝑦 𝜕𝜕𝐴𝐴𝑥𝑥 𝜕𝜕𝐴𝐴𝑧𝑧 𝜕𝜕𝐴𝐴𝑦𝑦 𝜕𝜕𝐴𝐴𝑥𝑥
𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 𝐴𝐴⃗ = �∇⃗ × 𝐴𝐴⃗ = �� �� = � − � 𝑥𝑥� + � − � 𝑦𝑦� + � − � 𝑧𝑧̂
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝐴𝐴𝑥𝑥 𝐴𝐴𝑦𝑦 𝐴𝐴𝑧𝑧

In cylindrical coordinate system (coordinates 𝑟𝑟, 𝜑𝜑, 𝑧𝑧),


divergence and curl of a vector field 𝐴𝐴⃗ = 𝑟𝑟̂ 𝐴𝐴𝑟𝑟 + 𝜑𝜑�𝐴𝐴𝜑𝜑 + 𝑧𝑧̂ 𝐴𝐴𝑧𝑧 can be calculated as
1 𝜕𝜕(𝑟𝑟𝑟𝑟𝑟𝑟 ) 1 𝜕𝜕𝐴𝐴𝜑𝜑 𝜕𝜕𝐴𝐴𝑧𝑧
𝑑𝑑𝑑𝑑𝑑𝑑 𝐴𝐴⃗ = ∇
�⃗ ∙ 𝐴𝐴⃗ = + +
𝑟𝑟 𝜕𝜕𝜕𝜕 𝑟𝑟 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝑟𝑟̂ 𝑟𝑟𝜑𝜑� 𝑧𝑧̂
1 𝜕𝜕 𝜕𝜕 𝜕𝜕
�⃗ × 𝐴𝐴⃗ = ��
𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 𝐴𝐴⃗ = ∇ �� =
𝑟𝑟 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝐴𝐴𝑟𝑟 𝑟𝑟𝑟𝑟𝜑𝜑 𝐴𝐴𝑧𝑧
1 𝜕𝜕𝐴𝐴𝑧𝑧 𝜕𝜕𝐴𝐴𝜑𝜑 𝜕𝜕𝐴𝐴𝑟𝑟 𝜕𝜕𝐴𝐴𝑧𝑧 1 𝜕𝜕(𝑟𝑟𝐴𝐴𝜑𝜑 ) 𝜕𝜕𝐴𝐴𝑟𝑟
=� − � 𝑟𝑟̂ + � − � 𝜑𝜑� + � − � 𝑧𝑧̂
𝑟𝑟 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝑟𝑟 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕

In spherical coordinate system (coordinates 𝑅𝑅, 𝜃𝜃, 𝜑𝜑)


divergence and curl of a vector field 𝐴𝐴⃗ = 𝑅𝑅� 𝐴𝐴𝑅𝑅 + 𝜃𝜃�𝐴𝐴𝜃𝜃 + 𝜑𝜑�𝐴𝐴𝜑𝜑 can be calculated as
1 𝜕𝜕(𝑅𝑅 2 𝐴𝐴𝑅𝑅 ) 1 𝜕𝜕(𝐴𝐴𝜃𝜃 sin 𝜃𝜃) 1 𝜕𝜕𝐴𝐴𝜑𝜑
𝑑𝑑𝑑𝑑𝑑𝑑 𝐴𝐴⃗ = ∇
�⃗ ∙ 𝐴𝐴⃗ =
2
+ +
𝑅𝑅 𝜕𝜕𝜕𝜕 𝑅𝑅 sin 𝜃𝜃 𝜕𝜕𝜕𝜕 𝑅𝑅 sin 𝜃𝜃 𝜕𝜕𝜕𝜕

𝑅𝑅 �
𝑅𝑅𝜃𝜃 𝑅𝑅 sin 𝜃𝜃 𝜑𝜑�
1 𝜕𝜕 𝜕𝜕 𝜕𝜕
𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 𝐴𝐴⃗ = ∇ �⃗ × 𝐴𝐴⃗ = �� �� =
2
𝑅𝑅 sin 𝜃𝜃 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝐴𝐴𝑅𝑅 𝑅𝑅𝑅𝑅𝜃𝜃 (𝑅𝑅 sin 𝜃𝜃)𝐴𝐴𝜑𝜑
1 𝜕𝜕(𝐴𝐴𝜑𝜑 sin 𝜃𝜃) 𝜕𝜕𝐴𝐴𝜃𝜃 1 1 𝜕𝜕𝐴𝐴𝑅𝑅 𝜕𝜕(𝑅𝑅𝑅𝑅𝜑𝜑 )
= � − � 𝑅𝑅� + � − � 𝜃𝜃�
𝑅𝑅 sin 𝜃𝜃 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝑅𝑅 sin 𝜃𝜃 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
1 𝜕𝜕(𝑅𝑅𝑅𝑅𝜃𝜃 ) 𝜕𝜕𝐴𝐴𝑅𝑅
+ � − � 𝜑𝜑�
𝑅𝑅 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕

To transform a vector from cylindrical to the Cartesian coordinate system, transform


vector components:
𝐴𝐴𝑥𝑥 = 𝐴𝐴𝑟𝑟 cos(𝜑𝜑) − 𝐴𝐴𝜑𝜑 sin(𝜑𝜑)
𝐴𝐴𝑦𝑦 = 𝐴𝐴𝑟𝑟 sin(𝜑𝜑) + 𝐴𝐴𝜑𝜑 cos(𝜑𝜑)
𝐴𝐴𝑧𝑧 = 𝐴𝐴𝑧𝑧
and coordinate variables:
𝑥𝑥 = 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟(𝜑𝜑)
𝑦𝑦 = 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟(𝜑𝜑)
𝑟𝑟 = �𝑥𝑥 2 + 𝑦𝑦 2
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

Example of a MATLAB code to find divergence and curl:


Divergence code

% Define the grid


step = 0.1;
min = -1; max = 1;
[x, y] = meshgrid(min:step:max, min:step:max);

% Coordinate transformation
r = sqrt(x.^2 +y.^2);
phi = atan2d(y, x);

% Given vector
Ax = ...
ADD AN EXPRESSION TO COMPLETE THIS CODE
Ay = ...

% Calculate divergence
~~~~~~~~~~ do not copy this image ~~~~~~~~~~

D = divergence(x, y, Ax, Ay);

% Create a figure
quiver(x, y, Ax, Ay)
grid on; axis square; hold on
contour(x, y, D, 30)
xlabel('x'); ylabel('y')
xlim([min max]); ylim([min max]);
set(gca, 'Fontsize', 18)

% Choose divergence test points


probe_ind = [26, 26];
probe_x = x(probe_ind(1), probe_ind(2));
probe_y = y(probe_ind(1), probe_ind(2));
probe_r = sqrt(probe_x^2 + probe_y^2);

% Divergence calculated in MATLAB


probe_div = D(probe_ind(1), probe_ind(2));
% Divergence expression calculated manually
calcul_div = ... ADD AN EXPRESSION TO COMPLETE THIS CODE

% Print the answers


fprintf('x = %.10f y = %.10f\n', probe_x, probe_y);
fprintf('divergence calculated analytically = %.10f\n', calcul_div);
fprintf('divergence calculated by matlab = %.10f\n', probe_div);
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

Curl code

% Define the grid


step = 0.1;
min = -4.7; max = 4.7;
[x, y] = meshgrid(min:step:max, min:step:max);

% Coordinate transformation
r = sqrt(x.^2 +y.^2);

% Define vector components in the Cartesian c.s.


Bx = ...
ADD AN EXPRESSION TO COMPLETE THIS CODE
By = ...

% Calculate curl of B
[curlz, cav] = curl(x, y, Bx, By);
~~~~~~~~~~ do not copy this image ~~~~~~~~~~

% Create a figure
quiver(x, y, Bx, By)
grid on; axis square; hold on
contour(x, y, curlz, 30)
xlabel('x'); ylabel('y')
xlim([min max]); ylim([min max]);
set(gca, 'Fontsize', 18)

% Test point
probe_ind = [68, 78];
probe_x = x(probe_ind(1), probe_ind(2));
probe_y = y(probe_ind(1), probe_ind(2));
probe_r = sqrt(probe_x^2 + probe_y^2);

% Curl value at the test point calculated in MATLAB


matlab_curl = curlz(probe_ind(1), probe_ind(2));

% Curl expression calculated manually


calcul_curl = ... ADD AN EXPRESSION TO COMPLETE THIS CODE

% Print answers
fprintf('x = %.10f y = %.10f\n', probe_x, probe_y);
fprintf('curl calculated analytically = %.10f\n', calcul_curl);
fprintf('curl calculated by matlab = %.10f\n', matlab_curl);
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

2. Electrostatics
The idea of electric flux line (or electric lines of force as they are sometimes called) was
introduced by Michael Faraday (1791 - 1867) in his experimental investigation as a way of
visualizing the electric field. An electric flux line is an imaginary path or line drawn in such a
way that its direction at any point is the direction of the electric field at that point. A typical
application of field mapping (flux lines and equipotential surfaces) is found in the diagnosis of
the human heart.

Electric field intensity 𝐸𝐸�⃗ due to a charge distribution can be obtained from Coulomb’s law or
from Gauss’s law when the charge distribution is symmetric. Another way of obtaining 𝐸𝐸�⃗ is
from the electric scalar potential 𝑉𝑉. For an electrostatic field, the negative gradient of voltage
is the electric field:
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
𝐸𝐸�⃗ = −∇
�⃗𝑉𝑉 = − � 𝑥𝑥� + 𝑦𝑦� + 𝑧𝑧̂ �
𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕 𝜕𝜕𝜕𝜕
Electric potential is related to the work done in carrying a charge from one point to another.
Electric potential due to a charge distribution can be found as:
𝑄𝑄 𝑘𝑘𝑘𝑘
𝑉𝑉 = =
4𝜋𝜋𝜀𝜀0 𝑅𝑅 𝑅𝑅
where the proportionality constant (also called Coulomb’s constant) can be defined as:
1 𝑚𝑚
𝑘𝑘 = � �
4𝜋𝜋𝜀𝜀0 𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹
According to the superposition principle, the electric potential at point 𝑃𝑃𝑡𝑡 due to a system of 𝑛𝑛
discrete point charges located at 𝑃𝑃1 , 𝑃𝑃2 , … , 𝑃𝑃𝑛𝑛 is the sum of the potentials due to the individual
charges:
𝑄𝑄1 𝑄𝑄2 𝑄𝑄𝑛𝑛
𝑉𝑉 = + + ⋯+
4𝜋𝜋𝜀𝜀0 |𝑅𝑅�⃗ − 𝑅𝑅�⃗1 | 4𝜋𝜋𝜀𝜀0 |𝑅𝑅�⃗ − 𝑅𝑅�⃗2 | 4𝜋𝜋𝜀𝜀0 |𝑅𝑅�⃗ − 𝑅𝑅�⃗𝑛𝑛 |

where 𝑅𝑅�⃗ is the position vector of 𝑃𝑃𝑡𝑡 and 𝑅𝑅


����⃗
𝑛𝑛 is the position vector of the point charges.

Example of a MATLAB code to plot electric field and equipotential lines is given below:
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

eps_0 = 8.854e-12; % Farad/m


k = 1/(4*pi*eps_0); % Coulomb's constant, m/F

% Define point charges and their positions in the


Cartesian c.s.
p = [3,1; 3,5];
Q = [-1e-9; 1e-9];

% Create a grid of coordinates where V is to be


calculated
[X,Y] = meshgrid(0:0.02:6);

% Plot electric potential


V = zeros(size(X));
% Sum the electric potential for each charge
for i = 1:numel(Q)
V = V + k * Q(i) ./ hypot(p(i,1)-X, p(i,2)-Y);
end
contourf(X,Y,V,30); colorbar; hold on
ylabel('Electric potential (V)')

% Plot electric field


[Ex, Ey] = gradient(V);
Ex = -Ex; Ey = -Ey;
non_inf_columns = all(isfinite(Ex) & isfinite(Ey));
% Use streamslice to plot the electric field
eLines =
streamslice(X(:,non_inf_columns),Y(:,non_inf_columns),E
x(:,non_inf_columns),Ey(:,non_inf_columns));
set(eLines,'Color','g');

_______________________________________________________________

Task 1: Divergence and curl of a vector field


(a) For the given vector field
𝑟𝑟2
−� �
𝐴𝐴⃗ = 3𝑟𝑟 𝑒𝑒 16 𝑟𝑟̂ ,
find 𝑑𝑑𝑑𝑑𝑑𝑑(𝐴𝐴⃗) analytically and using MATLAB* (transformation to the Cartesian c.s. is
required). Plot the vector field 𝐴𝐴⃗ and the contours of the constant values of the
divergence in the same figure. Use two interval values: [−1 ≤ 𝑥𝑥, 𝑦𝑦 ≤ 1] and
[−10 ≤ 𝑥𝑥, 𝑦𝑦 ≤ 10] with 0.1 step in each axis to produce two plots. Compare the value of
the divergence at points 𝑃𝑃1 = (𝑥𝑥1 , 𝑦𝑦1 ) = (0.6, 0.6) and 𝑃𝑃2 = (𝑥𝑥2 , 𝑦𝑦2 ) = (5, 7). Create a
comparison table. Explain the discrepancy.

(b) For the given vector field


𝑟𝑟 2
�⃗ = 5𝑟𝑟 𝑒𝑒 −�4� 𝜑𝜑� + 3𝑧𝑧 𝑧𝑧̂ ,
𝐵𝐵
�⃗) analytically and using MATLAB*. Plot the vector field 𝐵𝐵
find 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐(𝐵𝐵 �⃗ and the contours
of the constant values of the curl in the 𝑥𝑥𝑥𝑥 plane (2D plot) in the same figure. Use two
interval values: [−0.8 ≤ 𝑥𝑥, 𝑦𝑦 ≤ 0.8] and [−10 ≤ 𝑥𝑥, 𝑦𝑦 ≤ 10] with 0.1 step in each axis to
ELEN3002/6017 Lab 1 Prepared by M. Kovaleva

produce two plots. Compare the value of the curl at points 𝑃𝑃1 = (𝑥𝑥1 , 𝑦𝑦1 ) = (0.6, 0.6) and
𝑃𝑃2 = (𝑥𝑥2 , 𝑦𝑦2 ) = (5, 7). Create a comparison table. Explain the discrepancy.

Task 2: Plot electric field and equipotential lines due to:


(a) two point charges 𝑄𝑄1 = 2 𝑛𝑛𝑛𝑛 and 𝑄𝑄2 = −2 𝑛𝑛𝑛𝑛 located at point 𝑃𝑃1 = (5, 3) and 𝑃𝑃2 = (1, 3),
respectively. Verify the value of the electric potential at point 𝑃𝑃𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 = (0, 0) by calculating it
manually.
(b) three point charges 𝑄𝑄1 = 3 𝜇𝜇𝜇𝜇, 𝑄𝑄2 = −4 𝜇𝜇𝜇𝜇 and 𝑄𝑄3 = 6 𝜇𝜇𝜇𝜇 located at points
𝑃𝑃1 = (2, 1), 𝑃𝑃2 = (5, 1) and 𝑃𝑃3 = (3.5, 4), respectively. Verify the answer of the electric
potential at point 𝑃𝑃𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 = (1, 4) by calculating it manually.

* The use of Python or another programming language instead of MATLAB to perform this
Laboratory is allowed.

END OF THE LABORATORY

You might also like