Sympy Lie Algebra extensions powered by rust.
Project description
liesym
Lie Algebras using Sympy and backend powered by Rust's pyO3 and ndarray
Overview
In an effort to supply python with the same computer algebra software (CAS)
capabilities, SymPy was written. This python
library is well written and allows an open source alternative to proprietary
choices like Mathematica/WolframLanguage and Maple. Due to the nature of
how SymPy was written, certain symbolic calculation can be extremely unoptimized
in python. Even using numpy could offer little speed ups as it is not geared
towards rational numbers (fractions). Sympy does currently offer a liealgebras
module, but due to the performance limitations, certain tradeoffs had to be
made such as locking the basis for the classic lie algebras in favor of speed.
This is a fair trade off, but would require anyone using a different basis
to hand calculate the representations of the algebra all over again.
An alternative to solve this problem would be to use a compiled
backend that supports generics (and isn't a pain to build with python).
Rust has good python binding support through py03 and allows easy communication through numpy using rust-numpy as well as numpy like api inside rust using ndarray.
Install
pip install liesym
Examples
See also example notebook
import liesym as ls
from sympy import Matrix
from IPython.display import display, Markdown
from sympy.printing.str import StrPrinter
Cartan Matrix
A3 = ls.A(3)
A3.cartan_matrix
$$\displaystyle \left[\begin{matrix}2 & -1 & 0\\ -1 & 2 & -1\\0 & -1 & 2\end{matrix}\right]$$
Positive Roots
for i in A3.positive_roots():
display(i)
$$\displaystyle \left[\begin{matrix}1 & 0 & 1\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}-1 & 1 & 1\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}1 & 1 & -1\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}-1 & 2 & -1\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}0 & -1 & 2\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}2 & -1 & 0\end{matrix}\right]$$
Simple Roots
for i in A3.simple_roots():
display(i)
$$\displaystyle \left[\begin{matrix}1 & -1 & 0 & 0\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}0 & 1 & -1 & 0\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}0 & 0 & 1 & -1\end{matrix}\right]$$
Fundamental Weights
for i in A3.fundamental_weights(): # defaulted to orthogonal basis
display(i)
$$\displaystyle \left[\begin{matrix}\frac{3}{4} & - \frac{1}{4} & - \frac{1}{4} & - \frac{1}{4}\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}\frac{1}{2} & \frac{1}{2} & - \frac{1}{2} & - \frac{1}{2}\end{matrix}\right]$$
$$\displaystyle \left[\begin{matrix}\frac{1}{4} & \frac{1}{4} & \frac{1}{4} & - \frac{3}{4}\end{matrix}\right]$$
Dimension of representation
table = """\
| Dim | Irrep Name | Rep (Omega) |
| :-: | :-: | :-: |
"""
for i in A3.fundamental_weights(basis="omega"):
table += f"""\
| {A3.dim(i)} | $${A3.dim_name(i)}$$ | $${i.table(StrPrinter())}$$|
"""
Markdown(table)
Dim | Irrep Name | Rep (Omega) |
---|---|---|
4 | $$4$$ | $$[1, 0, 0]$$ |
6 | $$6$$ | $$[0, 1, 0]$$ |
4 | $$\bar{4}$$ | $$[0, 0, 1]$$ |
Name of rep
Commonly in literature (especially physics), names of the reps are the dimension rather than the matrix rep.
A3.dim_name(Matrix([[0, 0, 1]]))
$$\displaystyle \bar{4}$$
A3.irrep_lookup(r"\bar{4}")
$$\displaystyle \left[\begin{matrix}0 & 0 & 1\end{matrix}\right]$$
Tensor product decomps
The decomp of irreps from a product of irreps
results = A3.tensor_product_decomposition([
Matrix([[1,0,0]]),
Matrix([[1,0,0]]),
])
table = """\
| Rep | Dim name |
| :-: | :-: |
"""
for i in results:
table += f"""\
| $${i.table(StrPrinter())}$$ | $${A3.dim_name(i)}$$ |
"""
Markdown(table)
Rep | Dim name |
---|---|
$$[0, 1, 0]$$ | $$6$$ |
$$[2, 0, 0]$$ | $$\bar{10}$$ |
Lie Groups
Currently supports SU(N), SO(N), Sp(N)
su2 = ls.SU(2)
su2.generators()
[Matrix([
[ 0, 1/2],
[1/2, 0]]),
Matrix([
[ 0, -I/2],
[I/2, 0]]),
Matrix([
[1/2, 0],
[ 0, -1/2]])]
# cartan generators
su2.generators(cartan_only=True)
[Matrix([
[1/2, 0],
[ 0, -1/2]])]
Structure constants. SU(2) structure constants are $e_{ijk}$
su2.structure_constants()
$$\displaystyle \left[\begin{matrix}\left[\begin{matrix}0 & 0 & 0\\0 & 0 & 1\\0 & -1 & 0\end{matrix}\right] & \left[\begin{matrix}0 & 0 & -1\\0 & 0 & 0\\1 & 0 & 0\end{matrix}\right] & \left[\begin{matrix}0 & 1 & 0\\ -1 & 0 & 0\\0 & 0 & 0\end{matrix}\right]\end{matrix}\right]$$
A1 = ls.A(1)
for x in A1.simple_roots(basis="omega"):
display(x)
$$\displaystyle \left[\begin{matrix}2\end{matrix}\right]$$
Quadratic Casimir
s = ls.Sp(6)
r = s.algebra.fundamental_weights()[0]
s.quadratic_casimir(r)
$$\displaystyle \frac{7}{2}$$
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for liesym-0.8.0-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d311d386be4b357573c449b552ce8565c58eeac571daa5fed807ab1b09f909 |
|
MD5 | 8ac3a5ad819203628923083a01c048a6 |
|
BLAKE2b-256 | 32c739201497f28f7848f375753007dab10a727d8d37acabac1ba0a37727b9c7 |
Hashes for liesym-0.8.0-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d85cf46a3b57f07b7ae7e46ca14b5ecb6a9608b443648665b83b9b430959900 |
|
MD5 | 9051179235c9c0a22c61bf5cc43b33a6 |
|
BLAKE2b-256 | c0347c939770a3c9dd9b9b4b1c3b817e6ee00a52b792c18e66faf3afab7e0a3c |
Hashes for liesym-0.8.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59272f135b0d0f0d8009c815b1e6bef60223823702b414cf742e96b0b8893369 |
|
MD5 | 23642bf4d01a2050caa558d19426107d |
|
BLAKE2b-256 | 1583163f89de9a0af9ba77e1c37a15efc00e5eae066eb258ea92b294772361a2 |
Hashes for liesym-0.8.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e01824adf15cbbd69a91e2c361abd1d203801e6694ecb37b9a23b587353dbc98 |
|
MD5 | 9bee5f9d23ce311fa46dceaff755256e |
|
BLAKE2b-256 | f27e791cffc4a9b95f92910c8c0937a7acc18918baa2d1225f8991610049bb1d |
Hashes for liesym-0.8.0-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d958073738e5003b02791921689719eb5b8285cd4e593774553af74811bc09a5 |
|
MD5 | 647a01cefbf2f0ffa831c370e10d9fc8 |
|
BLAKE2b-256 | 395796c8c8181e378c83c6261d0b3645c49f22348aec5058d2601dcef3179064 |
Hashes for liesym-0.8.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 762b5308633fac1b6f510cd85c433ceaed334056170a8a3be8ea7a7963c2ce04 |
|
MD5 | 78372265563233844ad42cc2d0e5f765 |
|
BLAKE2b-256 | 0d7a5895da31a1d716ddaa48fb327ce70451a6d04df2d7e77c0e206bc2966aca |
Hashes for liesym-0.8.0-cp38-abi3-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61cc7d618b4ab6be3c784d7f7916c7cf1eee37485384ba9c2c8e2c6e5b48d946 |
|
MD5 | 2a3cd2e4a71ed1f8c2b772921f632882 |
|
BLAKE2b-256 | 4f86673f109bb477e46aaef0ee8f28304b869d046404f7d470e2ce19664fc09d |