Python bindings and ASE adapters for potlib
Reason this release was yanked:
Wheels <3.10 are still wrong.
Project description
pypotlib
Python bindings and ASE adapters for potlib
.
Details
The library consists of thin wrappers to potlib
under cpot
and a
PyPotLibCalc
class which is an ase
calculator under ase_adapters
.
Installation
This is on PyPI, with wheels, so usage is simply:
pip install pypotlib
Users are advised to not try to build from source, since the underlying potlib
code includes fortran
and cpp
dependencies which can be slightly tricky to
work with.
Local Development
The easiest way is to use the environment file, compatible with conda
,
mamba
, micromamba
etc.
mamba env create -f environment.yml
mamba activate rgpotpy
pdm install
Production
As such, due to the compiled extensions and what not, cibuildwheel
is used to
generate macos
and linux
wheels. Locally this may be emulated (on linux
)
by:
cibuildwheel --output-dir wheelhouse --platform linux
Usage examples
The simplest usage is just:
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))
For using the ASE calculator we need an instantiated class.
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())
To run an NEB with this, consider the following toy example:
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)
Contributions
All contributions are welcome, this includes code and documentation contributions but also questions or other clarifications. Note that we expect all contributors to follow our Code of Conduct.
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
File details
Details for the file pypotlib-0.0.9.tar.gz
.
File metadata
- Download URL: pypotlib-0.0.9.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e5449a369050bd136d11e05e20613ed3b373362e141cd8cd2f8a9ddb7dba91d |
|
MD5 | 0a29ccccc4dcd9bc924c8aaceaea3c81 |
|
BLAKE2b-256 | 4d1ad689306b0dc6e6c6ff9cefabc009624c79d9fe0a5515af78a1a2e3d60260 |