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
- A C++ compiler and CMake (version 3.10 or above)
- Python 3.6+ with pip
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:
-
Open a terminal in the project root and create a build directory:
mkdir build cd build
-
Run CMake and build:
cmake .. makeThe
molecule_moduleshared library will be placed inbuild/pythonas defined in theCMakeLists.txt. The core shared library built from yoursrc/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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file co2_potential-0.1.0.tar.gz.
File metadata
- Download URL: co2_potential-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b6d2f15f59f23ca875cb7040606ced4361a6dde5a0aeb425efe04e962c3e89b
|
|
| MD5 |
906850f4e93e643cbf1ad2901270381f
|
|
| BLAKE2b-256 |
9cea977a029664025df2f71ce70f7fd74ab5a1a622cdf92f2a537ec370fd9da8
|
File details
Details for the file co2_potential-0.1.0-py3-none-any.whl.
File metadata
- Download URL: co2_potential-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c637c7ec8fba85432e515429eb59a82a0893a3c73ab889a033436ba086579d41
|
|
| MD5 |
21de809f277d14816e8d5b6264c97d2e
|
|
| BLAKE2b-256 |
ed3e3340e71e99ae8218e55ef4294e87ae9c62c7de3bf625726446581262e78a
|