Skip to main content

Python bindings and ASE adapters for potlib

Reason this release was yanked:

Wheels for <3.10 are incorrect

Project description

pypotlib Contributor Covenant Builds Wheels

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypotlib-0.0.8.tar.gz (17.2 kB view details)

Uploaded Source

File details

Details for the file pypotlib-0.0.8.tar.gz.

File metadata

  • Download URL: pypotlib-0.0.8.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for pypotlib-0.0.8.tar.gz
Algorithm Hash digest
SHA256 5a3accc51827c05979c31ad0ea02f69cf3fbefb3ff042d2021361c4f162ea360
MD5 2afdce572b212515dcd6148f529cb1cb
BLAKE2b-256 38a5045046a8e4fe0c2bf6162cf44b58e855365e811eb10f4be9a71c4d5a830e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page