Skip to main content

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


Download files

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

Source Distribution

liesym-0.8.1.tar.gz (322.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

liesym-0.8.1-cp38-abi3-win_amd64.whl (321.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

liesym-0.8.1-cp38-abi3-win32.whl (313.8 kB view details)

Uploaded CPython 3.8+Windows x86

liesym-0.8.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

liesym-0.8.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

liesym-0.8.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (1.5 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.12+ i686

liesym-0.8.1-cp38-abi3-macosx_11_0_arm64.whl (471.4 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

liesym-0.8.1-cp38-abi3-macosx_10_12_x86_64.whl (484.8 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file liesym-0.8.1.tar.gz.

File metadata

  • Download URL: liesym-0.8.1.tar.gz
  • Upload date:
  • Size: 322.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for liesym-0.8.1.tar.gz
Algorithm Hash digest
SHA256 88c7aefc25b2d1cf3d6dba6de3624d574533fc11817458eef774101027d8f7ab
MD5 8f0c868a64f03e0ebc30ea3e89a2c191
BLAKE2b-256 36554847b5b4ea2ac853a83b484b7a11adcc05b2ad15635f5cdb4cb6f35fb724

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: liesym-0.8.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 321.6 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for liesym-0.8.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 171179785ec0d62c32e7876fc4961cfdae1b623ced36c10b43a82a3b12edd14c
MD5 4fe0bf89b421e6f4c71695a786da5454
BLAKE2b-256 0dc414e8440ec880a9b23d2df181b3f4e5565136a89691fc8eed22ba09da5d99

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-win32.whl.

File metadata

  • Download URL: liesym-0.8.1-cp38-abi3-win32.whl
  • Upload date:
  • Size: 313.8 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for liesym-0.8.1-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 77409b7372c726b35fa76e16cb81b355b8f373347c81074c82c5744670691106
MD5 8116a312feff53e5a1cd066170739a90
BLAKE2b-256 c607356840cf2e12691e707ec9235b2d81871d72f2cfd4634075470a2e9a6a93

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for liesym-0.8.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e9fafc2cab02f44749d72cad187188485bd0be091a9516809121cc2ad06cb65
MD5 f7e224b8afbaea4268c37f179607b631
BLAKE2b-256 a1a4b7e441de81bb87c012b8a6fd2ce17417ad0a96429beadd3ceeff2eba22a6

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for liesym-0.8.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 08f55700b5cf787def4adee7879e4449ecad683792ec0b3683daafc05b2d02c5
MD5 475c0b9aa2997ae07f7e657876454b15
BLAKE2b-256 4061fb70915395a633663b457ec096d70d8a2ab6e9ac6fc545a2b9b150b0596b

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for liesym-0.8.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 978c39fa89d15f3dd5b8ec4b2cb0d260001dce985461782f019c6039d17bd5f9
MD5 45783a0cbb190d7d764eb50e8a29edf0
BLAKE2b-256 70d1bed486635ab06921179c44078e1e69fe352fc8c92d16836627618d1236cc

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for liesym-0.8.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e304e5ee45867f72c4698c9c66a3007a986ccc4ab3d447bd6da281cad153163
MD5 69eec52d170fc04358d28a5a6b63cb72
BLAKE2b-256 ff285f3178ed946a6a05af6a496f053398bc581f3014ba859c757245fc3bc860

See more details on using hashes here.

File details

Details for the file liesym-0.8.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for liesym-0.8.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 07a0fc7cf3c3fb1b276959d5347e72d54eedaadd2b6101120a42372955e3f28e
MD5 9457466cbc7388458ea680be51d7cdf0
BLAKE2b-256 b72a27c92f46b2cbc790a10c33a05a83a6f3a85b7f0be5091670e8b2062ff813

See more details on using hashes here.

Supported by

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