Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Schwarzschild Solution in MatLab

  1. Jan 6, 2009 #1
    This is the Schwarzschild Solution for the metric tensor g_ab in MatLab. Could someone take a look at my code. Getting the correct answers for Affinity. Some of the correct answers for Riemann. Why not all? This will yield a zero Ricci Tensor if done correctly. Here is my code:

    [tex]\Gamma^{i}_{jk} = 1/2*g^{il}*(d/dx^{j}*g_{lk}+d/dx^{k}*g_{lj)-d/dx^{l}*g_{jk})[/tex]

    [tex]R^{i}_{jkl} = \Gamma^{r}_{jl}*\Gamma^{i}_{kr}-\Gamma^{r}_{jk}*\Gamma^{i}_{jl}+d/dx^{k}*\Gamma^{i}_{jl}-d/dx^{l}*\Gamma^{i}_{jk}[/tex]

    syms r theta m
    g_ab = [1/(1-2*m/r) 0 0 0;0 r^2 0 0;0 0 r^2*(sin(h))^2,0;0,0,0,-(1-2*m/r)]
    gupab = g_ab^-1
    Affinity=sym(zeros(4,4,4))
    Riemann=sym(zeros(4,4,4,4))
    d(1)=r
    d(2)=h
    d(3)=p
    d(4)=t
    for i=1:4
    for j=1:4
    for k=1:4
    for l=1:4
    Affinity(i,j,k)=Affinity(i,j,k) + 1/2*gupab(i,l)*(diff(g_ab(l,k),d(j))+diff(g_ab(l,j),d(k))-diff(g_ab(j,k),d(l)))
    end
    end
    end
    end
    for i=1:4
    for j=1:4
    for k=1:4
    for l=1:4
    for r=1:4
    Riemann(i,j,k,l)=Riemann(i,j,k,l)+Affinity(r,j,l)*Affinity(i,k,r)-Affinity(r,j,k)*Affinity(i,l,r)+diff(Affinity(i,j,l),d(k))-diff(Affinity(i,j,k),d(l))
    end
    end
    end
    end
    end

    Correct Answers 'not from MatLab' with the last two digit interchangable:

    Affinity(1,1,1) = m/r/(2*m-r)
    Affinity(1,2,2) = (2*m-r)
    Affinity(1,3,3) = (2*m-r)*(sin(theta))^2
    Affinity(1,4,4) = m*(2*m-r)/r^3
    Affinity(2,2,1) = 1/r
    Affinity(2,3,3) = -cos(theta)*sin(theta)
    Affinity(3,3,1) = 1/r
    Affinity(3,3,2) = cot(theta)
    Affinity(4,4,1) = -m/r/(2*m-r)
    Rest zero except the interchangable ones(the last two indices).

    Riemann(1,2,2,1)=m/r
    Riemann(1,3,3,1)=m*(sin(theta))^2/r
    Riemann(1,4,4,1)=2*m*(r-2*m)/r^4
    Riemann(2,1,2,1)=m/r^2/(2*m-r)
    Riemann(2,3,3,2)=-2*m*(sin(theta))^2/r
    Riemann(2,4,4,2)=m*(2*m-r)/r^4
    Riemann(3,1,3,1)=m/(2*m-r)/r^2
    Riemann(3,2,3,2)=2*m/r
    Riemann(3,4,4,3)=m*(2*m-r)/r^4
    Riemann(4,1,4,1)=-2*m/(2*m-r)/r^2
    Riemann(4,2,4,2)=-m/r
    Riemann(4,3,4,3)=-m*(sin(theta))^2/r
    Rest zero except the interchangable ones (the last two indices).

    Why does the Riemann in MatLab not agree with the above result I got from a book?
     
    Last edited: Jan 6, 2009
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted



Similar Discussions: Schwarzschild Solution in MatLab
  1. Schwarzschild solution (Replies: 6)

Loading...