- 积分
- 33
- 注册时间
- 2005-6-2
- 仿真币
-
- 最后登录
- 1970-1-1
|
常常我们要进行一些坐标转换,有时比较复杂,这里用Mathematica简化这个过程。
基本的关系(见图):
Mathematica实现:- cotransform[u_Symbol, var_List, relation_List] :=
- Module[{h, hi, delu}, h = D[relation, {var}];
- hi = Simplify[
- Sqrt[h[[All, #]].h[[All, #]]] & /@ Range[Length[var]],
- Assumptions -> {0 < var[[#]] < \[Pi] & /@ Range[Length[var]]}];
- delu = 1/hi[[#]] D[u @@ var, var[[#]]] & /@ Range[Length[var]] //
- Simplify;
- Print["Gradient is ", delu // Total];
- lapu = 1/Times @@ hi D[Times @@ hi/hi[[#]] delu[[#]], var[[#]]] & /@
- Range[Length[var]] // Total // Simplify;
- Print["Laplacian is ", lapu]; Return[{delu, lapu}];];
复制代码 例子:- cotransform[f, {x, y, z}, {x, y, z}]
复制代码 结果:- Gradient is f^(0,0,1)[x,y,z]+f^(0,1,0)[x,y,z]+f^(1,0,0)[x,y,z]
- Laplacian is f^(0,0,2)[x,y,z]+f^(0,2,0)[x,y,z]+f^(2,0,0)[x,y,z]
复制代码 柱坐标例子:- cotransform[f, {r, \[Theta], z}, {r Cos[\[Theta]], r Sin[\[Theta]],
- z}]
复制代码 结果:
- Gradient is \
- f^(0,0,1)[r,\[Theta],z]+f^(0,1,0)[r,\[Theta],z]/r+f^(1,0,0)[r,\[Theta]\
- ,z]
- Laplacian is \
- f^(0,0,2)[r,\[Theta],z]+f^(0,2,0)[r,\[Theta],z]/r^2+f^(1,0,0)[r,\
- \[Theta],z]/r+f^(2,0,0)[r,\[Theta],z]
复制代码
球坐标例子:- cotransform[f, {r, \[Theta], \[Phi]}, {r Sin[\[Theta]] Cos[\[Phi]],
- r Sin[\[Phi]] Sin[\[Theta]], r Cos[\[Theta]]}]
复制代码 结果:
- Gradient is (Csc[\[Theta]] \
- f^(0,0,1)[r,\[Theta],\[Phi]])/r+f^(0,1,0)[r,\[Theta],\[Phi]]/r+f^(1,0,\
- 0)[r,\[Theta],\[Phi]]
- Laplacian is 1/r^2(Csc[\[Theta]]^2 f^(0,0,2)[r,\[Theta],\[Phi]]+Cot[\
- \[Theta]] f^(0,1,0)[r,\[Theta],\[Phi]]+f^(0,2,0)[r,\[Theta],\[Phi]]+2 \
- r f^(1,0,0)[r,\[Theta],\[Phi]]+r^2 f^(2,0,0)[r,\[Theta],\[Phi]])
复制代码
验证和推导的网页:
http://mathworld.wolfram.com/Laplacian.html
http://en.wikipedia.org/wiki/Laplacian
以及:
http://planetmath.org/encyclopedia/%3Chttp://planetmath.org/?method=l2h&;from=collab&id=76&op=getobj
自己代换,自己玩玩。
[ 本帖最后由 smarten 于 2008-7-4 12:13 编辑 ] |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|