0
$\begingroup$

So typed the below code into my personal computer and it worked just fine. I then moved the file to my work computer so I could look at it there, and now VectorPlot comes up blank. I am not sure if there was a version change, but I have double checked the syntax against the documentation and it looks fine. I have evaluated my functions in multiple places to check that Mathematica is understanding my function and it looks fine to me. Can someone help me figure out why my plot won't show up?

ClearAll["Global`*"]

\[Mu] = 1.25663753*10^(-6);
i = 1;
L = 2;
a = 0.5;
\[Omega] = 1*2*\[Pi];

H[\[Rho]_] := (4*a*\[Rho])/(a + \[Rho])^2;
kplus[z_, \[Rho]_] := (4*a*\[Rho])/((a + \[Rho])^2 + (z - L/2)^2);
kminus[z_, \[Rho]_] := (4*a*\[Rho])/((a + \[Rho])^2 + (z + L/2)^2);

Subscript[A, \[Phi]][z_, \[Rho]_] := (\[Mu] i)/(4 \[Pi])*1/L*Sqrt[
   a/\[Rho]]*((z - L/2) kplus[
   z, \[Rho]] ((
     kplus[z, \[Rho]]^2 + H[\[Rho]]^2 - 
      H[\[Rho]]^2 kplus[z, \[Rho]]^2)/(
     H[\[Rho]]^2 kplus[z, \[Rho]]^2)*
     EllipticK[kplus[z, \[Rho]]^2] - 
    1/kplus[z, \[Rho]]^2 EllipticE[kplus[z, \[Rho]]^2] + (
     H[\[Rho]]^2 - 1)/
     H[\[Rho]]^2 EllipticPi[H[\[Rho]]^2, 
      kplus[z, \[Rho]]^2]) - (z + L/2) kminus[
   z, \[Rho]] ((
     kminus[z, \[Rho]]^2 + H[\[Rho]]^2 - 
      H[\[Rho]]^2 kminus[z, \[Rho]]^2)/(
     H[\[Rho]]^2 kminus[z, \[Rho]]^2)*
     EllipticK[kminus[z, \[Rho]]^2] - 
    1/kminus[z, \[Rho]]^2 EllipticE[kminus[z, \[Rho]]^2] + (
     H[\[Rho]]^2 - 1)/
     H[\[Rho]]^2 EllipticPi[H[\[Rho]]^2, kminus[z, \[Rho]]^2]));

Evaluate[Subscript[A, \[Phi]][0, 2]]

Subscript[A, \[Rho]][z_, \[Rho]_] := 0;
Subscript[A, z][z_, \[Rho]_] := 0;
Subscript[A, x][x_, y_, z_] := 
Subscript[A, \[Phi]][
    z, \[Rho] = Sqrt[x^2 + y^2]]*(-Sin[ArcTan[y/x]]);
Subscript[A, y][x_, y_, z_] := 
Subscript[A, \[Phi]][z, \[Rho] = Sqrt[x^2 + y^2]]*(Cos[ArcTan[y/x]]);
Subscript[A, z][x_, y_, z_] := Subscript[A, z][z, \[Rho]];
Evaluate[Subscript[A, x][x = 1, y = 2, z = 0]]
Evaluate[Subscript[A, y][x = 1, y = 2, z = 0]]

VectorPlot[{Subscript[A, x][x, y, z = 0], 
Subscript[A, y][x, y, z = 0]}, {x, -2, 2}, {y, -2, 2}]
$\endgroup$
  • 1
    $\begingroup$ What if you ditch the Subscripts and just use regular variables ...? $\endgroup$ – ktm Dec 13 '18 at 19:24
  • $\begingroup$ That worked! Do newer versions of Mathematica not work well with subscripts then? $\endgroup$ – Physika Dec 13 '18 at 19:29
  • $\begingroup$ They can just cause issues (like this one) that I find are headaches, so I just avoid using subscripts entirely. $\endgroup$ – ktm Dec 13 '18 at 19:30
  • $\begingroup$ Makes sense, thank you! $\endgroup$ – Physika Dec 13 '18 at 19:31
1
$\begingroup$

Inside the VectorPlot function, Mathematica reads the subscripts for "x" and "y" as variables for the plot, instead of recognizing that they are part of the name of the function to be plotted. This can be seen by looking at the colors of the variables inside VectorPlot. The subscripts x and y are green--the same color as the variables being plotted against.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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