Skip to main content

High-performance sparse matrix RK4 solver for quantum excitation dynamics

Project description

Excitation RK4 Sparse

量子力学的な励起ダイナミクスを計算するための疎行列ベースのRK4ソルバー。

機能

  • CSR形式の疎行列サポート
  • OpenMPによる並列化(動的スケジューリング最適化)
  • Python/C++のハイブリッド実装
  • 包括的なベンチマーク機能
    • 2準位系と調和振動子のテストケース
    • 詳細なパフォーマンス分析
    • 解析解との比較
  • メモリ最適化
    • キャッシュライン境界を考慮したアライメント
    • 疎行列パターンの再利用

バージョン情報

  • 現在のバージョン: v0.2.5
  • ステータス: 安定版
  • 最終更新: 2024-07-15
  • 新機能: プロジェクト構造の大幅改善、性能問題の解決

必要条件

  • Python 3.10以上
  • C++17対応コンパイラ
  • CMake 3.16以上
  • pybind11
  • Eigen3
  • OpenMP(推奨)

インストール

pip install(推奨)

pip install rk4-sparse-cpp

この場合、rk4_sparseモジュールがsite-packagesにインストールされます。

開発用インストール

git clone https://github.com/1160-hrk/excitation-rk4-sparse.git
cd excitation-rk4-sparse

# C++ライブラリのビルド
./tools/build.sh --clean

# Pythonパッケージのインストール
pip install -e .

# または、直接パスを追加して使用
# sys.path.append('python')

クイックテスト

# 2準位系のテスト
python examples/python/two_level_excitation.py

# 調和振動子のベンチマーク
python examples/python/benchmark_ho.py

使用例

基本的な使用法

# pip installでインストールした場合
from rk4_sparse import rk4_sparse_py, rk4_sparse_cpp

# 開発用インストールの場合
# import sys
# import os
# sys.path.append(os.path.join(os.path.dirname(__file__), 'python'))
# from rk4_sparse import rk4_sparse_py, rk4_sparse_cpp

# Python実装
result_py = rk4_sparse_py(H0, mux, muy, Ex, Ey, psi0, dt, return_traj, stride, renorm)

# C++実装(高速)
result_cpp = rk4_sparse_cpp(H0, mux, muy, Ex, Ey, psi0, dt, return_traj, stride, renorm)

例題

すべての例はexamples/python/ディレクトリにあります:

  1. 基本例
python examples/python/two_level_excitation.py  # 2準位励起
  1. ベンチマーク
python examples/python/benchmark_ho.py         # 調和振動子系での比較

ベンチマーク

以下のスクリプトで様々なベンチマークを実行できます:

  1. 実装間の比較
python examples/python/benchmark_ho.py         # 調和振動子系での比較
  1. 2準位系のテスト
python examples/python/two_level_excitation.py # 2準位励起のテスト

性能

最新のベンチマーク結果(2025年7月15日)による高性能を実現:

システムサイズ scipy.sparse [ms] numba [ms] C++ [ms] C++ vs scipy C++ vs numba
2レベル 11.6 0.2 0.1 110x 2.0x
4レベル 10.7 0.2 0.1 116x 2.6x
8レベル 11.0 0.4 0.1 75x 2.9x
16レベル 10.9 1.1 0.2 53x 5.5x
32レベル 11.5 3.8 0.3 34x 11.3x
64レベル 12.3 13.6 0.6 20x 22.5x
128レベル 13.9 55.1 1.2 12x 46.9x
256レベル 17.5 230.5 2.4 7.3x 96.0x

最適化の特徴

v0.2.0での主要改善

  1. 条件付きデバッグ出力: I/Oオーバーヘッドの除去
  2. 適応的並列化: 小規模データでのOpenMPオーバーヘッド回避
  3. 最適化されたスケジューリング: 静的スケジューリングによる効率化

コア技術

  1. メモリアライメント

    • キャッシュライン境界(64バイト)に合わせたアライメント
    • 作業バッファの効率的な配置
  2. 適応的並列化

    • 閾値ベースの条件分岐(10,000要素以上で並列化)
    • 静的スケジューリング最適化
  3. 疎行列最適化

    • 非ゼロパターンの事前計算
    • データ構造の再利用
    • 効率的な行列-ベクトル積

ドキュメント

包括的なドキュメントが利用可能です:

ライセンス

MITライセンス

作者

  • Hiroki Tsusaka
  • IIS, UTokyo
  • tsusaka4research "at" gmail.com
pip install -e .

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

rk4_sparse_cpp-0.0.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

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

rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_x86_64.whl (233.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_aarch64.whl (214.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_x86_64.whl (233.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_aarch64.whl (214.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (231.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_aarch64.whl (213.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ ARM64

rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (230.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_aarch64.whl (212.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ ARM64

rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (230.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_aarch64.whl (212.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ ARM64

File details

Details for the file rk4_sparse_cpp-0.0.0.tar.gz.

File metadata

  • Download URL: rk4_sparse_cpp-0.0.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rk4_sparse_cpp-0.0.0.tar.gz
Algorithm Hash digest
SHA256 f2e288460108b7214c35a1cab9b18c744fd5880a95b46ea6c127fc00dffd842d
MD5 99886a85e55e9da6477235410f73c5f7
BLAKE2b-256 cbfc9009133a340f24e9dcf3fa13b0cec617f067057c3a6be9e700b417964e52

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 12fea4be1f7e6ce6d0b39e9e3ad9fa530b2653b8be4be1046f1d224230839fc5
MD5 c028c1b26f9fb7d47aab52f804d559d2
BLAKE2b-256 382c4c69b2a53aeec7556f501861485f4e19799215d94b0e4bd7847815ce16ca

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 3f640fcfb619060d1ea8d01b8175a8d82e90444da4967f31ec26da2741d7c6ee
MD5 eedb58739b7b9f7624d026e990f64fa1
BLAKE2b-256 7e0a8462ea023a526eff5972fb13bbfb4e5fe113a6a9717da61d628c7c27df96

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 43f070d69f990b80204bc84e347cc27e8b34ed9b6fe2a769f80cc29bb3343b53
MD5 95e153042e326c17db70a63cde06d96a
BLAKE2b-256 9088b12ded78ea7a5b1547aaa1668bb64a46388addb15608b4f0922d491ea518

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a6072a97f704260cee7461a5691ac27936b5744b03c22876cce693b113f31deb
MD5 ea089c26e2dce1e3bcdf62ea9a55fbf7
BLAKE2b-256 f5797cdb3f47533407075668abb0e3f56dc7c4768fff7dfd39aa4268f5c4bf6e

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 953835c271c8324a43d70d73cf29ce749a94242f30cf68692eb37ae8ac42607f
MD5 2c670b23f629013959d1f4f26da61257
BLAKE2b-256 b01ff7b0a25d533853e75018f4369ea2c783ee4ea5406b3537496ed5a05f35f2

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 31ee8e8f81dc241648745bee0553dad05fc522363074fedf95f7cf78f95188ae
MD5 26a19928140490641c319ffea75340d3
BLAKE2b-256 97da9ba2a73e7a3919da7614897879aae1c7fa77a211a0b7aae020113646af45

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 776842c3ad966aec4b4b588ae852b1df640adca8628ddd0b8f55e97dcab6188a
MD5 474e2852183a6e03bf74878263aa4661
BLAKE2b-256 7821d6d134d9a322bb74f3bd6453e765b2ec115fb70bd2d1302de0756757eda7

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ee2baa416296b8cb24bb8cf190ee5f25ed8e8f4a112c0bc9e02d54a4a5ceff81
MD5 4c6f836ab6931f2b7400a48bc71c2ac0
BLAKE2b-256 36e27fd38a18ef56b75733511930c1b48c059ef8124cd578f88db4a3332d42d2

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9b4f3a0464a9499f2c729d734b2d1050e9615a422478e44c92461e1c9c7d7f1e
MD5 340ae95a88fb17159a623c1cafc84566
BLAKE2b-256 4cb5227ab4b78ca0be1038a7f74a9490007c018d22246f0099c2872fda30f0ef

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8b878553138c7820cd8375221e92d6fae4af1342cccd855cd1b783ee4216420a
MD5 5e9c93435034d98b96f031cf873bbe87
BLAKE2b-256 d8384f500ff8a34ac70de6549b747450b4f8003b728ae899c489135477f75eef

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 54b57162b5b600cdb2665f51180fa9f79b1739c7f357454ea4c788c207b099af
MD5 aa224cda49e9ca68d542a8e23794d1de
BLAKE2b-256 b34cdaa4388fd7843ef1ec43b702f8c5a99ed9699fc280bdc77134a7ba6c37e3

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b8b5e4da757f778a1f4713985a281ed6ad3d12035bd0a73f7d2e76e8511c2c23
MD5 8f6c4271fbea310ac670f5b519e69f54
BLAKE2b-256 41b603c92276f3fe94105f96435b537a2e760f5131a17c86b2c0b71eca461a03

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0c88e4bea3b6cd640c558717445ee3ae245b6a51c0657de0725394756515f399
MD5 94b05bb70b08df32d233e0761cb3d1e2
BLAKE2b-256 0de249c9c503eee067a06c435953ce2ec19df507c9e5da73f36433ec43899746

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7ad7e007ccbf864474bff607dd1c194fcb043a29510fa79781ea2de72f40eed7
MD5 e654ffb972e67d7e29b782930e27165f
BLAKE2b-256 c1a4167f835f94494e0813b12ad06d2e713b9351dac6825a3ab0ce8d0f1f7e25

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 33d27193960fe16ded89864c80fc7b6834273f2a1118fa9d511f1ed68a00b92f
MD5 eea9daf95a3e13eb93ad869f2cf94192
BLAKE2b-256 fc7b95f04185ffc31eee7485b5410f24672602de480fb886ff004e00f12bd812

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1495ffc9f00943503020b132165986bf80bff252c0f1f767efeab3203ac686fb
MD5 466e19b62a319727bef54f674211882b
BLAKE2b-256 cf191f8c0db7f966c44542f6155b8c54b40d761c9674d51436f7fc5bee2e9ac6

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0bc5a504cc0ec220f6023da97a464ece74cebb7ea96a7dda2c6eb899d373d3e6
MD5 e882019cc5630004f1dd31bfcf993ad0
BLAKE2b-256 8e680d2e9a4d3b318fb618ac69409c5a19409a34823db006768a43654415d536

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp39-cp39-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9c39066e657d0768276d52c9d7815570ad6d0881cfb7ba5458a8d8c16a0e95da
MD5 71760bc55158214e8e652a58449d1add
BLAKE2b-256 54bb7c6b145b9a5d28ad7b41c377574c635b61638c06534ec5ac9d70483a291f

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad6fbf141a549be96eed40a642c9fa2fdcaa413f3ef4204b32806a389a0ce152
MD5 f994f9e044bf4c7ed48c10a5fbfb8968
BLAKE2b-256 9240f7ee4f349370679daf9ae342175cb104ddc79c053a79964e85c4e0a93d84

See more details on using hashes here.

File details

Details for the file rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rk4_sparse_cpp-0.0.0-cp39-cp39-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a87b1859c361b956110ce5a567e95de3d72158a76c906eb33c72b4c78b71f49a
MD5 812e9e8836f5d26f821443ea5ecd51a3
BLAKE2b-256 b77019bb1903711334d1164bafdc8c00093b63cfc35a2b8a4668a2c59eaaecb0

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