0% found this document useful (0 votes)
35 views10 pages

CEM Lab 4 - Merged

This document contains the details of a computational electromagnetics lab experiment conducted by Shrie Varshini. The experiment involves plotting the electric potential and flux/equipotential surfaces for a given 2D region in MATLAB. For the first question, the code calculates potential values at specific points using a custom quadratic equation and plots the results. For the second question, the code generates a graphic showing flux lines and equipotential contours along with electric field vectors to visualize how potential and flux interact in the region. Both questions provide visualizations that help understand electric field behavior and how charges produce fields in space.

Uploaded by

Shrie Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views10 pages

CEM Lab 4 - Merged

This document contains the details of a computational electromagnetics lab experiment conducted by Shrie Varshini. The experiment involves plotting the electric potential and flux/equipotential surfaces for a given 2D region in MATLAB. For the first question, the code calculates potential values at specific points using a custom quadratic equation and plots the results. For the second question, the code generates a graphic showing flux lines and equipotential contours along with electric field vectors to visualize how potential and flux interact in the region. Both questions provide visualizations that help understand electric field behavior and how charges produce fields in space.

Uploaded by

Shrie Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Name: Shrie Varshini

Roll no.: CH.EN.U4CCE22040

Date: 21-08-2023

COMPUTATIONAL ELECTROMAGNETICS
LAB EXPERIMENT 4

QUESTION 1:
Abstract:
To plot a graph of electric potential in MATLAB with the given specific
points.

Theory:
The amount of effort required to transport a unit charge from a reference
point to a particular place inside the field without causing an acceleration is
known as the electrostatic potential, also known as the electric field potential, or
potential drop.

 Electric potential is a scalar quantity.


 It is denoted by ‘V’.
 Formula: V = W/q.
 Unit of V is Volt.

The equation V = k [q/r] yields the electric potential (also known as electric
potential energy per unit charge) at a location in an electric field.
Code:
clean all
close all
% Given parameters
Vo = 100.0;
a = 1;
b = a;
x = linspace(0, b, 100);
y = linspace(0, a, 100);
[X, Y] = meshgrid(x, y);
c = -4 * Vo / pi;

% Calculate the potential values


V = zeros(size(X));
for k = 1:10
n = 2 * k - 1;
al = sin(n * pi * X / b);
a2 = sinh(n * pi * (a - Y) / b);
a3 = n * sinh(n * pi * a / b);
V = V + c * al .* a2 / a3;
end

% Calculate electric field vectors


[Ex, Ey] = gradient(-V);

% Calculate flux lines


streamslice(X, Y, Ex, Ey);

% Plot equipotential lines


hold on;
contour(X, Y, V, 20);

% Plot electric field vectors


quiver(X, Y, Ex, Ey, 2);
xlabel('x');
ylabel('y');
title('Flux, Equipotential Lines, and Electric Field Vectors');
legend('Flux Lines', 'Equipotential Lines', 'Electric Field Vectors');
grid on;
axis equal;
axis ij; % Invert y-axis
hold off;

% Parameters
initialVelocity = 100.0;
length_a = 1.0;
length_b = length_a;
constant_c = 4 * initialVelocity / pi;
numTerms = 10; % Number of terms in the series

% Calculate potentials at specific points


x_points = linspace(0.2 * length_a, 0.8 * length_a, 3); % Adjusted range
y_points = linspace(0.2 * length_b, 0.8 * length_b, 3); % Adjusted range
[X_points, Y_points] = meshgrid(x_points, y_points);
potentials = zeros(size(X_points));

for i = 1:numel(X_points)
x = X_points(i);
y = Y_points(i);
sum = 0.0;

for k = 1:numTerms
n = 2 * k - 1;
al = sin(n * pi * x / length_b);
a2 = sinh(n * pi * y / length_b);
a3 = n * sinh(n * pi * length_a / length_b);
sum = sum + constant_c * al * a2 / a3;
end

% Change the potential calculation here


% For example, use a different equation or expression
% Let's use a simple quadratic equation
potentials(i) = x^2 + y^2; % Custom potential equation
end

% Plot potential values at specific points


figure;
scatter(X_points(:), Y_points(:), 100, 'k', 'filled');
xlabel('x');
ylabel('y');
title('Custom Electric Potential Values at Specific Points');
axis([0 length_a 0 length_b]); % Set axis boundaries
axis equal;

% Annotate potential values slightly above each point


for i = 1:numel(X_points)
x = X_points(i);
y = Y_points(i);
value = potentials(i);
text(x, y + 0.05, sprintf('V = %.2f', value), 'FontSize', 10,
'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle', 'Color',
'k');
end
Output:

Figure 1

Inference:
The algorithm creates a 2D visual depiction of electric fields and
potentials using a grid of computed points. Using arrows to denote the intensity
and direction of the electric field vectors, it illustrates how the area's electric
potential varies. We can better comprehend how potential energy is spread in
space and how charges produce fields thanks to this visualisation.
QUESTION 2:
Abstract:
To plot a graph in MATLAB for flux and equipotent surfaces

Theory:
Equipotential points are those in an electric field that are all at the same
electric potential. A line or curve connecting these places is referred to as an
equipotential line. An equipotential surface is one where such points are present.
A space or volume is referred to as an equipotential volume if these points are
dispersed throughout it.
Moving a charge between two places on an equipotential surface requires no
labour at all. In an equipotential surface, the effort required to transport a point
charge from point VA to point VB is given by
W = q0 (VA –VB)
As VA – VB is equal to zero, the total work done is W = 0.

Code:
% Given parameters
Vo = 100.0;
a = 1;
b = a;
x = linspace(0, b, 100);
y = linspace(0, a, 100);
[X, Y] = meshgrid(x, y);

c = -4 * Vo / pi;

% Calculate the potential values


V = zeros(size(X));

for k = 1:10
n = 2 * k - 1;
al = sin(n * pi * X / b);
a2 = sinh(n * pi * (a - Y) / b);
a3 = n * sinh(n * pi * a / b);
V = V + c * al .* a2 / a3;
end

% Calculate electric field vectors


[Ex, Ey] = gradient(-V);

% Calculate flux lines


streamslice(X, Y, Ex, Ey);
% Plot equipotential lines
hold on;
contour(X, Y, V, 20);

% Plot electric field vectors


quiver(X, Y, Ex, Ey, 2);

xlabel('x');
ylabel('y');
title('Flux, Equipotential Lines, and Electric Field Vectors');
legend('Flux Lines', 'Equipotential Lines', 'Electric Field Vectors');
grid on;
axis equal;
axis ij; % Invert y-axis
hold off;

output:

Figure 2
Inference:
The programme produces a graphic representation that shows how
potentials and electric flux interact in a 2D environment. Electric potential may
be visualised by calculating it at several locations and comparing the results.
Incorporating flux lines and arrows to represent the electric field vectors aids in
our comprehension of how charged particles might flow inside the field.
Additionally, the graph's overlaying equipotential lines highlight areas with
constant energy levels.

You might also like