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

co2_potential-0.1.2.tar.gz (88.4 kB view details)

Uploaded Source

Built Distribution

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

co2_potential-0.1.2-py3-none-any.whl (86.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for co2_potential-0.1.2.tar.gz
Algorithm Hash digest
SHA256 01ae01a5909b4379ca670866cdc1b74668b39f121927230c259e18d3bcf4ab92
MD5 6dbe760ad1400c4e6bd5a7aa6eaa9c81
BLAKE2b-256 96fd039b281d3741333065bcc3a51cd1364b6fe5b6ea50c2c039ac6be33b9ec3

See more details on using hashes here.

File details

Details for the file co2_potential-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for co2_potential-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0dbfc3b0b39a17f2f9874d192f26ea6c21cefb3c43270288800060e7a14c4c6
MD5 935b8a11c8960e9892e984f25d935608
BLAKE2b-256 00c3aaf475cb28cdb5fd9de4b6d2b563ec05dc31b31b47fa9b55f5c386d748b5

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