Message Boards Message Boards

0
|
12972 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Trying to simulate electric field lines from collection of point charges

Posted 10 years ago

So, I'm fairly new to Mathematica; sorry if this ends up being a very dumb question. I've been trying to simulate and plot electric field lines from point charges in Mathematica. The first resource I found is Wolfram's Electric Field Lines Due To A Collection of Point Charges, but I've been having trouble figuring out how one would incorporate more source charges. What I think I'm not quite understanding is the first lines of code defining the electric field - I don't understand how p and pp are being defined, or why it wouldn't work to simply add a third term along the lines of qi and so on. If anyone can offer any insight, I'd be very grateful.

 eeX = Compile[{{q, _Real, 1}, {pp, _Real, 2}, {p, _Real, 1}}, 
        Sum[{-((q[[i]] (p[[1]] - pp[[i, 1]]))/
((p[[1]] - pp[[i, 1]])^2 + (p[[2]] - pp[[i, 2]])^2)^(3/2)), 
-((q[[i]] (p[[2]] - pp[[i, 2]]))/
((p[[1]] - pp[[i, 1]])^2 + (p[[2]] - pp[[i, 2]])^2)^(3/2)),
 {i, Length[pp]}]]
POSTED BY: Amy Zimmerman
2 Replies
Posted 10 years ago
POSTED BY: David Keith

Hey Amy,

If you are given a point p in the plane and two sources pp = {source_1 , source_2}, the field at this point should be the vector sum of the fields induced by the two point sources. In your code, p is coordinate of a point you are interested and p[[1]] gives the x-coordinate of the point and so on. pp[[1,1]] gives the x-coordinate of source_1 and so on.

You do not have "tjhe third item" item because we are working on the 2D plane.

POSTED BY: Shenghui Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract