1
$\begingroup$

I wanted to plot vector field of 12 positive charges Standing in a circular way with a positive charge at the center all same magnitude. I do not know how to start. Can you please help me Thanks.

$\endgroup$
3
  • 2
    $\begingroup$ Look up VectorPlot or VectorPlot3D depending on whether it's in the plane or in space. $\endgroup$
    – Michael E2
    Oct 3 '19 at 14:40
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Dunlop
    Oct 3 '19 at 17:40
  • $\begingroup$ can you upload sketch hand draw of what you mean!? $\endgroup$
    – Alrubaie
    Oct 3 '19 at 18:04
2
$\begingroup$

Electric field lines for 12 negative (left) and 12 positive (right) charges located on a circle

p = Table[{Cos[x], Sin[x], 0}, {x, 0, 2 Pi - Pi/6, Pi/6}];

U[x_, y_, z_] := 
 Sum[1/Sqrt[({x, y, z} - p[[i]]).({x, y, z} - p[[i]])], {i, Length[p]}]

Efield = Grad[U[x, y, z], {x, y, z}];

StreamDensityPlot[{Efield[[1]], Efield[[2]]} /. z -> 0.1, {x, -1.5, 
  1.5}, {y, -1.5, 1.5}, ColorFunction -> "Rainbow", 
 StreamStyle -> LightGray, StreamPoints -> Fine]

StreamDensityPlot[{-Efield[[1]], -Efield[[2]]} /. z -> 0.05, {x, -1.5,
   1.5}, {y, -1.5, 1.5}, ColorFunction -> Hue, 
 StreamStyle -> LightGray, StreamPoints -> Fine]

Figure 1

Electric field lines for 12 negative (left) and 12 positive (right) charges located on a circle + one in the center

p = Table[{Cos[x], Sin[x], 10^-3}, {x, 0, 2 Pi - Pi/6, Pi/6}];

U[x_, y_, z_] := 
 Sum[1/Sqrt[({x, y, z} - p[[i]]).({x, y, z} - p[[i]])], {i, 
    Length[p]}] + 1/Sqrt[{x, y, z}.{x, y, z}]

Efield = Grad[U[x, y, z], {x, y, z}];

StreamDensityPlot[{Efield[[1]], Efield[[2]]} /. z -> 0.1, {x, -1.5, 
  1.5}, {y, -1.5, 1.5}, ColorFunction -> "Rainbow", 
 StreamStyle -> LightGray, StreamPoints -> Fine]

StreamDensityPlot[{-Efield[[1]], -Efield[[2]]} /. z -> 0.05, {x, -1.5,
   1.5}, {y, -1.5, 1.5}, ColorFunction -> Hue, 
 StreamStyle -> LightGray, StreamPoints -> Fine]

Figure 2

$\endgroup$
7
  • $\begingroup$ Many thanks🙏, how is it like when a same charge is placed at the center? $\endgroup$ Oct 9 '19 at 7:35
  • $\begingroup$ @ElaheLashgari Do you ask or answer? $\endgroup$ Oct 9 '19 at 11:38
  • $\begingroup$ I asked what if we put a charge with same magnitude and positive right at the center of each circle, how the field looks like then? So imagin we have 13 positive charges instead of 12 $\endgroup$ Oct 9 '19 at 12:53
  • $\begingroup$ @ElaheLashgari See update to my answer. $\endgroup$ Oct 9 '19 at 15:43
  • $\begingroup$ Thanks, just a question, what does this line mean? What is P[[i]] here?Sum[1/Sqrt[({x, y, z} - p[[i]]).({x, y, z} - p[[i]])], {i, Length[p]}] + 1/Sqrt[{x, y, z}.{x, y, z} $\endgroup$ Oct 11 '19 at 6:01
1
$\begingroup$

This is beginning you can do the rest!

or = Graphics[{PointSize[Large], Point[{0, 0}]}];
g1 = ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}];
pp = Table[{Cos[t], Sin[t]}, {t, 0, 2 Pi, Pi/6}];
g2 = ListPlot[pp, PlotStyle -> {Black, PointSize[Large]}];
Show[g1, g2, or]

enter image description here

$\endgroup$
2
  • $\begingroup$ Great,many Thanks it is a big help🙏 $\endgroup$ Oct 7 '19 at 5:41
  • $\begingroup$ This is exactly what I wanted to plot it’s electric field vector. Can you please help me with that. $\endgroup$ Oct 8 '19 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.