def get_decay_part(decay, ls, lambda_list, symbol_list): """ .. math:: \\sqrt{\\frac{ 2 l + 1 }{ 2 j_a + 1 }} \\langle j_b, j_c, \\lambda_b, - \\lambda_c | s, \\lambda_b - \\lambda_c \\rangle \\langle l, s, 0, \\lambda_b - \\lambda_c | j_a, \\lambda_b - \\lambda_c \\rangle .. math:: D_{\\lambda_a, \\lambda_b - \\lambda_c}^{J_{A}*} (\\phi, \\theta, 0) """ a = decay.core b, c = decay.outs l, s = ls lambda_list = {k: spin_int(v) for k, v in lambda_list.items()} delta = lambda_list[b] - lambda_list[c] if abs(delta) > a.J: return 0 d_part = WignerD( spin_int(a.J), lambda_list[a], delta, symbol_list[decay]["alpha"], symbol_list[decay]["beta"], 0, ) # print(lambda_list) cg_part = sym.sqrt((2 * l + 1)) / sym.sqrt((2 * spin_int(a.J) + 1)) cg_part = cg_part * CG(l, 0, spin_int(s), delta, spin_int(a.J), delta) cg_part = cg_part * CG( spin_int(b.J), lambda_list[b], spin_int(c.J), -lambda_list[c], spin_int(s), delta, ) return simplify(d_part.conjugate() * cg_part)
def test_wignerd(): j, m, mp, alpha, beta, gamma = symbols('j m mp alpha beta gamma') assert Rotation.D(j, m, mp, alpha, beta, gamma) == WignerD(j, m, mp, alpha, beta, gamma) assert Rotation.d(j, m, mp, beta) == WignerD(j, m, mp, 0, beta, 0)
def test_sympy__physics__quantum__spin__WignerD(): from sympy.physics.quantum.spin import WignerD assert _test_args(WignerD(0, 1, 2, 3, 4, 5))
def test_spin(): lz = JzOp('L') ket = JzKet(1, 0) bra = JzBra(1, 0) cket = JzKetCoupled(1, 0, (1, 2)) cbra = JzBraCoupled(1, 0, (1, 2)) cket_big = JzKetCoupled(1, 0, (1, 2, 3)) cbra_big = JzBraCoupled(1, 0, (1, 2, 3)) rot = Rotation(1, 2, 3) bigd = WignerD(1, 2, 3, 4, 5, 6) smalld = WignerD(1, 2, 3, 0, 4, 0) assert str(lz) == 'Lz' ascii_str = \ """\ L \n\ z\ """ ucode_str = \ u"""\ L \n\ z\ """ assert pretty(lz) == ascii_str assert upretty(lz) == ucode_str assert latex(lz) == 'L_z' sT(lz, "JzOp(Symbol('L'))") assert str(J2) == 'J2' ascii_str = \ """\ 2\n\ J \ """ ucode_str = \ u"""\ 2\n\ J \ """ assert pretty(J2) == ascii_str assert upretty(J2) == ucode_str assert latex(J2) == r'J^2' sT(J2, "J2Op(Symbol('J'))") assert str(Jz) == 'Jz' ascii_str = \ """\ J \n\ z\ """ ucode_str = \ u"""\ J \n\ z\ """ assert pretty(Jz) == ascii_str assert upretty(Jz) == ucode_str assert latex(Jz) == 'J_z' sT(Jz, "JzOp(Symbol('J'))") assert str(ket) == '|1,0>' assert pretty(ket) == '|1,0>' assert upretty(ket) == u'❘1,0⟩' assert latex(ket) == r'{\left|1,0\right\rangle }' sT(ket, "JzKet(Integer(1),Integer(0))") assert str(bra) == '<1,0|' assert pretty(bra) == '<1,0|' assert upretty(bra) == u'⟨1,0❘' assert latex(bra) == r'{\left\langle 1,0\right|}' sT(bra, "JzBra(Integer(1),Integer(0))") assert str(cket) == '|1,0,j1=1,j2=2>' assert pretty(cket) == '|1,0,j1=1,j2=2>' assert upretty(cket) == u'❘1,0,j₁=1,j₂=2⟩' assert latex(cket) == r'{\left|1,0,j_{1}=1,j_{2}=2\right\rangle }' sT( cket, "JzKetCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2)),Tuple(Tuple(Integer(1), Integer(2), Integer(1))))" ) assert str(cbra) == '<1,0,j1=1,j2=2|' assert pretty(cbra) == '<1,0,j1=1,j2=2|' assert upretty(cbra) == u'⟨1,0,j₁=1,j₂=2❘' assert latex(cbra) == r'{\left\langle 1,0,j_{1}=1,j_{2}=2\right|}' sT( cbra, "JzBraCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2)),Tuple(Tuple(Integer(1), Integer(2), Integer(1))))" ) assert str(cket_big) == '|1,0,j1=1,j2=2,j3=3,j(1,2)=3>' # TODO: Fix non-unicode pretty printing # i.e. j1,2 -> j(1,2) assert pretty(cket_big) == '|1,0,j1=1,j2=2,j3=3,j1,2=3>' assert upretty(cket_big) == u'❘1,0,j₁=1,j₂=2,j₃=3,j₁,₂=3⟩' assert latex(cket_big) == \ r'{\left|1,0,j_{1}=1,j_{2}=2,j_{3}=3,j_{1,2}=3\right\rangle }' sT( cket_big, "JzKetCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2), Integer(3)),Tuple(Tuple(Integer(1), Integer(2), Integer(3)), Tuple(Integer(1), Integer(3), Integer(1))))" ) assert str(cbra_big) == '<1,0,j1=1,j2=2,j3=3,j(1,2)=3|' assert pretty(cbra_big) == u'<1,0,j1=1,j2=2,j3=3,j1,2=3|' assert upretty(cbra_big) == u'⟨1,0,j₁=1,j₂=2,j₃=3,j₁,₂=3❘' assert latex(cbra_big) == \ r'{\left\langle 1,0,j_{1}=1,j_{2}=2,j_{3}=3,j_{1,2}=3\right|}' sT( cbra_big, "JzBraCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2), Integer(3)),Tuple(Tuple(Integer(1), Integer(2), Integer(3)), Tuple(Integer(1), Integer(3), Integer(1))))" ) assert str(rot) == 'R(1,2,3)' assert pretty(rot) == 'R (1,2,3)' assert upretty(rot) == u'ℛ (1,2,3)' assert latex(rot) == r'\mathcal{R}\left(1,2,3\right)' sT(rot, "Rotation(Integer(1),Integer(2),Integer(3))") assert str(bigd) == 'WignerD(1, 2, 3, 4, 5, 6)' ascii_str = \ """\ 1 \n\ D (4,5,6)\n\ 2,3 \ """ ucode_str = \ u"""\ 1 \n\ D (4,5,6)\n\ 2,3 \ """ assert pretty(bigd) == ascii_str assert upretty(bigd) == ucode_str assert latex(bigd) == r'D^{1}_{2,3}\left(4,5,6\right)' sT( bigd, "WignerD(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6))" ) assert str(smalld) == 'WignerD(1, 2, 3, 0, 4, 0)' ascii_str = \ """\ 1 \n\ d (4)\n\ 2,3 \ """ ucode_str = \ u"""\ 1 \n\ d (4)\n\ 2,3 \ """ assert pretty(smalld) == ascii_str assert upretty(smalld) == ucode_str assert latex(smalld) == r'd^{1}_{2,3}\left(4\right)' sT( smalld, "WignerD(Integer(1), Integer(2), Integer(3), Integer(0), Integer(4), Integer(0))" )
def test_spin(): lz = JzOp("L") ket = JzKet(1, 0) bra = JzBra(1, 0) cket = JzKetCoupled(1, 0, (1, 2)) cbra = JzBraCoupled(1, 0, (1, 2)) cket_big = JzKetCoupled(1, 0, (1, 2, 3)) cbra_big = JzBraCoupled(1, 0, (1, 2, 3)) rot = Rotation(1, 2, 3) bigd = WignerD(1, 2, 3, 4, 5, 6) smalld = WignerD(1, 2, 3, 0, 4, 0) assert str(lz) == "Lz" ascii_str = """\ L \n\ z\ """ ucode_str = u("""\ L \n\ z\ """) assert pretty(lz) == ascii_str assert upretty(lz) == ucode_str assert latex(lz) == "L_z" sT(lz, "JzOp(Symbol('L'))") assert str(J2) == "J2" ascii_str = """\ 2\n\ J \ """ ucode_str = u("""\ 2\n\ J \ """) assert pretty(J2) == ascii_str assert upretty(J2) == ucode_str assert latex(J2) == r"J^2" sT(J2, "J2Op(Symbol('J'))") assert str(Jz) == "Jz" ascii_str = """\ J \n\ z\ """ ucode_str = u("""\ J \n\ z\ """) assert pretty(Jz) == ascii_str assert upretty(Jz) == ucode_str assert latex(Jz) == "J_z" sT(Jz, "JzOp(Symbol('J'))") assert str(ket) == "|1,0>" assert pretty(ket) == "|1,0>" assert upretty(ket) == u"❘1,0⟩" assert latex(ket) == r"{\left|1,0\right\rangle }" sT(ket, "JzKet(Integer(1),Integer(0))") assert str(bra) == "<1,0|" assert pretty(bra) == "<1,0|" assert upretty(bra) == u"⟨1,0❘" assert latex(bra) == r"{\left\langle 1,0\right|}" sT(bra, "JzBra(Integer(1),Integer(0))") assert str(cket) == "|1,0,j1=1,j2=2>" assert pretty(cket) == "|1,0,j1=1,j2=2>" assert upretty(cket) == u"❘1,0,j₁=1,j₂=2⟩" assert latex(cket) == r"{\left|1,0,j_{1}=1,j_{2}=2\right\rangle }" sT( cket, "JzKetCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2)),Tuple(Tuple(Integer(1), Integer(2), Integer(1))))", ) assert str(cbra) == "<1,0,j1=1,j2=2|" assert pretty(cbra) == "<1,0,j1=1,j2=2|" assert upretty(cbra) == u"⟨1,0,j₁=1,j₂=2❘" assert latex(cbra) == r"{\left\langle 1,0,j_{1}=1,j_{2}=2\right|}" sT( cbra, "JzBraCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2)),Tuple(Tuple(Integer(1), Integer(2), Integer(1))))", ) assert str(cket_big) == "|1,0,j1=1,j2=2,j3=3,j(1,2)=3>" # TODO: Fix non-unicode pretty printing # i.e. j1,2 -> j(1,2) assert pretty(cket_big) == "|1,0,j1=1,j2=2,j3=3,j1,2=3>" assert upretty(cket_big) == u"❘1,0,j₁=1,j₂=2,j₃=3,j₁,₂=3⟩" assert (latex(cket_big) == r"{\left|1,0,j_{1}=1,j_{2}=2,j_{3}=3,j_{1,2}=3\right\rangle }") sT( cket_big, "JzKetCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2), Integer(3)),Tuple(Tuple(Integer(1), Integer(2), Integer(3)), Tuple(Integer(1), Integer(3), Integer(1))))", ) assert str(cbra_big) == "<1,0,j1=1,j2=2,j3=3,j(1,2)=3|" assert pretty(cbra_big) == u"<1,0,j1=1,j2=2,j3=3,j1,2=3|" assert upretty(cbra_big) == u"⟨1,0,j₁=1,j₂=2,j₃=3,j₁,₂=3❘" assert (latex(cbra_big) == r"{\left\langle 1,0,j_{1}=1,j_{2}=2,j_{3}=3,j_{1,2}=3\right|}") sT( cbra_big, "JzBraCoupled(Integer(1),Integer(0),Tuple(Integer(1), Integer(2), Integer(3)),Tuple(Tuple(Integer(1), Integer(2), Integer(3)), Tuple(Integer(1), Integer(3), Integer(1))))", ) assert str(rot) == "R(1,2,3)" assert pretty(rot) == "R (1,2,3)" assert upretty(rot) == u"ℛ (1,2,3)" assert latex(rot) == r"\mathcal{R}\left(1,2,3\right)" sT(rot, "Rotation(Integer(1),Integer(2),Integer(3))") assert str(bigd) == "WignerD(1, 2, 3, 4, 5, 6)" ascii_str = """\ 1 \n\ D (4,5,6)\n\ 2,3 \ """ ucode_str = u("""\ 1 \n\ D (4,5,6)\n\ 2,3 \ """) assert pretty(bigd) == ascii_str assert upretty(bigd) == ucode_str assert latex(bigd) == r"D^{1}_{2,3}\left(4,5,6\right)" sT( bigd, "WignerD(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6))", ) assert str(smalld) == "WignerD(1, 2, 3, 0, 4, 0)" ascii_str = """\ 1 \n\ d (4)\n\ 2,3 \ """ ucode_str = u("""\ 1 \n\ d (4)\n\ 2,3 \ """) assert pretty(smalld) == ascii_str assert upretty(smalld) == ucode_str assert latex(smalld) == r"d^{1}_{2,3}\left(4\right)" sT( smalld, "WignerD(Integer(1), Integer(2), Integer(3), Integer(0), Integer(4), Integer(0))", )