| 查看: 545 | 回复: 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 ] |
» 猜你喜欢
网上报道青年教师午睡中猝死、熬夜猝死的越来越多,主要哪些原因引起的?
已经有3人回复
为什么中国大学工科教授们水了那么多所谓的顶会顶刊,但还是做不出宇树机器人?
已经有10人回复
版面费该交吗
已经有12人回复
面上可以超过30页吧?
已经有5人回复
体制内长辈说体制内绝大部分一辈子在底层,如同你们一样大部分普通教师忙且收入低
已经有13人回复
“人文社科而论,许多学术研究还没有达到民国时期的水平”
已经有5人回复
什么是人一生最重要的?
已经有4人回复
watercamel
银虫 (著名写手)
- 应助: 1 (幼儿园)
- 金币: 120.2
- 红花: 3
- 帖子: 1882
- 在线: 311.1小时
- 虫号: 342291
- 注册: 2007-04-09
- 专业: 固体力学
2楼2010-10-10 12:54:00













回复此楼