| 查看: 536 | 回复: 1 | |||
[交流]
【求助】帮我看看这个程序有问提不哦,求引力场方程的 已有1人参与
|
|
BeginPackage[”Einstein‘”] Einstein::usage= ”Einstein[g-,v-] calculate the Ricci Tensor and the Curvature Scalar from the given metric. g-is the given metric, and v-are the variables.” Begin[”‘private‘”] Einstein[g-,v-]:= Block[ {invg, dg1, dg2, dg3, G, dG, Ruv1, Ruv2, Ruv3, Ruv4, Ruv, Rrr, Result} Result ={}; (* Result save the return Values. *) (* Calculate the inverse metric of g. *) invg = Inverse[ g ]; (* Calculate the affine connection. *) dg1 = Outer[ D, g, v ]; dg2 = Transpose[ dg1,{1,3,2} ]; dg3 = Transpose[ dg1,{2,3,1} ]; G = (1/2) invg . ( dg1 + dg2 - dg3 ); (* Calculate the Ricci tensor. *) dG = Outer[ D, G, v ]; Ruv1 = Table[Sum[dG[[k,i,k,j]],{k,4}],{i,4},{j,4}]; Ruv2 = Table[Sum[dG[[k,i,j,k]],{k,4}],{i,4},{j,4}]; Ruv3 = Table[Sum[G[[k,i,j]]G[[h,k,h]],{k,4},{h,4}],{i,4},{j,4}]; Ruv4 = Table[Sum[G[[k,i,h]]G[[h,j,k]],{k,4},{h,4}],{i,4},{j,4}]; Ruv = Ruv1 - Ruv2 - Ruv3 + Ruv4; Result = Append[ Result, Simplify[ Ruv ] ]; (* Calculate the Curvature Scalar. *) Rrr = Sum[ invg[[i,i]]Ruv[[i,i]], {i,4}]; Result = Append[ Result, Simplify[ Rrr ] ]; (* Return the Result. *) Return[ Result ] ] End[] EndPackage[] [ Last edited by nono2009 on 2009-12-1 at 07:14 ] |
» 猜你喜欢
萌生出自己或许不适合搞科研的想法,现在跑or等等看?
已经有3人回复
参与限项
已经有3人回复
假如你的研究生提出不合理要求
已经有7人回复
实验室接单子
已经有4人回复
全日制(定向)博士
已经有4人回复
对氯苯硼酸纯化
已经有3人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有12人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
北核录用
已经有3人回复
watercamel
银虫 (著名写手)
- 应助: 1 (幼儿园)
- 金币: 120.2
- 红花: 3
- 帖子: 1882
- 在线: 311.1小时
- 虫号: 342291
- 注册: 2007-04-09
- 专业: 固体力学
2楼2010-10-10 12:54:00












回复此楼