1
$\begingroup$

I am having a very rough time trying to properly define and then vectorplot the expression for the electric field of the Lienard-Wiechert potentials I have been trying to code. Up to this point, the code I have in place for the scalar and vector potentials works and produces something, but I cannot get these into an electric field equation. What I have so far is the following, please excuse the length:

The constants used

q = 1; (*elementary charge*)
c = 1;(*speed of light*)
\[CurlyEpsilon] = 1;(*vacuum permittivity of free space*)
\[Mu] = 1;(*vacuum permeability of free space*)
u = 0.1*c;

Point charge equation of motion, retarded time expression, field point location

xs[t_] := (u*Cos[30 Degree]*t) ;(*x-pos of source*)
ys[t_] := (u*Sin[30 Degree]*t) ;(*y-pos of source*)
rs[t_] := {xs[t], ys[t]};(*location of the source*)
v[t_] = D[rs[t], t];(*velocity of source*)

r = {x, y};(*location of the field point*)

tr[r_, t_] := t - Norm[r - rs[t]]/c (*the retarded time as a function of the separation distance
 and time elapsed*)

Expressions for the Lienard-Wiechert scalar and vector potentials

LWS[r_, t_] := (1/(4*Pi*\[CurlyEpsilon]))*(q*c/
      (Norm[r - rs[t]]*c -
        Dot[r - rs[t], v[tr[r, t]]]));(*equation for the Lienard-Wiechert scalar potential*)

LWV[r_, t_] := (\[Mu]/4*Pi) (q*c*v[tr[r, t]]/
      (Norm[r - rs[t]]*c -
        Dot[r - rs[t], v[tr[r, t]]]));(*equation for the Lienard-Wiechert vector potential*)

And FINALLY, this is how I am trying to get an expression for the electric field that is plottable

LWVdt = D[LWV[r, t], t];
LWSgrad = Grad[LWS[r, t], {r}];
LWEField[r_, t_] := -LWSgrad - LWVdt;(*LW electric field equation*)

The issue is that defining LWEField as I have produces the Tag List error message that [r_,t_] is protected. Thing is, is that the field is a literal function of r and t, so I do not understand how to get a plot of it without specifying it as a function of those variables. Could part of the issue be all the SetDelay I have throughout? Again I deeply apologize for the volume of this question. Even a nudge in the right direction would be great; I am wanting to know where I went wrong so far.

$\endgroup$

1 Answer 1

0
$\begingroup$

I'm not sure about the Tag List error; posting your plot code may yield some insight.

That being said, it plots fine with three changes:

  1. make LWVdt and LWSgrad functions of $t$,
  2. replace instances of $|x|^2$ with $x^2$ (Norm inserts absolute values which mess with the derivatives), and
  3. call Grad with r instead of {r}.

So the last box of code becomes

Remove[LWVdt,LWSgrad,LWEField]
LWVdt[t_] = D[LWV[r, t] /.Abs@x_^2:>x^2, t];
LWSgrad[t_] = Grad[LWS[r, t] /.Abs@x_^2:>x^2, r];
LWEField[r_, t_] := -LWSgrad@t - LWVdt@t;(*LW electric field equation*)

Then Plot3D[Evaluate@LWEField[r,0],{x,-4,4},{y,-4,4}] yields

t=0

which may or may not be the right surfaces.

$\endgroup$
4
  • 1
    $\begingroup$ Holy cow that plot looks so pretty, thank you for the promptness delivered! I do have two questions though: for one, could you elaborate a little more on the Norm situation and what you did to rectify it? I am having a hard time understanding what /.Abs@x_^2:>x^2 does. I found that it is called RuleDelayed, so is it replacing |x|^2 with x^2 each time you call it? And for two, why do we not want to call Grad with {r}? Is it because r is technically {x,y}, so I would end up calling {{x,y}} which does not make sense? $\endgroup$
    – JDRobin
    Jul 23, 2023 at 15:47
  • $\begingroup$ Little update: I just made the changes you did and my vector plot works! Thank you so much, I cannot express how helpful this is, I have been stumped for over at least two weeks on this. $\endgroup$
    – JDRobin
    Jul 23, 2023 at 16:07
  • $\begingroup$ No problem. Your reasoning about {{x,y}} is exactly right. blah/.Abs@x_^2:>x^2 is a substitution. /. is called ReplaceAll, Abs@x_^2 is the pattern. x_ is a Blank. $\endgroup$
    – Adam
    Jul 26, 2023 at 11:44
  • $\begingroup$ Mathematica takes the derivative of Abs if it is present, which is not desirable in this case. It is introduced by Norm, so either roll your own Norm function or just remove the Abs. $\endgroup$
    – Adam
    Jul 26, 2023 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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