Message Boards Message Boards

0
|
3952 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Generate discrete 3d plots for magnetic field lines?

Posted 5 years ago

I want to generate a discrete 3d set of plots for magnetic field lines. The equation is:

r=rn Cos[\[Omega] + \[Xi] Cos[\[Phi] + \[Phi]0]]^2

rn and [Phi]0 are constants, rn could be =1, [Phi]0=0, [Xi]=-.18, [Omega] runs from 0 to 2 Pi, I want to plot r for a set of discrete values of [Phi] , such as, [Phi] =0, 0.1, 0.2, 0.3, 0.4... How can I do it? Thanks

POSTED BY: Hong-Yee Chiu
3 Replies
Posted 5 years ago

I got two responses quickly, and one of them furnishes partial answer, First I need to generate the data, which was furnished by Rohit Namjoshi Then I found how to convert the spherical coordinate data to Cartesian coordinates so that I can plot them from an earlier discussion, https://stackoverflow.com/questions/16758837/multiple-listpolarplots-in-3d-in-mathematica the content is copied below, When you want to make a 3D plot you will need to have 3D data first. Therefore, I assume you really meant a ListSphericalPlot3D. If you already have the list of your points in spherical coordinates, it's not really hard to plot them. What we do is, basically first changing the coordinates to "Cartesian", then plotting it:

ListSphericalPlotPoints3D[list_List] := ListPointPlot3D[Map[CoordinateTransformData["Spherical" -> "Cartesian","Mapping", #] &,Map[{#[[1]], Mod[#[[2]], [Pi]], Mod[#[[3]], 2 [Pi]]} &, list]]]; ListSphericalPlot3D[list_List] := ListPlot3D[Map[CoordinateTransformData["Spherical" -> "Cartesian", "Mapping", #] &, Map[{#[[1]], Mod[#[[2]], [Pi]], Mod[#[[3]], 2 [Pi]]} &,list]]]; These two functions will hopefully do, what you are asking for. Update: Since this transformation is rather simple, it is straightforward to write the whole transformation by hand: ListSphericalPlotPoints3D[list_List] := ListPointPlot3D[Map[{#[[1]] Sin[#[[2]]] Cos[#[[3]]], #[[1]] Sin[#[[2]]] Sin[#[[3]]], #[[1]] Cos[#[[2]]]} &,Map[{#[[1]], Mod[#[[2]], [Pi]], Mod[#[[3]], 2 [Pi]]} &, list]]]; ListSphericalPlot3D[list_List] := ListPlot3D[Map[{#[[1]] Sin[#[[2]]] Cos[#[[3]]], #[[1]] Sin[#[[2]]] Sin[#[[3]]], #[[1]] Cos[#[[2]]]} &, Map[{#[[1]], Mod[#[[2]], [Pi]], Mod[#[[3]], 2 [Pi]]} &,list]]];

so now I have the answers. Thanks

POSTED BY: Hong-Yee Chiu

Do you mean a 3D version of StreamPlot? There is something a bit like that in my package CurvesGraphics6 http://www.dimi.uniud.it/gorni/Mma

POSTED BY: Gianluca Gorni
Posted 5 years ago

I am not sure exactly what you mean by "discrete 3d set of plots for magnetic field lines".

Is this the correct WL definition of the equation?

r[?_, ?_] := Module[{rn = 1, ?0 = 0, ? = -0.18}, rn Cos[? + ? Cos[? + ?0]]^2]

If so, you can use Table to generate a list of values of the function for a range of ? and ? that you can then plot. e.g.

Table[{?, ?, r[?, ?]}, {?, 0, 2 Pi, Pi/12}, {?, 0, 0.4, 0.1}];
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract