Skip to main content

A Python package interfacing with the CO2CO2 shared library.

Project description

Molecule Potential Energy Library

This project provides a high-performance C++ library for calculating the potential energy of a CO₂ molecular system. The C++ routines are exposed to Python via both a ctypes-based wrapper and a (optional) pybind11 module, allowing you to leverage the speed of C++ with the ease-of-use of Python.

Project Structure

molecule-potential/            # Root directory
├── src/                     # C++ source files
│   ├── mbCO2CO2.cpp         # Implements the energy routines and exports functions
│   ├── mbCO2CO2.h           # Declarations for the energy routine functions:
│   │                         //   double p1b(double* xyz);
│   │                         //   double p2b(double* xyz);
│   │                         //   double sapt(double* xyz);
│   └── ... (other files)
├── python/                  # (Optional) pybind11 C++ binding module source
│   └── module.cpp           # Implements a Python module using pybind11
├── wrapper.py               # Python wrapper using ctypes to load the shared library
├── CMakeLists.txt           # CMake configuration to build the shared libraries
├── setup.py                 # Setup script for building and packaging the project for PyPI
├── README.md                # This file
└── LICENSE                  # License file (e.g., MIT License)

Installation

Prerequisites

Build the C++ Shared Library

This project uses CMake to build two targets:

  • potential_energy: The core shared library built from all C++ source files in the src/ directory.
  • molecule_module: A Python module (using pybind11) that links against potential_energy (optional if you prefer the ctypes wrapper).

To build the shared library:

  1. Open a terminal in the project root and create a build directory:

    mkdir build
    cd build
    
  2. Run CMake and build:

    cmake ..
    make
    

    The molecule_module shared library will be placed in build/python as defined in the CMakeLists.txt. The core shared library built from your src/ files will be named (for example) libCO2CO2.so.

Install the Package

The project can be installed as a Python package using pip. The provided setup.py script calls a custom build command to build the C++ shared library before packaging.

From the project root, run:

pip install .

This process will:

  • Build the C++ shared library (via CMake or Makefile as configured).
  • Package the Python wrapper (and optionally the pybind11 module) along with the shared library so that they can be imported in Python.

Usage

You can access the energy routines through the wrapper.py interface (which uses ctypes to load the shared library). For example:

from wrapper import p1b, p2b, sapt

# Example coordinates for 6 atoms (each atom has 3 coordinates);
# adjust these values as required by your application:
xyz = [
    0.0,  0.0,  0.000,   # Atom 1 (C)
    0.0,  0.0, -1.162,   # Atom 2 (O)
    0.0,  0.0,  1.162,   # Atom 3 (O)
    7.0,  0.0,  0.000,   # Atom 4 (C)
    7.0,  0.0, -1.162,   # Atom 5 (O)
    7.0,  0.0,  1.162    # Atom 6 (O)
]

energy_p1 = p1b(xyz)
energy_p2 = p2b(xyz)
energy_sapt = sapt(xyz)

print("Energy from p1b:", energy_p1)
print("Energy from p2b:", energy_p2)
print("Energy from sapt:", energy_sapt)

Note: If you built the pybind11 module (from python/module.cpp), you can alternatively import the module (e.g., import co2_potential) and call its functions (provided they are bound similarly to the ctypes wrappers).

Functionality

The library calculates the potential energy of a CO₂ system using multiple routines:

  • p1b: Computes a portion of the potential energy (using routines from x1b).
  • p2b: Computes another portion of the potential energy (using routines from x2b).
  • sapt: Calculates energy contributions based on SAPT (Symmetry-Adapted Perturbation Theory) components.

The core computations are implemented in C++ for performance.

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

co2co2-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

CO2CO2-0.1.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file co2co2-0.1.1.tar.gz.

File metadata

  • Download URL: co2co2-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.13

File hashes

Hashes for co2co2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bf8dcb904b6eec26c31028267fdbaf3e81a650f4c0cddccaa09b3b83ede93178
MD5 22ce9cb0b8e92efe9b5f95b74622050a
BLAKE2b-256 5c85d83bc3a89736e155bf82b6adeb5c66265773dba4087a137e6bac8a54cf37

See more details on using hashes here.

File details

Details for the file CO2CO2-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: CO2CO2-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.13

File hashes

Hashes for CO2CO2-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 470f9516582cc630e347d10d605fa205e638deb362f7c6daf8fe1f2cafdea8d9
MD5 0501b536b4ea2767a7f9a4a3587b1d29
BLAKE2b-256 3ee9f9747853324c26a5a0e63242df0676c24255e23475429511d29a6ee1a733

See more details on using hashes here.

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