Skip to main content

CI DOI


chmpy logo

chmpy

A library for computational chemistry in python.
Documentation»
Report a bug · Request a new feature

chmpy supports handling molecules, crystals, Hirshfeld & promolecule density isosurfaces, spherical harmonic shape descriptors and much more...

Installation

Basic installation can be done through the python package manager pip:

pip install chmpy
# or to install directly from GitHub:
pip install git+https://github.com/peterspackman/chmpy.git

Plotting and mesh handling are optional extras, so the default install stays small:

pip install 'chmpy[plots]'   # matplotlib, for the plotting helpers
pip install 'chmpy[mesh]'    # trimesh, for isosurfaces and meshes
pip install 'chmpy[all]'     # everything

For development or modifications, install locally using pip:

pip install -e .

Features

While the library is intended to be flexible and make it easy to build complex pipelines or properties, the following is a brief summary of intended features:

  • Load crystal structures from .cif, .res, POSCAR files.
  • Evaluate promolecule and procrystal electron densities.
  • Easily generate Hirshfeld or promolecule isosurfaces and associated properties.
  • Easily generate spherical harmonic shape descriptors for atoms, molecules, or molecular fragments.
  • Efficiently calculate crystal slabs, periodic connectivity and more...
  • Automatic parallelization of some calculations using OpenMP (set the OMP_NUM_THREADS environment variable)
  • View structures directly in a terminal, with no graphical display, via chmpy-view or chmpy.tui.render

It should also serve as a simple, easy to read library for learning how to represent crystal structures, molecules etc. and evaluate scientifically relevant information quickly and efficiently using python.

Examples

Crystal structures and molecules

Loading a crystal structure from a CIF (.cif) or SHELX (.res) file, or a molecule from an XMOL (.xyz) file is straightforward:

from chmpy import Crystal, Molecule
c = Crystal.load("tests/acetic_acid.cif")
print(c)
# <Crystal C2H4O2 Pna2_1>
# Calculate the unique molecules in this crystal
c.symmetry_unique_molecules()
# [<Molecule: C2H4O2(2.12,1.15,0.97)>]
m = Molecule.load("tests/water.xyz")
print(m)
# <Molecule: H2O(-0.67,-0.00,0.01)>

Hirshfeld and promolecule density isosurfaces

Hirshfeld and promolecule density isosurfaces

Generation of surfaces with the default settings can be done with minimal hassle, simply by using the corresponding members of the Crystal class:

c = Crystal.load("tests/test_files/acetic_acid.cif")
# This will generate a high resolution surface
# for each symmetry unique molecule in the crystal
surfaces = c.hirshfeld_surfaces()
print(surfaces)
# [<trimesh.Trimesh(vertices.shape=(3598, 3), faces.shape=(7192, 3))>]
# We can generate lower resolution surfaces with the separation parameter
surfaces = c.hirshfeld_surfaces(separation=0.5)
print(surfaces)
# [<trimesh.Trimesh(vertices.shape=(584, 3), faces.shape=(1164, 3))>]
# Surfaces can be saved via trimesh, or a utility function provided in chmpy
from chmpy.util.mesh import save_mesh
save_mesh(surfaces[0], "acetic_acid.ply")

The resulting surface should look something like this when visualized:


Acetic acid

Metadata

Release files for chmpy 1.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chmpy 1.9.1
File Size Uploaded Provenance Actions
chmpy-1.9.1.tar.gz 4.1 MB With provenance Details for chmpy-1.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chmpy 1.9.1
File Interpreter ABI Platform Actions
chmpy-1.9.1-py3-none-any.whl Python 3 none any Details for chmpy-1.9.1-py3-none-any.whl

Total release size: 8.4 MB

Release files / chmpy-1.9.1.tar.gz

Download URL chmpy-1.9.1.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
0e0ed6bed810b591aeefee5f4d081ce91685bae36d1f4ff6e6e250576a403f87
BLAKE2b-256 checksum
How to use checksums
791a3e922faf9faf863a04e908a5baa90abff53ae124c190ba440654a4aef449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / chmpy-1.9.1-py3-none-any.whl

Download URL chmpy-1.9.1-py3-none-any.whl
Size 4.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
cbe6ebeaa65348aac041053086928b9e29d0c05c946a610d652fe357b8b5c089
BLAKE2b-256 checksum
How to use checksums
3c5d84ebf6940988eb7e1755491dc3d5e6784239e1480e8adc32e13e34b5c198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for chmpy 1.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for chmpy-1.9.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page