# Plotting the electric field from a moving charge in 3D

I want to show a 3D electric field changing with time in response to the path of a moving charged particle. I have an animation of a particle traveling along a helical path using the parametrization for a helix (cos[t],sin[t], t). I took derivatives of this parametrization to find velocity and acceleration and using geometrized units (q=e0=c=1), subbed this into the equation for the E field of a moving particle :

My plan was to make animations for the moving particle and changing field separately and then show them together. So far I was able to get the moving particle but I can't get an animation for the changing E field yet. I'm thinking this is because I have an E[t] whereas Vectorplot3D needs an x,y,z so I'm not sure how to proceed. Any suggestions would be helpful. Many thanks!

My code so far is as follows. I'm not very adept at this kind of thing yet so I apologize that my code is not as clear as it could be, hopefully what I'm trying to do is clear. (Note - I used a z component of t/4 to adjust the height of the helix to look nice in the animation and I used z=8 in my r' because that appears to be the total height the helix reaches.)

   Animate[ParametricPlot3D[{Cos[t], Sin[t], t/4}, {t, 0, u},
ImageSize -> Small,
MeshFunctions -> {#4 &},
Mesh -> {{u}},
MeshStyle -> Red,
Method -> {"BoundaryOffset" -> False},
PlotRange -> {{-2, 2}, {-2, 2}, {0, 8}}] /.
Point -> (Sphere[#, 0.15] &), {u, 10^-8, 30}, AnimationRate -> 0.12]

Rvector = {-Cos[t], -Sin[t], 8 - t/4};

Rnorm = Norm[Rvector];

Vvector = {-Sin[t], Cos[t], 1/4};

Vnorm = Norm[Vvector];

Alpha = Rvector/Rnorm - Vvector;

a = {-Cos[t], -Sin[t], 0};

Evector =
Rnorm/(4*\[Pi] (Rvector.Alpha)^3) ((1 - Vnorm^2)*Alpha +
Cross[Rvector, Cross[Alpha, a]]);

Ex = Evector[[1]];

Ey = Evector[[2]];
Ez = Evector[[3]];

Animate[VectorPlot3D[{Ex, Ey, Ez}, {x, -5, 5}, {y, -5, 5}, {z, -5,
5}], {t, 10^-50, }]


So far I was able to get the moving particle but I can't get an animation for the changing E field yet.

I have not followed your code, but you can get the last part to work by doing this

Animate[VectorPlot3D[
Evaluate[{Ex, Ey, Ez} /. t -> t0], {x, -5, 5}, {y, -5, 5}, {z, -5,
5}], {t0, 10^-50, 1}]


The above also works without using Evaluate as in

Animate[VectorPlot3D[
{Ex, Ey, Ez} /. t -> t0, {x, -5, 5}, {y, -5, 5}, {z, -5,
5}], {t0, 10^-50, 1}]


But you need to play around with scaling and spacing by changing some options to make it easier to see.

But why use Animate when one can Manipulate? Manipulate does what Animate does but much more. I do not use Animate myself at all. I see no need for it. For example

 Animate[Cos[a t], {a, 0, 1, .1}]


And this

 Manipulate[Cos[a t], {{a, 0, "a"}, 0, 1, .1}]


Do the same thing. But Manipulate has many more options and much more flexible.

• Hi Nasser, thank you for your reply! I'm sorry my code wasn't clear. I'm trying to plot the electric field changing in time where the electric field is given by the equation listed, the particle is traveling along a helix (r') and it starts from the origin .The maximum height reached in the animation of the helix was 8 so I used 0,0,8 for r,. The script r in the equation is what I called capital R and is given by r-r'. Velocity and acceleration are wrt the particle so I took derivatives of r' to get V and A. The U in the equation I called alpha to be consistent with my class notes is Rhat - V – Brennan Rodgers Dec 15 '19 at 20:55
• Also, thank you for pointing out manipulate over animate! I'm still learning and I have no reason to use animate over manipulate other than it was the first thing I thought to do that could work. Thank you for all your help!! – Brennan Rodgers Dec 15 '19 at 20:56

I can't post code in comments so I am responding to @Nasser using an "answer". I apologize if this is inappropriate.

I am having trouble getting both animations to play on top of each other. I am using manipulate like so:

 Manipulate[
ParametricPlot3D[{Cos[t], Sin[t], t/4}, {t, 0, t0},
ImageSize -> Small,
MeshFunctions -> {#4 &},
Mesh -> {{t0}},
MeshStyle -> Red,
Method -> {"BoundaryOffset" -> False},
PlotRange -> {{-2, 2}, {-2, 2}, {0, 8}}] /.
Point -> (Sphere[#, 0.15] &),
VectorPlot3D[{Ex, Ey, Ez} /. t -> t0, {x, -2, 2}, {y, -2, 2}, {z, 0,
8}],
{t0, 0, 30}]


But I am getting an error on VectorPlot3D "Manipulate argument VectorPlot3D[{Ex,Ey,Ez}/. t->t0,{x,-2,2},{y,-2,2},{z,0,8}] does not have the correct form for a variable specification". When I do the manipulate for VectorPlot3D on it's own, it's fine but it seems that having both at once is causing an issue. I was wondering if you have any advice in regards to this. Many thanks.

• May be use Show? see if this does wat you want. Manipulate[p1 = ParametricPlot3D[{Cos[t], Sin[t], t/4}, {t, 0, t0}, ImageSize -> Small, MeshFunctions -> {#4 &}, Mesh -> {{t0}}, MeshStyle -> Red, Method -> {"BoundaryOffset" -> False}, PlotRange -> {{-2, 2}, {-2, 2}, {0, 8}}] /. Point -> (Sphere[#, 0.15] &); p2 = VectorPlot3D[{Ex, Ey, Ez} /. t -> t0, {x, -2, 2}, {y, -2, 2}, {z, 0, 8}]; Show[p1, p2, PlotRange -> All] , {{t0, 0.01, "max time?"}, 0.01, 2, 0.01}, TrackedSymbols :> {t0} ] – Nasser Dec 15 '19 at 23:10