Beispiel #1
0
def test_simplify_lines():
    i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12 = tensor_indices(
        'i0:13', G.LorentzIndex)
    s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16 = \
       tensor_indices('s0:17', DiracSpinorIndex)

    g = G.LorentzIndex.metric
    Sdelta = DiracSpinorIndex.delta
    t = G(i1, s1, -s2) * G(i2, s2, -s1) * G(i3, s4, -s5) * G(i4, s5, -s6) * G(
        i5, s7, -s8)
    r = G.simplify_lines(t)
    assert r.equals(4 * G(i5, s7, -s8) * G(i3, s4, -s0) * G(i4, s0, -s6) *
                    g(i1, i2))

    t = G(i1, s1, -s2) * G(i2, s2, -s1) * G(i3, s4, -s5) * G(-i3, s5, -s6) * G(
        i5, s7, -s8)
    r = G.simplify_lines(t)
    assert r.equals(16 * G(i5, s7, -s8) * Sdelta(s4, -s6) * g(i1, i2))
    t = G(i1, s1, -s2) * G(i2, s2, -s1) * G(i3, s4, -s5) * G(i4, s5, -s6) * G(
        i5, s7, -s8)
    r = G.simplify_lines(t)
    assert r.equals(4 * G(i5, s7, -s8) * G(i3, s4, s0) * G(i4, -s0, -s6) *
                    g(i1, i2))
    t = G(i5, s7, -s8) * G(i6, s9, -s10) * G(i1, s1, -s2) * G(i3, s4, -s5) * G(
        i2, s2, -s1) * G(i4, s5, -s6) * G(-i6, s10, -s9)
    r = G.simplify_lines(t)
    assert r.equals(64 * G(i5, s7, -s8) * G(i3, s4, s0) * G(i4, -s0, -s6) *
                    g(i1, i2))
    t = G(i5,s7,-s8)*G(i6,s9,-s10)*G(i1,s1,-s2)*G(i7,s12,-s11)*G(i3,s4,-s5)*\
        G(i2,s2,-s1)*G(i4,s5,-s6)*G(-i6,s10,-s9)*G(-i7,s11,-s13)
    r = G.simplify_lines(t)
    assert r.equals(256*G(i5, s7, -s8)*G(i3, s4, s0)*G(i4, -s0, -s6)*\
           g(i1, i2)*Sdelta(s12,-s13))
Beispiel #2
0
def test_simplify_lines():
    i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12 = tensor_indices('i0:13', G.LorentzIndex)
    s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16 = \
       tensor_indices('s0:17', DiracSpinorIndex)

    g = G.LorentzIndex.metric
    Sdelta = DiracSpinorIndex.delta
    t = G(i1,s1,-s2)*G(i2,s2,-s1)*G(i3,s4,-s5)*G(i4,s5,-s6)*G(i5,s7,-s8)
    r = G.simplify_lines(t)
    assert r.equals(4*G(i5, s7, -s8)*G(i3, s4, -s0)*G(i4, s0, -s6)*g(i1, i2))

    t = G(i1,s1,-s2)*G(i2,s2,-s1)*G(i3,s4,-s5)*G(-i3,s5,-s6)*G(i5,s7,-s8)
    r = G.simplify_lines(t)
    assert r.equals(16*G(i5, s7, -s8)*Sdelta(s4, -s6)*g(i1, i2))
    t = G(i1,s1,-s2)*G(i2,s2,-s1)*G(i3,s4,-s5)*G(i4,s5,-s6)*G(i5,s7,-s8)
    r = G.simplify_lines(t)
    assert r.equals(4*G(i5, s7, -s8)*G(i3, s4, s0)*G(i4, -s0, -s6)*g(i1, i2))
    t = G(i5,s7,-s8)*G(i6,s9,-s10)*G(i1,s1,-s2)*G(i3,s4,-s5)*G(i2,s2,-s1)*G(i4,s5,-s6)*G(-i6,s10,-s9)
    r = G.simplify_lines(t)
    assert r.equals(64*G(i5, s7, -s8)*G(i3, s4, s0)*G(i4, -s0, -s6)*g(i1, i2))
    t = G(i5,s7,-s8)*G(i6,s9,-s10)*G(i1,s1,-s2)*G(i7,s12,-s11)*G(i3,s4,-s5)*\
        G(i2,s2,-s1)*G(i4,s5,-s6)*G(-i6,s10,-s9)*G(-i7,s11,-s13)
    r = G.simplify_lines(t)
    assert r.equals(256*G(i5, s7, -s8)*G(i3, s4, s0)*G(i4, -s0, -s6)*\
           g(i1, i2)*Sdelta(s12,-s13))
Beispiel #3
0
def test_simple_trace_cases_symbolic_dim():
    from sympy import symbols
    D = symbols('D')
    G = GammaMatrixHead(dim=D)

    m0, m1, m2, m3 = tensor_indices('m0:4', G.LorentzIndex)
    g = G.LorentzIndex.metric

    t = G(m0)*G(m1)
    t1 = G._trace_single_line(t)
    assert _is_tensor_eq(t1, 4 * G.LorentzIndex.metric(m0, m1))

    t = G(m0)*G(m1)*G(m2)*G(m3)
    t1 = G._trace_single_line(t)
    t2 = -4*g(m0, m2)*g(m1, m3) + 4*g(m0, m1)*g(m2, m3) + 4*g(m0, m3)*g(m1, m2)
    assert _is_tensor_eq(t1, t2)
Beispiel #4
0
def test_simple_trace_cases_symbolic_dim():
    from sympy import symbols
    D = symbols('D')
    G = GammaMatrixHead(dim=D)

    m0, m1, m2, m3 = tensor_indices('m0:4', G.Lorentz)
    g = G.Lorentz.metric

    t = G(m0)*G(m1)
    t1 = G.trace_tens(t)
    assert t1 == 4 * G.Lorentz.metric(m0, m1)

    t = G(m0)*G(m1)*G(m2)*G(m3)
    t1 = G.trace_tens(t)
    t2 = -4*g(m0, m2)*g(m1, m3) + 4*g(m0, m1)*g(m2, m3) + 4*g(m0, m3)*g(m1, m2)
    assert t1 == t2
Beispiel #5
0
def test_simple_trace_cases_symbolic_dim():
    from sympy import symbols
    D = symbols('D')
    G = GammaMatrixHead(dim=D)

    m0, m1, m2, m3 = tensor_indices('m0:4', G.LorentzIndex)
    g = G.LorentzIndex.metric

    t = G(m0) * G(m1)
    t1 = G._trace_single_line(t)
    assert _is_tensor_eq(t1, 4 * G.LorentzIndex.metric(m0, m1))

    t = G(m0) * G(m1) * G(m2) * G(m3)
    t1 = G._trace_single_line(t)
    t2 = -4 * g(m0, m2) * g(m1, m3) + 4 * g(m0, m1) * g(m2, m3) + 4 * g(
        m0, m3) * g(m1, m2)
    assert _is_tensor_eq(t1, t2)
Beispiel #6
0
def test_simple_trace_cases_symbolic_dim():
    from sympy import symbols
    D = symbols('D')
    G = GammaMatrixHead(dim=D)

    m0, m1, m2, m3 = tensor_indices('m0:4', G.Lorentz)
    g = G.Lorentz.metric

    t = G(m0) * G(m1)
    t1 = G.trace_tens(t)
    assert t1 == 4 * G.Lorentz.metric(m0, m1)

    t = G(m0) * G(m1) * G(m2) * G(m3)
    t1 = G.trace_tens(t)
    t2 = -4 * g(m0, m2) * g(m1, m3) + 4 * g(m0, m1) * g(m2, m3) + 4 * g(
        m0, m3) * g(m1, m2)
    assert t1 == t2
Beispiel #7
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))
Beispiel #8
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))
GMH = GammaMatrixHead()
index1 = tensor_indices('index1', G.LorentzIndex)
GMH(index1)

index1 = tensor_indices('index1', GammaMatrix.LorentzIndex)
GM(index1)

GammaMatrix.LorentzIndex.metric




p, q = tensorhead('p, q', [G.LorentzIndex], [[1]])
index0,index1,index2,index3,index4,index5 = tensor_indices('index0:6', G.LorentzIndex)
ps = p(index0)*GM(-index0)
qs = q(index0)*GM(-index0)
GM.gamma_trace(GM(index0)*GM(index1))
GM.gamma_trace(ps*ps) - 4*p(index0)*p(-index0)
GM.gamma_trace(ps*qs + ps*ps) - 4*p(index0)*p(-index0) - 4*p(index0)*q(-index0)

p, q = tensorhead('p, q', [GM.LorentzIndex], [[1]])
index0,index1,index2,index3,index4,index5 = tensor_indices('index0:6', G.LorentzIndex)
ps = p(index0)*G(-index0)
qs = q(index0)*G(-index0)
GM.simplify_gpgp(ps*qs*qs)

index0,index1,index2,index3,index4,index5 = tensor_indices('index0:6', GammaMatrix.LorentzIndex)
spinorindex0,spinorindex1,spinorindex2,spinorindex3,spinorindex4,spinorindex5,spinorindex6,spinorindex7 = tensor_indices('spinorindex0:8', DiracSpinorIndex)
GM = GammaMatrix
t = GM(index1,spinorindex1,-spinorindex2)*GM(index4,spinorindex7,-spinorindex6)*GM(index2,spinorindex2,-spinorindex3)*GM(index3,spinorindex4,-spinorindex5)*GM(index5,spinorindex6,-spinorindex7)
GM.simplify_lines(t)