跳转到主要内容

potlib的Python绑定和ASE适配器

项目描述

pypotlib Contributor Covenant Builds Wheels

Python绑定和ASE适配器用于potlib

详情

该库由在cpot下的potlib的薄包装和一个在ase_adapters下的PyPotLibCalc类组成,这是一个在ase下的计算器。

安装

这是在PyPI上,有轮子,所以用法很简单

pip install pypotlib

建议用户不要尝试从源代码构建,因为底层的potlib代码包括fortrancpp依赖项,这些依赖项可能稍微有些棘手。

本地开发

最简单的方法是使用环境文件,兼容于condamambamicromamba等。

mamba env create -f environment.yml
mamba activate rgpotpy
pdm install

生产

因此,由于编译的扩展等,使用cibuildwheel生成macoslinux轮子。在本地(在linux上)可以通过以下方式模拟

cibuildwheel --output-dir wheelhouse --platform linux

使用示例

最简单的用法是

import pypotlib as ppl
import numpy as np
ljpot = ppl.cpot.LJPot()
pos = np.array([1, 2, 3, 1.2, 2.3, 3.6]).reshape(-1, 3)
atm_types = [0, 0]
cell_dim = np.eye(3)*50
print(ljpot(pos, atm_types, cell_dim))

要使用ASE计算器,我们需要一个实例化的类。

from ase import Atoms
from pypotlib import cpot
from pypotlib.ase_adapters import PyPotLibCalc
atoms = Atoms(symbols=['Cu', 'H'], positions=[[0, 0, 0], [0.5, 0.5, 0.5]])
calc = PyPotLibCalc(cpot.CuH2Pot())
atoms.set_calculator(calc)
print(atoms.get_potential_energy())
print(atoms.get_forces())

要使用此进行NEB,请考虑以下玩具示例

from ase import Atoms
from ase.neb import NEB
from ase.optimize import BFGS

from pypotlib import cpot
from pypotlib.ase_adapters import PyPotLibCalc

atoms_initial = Atoms(symbols=['H', 'H'], positions=[(0, 0, 0), (0, 0, 1)])
atoms_final = Atoms(symbols=['H', 'H'], positions=[(0, 0, 2), (0, 0, 3)])

images = [atoms_initial]
images += [atoms_initial.copy() for idx in range(3)]
images += [atoms_final]

for image in images:
    image.calc = PyPotLibCalc(cpot.LJPot())

neb = NEB(images)
neb.interpolate(method = 'idpp')
optimizer = BFGS(neb)
optimizer.run(fmax=0.04)

贡献

所有贡献都欢迎,这包括代码和文档贡献,但也包括问题或其他澄清。请注意,我们期望所有贡献者遵循我们的行为准则

许可证

MIT.

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

pypotlib-0.0.13.tar.gz (18.7 kB 查看哈希值)

上传时间 源代码

构建的分发版

pypotlib-0.0.13-cp311-cp311-musllinux_1_1_x86_64.whl (3.3 MB 查看哈希值)

上传时间 CPython 3.11 musllinux: musl 1.1+ x86-64

pypotlib-0.0.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ x86-64

pypotlib-0.0.13-cp311-cp311-macosx_10_9_x86_64.whl (3.4 MB 查看哈希值)

上传时间 CPython 3.11 macOS 10.9+ x86-64

pypotlib-0.0.13-cp310-cp310-musllinux_1_1_x86_64.whl (3.3 MB 查看哈希值)

上传时间 CPython 3.10 musllinux: musl 1.1+ x86-64

pypotlib-0.0.13-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.17+ x86-64

pypotlib-0.0.13-cp310-cp310-macosx_10_9_x86_64.whl (3.4 MB 查看哈希值)

上传时间 CPython 3.10 macOS 10.9+ x86-64

pypotlib-0.0.13-cp39-cp39-musllinux_1_1_x86_64.whl (3.3 MB 查看哈希值)

上传时间 CPython 3.9 musllinux: musl 1.1+ x86-64

pypotlib-0.0.13-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB 查看哈希值)

上传于 CPython 3.9 manylinux: glibc 2.17+ x86-64

pypotlib-0.0.13-cp39-cp39-macosx_10_9_x86_64.whl (3.4 MB 查看哈希值)

上传于 CPython 3.9 macOS 10.9+ x86-64

pypotlib-0.0.13-cp38-cp38-musllinux_1_1_x86_64.whl (3.3 MB 查看哈希值)

上传于 CPython 3.8 musllinux: musl 1.1+ x86-64

pypotlib-0.0.13-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB 查看哈希值)

上传于 CPython 3.8 manylinux: glibc 2.17+ x86-64

pypotlib-0.0.13-cp38-cp38-macosx_10_9_x86_64.whl (3.4 MB 查看哈希值)

上传于 CPython 3.8 macOS 10.9+ x86-64

支持