Skip to main content

Python bindings for MSH-QC quantum mechanics library

Project description

MSHQC - Multi-State High-Quality Calculations

License: MIT C++17 Python 3.10-3.13 PyPI version

MSHQC is a high-performance, open-source quantum chemistry library implementing modern electronic structure methods with seamless Python bindings. Designed for advanced research in physics and materials science, it focuses on both accuracy and extreme computational efficiency. The C++ core is heavily optimized, leveraging hardware-specific vectorization (AVX2/FMA) and Interprocedural Optimization (IPO/LTO) to maximize floating-point throughput.


🌟 Features

1. Self-Consistent Field (SCF)

  • Restricted, Unrestricted, and Restricted Open-shell Hartree-Fock (RHF, UHF, ROHF)
  • DIIS convergence acceleration
  • Cholesky Decomposition Variants (CD-RHF, CD-UHF, CD-ROHF)

2. Perturbation Theory (MPn)

  • Møller-Plesset MP2 & MP3 (Restricted and Unrestricted)
  • Orbital-Optimized MP2/MP3 (OMP2/OMP3)
  • Cholesky Decomposition Variants (CD-RMP2/3, CD-UMP2/3, CD-OMP2/3)

3. Multi-Configurational Methods (MCSCF)

  • Complete Active Space SCF (CASSCF) & State-Averaged CASSCF (SA-CASSCF)
  • Complete Active Space Perturbation Theory 2nd order (CASPT2)
  • Cholesky Decomposition Variants (CD-CASSCF, CD-SA-CASSCF)
  • Cholesky Decomposition Perturbation Theories (CD-CASPT2, CD-SA-CASPT2, CD-SA-CASPT3)

4. Advanced Tooling

  • Integral Transformations: Cholesky decomposition for ERI and Four-Index Transformations
  • Gradients: Analytical and numerical gradients, and geometry optimization
  • Properties: Natural orbitals, transition density matrices, and one-particle density matrices (OPDM)

🚀 The "Ultimate" Computational Engine & Dependencies

Under the hood, MSHQC bridges C++17 and Python using a deeply integrated scientific computing stack. The build system (CMakeLists.txt) strictly requires the following dependencies to handle massive out-of-core calculations and tensor operations:

  • Compiler: GCC 7+ or Clang 5+ (must support C++17, AVX2, FMA, and IPO/LTO)
  • CMake: Version 3.14 or higher
  • Python Binding: nanobind (lightweight, highly efficient C++/Python interface)
  • Multi-threading: OpenMP (native shared-memory parallelization)
  • Integral Engine: libcint (high-performance analytical electron repulsion integrals)
  • Tensor Contraction: TBLIS (fast tensor contraction avoiding explicit multidimensional array transposition)
  • Out-of-Core Data: HDF5 (C and C++ bindings required for massive tensor storage and ABI stability)
  • Linear Algebra (Templates): Eigen3 (modern heavily vectorized matrix operations)
  • BLAS Backend: BLIS (preferred) or OpenBLAS
  • LAPACK Backend: libflame (preferred) or standard LAPACK + LAPACKE (C interface)

📦 Installation

Option A: Install Pre-compiled Wheels via PyPI (Recommended)

MSHQC is continuously tested and deployed via GitHub Actions. Pre-compiled, manylinux-compatible wheels are available for Python 3.10 through 3.13.

pip install mshqc

Option B: Compiling from Source (Super-Turbo Mode)

For maximum performance, compile MSHQC locally to leverage -march=native optimizations for your specific CPU architecture. An isolated Conda environment is highly recommended to manage the complex C++ libraries.

1. Conda Environment Setup

Install the complete dependency stack via conda-forge:

# Create and activate environment
conda create -n mshqc_env python=3.12
conda activate mshqc_env

# Install critical C++ libraries and build tools
conda install -y -c conda-forge \
    cmake make compilers eigen pkg-config \
    "hdf5=1.14.3" pip libcint tblis liblapacke openblas

# Install Python-level build requirements
python -m pip install build wheel nanobind numpy scipy

2. Build and Install

Clone the repository and install it in editable mode. The CMake build system will automatically detect the Conda environment and link against the optimized C++ libraries.

git clone https://github.com/syahrulhidayat/mshqc.git
cd mshqc

# Compile and install the Python bindings
pip install -e .

💻 Quick Start (Anti-Crash Configuration)

⚠️ CRITICAL WARNING: MSHQC and scientific libraries like numpy both utilize multithreaded BLAS backends (e.g., OpenBLAS). To prevent catastrophic CPU thread collisions or segmentation faults, you must configure thread limits at the OS level before importing any libraries.

import os

# 1. Lock thread counts BEFORE importing to prevent OpenBLAS collisions
os.environ["OMP_NUM_THREADS"] = "4"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["TBLIS_ARCH"] = "x86_64"

# 2. Import MSHQC FIRST
import mshqc

# 3. Import other scientific libraries
import numpy as np

# Set up your calculation parameters
print(f"MSHQC Version: {mshqc.__version__}")

🛠️ Development & CI/CD

This project utilizes GitHub Actions for continuous integration. Upon pushing to specified branches or tagging releases, the pipeline automatically:

  1. Compiles the C++ core with Universal HPC optimizations (-O3 -mavx2 -mfma)
  2. Generates Python bindings via nanobind
  3. Repairs Linux binaries using auditwheel to ensure cross-platform ABI compatibility
  4. Deploys the wheels directly to PyPI and the public-facing repository

🐛 Bug Reports & Contributions

If you encounter any issues, compilation errors, or have feature requests, please report them on the Issue Tracker. Code contributions, bug fixes, and documentation improvements are highly appreciated.


📄 License & Author

  • Author: Muhamad Syahrul Hidayat
  • 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

mshqc-1.0.0.dev98-cp313-cp313-manylinux_2_39_x86_64.whl (72.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

mshqc-1.0.0.dev98-cp312-cp312-manylinux_2_39_x86_64.whl (72.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

mshqc-1.0.0.dev98-cp311-cp311-manylinux_2_39_x86_64.whl (72.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

mshqc-1.0.0.dev98-cp310-cp310-manylinux_2_39_x86_64.whl (72.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

File details

Details for the file mshqc-1.0.0.dev98-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mshqc-1.0.0.dev98-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 eb90638cbbee9f7e5d99682cdf9007ed628990768d8bc91f62ce25da88df95cc
MD5 800c9f89e085e869cd6f5f4e8a54215e
BLAKE2b-256 a63933a30df98bec8f618b5d5d7e9e468ee69fea87bedf6407506203cb6c7991

See more details on using hashes here.

File details

Details for the file mshqc-1.0.0.dev98-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mshqc-1.0.0.dev98-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 880902304f21f7d34b42968ee191cdc5ba0f63b06d81c3d1cce184da6e65a24a
MD5 5d06d9b0c6a1b39aee3cf2050ee170b4
BLAKE2b-256 b5bbefcd057112ff8d2ece3b79c71360b6823823651a4e59ceea87043e923b9c

See more details on using hashes here.

File details

Details for the file mshqc-1.0.0.dev98-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mshqc-1.0.0.dev98-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 3c1ad6c7d19f7836b08e4f5d2342684d720eb306ea4389e31f3c5ffabc685519
MD5 6bad6672e155b456fa1161958f2f00d1
BLAKE2b-256 e17af2b982f9d6272c3245017005252a28f928693ce9b8549627fc36ac87a4fd

See more details on using hashes here.

File details

Details for the file mshqc-1.0.0.dev98-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mshqc-1.0.0.dev98-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 28e6f2bd78640869927b0ab57d86d934acf3bbb788e640599823c5c25c5d0546
MD5 cf3dee8bf8937f0d01ee1cca718396b1
BLAKE2b-256 30cc1c9feafd4160d52f7f0a6ba630abe2739cb8c49b53ff6b1abb5432536336

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