For the sake of demonstration (for my students) and practice, I wanted to numerically calculate the electric and magnetic field (3D) for a sphere of uniform density moving slightly to the right and back. Just to show/see that the changes in the E-M fields propagate at a fixed speed, as predicted by Maxwell's theory, but because of the Gauge Invariance of the potentials, they don't necessarily always follow that restriction.
I'm trying to have Mathematica solve Maxwell's equations numerically for the scalar and vector potentials for the given situation (with no success). Could you guys help me point out where I'm messing up? Thanks!
PS: I've elected to have the change distribution and it's motion being defined as an interpolating function, which gives me room to improve accuracy as necessary, for testing sake.
Here is the code as neatly as I could put it :)

    (*Max time of the simulation*)
    (*x coordinate shift of the charged sphere, you can run Plot[\[ScriptX][t],{t,0,tMax}] to see what it looks like*)
      Interpolation[{{0, 0},{3, 0},{5, 2},{7, 0},{tMax, 0}},InterpolationOrder->1];
    (*Charge distribution as a interpolating function in 4D (x,y,z,t), all points are zero except the inside of the sphere which is 1, you can run Manipulate[Plot[ρ[x,0,0,t],{x,-5,5}],{t,0,tMax}] to see what it looks like*)
    (*Current Density, defined as \[ScriptJ]=ρv*)
    \[ScriptJ]=ρ[x, y, z, t]{\[ScriptX]'[t],0,0};
    (*scalar potential*)
    (*Vector potential*)
    (*Electric field in terms of scalar and vector potentials*)
    (*Magnetic field in terms of vector potential*)
    (*Relevant maxwell's equations
    The equation ∇.ℬ=0 is trivial form the definition of ℬ in terms of \[ScriptCapitalA], if you try to use it, it simply returns "True", which it is.
    Same for ∇\[Cross]ℰ=-\!\(
    \*SubscriptBox[\(∂\), \(t\)]ℬ\), so those can be ignored if we're dealing with potentials*)
    NDSolve[Eqs, {φ, \[ScriptCapitalA]x, \[ScriptCapitalA]y, \[ScriptCapitalA]z},{x,-5,5},{y,-5,5},{z,-5,5},{t,0,tMax}]

(it's neater on the original format, but copying and pasting it into a mathematica notebook makes it not-so-ugly)
If you run it, you'll see that we get the error: "Boundary values may only be specified for one independent variable. Initial values may only be specified at one value of the other independent variable". Maybe I'm missing on some boundary conditions or initial conditions? But I cannot think of what those would be. I know that Gauge cannot be the problem, since it would not show in the solution anyway. Any help you could provide would be great!
PS: i know there are other tools I can use to do a numerical simulation, and I'm willing to learn them if that's what I have to do, but I'd be great if I could solve this and future problems with Mathematica :)

  • 2
    $\begingroup$ Such a straightforward approach will not do anything. It is necessary to formulate a boundary value problem and use FEM or BEM. I solved a similar problem for a flat capacitor moving at a constant speed. $\endgroup$ – Alex Trounev Sep 21 '19 at 5:35
  • 1
    $\begingroup$ If you're interested, I have some notebooks where I implemented basically everything is explained in this series of lectures on FDTD. $\endgroup$ – Fortsaint Sep 21 '19 at 8:09
  • 1
    $\begingroup$ The missing of i.c. and b.c. is certainly a problem, but it's not too hard to resolve (if you don't need things like PML). What's more serious is, NDSolve cannot handle terms like Derivative[0, 1, 0, 1][\[ScriptCapitalA]y][x, y, z, t] (mixture of temperal and spatial derivative) well, at least now. Related: mathematica.stackexchange.com/q/184281/1871 I believe one should first solve for electric field and magnetic field based on Faraday's law and Maxwell–Ampère law first using NDSolve and calculate for φ etc. afterwards. $\endgroup$ – xzczd Sep 21 '19 at 8:18
  • $\begingroup$ @ Fortsaint Could you share the notebooks on FDTD with me? $\endgroup$ – baker Sep 21 '19 at 13:33
  • $\begingroup$ @fortsaint I would like to see these as well, perhaps a question about implementing efficient fdtd methods? $\endgroup$ – CA Trevillian Sep 22 '19 at 0:35

Browse other questions tagged or ask your own question.