Message Boards Message Boards


Error plotting a streamfunction in polar coordinates.

Posted 8 years ago
1 Reply
0 Total Likes

Hi, I am trying to plot a streamfunction which is given in spherical coordinates

phis = 1/r*(1 - Sin[\[Theta]]^2*(2*Sin[a]^2 - Sin[\[Theta]]^2)/Sin[a]^4);

I find that I get a different answer depending on whether I a) convert the streamfunction itself to cartesian coordinates (either manually or using TransformCoordinates) and then use Ux=dphis/dy and Uy=-dphis/dx or b) calculate the components of the stream function in the r, theta direction(Ur=1/(r^2Sin[[Theta]]))d(phis)/dt, Ut=-1/(rSin[[Theta]])d(phis)/dr) and then convert to cartesian coordinates.

In the former case, the orientation of the vortices is correct but they are asymmetric where they should be symmetric. In the second case, the vortices are symmetric but they are rotated -90 degrees.

The code I am using for case A is

a = 5*Pi/180;
phis = 1/r*(1 - 
     Sin[\[Theta]]^2*(2*Sin[a]^2 - Sin[\[Theta]]^2)/Sin[a]^4);
phic = TransformedField["Spherical" -> "Cartesian", 
   phis, {r, \[Theta], \[CurlyPhi]} -> {x, y, z}];
u = D[phic2, z];
v = -D[phic2, y];
field = {u, v};
 field /. x -> 0 // Evaluate, {y, -10, 10}, {z, -10, 10}, 
 ColorFunction -> (ColorData["Rainbow"][Rescale[#5, {0, 100}]] &), 
 ColorFunctionScaling -> False, StreamPoints -> Fine, 
 StreamStyle -> Black]

enter image description here

Note that I get the same result if

u = D[phic, z];
v = -D[phic, y];

The code I am using for Case B is

dphisdr = -((
  1 - Csc[\[Pi]/
     36]^4 Sin[\[Theta]]^2 (2 Sin[\[Pi]/36]^2 - Sin[\[Theta]]^2))/r^2)
dphisdt = (
 2 Cos[\[Theta]] Csc[\[Pi]/36]^4 Sin[\[Theta]]^3 - 
  2 Cos[\[Theta]] Csc[\[Pi]/
    36]^4 Sin[\[Theta]] (2 Sin[\[Pi]/36]^2 - Sin[\[Theta]]^2))/r
field = {(1/(r^2*Sin[\[Theta]]))*dphisdt, -1/(r*Sin[\[Theta]])*
transfield = 
  TransformedField["Polar" -> "Cartesian", 
   field, {r, \[Theta]} -> {x, y}];
StreamDensityPlot[transfield, {x, -10, 10}, {y, -10, 10}, 
 ColorFunction -> (ColorData["Rainbow"][Rescale[#5, {0, 100}]] &), 
 ColorFunctionScaling -> False, StreamPoints -> Fine, 
 StreamStyle -> Black]

And the resultant image is enter image description here

I assume the issue involves my use of the "TransformedCoordinates" function but I am not sure how to work around it?


Looks like x and y are somehow interchanged in the transformed coordinates.

POSTED BY: S M Blinder
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract