Python library for Operator Product Expansion calculations in Vertex Operator Algebras
Project description
PyOPE
PyOPE is a Python library for symbolic Operator Product Expansion (OPE) calculations in Vertex Operator Algebras (VOA) and 2d Conformal Field Theory (CFT).
它基于 Python + SymPy,目标是提供一个可编程、可测试、可扩展的 OPE 计算环境,并尽量与 Mathematica 参考实现 OPEdefs.m 对齐。
Status
- 当前版本:
0.1.0 - 开发状态:Alpha
- Python 版本:
>=3.8 - 主要依赖:
sympy、numpy
当前项目已经具备以下能力:
- 基础算符的 OPE 注册与计算
- 导数算符、线性组合、正规序算符的 OPE 规则
NO(...)/normal_product(...)构造与化简bracket(A, B, n)提取各阶极点系数- Jacobi 恒等式验证
- 一组面向 C2、realization、null state 搜索的实验性工具
其中 C2、null state、realization 相关接口仍在快速演化,后续版本可能调整。
Installation
发布到 PyPI 后可直接安装:
pip install pyope-voa
安装后导入名仍然是:
import pyope
从源码安装:
pip install -e .
安装开发依赖:
pip install -e ".[dev]"
安装 Notebook 相关依赖:
pip install -e ".[jupyter]"
Quick Start
下面给出一个最小的 Virasoro 例子,定义 $T(z)T(w)$ 的 OPE:
import sympy as sp
from pyope import BasisOperator, Bosonic, MakeOPE, OPE
from pyope import One, Zero, NO, bracket, d
T = BasisOperator("T", conformal_weight=2)
Bosonic(T)
c = sp.Symbol("c")
OPE[T, T] = MakeOPE(
[
sp.Rational(1, 2) * c * One,
Zero,
2 * T,
d(T),
]
)
tt = OPE(T, T)
print("max pole =", tt.max_pole)
print("{TT}_4 =", bracket(T, T, 4))
print("{TT}_2 =", bracket(T, T, 2))
print("(TT) =", NO(T, T))
MakeOPE([...]) 采用与 Mathematica 版本一致的顺序:从最高阶极点到 $(z-w)^{-1}$。
例如上面的列表对应:
- $(z-w)^{-4}$ 系数
- $(z-w)^{-3}$ 系数
- $(z-w)^{-2}$ 系数
- $(z-w)^{-1}$ 系数
Core Concepts
1. Basis operators
通常先定义基础生成元,再声明其统计性:
from pyope import BasisOperator, Bosonic
J = BasisOperator("J", conformal_weight=1)
Bosonic(J)
2. Registering OPE data
OPE 的定义方式是:
OPE[A, B] = MakeOPE([...])
计算方式是:
result = OPE(A, B)
返回值是 OPEData,可以通过 .pole(n) 读取第 $n$ 阶极点系数。
3. Normal-ordered products
PyOPE 不允许把局域算符语义误写成普通乘法;对算符直接写 A * B 会抛错。
复合算符应使用:
NO(A, B)normal_product(A, B, C, ...)
例如:
from pyope import BasisOperator, Bosonic, normal_product, simplify
A = BasisOperator("A")
B = BasisOperator("B")
Bosonic(A, B)
expr = normal_product(B, A, B)
print(simplify(expr))
4. Derivatives and brackets
d(A)表示一阶导数dn(n, A)表示 $n$ 阶导数bracket(A, B, n)提取第 $n$ 阶 bracket
from pyope import bracket, d, dn
print(bracket(T, T, 4))
print(bracket(d(T), T, 3))
print(dn(2, T))
5. Jacobi identity checks
from pyope import verify_jacobi_identity
print(verify_jacobi_identity(T, T, T))
Available API
常用公开接口包括:
OPE,MakeOPE,NO,NO_product,normal_product,bracketBasisOperator,Operator,d,dnOne,Zero,Deltasimplifycheck_jacobi_identity,verify_jacobi_identity
另外还公开了一批偏研究型、实验性的结构化工具,例如:
C2Space,C2NullSearcher,GenericC2ReducerDescendantSpaceSingularVectorAnalyzerRealizationBackend及相关 realization 工具
完整导出列表可见 src/pyope/__init__.py。
Examples And References
仓库中已有较多示例和对照材料:
- GitHub 仓库:https://github.com/panyw5/pyope
- Demo 与 notebook:https://github.com/panyw5/pyope/tree/main/demo
- 测试框架说明:https://github.com/panyw5/pyope/blob/main/tests/TEST_FRAMEWORK.md
- Mathematica 参考材料:https://github.com/panyw5/pyope/tree/main/OPEdefs
当前示例覆盖:
- Virasoro
- Kac-Moody
- Jacobi identity
- 若干 W-algebra / null-state 相关实验
Running Tests
运行全部测试:
python -m pytest
只运行 Mathematica 参考类测试:
python -m pytest -m mathematica_ref
跳过慢测试:
python -m pytest -m "not slow"
Packaging Notes
当前 PyPI 发布内容以 src/pyope 核心包为主。
wheel只包含核心库与元数据- 仓库中的 notebook、
.wls、临时脚本不会进入当前 wheel
这意味着通过 pip install pyope-voa 安装时,用户拿到的是核心库,而不是整个研究仓库。
Citation And Background
- K. Thielemans, "An Algorithmic Approach to Operator Product Expansions, W-algebras and W-strings", arXiv:hep-th/9506159
License
MIT
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyope_voa-0.1.0.tar.gz.
File metadata
- Download URL: pyope_voa-0.1.0.tar.gz
- Upload date:
- Size: 100.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
837938f01be9da64e74dc49e664d90d5e74d734c063a172dd555ff7a58efdfb1
|
|
| MD5 |
f51024fce06a0228e2ae42c3e771338e
|
|
| BLAKE2b-256 |
d43102ad959b0352aa9345d72611fda0e82fc2e691c0d5d227a68be7ab1bac16
|
File details
Details for the file pyope_voa-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyope_voa-0.1.0-py3-none-any.whl
- Upload date:
- Size: 77.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
742b3dbe43eeeaa326fcec35a9ec60799160f3ca2130cf193bb0a0ceb4005a7d
|
|
| MD5 |
6bb5f67c0c52b0567d83777cc1eea2ea
|
|
| BLAKE2b-256 |
54942502c82b0781c5f86cfcd48cd3bd3d25e10db4b93e1b6544e5c8ce83f687
|