Esempio n. 1
0
def _f_gen(l, lp, i2, i1, nu, lam2, lam1):
    return Piecewise(
        (0, (nu > l + lp) | (nu > lam1 + lam2) | ((lam1 > 2 * i2) &
                                                  (lam2 > 2 * i2))),
        ((sqrt(prod([2 * i + 1 for i in locals().values()])) *
          (-1)**(lp + lam1 + lam2 + 1) * Wigner3j(l, 1, lp, -1, nu, 0) *
          Wigner9j(i2, l, i1, i2, lp, i1, lam2, nu, lam1)), True))
Esempio n. 2
0
def test_doit():
    assert Wigner3j(1 / 2, -1 / 2, 1 / 2, 1 / 2, 0, 0).doit() == -sqrt(2) / 2
    assert Wigner6j(1, 2, 3, 2, 1, 2).doit() == sqrt(21) / 105
    assert Wigner9j(2, 1, 1,
                    S(3) / 2,
                    S(1) / 2, 1,
                    S(1) / 2,
                    S(1) / 2, 0).doit() == sqrt(2) / 12
    assert CG(1 / 2, 1 / 2, 1 / 2, -1 / 2, 1, 0).doit() == sqrt(2) / 2
Esempio n. 3
0
def test_doit():
    assert (Wigner3j(S.Half, Rational(-1, 2), S.Half, S.Half, 0,
                     0).doit() == -sqrt(2) / 2)
    assert Wigner6j(1, 2, 3, 2, 1, 2).doit() == sqrt(21) / 105
    assert Wigner6j(3, 1, 2, 2, 2, 1).doit() == sqrt(21) / 105
    assert (Wigner9j(2, 1, 1, Rational(3, 2), S.Half, 1, S.Half, S.Half,
                     0).doit() == sqrt(2) / 12)
    assert CG(S.Half, S.Half, S.Half, Rational(-1, 2), 1,
              0).doit() == sqrt(2) / 2
Esempio n. 4
0
def test_cg():
    cg = CG(1, 2, 3, 4, 5, 6)
    wigner3j = Wigner3j(1, 2, 3, 4, 5, 6)
    wigner6j = Wigner6j(1, 2, 3, 4, 5, 6)
    wigner9j = Wigner9j(1, 2, 3, 4, 5, 6, 7, 8, 9)
    assert str(cg) == 'CG(1, 2, 3, 4, 5, 6)'
    ascii_str = \
"""\
 5,6    \n\
C       \n\
 1,2,3,4\
"""
    ucode_str = \
u"""\
 5,6    \n\
C       \n\
 1,2,3,4\
"""
    assert pretty(cg) == ascii_str
    assert upretty(cg) == ucode_str
    assert latex(cg) == r'C^{5,6}_{1,2,3,4}'
    sT(
        cg,
        "CG(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6))"
    )
    assert str(wigner3j) == 'Wigner3j(1, 2, 3, 4, 5, 6)'
    ascii_str = \
"""\
/1  3  5\\\n\
|       |\n\
\\2  4  6/\
"""
    ucode_str = \
u"""\
⎛1  3  5⎞\n\
⎜       ⎟\n\
⎝2  4  6⎠\
"""
    assert pretty(wigner3j) == ascii_str
    assert upretty(wigner3j) == ucode_str
    assert latex(wigner3j) == \
        r'\left(\begin{array}{ccc} 1 & 3 & 5 \\ 2 & 4 & 6 \end{array}\right)'
    sT(
        wigner3j,
        "Wigner3j(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6))"
    )
    assert str(wigner6j) == 'Wigner6j(1, 2, 3, 4, 5, 6)'
    ascii_str = \
"""\
/1  2  3\\\n\
<       >\n\
\\4  5  6/\
"""
    ucode_str = \
u"""\
⎧1  2  3⎫\n\
⎨       ⎬\n\
⎩4  5  6⎭\
"""
    assert pretty(wigner6j) == ascii_str
    assert upretty(wigner6j) == ucode_str
    assert latex(wigner6j) == \
        r'\left\{\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array}\right\}'
    sT(
        wigner6j,
        "Wigner6j(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6))"
    )
    assert str(wigner9j) == 'Wigner9j(1, 2, 3, 4, 5, 6, 7, 8, 9)'
    ascii_str = \
"""\
/1  2  3\\\n\
|       |\n\
<4  5  6>\n\
|       |\n\
\\7  8  9/\
"""
    ucode_str = \
u"""\
⎧1  2  3⎫\n\
⎪       ⎪\n\
⎨4  5  6⎬\n\
⎪       ⎪\n\
⎩7  8  9⎭\
"""
    assert pretty(wigner9j) == ascii_str
    assert upretty(wigner9j) == ucode_str
    assert latex(wigner9j) == \
        r'\left\{\begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array}\right\}'
    sT(
        wigner9j,
        "Wigner9j(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6), Integer(7), Integer(8), Integer(9))"
    )