1
$\begingroup$

Assuming I have a vector components: A_r(r,theta) and A_t(r,theta) so A=(A_r,A_t) I would like to show the Vector A on a ring. for some reason when I'm using VectorPlot it has to be in cartesian coordinates. So I have define A_x and A_y from A(r,t) and tried to use VectorPlot yet it shows nothing. the line:

VectorPlot[{ar[r, t], at[r, t]}, {r, R1, R2}, {t, 0, 2pi}]

shows a vector field, yet it is not on a ring. when I'm trying to use the cartesian coordinates:

VectorPlot[{FullSimplify[ax[x, y]], FullSimplify[ay[x, y]]}, {x, -R2, R2}, {y, -R2, R2}, RegionFunction -> Function[{x, y}, R1^2 < x^2 + y^2 < R2^2]]

It shows nothing. I have made the transformation by

A_x=A_r[sqrt(x^2+y^2),Arctan[x,y]]*(x/sqrt(x^2+y^2))-A_t[sqrt(x^2+y^2),Arctan[x,y]]*(y/sqrt(x^2+y^2))


A_y=A_r[sqrt(x^2+y^2),Arctan[x,y]]*(y/sqrt(x^2+y^2))+A_t[sqrt(x^2+y^2),Arctan[x,y]]*(x/sqrt(x^2+y^2))

For some reasons it does not work, Any help?

$\endgroup$

3 Answers 3

1
$\begingroup$

Edit

For the lower edition.

ar[r, t] = r*t;
at[r, t] = r + t;
polar2cartesian = 
  TransformedField[
   "Polar" -> "Cartesian", {ar[r, t], at[r, t]}, {r, t} -> {x, y}];
cutpolar2cartesian = 
  polar2cartesian*Boole[1/2 <= Sqrt[x^2 + y^2] <= 2];
VectorPlot[cutpolar2cartesian // Evaluate, {x, -2, 2}, {y, -2, 2}]

enter image description here

Original

Maybe one way is use TransformedField to translate the Polar to Cartesian.

ar[r, t] = r*t;
at[r, t] = r + t;
polar2cartesian = 
  TransformedField[
   "Polar" -> "Cartesian", {ar[r, t], at[r, t]}, {r, t} -> {x, y}];
VectorPlot[polar2cartesian // Evaluate, {x, -2, 2}, {y, -2, 2}, 
 RegionFunction -> 
  Function[{x, y}, 
   1/2 <= Sqrt[x^2 + y^2] <= 2 && -π <= ArcTan[x, y] <= π]]

enter image description here

$\endgroup$
3
  • $\begingroup$ We can also set ar[r, t] = r;at[r, t] =0; or ar[r, t] = 0;at[r, t] =t; to test the method. $\endgroup$
    – cvgmt
    Jan 6, 2021 at 0:53
  • $\begingroup$ I think the problem is with the RegionFunction. I have used TransformedField to get ax and ay, when I use 'Plot3D[Evaluate[polar2cartesian], {x, -R2, R2}, {y, -R2, R2}]' results are shown, yet when RegionFunction is added, it shows nothing, also when using RegionFunction in VectorPlot. It has to be done on a ring because for r=0 ax and ay are large so there are no other vectors. $\endgroup$
    – jonathan
    Jan 6, 2021 at 22:15
  • $\begingroup$ @jonathan test the updated. $\endgroup$
    – cvgmt
    Jan 6, 2021 at 23:28
1
$\begingroup$

Here is one way of doing it, using the cartesian components, given as a function of polar coordinates:

vec[r_, phi_] = 
 r {-Sin[phi], Cos[phi]}; (*cart. comp. of vector field*)
dat = Flatten[
  Table[{r { Cos[p], Sin[p]}, vec[r, p]}, {r, 0.6, 1, 0.1}, {p, 0, 
    2 Pi , Pi/6}], 1];
ListVectorPlot[dat, VectorPoints -> All]

enter image description here

$\endgroup$
0
$\begingroup$

We don't have the definitions of your functions, so unforutnately I can't use those in my answer, but here is an example that might get you started:

ring = Annulus[{0, 0}, {1, 2}];

VectorPlot[
  {2 x + y, x - y^2}, {x, y} ∈ ring,
  Prolog -> {FaceForm[LightGray], EdgeForm[Black], ring}
]

vector plot output overlaid on the annulus domain

$\endgroup$
2
  • $\begingroup$ For some reason the function Annulus gets the code to stuck $\endgroup$
    – jonathan
    Jan 5, 2021 at 21:16
  • $\begingroup$ @jonathan Gotta give us some more info there to troubleshoot the problem... $\endgroup$
    – MarcoB
    Jan 5, 2021 at 21:32

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.