def testdummy(self):
        i=g.idx(g.symbol("i"),3)
        j=g.idx(g.symbol("j"),3)
        k=g.idx(g.symbol("k"),3)
        l=g.idx(g.symbol("l"),3)
        A=g.symbol("A")
        B=g.symbol("B")
        C=g.symbol("C")

        e=g.indexed(A,i,j)*g.indexed(B,j,k)+g.indexed(C,k,l,i,l)
        #can vary from run to run
        #self.assertEqual(str(e),"C.k.l.i.l+B.j.k*A.i.j")
        f=e.get_free_indices()
        self.failUnless(type(f)==list)
        self.failUnless(f==[i,k] or f==[k,i])
        self.failUnless(str(f)=="[.i, .k]" or str(f)=="[.k, .i]")

        mu=g.varidx(g.symbol("mu"),4)
        nu=g.varidx(g.symbol("nu"),4)
        rho=g.varidx(g.symbol("rho"),4)
        sigma=g.varidx(g.symbol("sigma"),4)

        e=g.indexed(A,mu,nu)*g.indexed(B,nu.toggle_variance(),rho)+\
            g.indexed(C,mu,sigma,rho,sigma.toggle_variance())
        self.failUnless(e.get_free_indices()==[mu,rho] or 
            e.get_free_indices()==[rho,mu])

        e=g.indexed(A,mu,mu)
        self.assertEqual(e.get_free_indices(),[mu])
        self.assertNotEqual(e.get_free_indices(),[mu.toggle_variance()])
 def testsubs(self):
     mu=g.varidx(g.symbol("mu"),4)
     nu=g.varidx(g.symbol("nu"),4,True)
     A=g.symbol("A")
     e=g.indexed(A,mu)
     self.assertEqual(str(e),"A~mu")
     self.assertEqual(str(e.subs(mu==nu)),"A.nu")
     self.assertEqual(str(e.subs(mu==0)),"A~0")
 def testvaridx3(self):
     mu=g.varidx(g.symbol("mu"),4)
     nu=g.varidx(g.symbol("nu"),4)
     A=g.symbol("A")
     self.assertEqual(str(g.indexed(A,mu,nu)),"A~mu~nu")
     self.assertEqual(str(g.indexed(A,mu,nu.toggle_variance())),"A~mu.nu")
     self.assertEqual(str(g.indexed(A,mu.toggle_variance(),nu)),"A.mu~nu")
     self.failUnless(mu.is_contravariant())
     self.failUnless(nu.is_contravariant())
    def testlorentz(self):
        mu=g.varidx(g.symbol("mu"),4)
        e=g.delta_tensor(g.varidx(0,4),mu.toggle_variance())*\
            g.lorentz_g(mu,g.varidx(0,4))
        self.assertEqual(e.simplify_indexed(),1)

        e=g.delta_tensor(g.varidx(0,4),mu.toggle_variance())*\
            g.lorentz_g(mu,g.varidx(0,4),True)
        self.assertEqual(e.simplify_indexed(),-1)
    def testsimplify(self):
        mu=g.varidx(g.symbol("mu"),4)
        nu=g.varidx(g.symbol("nu"),4)
        A=g.symbol("A")

        e1=g.indexed(A,mu,mu.toggle_variance())
        e2=g.indexed(A,nu,nu.toggle_variance())
        self.assertNotEqual(e1,e2)
        self.assertEqual((e1-e2).simplify_indexed(),0)
    def testmetric(self):
        mu=g.varidx(g.symbol("mu"),4)
        nu=g.varidx(g.symbol("nu"),4)
        rho=g.varidx(g.symbol("rho"),4)
        A=g.symbol("A")

        e=g.metric_tensor(mu,nu)*g.indexed(A,nu.toggle_variance(),rho)
        self.assertEqual(e.simplify_indexed(),g.indexed(A,mu,rho))
        self.assertNotEqual(e.simplify_indexed(),g.indexed(A,nu,rho))

        e=g.delta_tensor(mu,nu.toggle_variance())*g.metric_tensor(nu,rho)
        self.assertEqual(e.simplify_indexed(),g.metric_tensor(mu,rho))

        e=g.metric_tensor(mu.toggle_variance(),nu.toggle_variance())*\
            g.metric_tensor(nu,rho)
        self.assertEqual(e.simplify_indexed(),
            g.delta_tensor(mu.toggle_variance(),rho))

        e=g.metric_tensor(nu.toggle_variance(),rho.toggle_variance())*\
            g.metric_tensor(mu,nu)*(g.delta_tensor(mu.toggle_variance(),rho)+\
            g.indexed(A,mu.toggle_variance(),rho))
        self.assertEqual((e-(4+g.indexed(A,rho.toggle_variance(),rho))).
            simplify_indexed(),0)
    def testeps(self):
        mu=g.varidx(g.symbol("mu"),4)
        nu=g.varidx(g.symbol("nu"),4)
        rho=g.varidx(g.symbol("rho"),4)
        sig=g.varidx(g.symbol("sig"),4)
        lam=g.varidx(g.symbol("lam"),4)
        bet=g.varidx(g.symbol("bet"),4)

        e=g.lorentz_eps(mu,nu,rho,sig)*g.lorentz_eps(mu.toggle_variance(),
            nu.toggle_variance(),lam,bet)
        g.simplify_indexed(e)

        i=g.idx(g.symbol("i"),3)
        j=g.idx(g.symbol("j"),3)
        k=g.idx(g.symbol("k"),3)
        A=g.symbol("A")
        B=g.symbol("B")
        e=g.epsilon_tensor(i,j,k)*g.indexed(A,j)*g.indexed(B,k)
        self.assertNotEqual(g.simplify_indexed(e),0)
        e=g.epsilon_tensor(i,j,k)*g.indexed(A,j)*g.indexed(A,k)
        self.assertEqual(g.simplify_indexed(e),0)
 def testvaridx1(self):
     i=g.varidx(g.symbol("i"),3)
     j=g.varidx(g.symbol("j"),3)
     A=g.symbol("A")
     self.assertEqual(str(g.indexed(A,i,j)),"A~i~j")
Beispiel #9
0
    print 'Start preparing ' + file_name

    MyTestGenerator = TestGenerator()
    MyListCreator = listcreator.ListCreator()

    dirac_gamma = swiginac.dirac_gamma
    dirac_slash = swiginac.dirac_slash
    dirac_gamma5 = swiginac.dirac_gamma5
    dirac_gammaR = swiginac.dirac_gammaR
    dirac_gammaL = swiginac.dirac_gammaL
    simplify_indexed = swiginac.simplify_indexed
    dirac_trace = swiginac.dirac_trace

    D = swiginac.symbol("D")
    i = swiginac.varidx(swiginac.symbol("i"), 4)
    j = swiginac.varidx(swiginac.symbol("j"), 4)
    k = swiginac.varidx(swiginac.symbol("k"), 4)
    l = swiginac.varidx(swiginac.symbol("l"), 4)

    m = swiginac.varidx(swiginac.symbol("m"), 4)
    n = swiginac.varidx(swiginac.symbol("n"), 4)
    o = swiginac.varidx(swiginac.symbol("o"), 4)
    p = swiginac.varidx(swiginac.symbol("p"), 4)

    iD = swiginac.varidx(swiginac.symbol("iD"), D)
    jD = swiginac.varidx(swiginac.symbol("jD"), D)
    kD = swiginac.varidx(swiginac.symbol("kD"), D)
    lD = swiginac.varidx(swiginac.symbol("lD"), D)

    mD = swiginac.varidx(swiginac.symbol("mD"), D)
    print 'Start preparing ' + file_name

    MyTestGenerator = TestGenerator()
    MyListCreator = listcreator.ListCreator()

    dirac_gamma = swiginac.dirac_gamma
    dirac_slash = swiginac.dirac_slash
    dirac_gamma5 = swiginac.dirac_gamma5
    dirac_gammaR = swiginac.dirac_gammaR
    dirac_gammaL = swiginac.dirac_gammaL
    simplify_indexed = swiginac.simplify_indexed
    dirac_trace = swiginac.dirac_trace

    D = swiginac.symbol("D")
    i = swiginac.varidx(swiginac.symbol("i"), 4)
    j = swiginac.varidx(swiginac.symbol("j"), 4)
    k = swiginac.varidx(swiginac.symbol("k"), 4)
    l = swiginac.varidx(swiginac.symbol("l"), 4)

    m = swiginac.varidx(swiginac.symbol("m"), 4)
    n = swiginac.varidx(swiginac.symbol("n"), 4)
    o = swiginac.varidx(swiginac.symbol("o"), 4)
    p = swiginac.varidx(swiginac.symbol("p"), 4)

    iD = swiginac.varidx(swiginac.symbol("iD"), D)
    jD = swiginac.varidx(swiginac.symbol("jD"), D)
    kD = swiginac.varidx(swiginac.symbol("kD"), D)
    lD = swiginac.varidx(swiginac.symbol("lD"), D)

    mD = swiginac.varidx(swiginac.symbol("mD"), D)