24小时热门版块排行榜    

查看: 536  |  回复: 1

lcqliu

银虫 (正式写手)

[交流] 【求助】帮我看看这个程序有问提不哦,求引力场方程的 已有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 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

watercamel

银虫 (著名写手)


小木虫(金币+0.5):给个红包,谢谢回帖交流
估计能看懂的人不多。否则早就有回帖了。不知lz现在认识上有何进步,能否讲讲?
2楼2010-10-10 12:54:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 lcqliu 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见