Skip to main content

A Python package interfacing with the CO2CO2 shared library.

Project description

CO₂–CO₂ Potential Energy Library

High-performance C++ routines for computing CO₂ dimer potentials (1-body, 2-body, SAPT-S), exposed to Python via a ctypes wrapper.

Repository Layout

CO2CO2_AUTODIFF/                 # Project root
├── src/                         # All C++ source + Makefile
│   ├── mbCO2CO2.cpp             # C-API exports (energies, grads, Hessians)
│   ├── mbCO2CO2.h               # Function declarations
│   ├── x1b.cpp/.h               # 1-body poly routines
│   ├── x2b.cpp/.h               # 2-body poly routines
│   ├── sapt-s.cpp               # SAPT-S routines
│   ├── poly-*.cpp/.h            # polynomial basis eval
│   ├── autodiff/                # bundled autodiff headers
│   ├── Eigen/                   # bundled Eigen headers
│   └── Makefile                 # builds libCO2CO2.so
├── co2_potential/               # Python package
│   ├── __init__.py
│   ├── libCO2CO2.so             # copied in by Makefile
│   ├── wrapper.py               # ctypes wrapper + convenience functions
│   └── benchmark.py             # benchmarking script
├── .github/
│   └── workflows/
│       └── wheels.yml           # CI: build wheels + upload to PyPI
├── setup.py                     # pip install / build-ext hook
├── pyproject.toml               # PEP 517 build config
├── MANIFEST.in                  # include shared lib & .py files
├── README.md
└── LICENSE

Installation

Linux (x86_64) and macOS (Apple Silicon)

pip install co2_potential

macOS (Intel x86_64)

Pre-built wheels are not available for Intel Macs. Install from source:

pip install co2_potential --no-binary co2_potential

This requires a C++ compiler (clang/g++) and may take some time to compile.

Building from Source

git clone https://github.com/sodelab/CO2CO2_AUTODIFF.git
cd CO2CO2_AUTODIFF
cd src && make clean && make && cd ..
pip install -e .

On macOS, to build a universal binary (x86_64 + arm64):

cd src && make clean && make UNIVERSAL=1 && cd ..

Usage

import numpy as np
from co2_potential.wrapper import p1b, p2b_4, p2b_5, sapt

# Example: 6-atom dimer → 18 coordinates
xyz = np.array([
    0.0,   0.0,  0.000,    # monomer A: C, O, O
    0.0,   0.0, -1.162,
    0.0,   0.0,  1.162,
    3.75,  0.0,  0.000,    # monomer B: C, O, O
    3.75,  0.0, -1.162,
    3.75,  0.0,  1.162
], dtype=np.double)

E1 = p1b(xyz)        # 1-body energy
E2_4 = p2b_4(xyz)    # 2-body 4th-order
E2_5 = p2b_5(xyz)    # 2-body 5th-order
Es = sapt(xyz)       # SAPT-S energy

print(f"E1 = {E1:.6f}, E2(5) = {E2_5:.6f}, SAPT = {Es:.6f}")

Functionality

The library provides the following Python functions via co2_potential.wrapper:

Dimension and Version Getters

  • get_p1b_dim(): Returns the number of coordinates for monomer (should be 9).
  • get_p2b_dim(): Returns the number of coordinates for dimer (should be 18).
  • get_p2b_4_dim(): Returns the number of coordinates for 2-body 4th-order.
  • get_p2b_5_dim(): Returns the number of coordinates for 2-body 5th-order.
  • get_sapt_dim(): Returns the number of coordinates for SAPT-S.
  • get_version(): Returns the version string of the underlying C++ library.

1B (Monomer) Functions

  • p1b(xyz): Monomer energy. xyz is a numpy array of shape (9,).
  • p1b_gradient(xyz): Monomer gradient. Returns numpy array of shape (9,).
  • p1b_hessian_rev(xyz): Monomer Hessian (reverse-mode autodiff). Returns numpy array of shape (9, 9).
  • p1b_hessian_fwd(xyz): Monomer Hessian (forward-mode autodiff). Returns numpy array of shape (9, 9).

2B (Dimer) Functions – 4th Order

  • p2b_4(xyz): Dimer 2-body 4th-order energy. xyz is a numpy array of shape (18,).
  • p2b_gradient_4(xyz): Dimer 2-body 4th-order gradient. Returns numpy array of shape (18,).
  • p2b_hessian_4_rev(xyz): Dimer 2-body 4th-order Hessian (reverse-mode). Returns numpy array of shape (18, 18).
  • p2b_hessian_4_fwd(xyz): Dimer 2-body 4th-order Hessian (forward-mode). Returns numpy array of shape (18, 18).

2B (Dimer) Functions – 5th Order

  • p2b_5(xyz): Dimer 2-body 5th-order energy. xyz is a numpy array of shape (18,).
  • p2b_gradient_5(xyz): Dimer 2-body 5th-order gradient. Returns numpy array of shape (18,).
  • p2b_hessian_5_rev(xyz): Dimer 2-body 5th-order Hessian (reverse-mode). Returns numpy array of shape (18, 18).
  • p2b_hessian_5_fwd(xyz): Dimer 2-body 5th-order Hessian (forward-mode). Returns numpy array of shape (18, 18).

SAPT-S Dimer Functions

  • sapt(xyz): SAPT-S dimer energy. xyz is a numpy array of shape (18,).
  • sapt_gradient(xyz): SAPT-S dimer gradient. Returns numpy array of shape (18,).
  • sapt_hessian_rev(xyz): SAPT-S dimer Hessian (reverse-mode). Returns numpy array of shape (18, 18).
  • sapt_hessian_fwd(xyz): SAPT-S dimer Hessian (forward-mode). Returns numpy array of shape (18, 18).

The core computations are implemented in C++ for performance and exposed to Python via a ctypes wrapper.

Benchmarking

This package includes a benchmarking script which tests the accuracy and performance of the CO₂ potential functions against reference values:

python -m co2_potential.benchmark --all         # Test all (default)
python -m co2_potential.benchmark --energies    # Test only energies
python -m co2_potential.benchmark --gradients   # Test only gradients
python -m co2_potential.benchmark --hessians    # Test only hessians
python -m co2_potential.benchmark --p1b         # Test only p1b functions
python -m co2_potential.benchmark --p2b_4       # Test only p2b_4 functions
python -m co2_potential.benchmark --p2b_5       # Test only p2b_5 functions
python -m co2_potential.benchmark --sapt        # Test only sapt functions

The benchmark compares computed results to hard-coded reference values (with units: energies in kcal/mol, gradients in kcal/mol/angstrom, and Hessians in kcal/mol/angstrom²) and reports pass/fail status for each test.

Supported Platforms

Platform Architecture Wheel Available
Linux x86_64 Yes
macOS arm64 (Apple Silicon) Yes
macOS x86_64 (Intel) Build from source

Contributing

Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

co2_potential-0.6.7.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

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

co2_potential-0.6.7-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

co2_potential-0.6.7-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

co2_potential-0.6.7-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

co2_potential-0.6.7-cp311-cp311-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

co2_potential-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

co2_potential-0.6.7-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

co2_potential-0.6.7-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

co2_potential-0.6.7-cp39-cp39-macosx_10_9_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file co2_potential-0.6.7.tar.gz.

File metadata

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

File hashes

Hashes for co2_potential-0.6.7.tar.gz
Algorithm Hash digest
SHA256 f47277e4a53bab400f4b96d9a02bcfea25a9513e0f2221beb5bbb2e79bcc899e
MD5 c85b45730bfcc6b043c3afca5421bda2
BLAKE2b-256 4bbab038a900f78a7185e27d08c4856a21978286faef5af9589fa01d4a5e6211

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7.tar.gz:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e14f6905f0289b6d2ef1d909ef92ce1f2e9f749d5334a6b60b6a469d4a30f11c
MD5 6332ee69b2a8b65260086cbb26bfe6e2
BLAKE2b-256 0221047bc88147b13d64fbc03e09dbcd5b8558f1ac5f13beea1ffff3eeb2c102

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ade5dcc69c367c4bbc435985df251d29ee5b93b720118122e5a65fa6b6092f8
MD5 1418ebbf89dc14ca38297af9e5172d13
BLAKE2b-256 90e0c584f1dc6b5c68fb0bd4ff9de8bfdb274a24d6fe54e4b6c8471dc2f2f482

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5546fbeb9e6e121366f5ea1b46d3fd8d91683584b73eba5b33e6c7edbb4991b9
MD5 c0d14e50601f0ab0addc6f7ad8068f96
BLAKE2b-256 5870736b1663575bf0ace94c5028323fcd6a8749282eecf3fdcba962c3e927c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5328ad3ce9b196cb746232192654dc1e748054bf6e2c47c4ce7a1f39aea00bdd
MD5 cd2ea05f9ae525fae18ce98843326b5e
BLAKE2b-256 190e770f0da9911e3b31c071fafdd1f63090e0a6910561398191051cfc8d1f51

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a39ce872828043d90d1df69fcf71b421338fbad36a95172426089495e532d5d2
MD5 cca029362bce22a41efd8f7ba1c3f640
BLAKE2b-256 db23eec677652053c037406c96444f1c3b95095b72590c7aba3ec2604ec5071b

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5c583ae44a2150ea6c2ec8c41ea3654bd3c90a6c1f7e92dbd8d8e2a45a0ca48
MD5 32cc71766d242f5d40bdebaccee1deef
BLAKE2b-256 816d94ff358e1e886ee5623ad202c500f37659ff26a1bc660bf57f5ed42b9b7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21bdd6a34c2b67e120cfd63c9b47bafd5d993e5fa459630721a04ba40f47bd1e
MD5 bc525324d86a6e38783850c828f3d8e1
BLAKE2b-256 3311a01ecd4948147582d67f1002f5aaa0c22dad384903737e46b757e9015f5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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

File details

Details for the file co2_potential-0.6.7-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for co2_potential-0.6.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e8db9d14879b82129e09ef3384b82cfe70ea0eb4937814c9fdc7d0ee5ffd793a
MD5 179ddcdb3eeb634df7eeff7bd40c8cb4
BLAKE2b-256 7468472839cdb1629a9a9059e44610cad9dd4628177941c0f171d244e25d55be

See more details on using hashes here.

Provenance

The following attestation bundles were made for co2_potential-0.6.7-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on sodelab/CO2CO2_AUTODIFF

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