Skip to main content

numpy compatible wigner 3n-J symbols

Project description

py3nj

travis

A small python library to calcluate wigner's 3j-, 6j- and 9j- symbols. py3nj is designed to be compatible with numpy's np.ndarray and its calculation is vectorized automatically.

Basic Usage

The basic interfaces are py3nj.wigner3j, py3nj.wigner6j, py3nj.wigner9j, and py3nj.clebsch_gordan.

>>> # Calculate (0/2, 1/2, 1/2,
... #           (0/2, 1/2,-1/2)
... # Note that all the arguments should be doubled
... py3nj.wigner3j(0, 1, 1,
...                0, 1,-1)
0.7071067811865476

>>> # vectorization is supported
... py3nj.wigner3j([0, 2], [1, 0], [ 1, 0],
...                [0, 0], [1, 0], [-1, 0])
array([0.70710678, 0.        ])

>>> # 6J symbol
>>> py3nj.wigner6j([2, 1], [1, 2], [1, 1],
...                [1, 2], [2, 1], [0, 0])
array([0.40824829, 0.40824829])

>>> # 9J symbol
>>> py3nj.wigner9j([2, 2], [4, 4], [2, 2],
...                [2, 4], [2, 6], [2, 2],
...                [2, 2], [2, 4], [2, 2])
array([0.05555556, 0.03651484])

>>> Clebsch Gordanh coefficient
>>> py3nj.clebsch_gordan(2, 2, 4,
...                      2, 0, 2)
0.7071067811865475

>>> # Vectorized calcluation of C.G. coef
... py3nj.clebsch_gordan([2, 1], [2, 1], [4, 0],
...                      [2,-1], [0, 1], [2, 0])
array([ 0.70710678, -0.70710678])

Install

py3nj can be installed through either pip or github repository. You'll likely need to have ninja installed.

Install by pip

pip install py3nj

Install through github

git clone https://github.com/fujiisoup/py3nj
cd py3nj
pip install .

Acknowledgement

py3nj wraps slatec fortran implementation. See http://www.netlib.org/slatec/ for the details.

License

Copyright 2018, py3nj Developers

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py3nj-0.2.1.tar.gz (50.0 kB view details)

Uploaded Source

File details

Details for the file py3nj-0.2.1.tar.gz.

File metadata

  • Download URL: py3nj-0.2.1.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for py3nj-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3f9a79b3b18a51570c835c174a941f3cd3b552d1d3414debebeb70ce759512fe
MD5 7e21cd953837d3a804abd9e491282752
BLAKE2b-256 7939608a0b4fa24bd07e42acfbe914eff4f32382e3861d81853d81f2c6d9fa7b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page