Skip to main content

Molecules, crystals, promolecule and Hirshfeld surfaces using python.

Project description

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

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)

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

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

chmpy-1.2.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chmpy-1.2.0-py3-none-any.whl (3.7 MB view details)

Uploaded Python 3

File details

Details for the file chmpy-1.2.0.tar.gz.

File metadata

  • Download URL: chmpy-1.2.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chmpy-1.2.0.tar.gz
Algorithm Hash digest
SHA256 224d26aec42ec0c961d157bf3e068cf7e07a52733040ac027f8737b4f6cfea59
MD5 3d3d01abf5cde80390df88e4d58284e4
BLAKE2b-256 1570032fe180e1f5e59745068e0a141f8ea18b69f8e22270121dcf31aba27535

See more details on using hashes here.

Provenance

The following attestation bundles were made for chmpy-1.2.0.tar.gz:

Publisher: pythonpackage.yml on peterspackman/chmpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chmpy-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: chmpy-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chmpy-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 224d7a5cc06047588242e54cdeb6dc084ab44aca91e7b0c4083f714df8c10fb1
MD5 b50e23e1258c14b15ecc3739823d416b
BLAKE2b-256 b8e81cf7d77c3ec8e340443bb9597b8743261dbfca3f901e51d5842afd3ae5be

See more details on using hashes here.

Provenance

The following attestation bundles were made for chmpy-1.2.0-py3-none-any.whl:

Publisher: pythonpackage.yml on peterspackman/chmpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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