Exemplo n.º 1
0
    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()])
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def testsimplify(self):
        i=g.idx(g.symbol("i"),3)
        j=g.idx(g.symbol("i"),3)
        A=g.symbol("A")
        B=g.symbol("B")
        C=g.symbol("C")
        sp=g.scalar_products()
        sp.add(A,B,0)
        sp.add(A,C,0)
        sp.add(A,A,4)

        e=g.indexed(A+B,i)*g.indexed(A+C,i)
        self.assertEqual(e.expand(g.expand_options.expand_indexed).
            simplify_indexed(sp),4+g.indexed(C,i)*g.indexed(B,i))
        self.assertEqual(g.simplify_indexed(e.expand(g.expand_options.
            expand_indexed),sp),4+g.indexed(C,i)*g.indexed(B,i))
        self.assertNotEqual(g.simplify_indexed(e.expand(g.expand_options.
            expand_indexed)),4+g.indexed(C,i)*g.indexed(B,i))
        self.assertNotEqual(g.simplify_indexed(e.expand(g.expand_options.
            expand_indexed),sp),5+g.indexed(C,i)*g.indexed(B,i))
        self.assertNotEqual(g.simplify_indexed(e.expand(g.expand_options.
            expand_indexed),sp),4+g.indexed(C,i)*g.indexed(B,j))
Exemplo n.º 4
0
    def testdelta(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")

        e=g.indexed(A,i,j)*g.indexed(B,k,l)*g.delta_tensor(i,k)*\
            g.delta_tensor(j,l)
        self.assertEqual((e-g.indexed(A,k,l)*g.indexed(B,k,l)).
            simplify_indexed(),0)
        self.assertEqual((e-g.indexed(B,k,l)*g.indexed(A,k,l)).
            simplify_indexed(),0)
        self.assertEqual((e-g.indexed(A,i,l)*g.indexed(B,i,l)).
            simplify_indexed(),0)
        self.assertEqual((e-g.indexed(A,i,j)*g.indexed(B,i,j)).
            simplify_indexed(),0)
        self.assertNotEqual((e-g.indexed(A,i,i)*g.indexed(B,k,k)).
            simplify_indexed(),0)
        self.assertEqual(g.delta_tensor(i,i),3)
        self.assertNotEqual(g.delta_tensor(i,i),4)
Exemplo n.º 5
0
    def testsymm(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")
        e=g.indexed(A,i,j)
        e=g.indexed(A,g.sy_none(), i,j)
        e=g.indexed(A,g.sy_none(0, 1), i,j)
        e=g.indexed(A,g.sy_none(g.symmetry(0), g.symmetry(1)), i,j)

        e=g.indexed(A,g.sy_symm(), i,j,k)
        e=g.indexed(A,g.sy_symm(0,1,2), i,j,k)
        e=g.indexed(A,g.sy_symm(2,0,1), i,j,k)

        e=g.indexed(A,g.sy_symm(0,1), i,j,k)
        e=g.indexed(A,g.sy_none(g.sy_symm(0,1),2), i,j,k)

        e=g.indexed(A,g.sy_anti(0,2), i,j,k)
        e=g.indexed(A,g.sy_none(g.sy_anti(0,2),1), i,j,k)

        e=g.indexed(A,g.sy_symm(g.sy_anti(0,1),g.sy_anti(2,3)), i,j,k,l)

        e=g.indexed(A,g.sy_cycl(), i,j,k)
        e=g.indexed(A,g.sy_cycl(0,1,2), i,j,k)

        #this is a deadlock... bug in ginac?
        #but nobody really needs that, so I don't care
        #g.sy_symm(0,1,2,3).add(4).add(5)

        e=g.indexed(A,g.sy_symm(),i,j)+g.indexed(A,g.sy_symm(),j,i)
        self.assertEqual(e,2*g.indexed(A,g.sy_symm(), i,j))

        e=g.indexed(A,g.sy_anti(),i,j)+g.indexed(A,g.sy_anti(),j,i)
        self.assertEqual(e,0)

        e=g.indexed(A,g.sy_anti(),i,j,k)+g.indexed(A,g.sy_anti(),j,i,k)
        self.assertEqual(e,0)
Exemplo n.º 6
0
 def testidx(self):
     i=g.idx(g.symbol("i"),3)
     j=g.idx(g.symbol("j"),3)
     A=g.symbol("A")
     self.assertEqual(str(g.indexed(A,i,j)),"A.i.j")