Skip to main content

Python bindings and ASE adapters for potlib

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.

Builds

Local usage

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.5.tar.gz (11.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: pypotlib-0.0.5.tar.gz
  • Upload date:
  • Size: 11.5 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.5.tar.gz
Algorithm Hash digest
SHA256 97bbffe5fa516039f9e9c4480a2d1dcf2f8e2bcc523c8badfb1cfbadf0109cfc
MD5 598e84eb0c3b0d51071cad0201e30094
BLAKE2b-256 59bd0da0ec3c13a2a610378abcc7d1b116315611d4bd85af806a24c4c198434b

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