{ "metadata": { "name": "", "signature": "sha256:6e47a59dd20fa0714b86d0189b03e2e37d5941217b2316fb40487da1c02cb929" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "christoffel symbols\n", "===" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$\\Gamma^a_{bc} = \\frac{1}{2}g^{ad}(g_{bd,c}+g_{cd,b}-g_{bc,d})$$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import sympy" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "markdown", "metadata": {}, "source": [ "2D in polar coordinates\n", "===" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$$g_{ab} = (1 0)\n", " (0 r^2)$$\n", " ? how to write matrices in latex?!" ] }, { "cell_type": "code", "collapsed": false, "input": [ "r, phi = sympy.symbols('r phi')\n", "\n", "gmn= sympy.Matrix([[1,0],[0,r**2]])\n", "gMN= gmn**(-1)\n", "indices = {0:'r', 1:'phi'}" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 20 }, { "cell_type": "code", "collapsed": false, "input": [ "for i in [0,1]:\n", " for j in [0,1]:\n", " for k in [0,1]:\n", " sum = 0\n", " for l in [0,1]:\n", " #print (1./2)*gMN[2*1+j]*(sympy.diff(gmn[2*0+j],phi) +sympy.diff(gmn[2*1+j],r) -sympy.diff(gmn[2*0+1],r))\n", " sum += (1./2)*gMN[2*k+l]*(sympy.diff(gmn[2*j+l],indices[i]) +sympy.diff(gmn[2*i+l],indices[j]) -sympy.diff(gmn[2*i+j],indices[l]))\n", " #print 'gamma',i,j,k,sum\n", " print 'gamma','^',indices[k],'_{',indices[i],indices[j],'}',sum" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "gamma ^ r _{ r r } 0\n", "gamma ^ phi _{ r r } 0\n", "gamma ^ r _{ r phi } 0\n", "gamma ^ phi _{ r phi } 1.0/r\n", "gamma ^ r _{ phi r } 0\n", "gamma ^ phi _{ phi r } 1.0/r\n", "gamma ^ r _{ phi phi } -1.0*r\n", "gamma ^ phi _{ phi phi } 0\n" ] } ], "prompt_number": 23 }, { "cell_type": "markdown", "metadata": {}, "source": [ "$S^2$ in polar coordinates\n", "===" ] }, { "cell_type": "code", "collapsed": false, "input": [ "r, theta, phi = sympy.symbols('r theta phi')\n", "\n", "gmn= sympy.Matrix([[r**2,0],[0,(r**2)*(sympy.sin(theta)**2)]])\n", "gMN= gmn**(-1)\n", "indices = {0:'theta', 1:'phi'}" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [ "for i in [0,1]:\n", " for j in [0,1]:\n", " for k in [0,1]:\n", " sum = 0\n", " for l in [0,1]:\n", " # print (1./2)*gMN[2*1+j]*(sympy.diff(gmn[2*0+j],phi) +sympy.diff(gmn[2*1+j],r) -sympy.diff(gmn[2*0+1],r))\n", " sum += (1./2)*gMN[2*k+l]*(sympy.diff(gmn[2*j+l],indices[i]) +sympy.diff(gmn[2*i+l],indices[j]) -sympy.diff(gmn[2*i+j],indices[l]))\n", " #print 'gamma',i,j,k,sum\n", " print 'gamma','^',indices[k],'_{',indices[i],indices[j],'}',sum" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "gamma ^ theta _{ theta theta } 0\n", "gamma ^ phi _{ theta theta } 0\n", "gamma ^ theta _{ theta phi } 0\n", "gamma ^ phi _{ theta phi } 1.0*cos(theta)/sin(theta)\n", "gamma ^ theta _{ phi theta } 0\n", "gamma ^ phi _{ phi theta } 1.0*cos(theta)/sin(theta)\n", "gamma ^ theta _{ phi phi } -1.0*sin(theta)*cos(theta)\n", "gamma ^ phi _{ phi phi } 0\n" ] } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }