3 Mathematica で一様流を可視化

複素数の計算、二変数関数の等高線と2次元ベクトル場の描画が出来れば良い。

虚数単位は I, 実部 Re[ ], 虚部 Im[ ], 共役複素数 Conjugate[ ], 絶対値 Abs[ ], 偏角(の主値) Arg[ ], 式の中のすべての変数を実数と仮定して展開する ComplexExpand[ ] などが用意されている。

2変数関数の等高線には ContourPlot[], ベクトル場の描画には VectorPlot[] が用意されている。 これらの使い方はオンライン・ヘルプを見よ (例えば ?ContourPlot)。

$ c=1-2i$ の場合の $ f(z)=cz$ を複素速度ポテンシャルとする流れ
c=1-2I
f[z_]:=c z
ComplexExpand[[f[x+I y]]
phi[x_,y_]:=ComplexExpand[Re[f[x+I y]]]
psi[x_,y_]:=ComplexExpand[Im[f[x+I y]]]
phi[x,y]
psi[x,y]

g1=ContourPlot[phi[x,y]==Table[c,{c,-5,5,1.0}],{x,-2,2},{y,-2,2},
  ContourStyle->Directive[Red]]
g2=ContourPlot[psi[x,y]==Table[c,{c,-5,5,1.0}],{x,-2,2},{y,-2,2},
  ContourStyle->Directive[Blue,Thin]]

u[x_, y_] := ComplexExpand[Re[f'[x + I y]]]
v[x_, y_] := -ComplexExpand[Im[f'[x + I y]]]
g3 = VectorPlot[{u[x, y], v[x, y]}, {x, -2, 2}, {y, -2, 2}]

g12=Show[g1,g2]
g13=Show[g1,g3]

ComplexExpand[] は事前に Evaluate させる効果も考えて採用したが、 いつもこれを使うのが良いかは良く分からない。

図 4: 等ポテンシャル線と流線は直交する
図 5: 等ポテンシャル線と速度ベクトル
\includegraphics[width=6cm]{image/g12.eps} \includegraphics[width=6cm]{image/g13.eps}

このように、一様流は素直なので簡単に描画できるが、 そうでないものは色々調整が必要になったりする。

桂田 祐史
2016-06-29