Skip to main content

ASE-lite

一个轻量的原子模拟环境库:只依赖 NumPy,约 2400 行,面向「读结构、算几何、跑脚本」这类日常任务。

不是 ASE 的功能替代品,而是在这些场景下更快、更省心的一个选择。

实测优势

场景 结果
CIF 解析 比 ASE 快 30–100 倍
全距离矩阵 比 ASE 快 2.3 倍
质心 / repeat 与 ASE 同量级
导入时间 约 32 ms,与 ASE 基本持平

数字由 benchmarks/compare_ase.py 实测,详见 PERFORMANCE.md。

CIF 容错能力

真实世界的 CIF 经常不规范。本库的解析器按 CIF 1.1 词法规范实现,并刻意容忍下列缺陷(均有测试覆盖,见 tests/test_cif.py):

  • 标准不确定度写法 0.36838(15)、分数 1/3、1.23(4)e-2
  • 单/双引号字符串、; 起始的多行文本块(含带缩进的闭合 ;)、行内与整行注释
  • CRLF 换行、UTF-8 BOM、latin-1 等非 UTF-8 编码
  • 制表符与混合空白、缺失或多余的列、被折成两行的原子记录
  • 缺失 data_ 头、多个 data block(跳过无效块继续找)、标签大小写混用
  • 列顺序任意、缺少 _atom_site_type_symbol(从 label 推断)、? 与 . 占位符
  • 笛卡尔坐标(_atom_site_Cartn_*)、氘/氚(D/T → H)
  • 显式对称操作(x,y,z / -x,y+1/2,-z / 1/3+x,2/3+y,z)展开与周期性去重

不推断文件未写出的对称操作。只给空间群名称、不给操作列表的文件,本库不会自动补全。

快速开始

pip install numpy
from aselite import Atoms

atoms = Atoms.read('structure.cif')
print(atoms, atoms.cell)

atoms = atoms.repeat((2, 2, 2))
distances = atoms.get_all_distances(mic=True)
atoms.write('output.vasp')

核心 API

from aselite import Atoms, Cell

atoms = Atoms(
    symbols=['C', 'O', 'O'],
    positions=[[0, 0, 0], [1.16, 0, 0], [-1.16, 0, 0]],
    cell=[10, 10, 10],
    pbc=True,
)

atoms.symbols          # 元素符号
atoms.positions        # 笛卡尔坐标
atoms.numbers          # 原子序数
atoms.masses           # 质量(惰性计算)
atoms.cell.lengths()   # (a, b, c)
atoms.cell.angles()    # (α, β, γ)
atoms.cell.volume()    # 体积

atoms.get_distance(0, 1, mic=True)
atoms.get_distances(0, [1, 2], mic=True)
atoms.get_all_distances(mic=True)
atoms.get_chemical_formula()
atoms.get_center_of_mass()

atoms.translate([1, 1, 1])
atoms.rotate(1.57, 'z')
atoms.center(vacuum=5.0)
atoms.repeat((2, 2, 2))
atoms[1:3]             # 切片
atoms + other          # 合并

读写格式:CIF、VASP(POSCAR/CONTCAR)、XYZ、PDB。

测试

python tests/test_core.py    # 核心功能
python tests/test_cif.py     # CIF 容错(25 个畸形输入用例)

项目结构

aselite/
├── atoms.py        Atoms 类
├── cell.py         晶胞与最小镜像约定
├── cif.py          CIF 词法/语法分析与对称展开
├── io.py           文件格式读写
├── geometry.py     旋转等几何工具
├── data.py         元素数据
└── calculators/    计算器接口
tests/              测试
examples/           使用示例
benchmarks/         与 ASE 的对比基准

边界

不打算实现:完整的计算器生态、结构优化与约束、空间群自动识别、可视化。需要这些请用 ASE。

许可证

MIT

Metadata

Release files for aselite 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aselite 0.1.0
File Size Uploaded Provenance Actions
aselite-0.1.0.tar.gz 27.3 kB Without provenance Details for aselite-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aselite 0.1.0
File Interpreter ABI Platform Actions
aselite-0.1.0-py3-none-any.whl Python 3 none any Details for aselite-0.1.0-py3-none-any.whl

Total release size: 51.5 kB

Release files / aselite-0.1.0.tar.gz

Download URL aselite-0.1.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c92a4aa2619f0667a34b2aa8538477dc783b02ff392eeaa3db9f605668f399e2
BLAKE2b-256 checksum
How to use checksums
b472b3cb1810a14406a37c132df01bcb41bac14f9afb746094bd48ea891d1433
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Release files / aselite-0.1.0-py3-none-any.whl

Download URL aselite-0.1.0-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0aa216d721f3546ba8714f2bbadc8e1147975819cb1202cfd9c231be86858411
BLAKE2b-256 checksum
How to use checksums
6200abeedf2f953f36a7581c6cf18bc50e8794caa1483e6030354af018b5d3e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.13

Security for aselite 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page