安装与快速上手¶
环境要求¶
LatticeGeom 支持 Python 3.10 及以上版本。核心运行时只依赖 NumPy。
python -m pip install latticegeom
可选依赖彼此独立:latticegeom[plot] 安装 Matplotlib,latticegeom[bz] 安装
用于二维第一 Brillouin 区几何的 SciPy。
开发安装与检查:
python -m pip install -e ".[test,plot,bz,docs]"
python -m pytest -q
构造晶格¶
from latticegeom import triangular
lat = triangular((6, 4), pbc=(True, False))
print(lat)
print(lat.positions.shape)
print(lat.bonds.pairs.shape)
extent 为每个原始平移方向给出一个正整数。pbc 可以是应用于所有方向的单个
布尔值,也可以是同长度的布尔序列,从而表达混合边界条件。
检查编译后的数组¶
print(lat.n_cells, lat.n_sites, lat.n_bonds, lat.n_plaquettes)
nearest = lat.bonds.indices(type="a1")
crossing = lat.bonds.indices(crossing=True)
vectors = lat.bond_vectors()
编译后的数组全部只读。应把 Lattice 当作稳定的几何值,并在独立数组中保存可变的
模型参数和计算结果。