Metadata-Version: 2.4
Name: pyope-voa
Version: 0.1.0
Summary: Python library for Operator Product Expansion calculations in Vertex Operator Algebras
Author: PyOPE Contributors
License-Expression: MIT
Project-URL: Homepage, https://github.com/panyw5/pyope
Project-URL: Repository, https://github.com/panyw5/pyope
Project-URL: Documentation, https://github.com/panyw5/pyope/tree/main/docs
Project-URL: Issues, https://github.com/panyw5/pyope/issues
Keywords: vertex operator algebra,VOA,OPE,conformal field theory,mathematical physics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: sympy>=1.12
Requires-Dist: numpy>=1.20.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: jupyter
Requires-Dist: ipython>=8.0.0; extra == "jupyter"
Requires-Dist: jupyter>=1.0.0; extra == "jupyter"
Requires-Dist: notebook>=6.5.0; extra == "jupyter"
Dynamic: license-file

# 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 后可直接安装：

```bash
pip install pyope-voa
```

安装后导入名仍然是：

```python
import pyope
```

从源码安装：

```bash
pip install -e .
```

安装开发依赖：

```bash
pip install -e ".[dev]"
```

安装 Notebook 相关依赖：

```bash
pip install -e ".[jupyter]"
```

## Quick Start

下面给出一个最小的 Virasoro 例子，定义 $T(z)T(w)$ 的 OPE：

```python
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

通常先定义基础生成元，再声明其统计性：

```python
from pyope import BasisOperator, Bosonic

J = BasisOperator("J", conformal_weight=1)
Bosonic(J)
```

### 2. Registering OPE data

OPE 的定义方式是：

```python
OPE[A, B] = MakeOPE([...])
```

计算方式是：

```python
result = OPE(A, B)
```

返回值是 `OPEData`，可以通过 `.pole(n)` 读取第 $n$ 阶极点系数。

### 3. Normal-ordered products

PyOPE 不允许把局域算符语义误写成普通乘法；对算符直接写 `A * B` 会抛错。

复合算符应使用：

- `NO(A, B)`
- `normal_product(A, B, C, ...)`

例如：

```python
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

```python
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

```python
from pyope import verify_jacobi_identity

print(verify_jacobi_identity(T, T, T))
```

## Available API

常用公开接口包括：

- `OPE`, `MakeOPE`, `NO`, `NO_product`, `normal_product`, `bracket`
- `BasisOperator`, `Operator`, `d`, `dn`
- `One`, `Zero`, `Delta`
- `simplify`
- `check_jacobi_identity`, `verify_jacobi_identity`

另外还公开了一批偏研究型、实验性的结构化工具，例如：

- `C2Space`, `C2NullSearcher`, `GenericC2Reducer`
- `DescendantSpace`
- `SingularVectorAnalyzer`
- `RealizationBackend` 及相关 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

运行全部测试：

```bash
python -m pytest
```

只运行 Mathematica 参考类测试：

```bash
python -m pytest -m mathematica_ref
```

跳过慢测试：

```bash
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
