0
$\begingroup$

I'm trying to use NDSolve to get a notion of the electric field around a uniform torus of density 1 (for simplicity) using Maxwell's equations. I'm running into some trouble.

R = 3;
r = 1;

densityDist[x_, y_, z_] := If[(R - Sqrt[x^2 + y^2])^2 + z^2 < r^2, 1, 0]; 

Ef[x_, y_, z_] = 
   Module[{Ef},
     Ef[x_, y_, z_] := {Ex[x, y, z], Ey[x, y, z], Ez[x, y, z]};
     Ef[x, y, z] /. 
       NDSolve[
         {Div[Ef[x, y, z], {x, y, z}] == densityDist[x, y, z], 
          Ef[0, 0, 0] == {0, 0, 0}},
         Ef[x, y, z],
         {x, -6, 6}, {y, -6, 6}, {z, -6, 6}]]

But I get

NDSolve::underdet: There are more dependent variables, {Ex[x, y, z], Ey[x, y, z], Ez[x, y, z]}, than equations, so the system is underdetermined.

Any clues of what other conditions I can put in?

$\endgroup$

closed as off-topic by m_goldberg, MarcoB, garej, mikado, LLlAMnYP Jun 19 '17 at 9:44

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "The question is out of scope for this site. The answer to this question requires either advice from Wolfram support or the services of a professional consultant." – MarcoB, garej, LLlAMnYP
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, mikado
If this question can be reworded to fit the rules in the help center, please edit the question.

2
$\begingroup$

What happened to Maxwell's other equations? You're missing $\nabla \times E = 0$ assuming there is no $B$ field.

R = 3;
r = 1;
densityDist[x_, y_, z_] := 
  If[(R - Sqrt[x^2 + y^2])^2 + z^2 < r^2, 1, 0];
Ef[x_, y_, z_] = {Ex[x, y, z], Ey[x, y, z], Ez[x, y, z]};

Then we can solve the equations as follows with some particular boundary conditions:

maxwell = {Div[Ef[x, y, z], {x, y, z}] == 0 densityDist[x, y, z]}~ Join~(# == 0 & /@ Curl[Ef[x, y, z], {x, y, z}])[[;; 2]];
NDSolve[maxwell~ Join~{Ex[-10, y, z] == 0, Ey[-10, y, z] == 0, Ez[-10, y, z] == 0}, {Ex, Ey, Ez}, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}]

For this problem however it would be better to take advantage of the symmetries and use spherical coordinates, then you can impose a vanishing boundary conditions at a large value of $r$.

$\endgroup$
1
$\begingroup$

It is easy to see what is happening if you look at what

Div[{Ex[x, y, z], Ey[x, y, z], Ez[x, y, z]}, {x, y, z}] == densityDist[x, y, z]

evaluates to.

R = 3;
r = 1;
densityDist[x_, y_, z_] = Boole[(R - Sqrt[x^2 + y^2])^2 + z^2 < r^2];

Div[{Ex[x, y, z], Ey[x, y, z], Ez[x, y, z]}, {x, y, z}] == densityDist[x, y, z]
Derivative[0, 0, 1][Ez][x, y, z] + Derivative[0, 1, 0][Ey][x, y, z] + 
    Derivative[1, 0, 0][Ex][x, y, z] == 
      Boole[(3 - Sqrt[x^2 + y^2])^2 + z^2 < 1]

Since you have done nothing to tell Mathematica that the partial derivatives are vectors rather than scalars, Mathematica simply sees one equation in thee unknowns. Hence, the error message. You need add equations the make the vector nature of the derivatives clear.

$\endgroup$

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