Last active
December 23, 2015 17:59
-
-
Save agamdua/6672239 to your computer and use it in GitHub Desktop.
Testing Wigner from sympy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1c1 | |
< r""" | |
--- | |
> """ | |
3a4,5 | |
> form http://pydoc.net/Python/sympy/0.7.1/sympy.physics.wigner/ | |
> | |
12,13c14 | |
< References | |
< ~~~~~~~~~~ | |
--- | |
> REFERENCES: | |
19,21d19 | |
< Credits and Copyright | |
< ~~~~~~~~~~~~~~~~~~~~~ | |
< | |
31d28 | |
< | |
34c31 | |
< from sympy import Integer, pi, sqrt, sympify | |
--- | |
> from sympy import Integer, pi, sqrt | |
40,41c37 | |
< _Factlist = [1] | |
< | |
--- | |
> _Factlist=[1] | |
87,88c83 | |
< Examples | |
< ======== | |
--- | |
> EXAMPLES:: | |
90,94c85,94 | |
< >>> from sympy.physics.wigner import wigner_3j | |
< >>> wigner_3j(2, 6, 4, 0, 0, 0) | |
< sqrt(715)/143 | |
< >>> wigner_3j(2, 6, 4, 0, 0, 1) | |
< 0 | |
--- | |
> sage: wigner_3j(2, 6, 4, 0, 0, 0) | |
> sqrt(5/143) | |
> sage: wigner_3j(2, 6, 4, 0, 0, 1) | |
> 0 | |
> sage: wigner_3j(0.5, 0.5, 1, 0.5, -0.5, 0) | |
> sqrt(1/6) | |
> sage: wigner_3j(40, 100, 60, -10, 60, -50) | |
> 95608/18702538494885*sqrt(21082735836735314343364163310/220491455010479533763) | |
> sage: wigner_3j(2500, 2500, 5000, 2488, 2400, -4888, prec=64) | |
> 7.60424456883448589e-12 | |
183c183 | |
< maxfact = max(j_1 + j_2 + j_3 + 1, j_1 + abs(m_1), j_2 + abs(m_2), | |
--- | |
> maxfact = max(j_1 + j_2 + j_3 + 1, j_1 + abs(m_1), j_2 + abs(m_2), \ | |
185c185 | |
< _calc_factlist(int(maxfact)) | |
--- | |
> _calc_factlist(maxfact) | |
187,196c187,196 | |
< argsqrt = Integer(_Factlist[int(j_1 + j_2 - j_3)] * | |
< _Factlist[int(j_1 - j_2 + j_3)] * | |
< _Factlist[int(-j_1 + j_2 + j_3)] * | |
< _Factlist[int(j_1 - m_1)] * | |
< _Factlist[int(j_1 + m_1)] * | |
< _Factlist[int(j_2 - m_2)] * | |
< _Factlist[int(j_2 + m_2)] * | |
< _Factlist[int(j_3 - m_3)] * | |
< _Factlist[int(j_3 + m_3)]) / \ | |
< _Factlist[int(j_1 + j_2 + j_3 + 1)] | |
--- | |
> argsqrt = Integer(_Factlist[int(j_1 + j_2 - j_3)] * \ | |
> _Factlist[int(j_1 - j_2 + j_3)] * \ | |
> _Factlist[int(-j_1 + j_2 + j_3)] * \ | |
> _Factlist[int(j_1 - m_1)] * \ | |
> _Factlist[int(j_1 + m_1)] * \ | |
> _Factlist[int(j_2 - m_2)] * \ | |
> _Factlist[int(j_2 + m_2)] * \ | |
> _Factlist[int(j_3 - m_3)] * \ | |
> _Factlist[int(j_3 + m_3)]) / \ | |
> _Factlist[int(j_1 + j_2 + j_3 + 1)] | |
205c205 | |
< for ii in range(int(imin), int(imax) + 1): | |
--- | |
> for ii in range(imin, imax + 1): | |
244c244 | |
< sqrt(3)/2 | |
--- | |
> 3**(1/2)/2 | |
246c246 | |
< -sqrt(2)/2 | |
--- | |
> -2**(1/2)/2 | |
266c266 | |
< res = (-1) ** sympify(j_1 - j_2 + m_3) * sqrt(2 * j_3 + 1) * \ | |
--- | |
> res = (-1) ** int(j_1 - j_2 + m_3) * sqrt(2 * j_3 + 1) * \ | |
313,316c313,316 | |
< argsqrt = Integer(_Factlist[int(aa + bb - cc)] * | |
< _Factlist[int(aa + cc - bb)] * | |
< _Factlist[int(bb + cc - aa)]) / \ | |
< Integer(_Factlist[int(aa + bb + cc + 1)]) | |
--- | |
> argsqrt = Integer(_Factlist[int(aa + bb - cc)] * \ | |
> _Factlist[int(aa + cc - bb)] * \ | |
> _Factlist[int(bb + cc - aa)]) / \ | |
> Integer(_Factlist[int(aa + bb + cc + 1)]) | |
340,341c340 | |
< Examples | |
< ======== | |
--- | |
> EXAMPLES:: | |
343,345c342,343 | |
< >>> from sympy.physics.wigner import racah | |
< >>> racah(3,3,3,3,3,3) | |
< -1/14 | |
--- | |
> sage: racah(3,3,3,3,3,3) | |
> -1/14 | |
380,381c378,379 | |
< maxfact = max(imax + 1, aa + bb + cc + dd, aa + dd + ee + ff, | |
< bb + cc + ee + ff) | |
--- | |
> maxfact = max(imax + 1, aa + bb + cc + dd, aa + dd + ee + ff, \ | |
> bb + cc + ee + ff) | |
415,416c413 | |
< Examples | |
< ======== | |
--- | |
> EXAMPLES:: | |
418,422c415,428 | |
< >>> from sympy.physics.wigner import wigner_6j | |
< >>> wigner_6j(3,3,3,3,3,3) | |
< -1/14 | |
< >>> wigner_6j(5,5,5,5,5,5) | |
< 1/52 | |
--- | |
> sage: wigner_6j(3,3,3,3,3,3) | |
> -1/14 | |
> sage: wigner_6j(5,5,5,5,5,5) | |
> 1/52 | |
> sage: wigner_6j(6,6,6,6,6,6) | |
> 309/10868 | |
> sage: wigner_6j(8,8,8,8,8,8) | |
> -12219/965770 | |
> sage: wigner_6j(30,30,30,30,30,30) | |
> 36082186869033479581/87954851694828981714124 | |
> sage: wigner_6j(0.5,0.5,1,0.5,0.5,1) | |
> 1/6 | |
> sage: wigner_6j(200,200,200,200,200,200, prec=1000)*1.0 | |
> 0.000155903212413242 | |
510,511c516 | |
< Examples | |
< ======== | |
--- | |
> EXAMPLES: | |
513,515c518,544 | |
< >>> from sympy.physics.wigner import wigner_9j | |
< >>> wigner_9j(1,1,1, 1,1,1, 1,1,0 ,prec=64) # ==1/18 | |
< 0.05555555... | |
--- | |
> A couple of examples and test cases, note that for speed reasons a | |
> precision is given:: | |
> | |
> sage: wigner_9j(1,1,1, 1,1,1, 1,1,0 ,prec=64) # ==1/18 | |
> 0.0555555555555555555 | |
> sage: wigner_9j(1,1,1, 1,1,1, 1,1,1) | |
> 0 | |
> sage: wigner_9j(1,1,1, 1,1,1, 1,1,2 ,prec=64) # ==1/18 | |
> 0.0555555555555555556 | |
> sage: wigner_9j(1,2,1, 2,2,2, 1,2,1 ,prec=64) # ==-1/150 | |
> -0.00666666666666666667 | |
> sage: wigner_9j(3,3,2, 2,2,2, 3,3,2 ,prec=64) # ==157/14700 | |
> 0.0106802721088435374 | |
> sage: wigner_9j(3,3,2, 3,3,2, 3,3,2 ,prec=64) # ==3221*sqrt(70)/(246960*sqrt(105)) - 365/(3528*sqrt(70)*sqrt(105)) | |
> 0.00944247746651111739 | |
> sage: wigner_9j(3,3,1, 3.5,3.5,2, 3.5,3.5,1 ,prec=64) # ==3221*sqrt(70)/(246960*sqrt(105)) - 365/(3528*sqrt(70)*sqrt(105)) | |
> 0.0110216678544351364 | |
> sage: wigner_9j(100,80,50, 50,100,70, 60,50,100 ,prec=1000)*1.0 | |
> 1.05597798065761e-7 | |
> sage: wigner_9j(30,30,10, 30.5,30.5,20, 30.5,30.5,10 ,prec=1000)*1.0 # ==(80944680186359968990/95103769817469)*sqrt(1/682288158959699477295) | |
> 0.0000325841699408828 | |
> sage: wigner_9j(64,62.5,114.5, 61.5,61,112.5, 113.5,110.5,60, prec=1000)*1.0 | |
> -3.41407910055520e-39 | |
> sage: wigner_9j(15,15,15, 15,3,15, 15,18,10, prec=1000)*1.0 | |
> -0.0000778324615309539 | |
> sage: wigner_9j(1.5,1,1.5, 1,1,1, 1.5,1,1.5) | |
> 0 | |
576,577c605 | |
< Examples | |
< ======== | |
--- | |
> EXAMPLES:: | |
579,583c607,620 | |
< >>> from sympy.physics.wigner import gaunt | |
< >>> gaunt(1,0,1,1,0,-1) | |
< -1/(2*sqrt(pi)) | |
< >>> gaunt(1000,1000,1200,9,3,-12).n(64) | |
< 0.00689500421922113448... | |
--- | |
> sage: gaunt(1,0,1,1,0,-1) | |
> -1/2/sqrt(pi) | |
> sage: gaunt(1,0,1,1,0,0) | |
> 0 | |
> sage: gaunt(29,29,34,10,-5,-5) | |
> 1821867940156/215552371055153321*sqrt(22134)/sqrt(pi) | |
> sage: gaunt(20,20,40,1,-1,0) | |
> 28384503878959800/74029560764440771/sqrt(pi) | |
> sage: gaunt(12,15,5,2,3,-5) | |
> 91/124062*sqrt(36890)/sqrt(pi) | |
> sage: gaunt(10,10,12,9,3,-12) | |
> -98/62031*sqrt(6279)/sqrt(pi) | |
> sage: gaunt(1000,1000,1200,9,3,-12).n(64) | |
> 0.00689500421922113448 | |
625c662 | |
< `J = l_1 + l_2 + l_3 = 2n` for `n` in `\mathbb{N}` | |
--- | |
> `J=l_1+l_2+l_3=2n` for `n` in `\Bold{N}` | |
679c716 | |
< prefac = Integer(_Factlist[bigL] * _Factlist[l_2 - l_1 + l_3] * | |
--- | |
> prefac = Integer(_Factlist[bigL] * _Factlist[l_2 - l_1 + l_3] * \ | |
681,683c718,719 | |
< _Factlist[2 * bigL + 1]/ \ | |
< (_Factlist[bigL - l_1] * | |
< _Factlist[bigL - l_2] * _Factlist[bigL - l_3]) | |
--- | |
> _Factlist[2 * bigL+1]/ \ | |
> (_Factlist[bigL - l_1] * _Factlist[bigL - l_2] * _Factlist[bigL - l_3]) | |
693c729 | |
< if prec is not None: | |
--- | |
> if prec != None: | |
696d731 | |
< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from sympy import S | |
In [2]: S | |
Out[2]: S | |
In [3]: S. | |
S.Catalan S.EulerGamma S.Half S.Infinity S.Naturals S.NegativeOne S.Reals | |
S.ComplexInfinity S.Exp1 S.IdentityFunction S.Integers S.Naturals0 S.One S.UniversalSet | |
S.EmptySet S.GoldenRatio S.ImaginaryUnit S.NaN S.NegativeInfinity S.Pi S.Zero | |
In [3]: from sympy.physics.wigner import clebsch_gordan | |
In [4]: clebsch_gordan(S(1)/2, S(1)/2, 1, S(1)/2, S(1)/2, 1) | |
Out[4]: 1 | |
In [5]: clebsch_gordan(.5, .5, 1, .5, .5, 1, prec=None) | |
Out[5]: 1.00000000000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay just narrowed it down. Importing S is unnecessary.
The error was coming because I was earlier importing the wigner file you gave me.