Skip to main content
added 14 characters in body
Source Link
henry
  • 2.6k
  • 1
  • 16
  • 29

##Method:

First I built up the geometry with a set of point charges.First I built up the geometry with a set of point charges.

Then I define points within the semi-circle.Then I define points within the semi-circle.

###Electric field at a single point in 2D space: IElectric 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

I then sum up the vectors to receive my electric field vector for that specific point in space. (see formula further down) In

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

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:

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:

##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:

added 83 characters in body
Source Link
henry
  • 2.6k
  • 1
  • 16
  • 29

###Electric field for everyat 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.

dataVectorPlot = {{x,y}, {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}} 

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, R*2 2*R}}] 

###Electric field for every point: 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)

{{x,y}, {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}} 

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 *)   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 = PlotRange -> {{0, R}, {0, R*2}}] 

###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.

dataVectorPlot = {{x,y}, {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}} 

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}}] 
Formatted code
Source Link
MarcoB
  • 68k
  • 19
  • 98
  • 205

#Plot of the electric field. That's where It beginns to be diffiult... I would like to use ListVectorPlotListVectorPlot, but I do not get the desired result. I define a list:

{{x,y},{totalElectricFieldComponent[x],toatalElectricFieldComponent[y]}}

{{x,y}, {totalElectricFieldComponent[x], toatalElectricFieldComponent[y]}} 

Where {x,y}: Point location in 2D Space

  and {totalElectricFieldComponent[x],toatalElectricFieldComponent[y] toatalElectricFieldComponent[y]}: Electric field vector at point {x,y}.

I would like to have the electric field vectors corresponding totto the chosen points in space to start at those points. --> But the result is not like an electric field of a charged semi-cirle But the result is not like an electric field of a charged semi-circle.

Definition of constants

ϵ=8.8541878176*10^−12; q=5;

n=20; (* Number of point charges *)

aStep=Pi/(2n); ( Angle Step Every n angle there is a point charge *)

R=1; (* Radius of half circle *)

Defintion of 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 = PlotRange -> {{0, R}, {0, R*2}}]

enter image description here

ϵ = 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 *) 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 = PlotRange -> {{0, R}, {0, R*2}}] 

Calculation of the electric field at every point {x,y} in 2D space:

Subscript[r, i]$r_i$ is the vector of the point charge rcharge; $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/(4Pi[Epsilon])q Table[(x - rX[[m]])/(Norm[x - rX[[m]] ])^3, {m, 1, n}];

eY[y_] := 1/(4Pi[Epsilon])q Table[(y - rY[[m]])/(Norm[y - rY[[m]] ])^3, {m, 1, n}];

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 (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
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}]];

totalElectricFieldComponentX[x_] := N[Sum[Part[eX[x], i], {i, 1, n}]]; totalElectricFieldComponentY[y_] := N[Sum[Part[eY[y], i], {i, 1, n}]]; 

(*Sum 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};

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 [Rule]
Choosen by hand for now
) 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}];

dataVectorPlot = Table[{{pointsX[[i]], pointsY[[i]]}, {totalElectricFieldComponentX[i], totalElectricFieldComponentY[i]}}, {i, 1, np}]; 

({{x,y},{totalElectricField[x],toatalElectricField[y]}}) Finally, this generates the plot and highlights the problem:

Show[geometry, ListVectorPlot[dataVectorPlot]] (* HERE IS THE PROBLEM !! *)

Show[geometry, ListVectorPlot[dataVectorPlot]] 

[enter image description hereenter image description here

#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:

{{x,y},{totalElectricFieldComponent[x],toatalElectricFieldComponent[y]}}

{x,y}: Point location in 2D Space

 {totalElectricFieldComponent[x],toatalElectricFieldComponent[y]}: Electric field vector at point {x,y}

I would like to have the electric field vectors corresponding tot the chosen points in space to start at those points. --> But the result is not like an electric field of a charged semi-cirle

Definition of constants

ϵ=8.8541878176*10^−12; q=5;

n=20; (* Number of point charges *)

aStep=Pi/(2n); ( Angle Step Every n angle there is a point charge *)

R=1; (* Radius of half circle *)

Defintion of 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 = PlotRange -> {{0, R}, {0, R*2}}]

enter image description here

Calculation of the electric field at every point {x,y} in 2D space

Subscript[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/(4Pi[Epsilon])q Table[(x - rX[[m]])/(Norm[x - rX[[m]] ])^3, {m, 1, n}];

eY[y_] := 1/(4Pi[Epsilon])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 [Rule]
Choosen by hand for now
)

dataVectorPlot = Table[{{pointsX[[i]], pointsY[[i]]}, {totalElectricFieldComponentX[i], totalElectricFieldComponentY[i]}}, {i, 1, np}];

({{x,y},{totalElectricField[x],toatalElectricField[y]}})

Show[geometry, ListVectorPlot[dataVectorPlot]] (* HERE IS THE PROBLEM !! *)

[enter image description here

#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:

{{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.

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 *) 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 = PlotRange -> {{0, R}, {0, R*2}}] 

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]] 

enter image description here

added 82 characters in body
Source Link
henry
  • 2.6k
  • 1
  • 16
  • 29
Loading
Source Link
henry
  • 2.6k
  • 1
  • 16
  • 29
Loading