Plot the electric field inside of a charged semi cirle.
Method:
First I built up the geometry with a set of point charges.
Then I define points within the semi-circle.
Electric field at a single point in 2D space:
I calculate the electric field vectors produced by each individual point charges along the semi circle.
I then sum up the vectors to receive my electric field vector for that specific point in space. (see formula further down)
In the end, I do this calculation for many different points in 2D space and will therefore receive an approximation of the total electric field.
Plot of the electric field.
That's where It beginns to be diffiult...
I would like to use ListVectorPlot
, but I do not get the desired result.
I define a list:
dataVectorPlot = {{x,y}, {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}}
Where {x,y}: Point location in 2D Space and {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}: Electric field vector at point {x,y}.
I would like to have the electric field vectors corresponding to the chosen points in space to start at those points. But the result is not like an electric field of a charged semi-circle.
So here is the code:
Definition of constants:
ϵ = 8.8541878176*10^−12;
q = 5;
n = 20; (* Number of point charges *)
aStep = Pi/(2*n); (* Angle Step Every n angle there is a point charge *)
R = 1; (* Radius of half circle *)
Definition of the geometry:
rX = Table[R*Sin[Pi/2 - a], {a, -Pi/2, Pi/2, aStep}];
rY = Table[R*(1 + Cos[Pi/2 - a]), {a, -Pi/2, Pi/2, aStep}];
r = Transpose[{rX, rY}];
geometry = ListPlot[r, AspectRatio -> Automatic, PlotRange -> {{0, R}, {0, 2*R}}]
Calculation of the electric field at every point {x,y} in 2D space:
$r_i$ is the vector of the point charge; $r$ is the vector to the point in 2D (or also 3D) space where we want to calculate the electric field.
Clear[x, y, i] (*local variables*)
np = 5; (*Number of points to evaluate the electric field*)
eX[x_] := 1/(4*Pi*ϵ)*q*Table[(x - rX[[m]])/(Norm[x - rX[[m]] ])^3, {m, 1, n}];
eY[y_] := 1/(4*Pi*ϵ)*q*Table[(y - rY[[m]])/(Norm[y - rY[[m]] ])^3, {m, 1, n}];
The x- and y component of the electric fields produced by each point charge q at (rX,rY), at point (x,y)in 2D space, are put into a list.
totalElectricFieldComponentX[x_] := N[Sum[Part[eX[x], i], {i, 1, n}]];
totalElectricFieldComponentY[y_] := N[Sum[Part[eY[y], i], {i, 1, n}]];
Sum of the Electric fields produced by each point charge at point point (x,y).
pointsX = {0.01, 0.2, 0.5, 0.7, 0.8};
pointsY = {0.01, 0.5, 1, 1.5, 1.7};
Points where the electric field should be evealuated; Chosen by hand for now.
dataVectorPlot = Table[{{pointsX[[i]], pointsY[[i]]}, {totalElectricFieldComponentX[i], totalElectricFieldComponentY[i]}}, {i, 1, np}];
Finally, this generates the plot and highlights the problem:
Show[geometry, ListVectorPlot[dataVectorPlot]]
{}
button above the edit window. The edit window help button?
is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful $\endgroup$