【发布时间】:2011-04-23 16:40:35
【问题描述】:
我正在寻找类似回音壁模式的东西——极坐标中的 2D 圆柱对称图。像这样的:
我在 Trott 的符号指南中找到了以下代码 sn-p。尝试在一个非常小的数据集上运行它;它吃掉了 4 GB 的内存并耗尽了我的内核:
(* add points to get smooth curves *)
addPoints[lp_][points_, \[Delta]\[CurlyEpsilon]_] :=
Module[{n, l}, Join @@ (Function[pair,
If[(* additional points needed? *)
(l = Sqrt[#. #]&[Subtract @@ pair]) < \[Delta]\[CurlyEpsilon], pair,
n = Floor[l/\[Delta]\[CurlyEpsilon]] + 1;
Table[# + i/n (#2 - #1), {i, 0, n - 1}]& @@ pair]] /@
Partition[If[lp === Polygon,
Append[#, First[#]], #]&[points], 2, 1])]
(* Make the plot circular *)
With[{\[Delta]\[CurlyEpsilon] = 0.1, R = 10},
Show[{gr /. (lp : (Polygon | Line))[l_] :>
lp[{#2 Cos[#1], #2 Sin[#1]} & @@@(* add points *)
addPoints[lp][l, \[Delta]\[CurlyEpsilon]]],
Graphics[{Thickness[0.01], GrayLevel[0], Circle[{0, 0}, R]}]},
DisplayFunction -> $DisplayFunction, Frame -> False]]
这里,gr 是一个矩形 2D ListContourPlot,使用类似这样的东西生成(例如):
data = With[{eth = 2, er = 2, wc = 1, m = 4},
Table[Re[
BesselJ[(Sqrt[eth] m)/Sqrt[er], Sqrt[eth] r wc] Exp[
I m phi]], {r, 0, 10, .2}, {phi, 0, 2 Pi, 0.1}]];
gr = ListContourPlot[data, Contours -> 50, ContourLines -> False,
DataRange -> {{0, 2 Pi}, {0, 10}}, DisplayFunction -> Identity,
ContourStyle -> {Thickness[0.002]}, PlotRange -> All,
ColorFunctionScaling -> False]
有没有一种直接的方法来绘制这样的圆柱图?.. 我很难相信我不得不求助于 Matlab 来满足我的曲线坐标需求:)
【问题讨论】:
-
由于您更喜欢解析解而不是数值解,即
ContourPlotv.ListContourPlot,您应该更改标题以反映事实。