예제 #1
0
def test_gamma_matrix_class():
    i, j, k = tensor_indices('i,j,k', G.LorentzIndex)

    # define another type of TensorHead to see if exprs are correctly handled:
    A = tensorhead('A', [G.LorentzIndex], [[1]])

    t = A(k)*G(i)*G(-i)
    ts = simplify(t)
    assert _is_tensor_eq(ts, 4*A(k)*DiracSpinorIndex.delta(DiracSpinorIndex.auto_left, -DiracSpinorIndex.auto_right))

    t = G(i)*A(k)*G(j)
    ts = simplify(t)
    assert _is_tensor_eq(ts, A(k)*G(i)*G(j))

    execute_gamma_simplify_tests_for_function(simplify, D=4)
예제 #2
0
def test_gamma_matrix_class():
    i, j, k = tensor_indices('i,j,k', G.LorentzIndex)

    # define another type of TensorHead to see if exprs are correctly handled:
    A = tensorhead('A', [G.LorentzIndex], [[1]])

    t = A(k) * G(i) * G(-i)
    ts = simplify(t)
    assert ts == 4 * A(k) * DiracSpinorIndex.delta(
        DiracSpinorIndex.auto_left, -DiracSpinorIndex.auto_right)

    t = G(i) * A(k) * G(j)
    ts = simplify(t)
    assert ts == A(k) * G(i) * G(j)

    execute_gamma_simplify_tests_for_function(simplify, D=4)
예제 #3
0
 def add_delta(ne):
     return ne * DiracSpinorIndex.delta(DiracSpinorIndex.auto_left, -DiracSpinorIndex.auto_right)
예제 #4
0
def test_kahane_simplify1():
    i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15 = tensor_indices('i0:16', G.LorentzIndex)
    mu, nu, rho, sigma = tensor_indices("mu, nu, rho, sigma", G.LorentzIndex)
    KD = DiracSpinorIndex.delta
    sl = DiracSpinorIndex.auto_left
    sr = DiracSpinorIndex.auto_right
    D = 4
    s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16 = \
                   tensor_indices('s0:17', DiracSpinorIndex)
    t = DiracSpinorIndex.delta(s0,s1)
    t = G(i0)*G(i1)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)

    t = G(i0)*G(i1)*G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2*G(i1))
    t = G(i0,s0,-s1)*G(i1,s1,-s2)*G(-i0,s2,-s3)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2*G(i1, s0, -s3))

    t = G(i0, s0, -s1)*G(i1, s1, -s2)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)
    t = G(i0, s0, -s1)*G(i1, s1, -s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)
    t = G(i0)*G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4*KD(sl, -sr))
    t = G(i0,s0,-s1)*G(-i0,s1,-s2)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4*KD(s0, -s2))
    t = G(i0,s0,-s1)*G(-i0,s1,-s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(16)
    t = G(i0)*G(i1)*G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2*G(i1))
    t = G(i0)*G(i1)*G(-i0)*G(-i1)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((2*D - D**2)*KD(sl, -sr))
    t = G(i0,s0,-s1)*G(i1,s1,-s2)*G(-i0,s2,-s3)*G(-i1,s3,-s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4*(2*D - D**2))
    t = G(i0,s0,-s1)*G(-i0,s2,-s3)*G(i1,s1,-s2)*G(-i1,s3,-s0)
    raises(ValueError, lambda: G._kahane_simplify(t.coeff, t._tids))
    t = (G(mu)*G(nu)*G(-nu)*G(-mu))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(D**2*KD(sl, -sr))
    t = (G(mu,s0,-s1)*G(nu,s1,-s2)*G(-nu,s2,-s3)*G(-mu,s3,-s4))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(D**2*KD(s0, -s4))
    t = (G(mu,s0,-s1)*G(nu,s1,-s2)*G(-nu,s2,-s3)*G(-mu,s3,-s0))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4*D**2)
    t = (G(mu)*G(nu)*G(-rho)*G(-nu)*G(-mu)*G(rho))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((4*D - 4*D**2 + D**3)*KD(sl, -sr))
    t = (G(-mu)*G(-nu)*G(-rho)*G(-sigma)*G(nu)*G(mu)*G(sigma)*G(rho))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((-16*D + 24*D**2 - 8*D**3 + D**4)*KD(sl, -sr))
    t = (G(-mu)*G(nu)*G(-rho)*G(sigma)*G(rho)*G(-nu)*G(mu)*G(-sigma))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((8*D - 12*D**2 + 6*D**3 - D**4)*KD(sl, -sr))

    # Expressions with free indices:
    t = (G(mu)*G(nu)*G(rho)*G(sigma)*G(-mu))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2*G(sigma)*G(rho)*G(nu))
    t = (G(mu,s0,-s1)*G(nu,s1,-s2)*G(rho,s2,-s3)*G(sigma,s3,-s4)*G(-mu,s4,-s5))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2*G(sigma,s0,-s1)*G(rho,s1,-s2)*G(nu,s2,-s5))
예제 #5
0
 def add_delta(ne):
     return ne * DiracSpinorIndex.delta(DiracSpinorIndex.auto_left,
                                        -DiracSpinorIndex.auto_right)
예제 #6
0
def test_kahane_simplify1():
    i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15 = tensor_indices(
        'i0:16', G.LorentzIndex)
    mu, nu, rho, sigma = tensor_indices("mu, nu, rho, sigma", G.LorentzIndex)
    KD = DiracSpinorIndex.delta
    sl = DiracSpinorIndex.auto_left
    sr = DiracSpinorIndex.auto_right
    D = 4
    s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16 = \
                   tensor_indices('s0:17', DiracSpinorIndex)
    t = DiracSpinorIndex.delta(s0, s1)
    t = G(i0) * G(i1)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)

    t = G(i0) * G(i1) * G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2 * G(i1))
    t = G(i0, s0, -s1) * G(i1, s1, -s2) * G(-i0, s2, -s3)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2 * G(i1, s0, -s3))

    t = G(i0, s0, -s1) * G(i1, s1, -s2)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)
    t = G(i0, s0, -s1) * G(i1, s1, -s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(t)
    t = G(i0) * G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4 * KD(sl, -sr))
    t = G(i0, s0, -s1) * G(-i0, s1, -s2)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4 * KD(s0, -s2))
    t = G(i0, s0, -s1) * G(-i0, s1, -s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(16)
    t = G(i0) * G(i1) * G(-i0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2 * G(i1))
    t = G(i0) * G(i1) * G(-i0) * G(-i1)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((2 * D - D**2) * KD(sl, -sr))
    t = G(i0, s0, -s1) * G(i1, s1, -s2) * G(-i0, s2, -s3) * G(-i1, s3, -s0)
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4 * (2 * D - D**2))
    t = G(i0, s0, -s1) * G(-i0, s2, -s3) * G(i1, s1, -s2) * G(-i1, s3, -s0)
    raises(ValueError, lambda: G._kahane_simplify(t.coeff, t._tids))
    t = (G(mu) * G(nu) * G(-nu) * G(-mu))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(D**2 * KD(sl, -sr))
    t = (G(mu, s0, -s1) * G(nu, s1, -s2) * G(-nu, s2, -s3) * G(-mu, s3, -s4))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(D**2 * KD(s0, -s4))
    t = (G(mu, s0, -s1) * G(nu, s1, -s2) * G(-nu, s2, -s3) * G(-mu, s3, -s0))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(4 * D**2)
    t = (G(mu) * G(nu) * G(-rho) * G(-nu) * G(-mu) * G(rho))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((4 * D - 4 * D**2 + D**3) * KD(sl, -sr))
    t = (G(-mu) * G(-nu) * G(-rho) * G(-sigma) * G(nu) * G(mu) * G(sigma) *
         G(rho))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((-16 * D + 24 * D**2 - 8 * D**3 + D**4) * KD(sl, -sr))
    t = (G(-mu) * G(nu) * G(-rho) * G(sigma) * G(rho) * G(-nu) * G(mu) *
         G(-sigma))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals((8 * D - 12 * D**2 + 6 * D**3 - D**4) * KD(sl, -sr))

    # Expressions with free indices:
    t = (G(mu) * G(nu) * G(rho) * G(sigma) * G(-mu))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2 * G(sigma) * G(rho) * G(nu))
    t = (G(mu, s0, -s1) * G(nu, s1, -s2) * G(rho, s2, -s3) *
         G(sigma, s3, -s4) * G(-mu, s4, -s5))
    r = G._kahane_simplify(t.coeff, t._tids)
    assert r.equals(-2 * G(sigma, s0, -s1) * G(rho, s1, -s2) * G(nu, s2, -s5))