fujiisoup / py3nj

Wigner's 3J, 6J, 9J symbols for python
https://py3nj.readthedocs.io/
Apache License 2.0
18 stars 5 forks source link

wigner 9j disagrees with online calculators #2

Closed jevonlongdell closed 4 years ago

jevonlongdell commented 5 years ago

I want to know what following 9j symbol evaluates to { 3/2 3/2 1 2 2 2 1/2 1/2 1 }

A couple of online calculators say the value is around 0.048:

I don't know who's right?

fujiisoup commented 5 years ago

Thanks for raising an issue. I will investigate it but may take a while.

Just a note, in py3nj, 9j symbol is calculated directly from 6j symbols. http://mathworld.wolfram.com/Wigner9j-Symbol.html

6j symbol requires a triangle condition. To me it looks that your the left lower triangle of your 9j matrix { 2 1/2 1/2 } violates this relation.

image (J13, J24, J3 in the last term need to satisfy the relation)

jevonlongdell commented 5 years ago

Thanks heap, this makes sense. It looks very much like

jevonlongdell commented 5 years ago

Although here is another member of the 0.048 camp https://arxiv.org/abs/1504.08329, DOI: | 10.1137/15M1021908

jevon@roc:~/Desktop/wigxjpf-1.10$ bin/wigxjpf --9j=1.5,1.5,1,2,2,2,0.5,0.5,1

9j(1.5 1.5 1.0 2.0 2.0 2.0 0.5 0.5 1.0) = 0.0483045891539648 `

e-eight commented 4 years ago

Possibly resulting from the same bug, wigner9j(0, 0, 0, 2 * 1, 0, 2 * 1, 2 * 1, 0, 2 * 1) gives 0, when the value should be 1/3 or 0.33333333333.

fujiisoup commented 4 years ago

Thanks for the report, @e-eight Are you sure if this should be 1/3?

I am still confusing for wigner9j. wigner6j returns 0 if the triangular relation is not satisfied, and in this case wigner9j also returns 0.

py3nj calculates this directly from wigner6j. https://github.com/fujiisoup/py3nj/blob/59ad68e3149ed87af470d97f8d3c5ded188312bb/py3nj/wigner.py#L165-L171

I would be grateful if you could send a fix for the above 7 lines.

e-eight commented 4 years ago

@fujiisoup Sorry for replying so late. I totally forgot about this. I calculated the value of wigner9j(0, 0, 0, 2 * 1, 0, 2 * 1, 2 * 1, 0, 2 * 1) using the formula given on Wolfram Mathworld, and it is indeed 1/3. I am not sure what is wrong with that piece of code, but I will try and see if I can fix it.

e-eight commented 4 years ago

I want to know what following 9j symbol evaluates to { 3/2 3/2 1 2 2 2 1/2 1/2 1 }

A couple of online calculators say the value is around 0.048:

* http://www-stone.ch.cam.ac.uk/cgi-bin/wigner.cgi?symbol=9j&a=3%2F2&b=3%2F2&c=1&d=2&e=2&f=2&g=1%2F2&h=1%2F2&i=1

* http://dentonwoods.nfshost.com/3j6j9j.html

* py3nj says the value is zero

* sympy.physics.wigner throws an error Value error saying the values must be integer or half integer and fulfill the triangle relation.

I don't know who's right?

@jevonlongdell, sympy gives the same answer as the online calculators. In sympy you need to enter half integers with an S, like S(3)/2, after you import S from sympy.

fujiisoup commented 4 years ago

Thanks, @e-eight

sympy gives the same answer as the online calculators. In sympy you need to enter half integers with an S, like S(3)/2, after you import S from sympy.

Then, it looks like a bug of my package. I have still no idea what's wrong in these lines though https://github.com/fujiisoup/py3nj/blob/59ad68e3149ed87af470d97f8d3c5ded188312bb/py3nj/wigner.py#L165-L171

This should represent the following... image

fujiisoup commented 4 years ago

Found a bug!!! Thanks, @jevonlongdell and @e-eight, for the bug report and clarification of the problem.