For fitting spectroscopic data to cooperative and isodesmic models of supramolecular polymerization.
Project description
sp-fitting-models
超分子ポリマーのフィッティングモデルライブラリ
A Python library for fitting supramolecular polymerization data with various thermodynamic models.
概要 / Overview
このライブラリは、超分子ポリマー形成データを解析するための数理モデルを提供します。特に温度依存的な会合挙動を定量的に解析し、熱力学パラメータ(エンタルピー、エントロピー)を推定することができます。
This library provides mathematical models for analyzing supramolecular polymerization data. It enables quantitative analysis of temperature-dependent aggregation behavior and estimation of thermodynamic parameters (enthalpy, entropy).
特徴 / Features
-
複数のモデルに対応
- Isodesmicモデル: すべての会合定数が等しい単純な会合モデル
- Cooperativeモデル: 核形成と伸長で異なる定数を持つ協同的会合モデル
- Mixedモデル: IsodesmicとCooperativeの2経路が競合するモデル
-
温度依存性の解析
- van't Hoff式に基づく温度依存的な会合定数の計算
- ΔH(エンタルピー変化)とΔS(エントロピー変化)の推定
-
フィッティング機能
- lmfitライブラリを使用した実験データへのフィッティング
- 複数濃度データの同時フィッティング(グローバルフィット)に対応
インストール / Installation
uv add https://github.com/IndigoCarmine/sp_fitting_models.git
使用方法 / Usage
基本的な使用例
import numpy as np
import matplotlib.pyplot as plt
from sp_fitting_models.models import temp_cooperative_model
# Temperature range
temps = np.linspace(280, 400, 200) # 280-400 K
# Thermodynamic parameters
deltaH = -96000 # Enthalpy change (J/mol)
deltaS = -180 # Entropy change (J/(mol·K))
deltaHnuc = 100000 # Nucleation penalty (J/mol)
c_tot = 5e-6 # Total concentration (M)
# Calculate aggregation
agg = temp_cooperative_model(
Temp=temps,
deltaH=deltaH,
deltaS=deltaS,
deltaHnuc=deltaHnuc,
c_tot=c_tot,
scaler=1.0
)
# Plot
plt.plot(temps - 273.15, agg)
plt.xlabel('Temperature (°C)')
plt.ylabel('Aggregation')
plt.show()
データフィッティング
import lmfit as lm
from sp_fitting_models.data import TempVsAggData
from sp_fitting_models.fitting import objective_temp_cooperative
# Prepare your experimental data
data_list = [
TempVsAggData(temp=temps1, agg=agg1, concentration=c1),
TempVsAggData(temp=temps2, agg=agg2, concentration=c2),
]
# Set up parameters
params = lm.Parameters()
params.add('deltaH', value=-100000, min=-200000, max=0)
params.add('deltaS', value=-180, min=-400, max=0)
params.add('deltaHnuc', value=50000, min=0, max=200000)
params.add('scaler', value=1.0, min=0.5, max=1.5)
# Fit
minner = lm.Minimizer(objective_temp_cooperative, params, fcn_args=(data_list,))
result = minner.minimize()
print(lm.fit_report(result))
インタラクティブな可視化
# Run the interactive mixed model example
python examples/interactive_mixed.py
スライダーを使用してパラメータを変更し、リアルタイムで会合曲線の変化を観察できます。
Windowsアプリとしてビルド (uv + PyInstaller)
examples/interactive_mixed.py をコンソールなしの Windows GUI アプリとしてビルドできます。
./scripts/build_interactive_mixed.ps1
または cmd.exe から:
build_interactive_mixed.bat
生成物:
dist/interactive_mixed/interactive_mixed.exe
このスクリプトは次を自動で行います。
uv syncで依存関係とローカルパッケージを同期uv run --with pyinstaller ...で GUI アプリをビルド
プロジェクト構造 / Project Structure
sp_fitting_models/
├── src/
│ └── sp_fitting_models/
│ ├── __init__.py
│ ├── data.py # Data structures
│ ├── models/ # Model implementations
│ │ ├── __init__.py
│ │ ├── isodesmic.py # Isodesmic models
│ │ ├── cooperative.py # Cooperative models
│ │ ├── mixed.py # Mixed models
│ │ └── utils.py # Utility functions
│ └── fitting/ # Fitting utilities
│ ├── __init__.py
│ └── objective.py # Objective functions for lmfit
├── tests/ # Test files
│ ├── test_isodesmic.py
│ ├── test_cooperative.py
│ ├── test_mixed.py
│ └── test_fitting.py
├── examples/ # Example scripts
│ ├── basic_usage.py
│ └── interactive_mixed.py
├── pyproject.toml
└── README.md
モデルの説明 / Model Description
Isodesmicモデル
すべての会合ステップが同じ平衡定数Kを持つモデルです。シグモイド型の会合曲線を示します。
$$K = \exp\left(-\frac{\Delta H}{RT} + \frac{\Delta S}{R}\right)$$
次のような平衡状態です。 供給されるモノマーは省略してあります。: $$M \stackrel{K}{\rightleftarrows} M_2\stackrel{K}{\rightleftarrows} M_3 \stackrel{K}{\rightleftarrows} ...$$
Cooperativeモデル
核形成と伸長で異なる平衡定数を持つモデルです。非シグモイド型の会合曲線を示します。核形成ペナルティσにより協同性が表現されます。
$$\sigma = \exp\left(-\frac{\Delta H_{nuc}}{RT}\right)$$
$$ K = \exp\left(-\frac{\Delta H}{RT} + \frac{\Delta S}{R}\right)$$
$$ K_{nuc} = \sigma K $$ 次のような平衡状態です。 $$M \stackrel{K_{nuc}}{\rightleftarrows} M_2\stackrel{K}{\rightleftarrows} M_3 \stackrel{K}{\rightleftarrows} ...$$
Mixedモデル
IsodesmicとCooperativeの2つの経路が同じモノマープールを共有して競合するモデルです。実験系で複数の会合機構が同時に起こる場合に適用できます。
次のような平衡状態を考えています。 $$M \stackrel{K_{nuc}}{\rightleftarrows} M_2\stackrel{K}{\rightleftarrows} M_3 \stackrel{K}{\rightleftarrows} ...$$ $$ \searrow \nwarrow^{K_{iso}} M_2\stackrel{K_{iso}}{\rightleftarrows} M_3 \stackrel{K_{iso}}{\rightleftarrows} ...$$ (MDではこれ以上きれいに書けませんでした...)
テスト / Testing
# Run all tests
python -m pytest tests/
# Run specific test
python tests/test_cooperative.py
サンプル / Examples
# Basic usage examples
python examples/basic_usage.py
# Interactive mixed model visualization
python examples/interactive_mixed.py
依存関係 / Dependencies
- Python >= 3.13
- numpy >= 2.4.2
- numba >= 0.64.0
- lmfit >= 1.3.4
- matplotlib >= 3.10.8
引用 /Citation
書いていただけるなら嬉しいですが、必ずしも論文で言及する必要はありません。 ご自由にお使いください。
I would be grateful if you could cite this library in your publications, but it is not mandatory. Please feel free to use it as you see fit.
作成者 / Author
山田悠平 (Yuhei Yamada, Orcid: 0009-0003-9780-4135, google scholar: Yuhei Yamada)
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 Distributions
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 sp_fitting_models-1.3.4.tar.gz.
File metadata
- Download URL: sp_fitting_models-1.3.4.tar.gz
- Upload date:
- Size: 365.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37ea17ec69f5cffb18434ecfbd71081780aae7ae755bbfe1dee9ee27b403c380
|
|
| MD5 |
94a7fda3f4264fde413d0eea829637d8
|
|
| BLAKE2b-256 |
e7358eb5cb3b4d2ef74e06c623d84afd9404da76bdac2487c7462ff2ad62ec62
|
Provenance
The following attestation bundles were made for sp_fitting_models-1.3.4.tar.gz:
Publisher:
python-publish.yml on IndigoCarmine/sp_fitting_models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sp_fitting_models-1.3.4.tar.gz -
Subject digest:
37ea17ec69f5cffb18434ecfbd71081780aae7ae755bbfe1dee9ee27b403c380 - Sigstore transparency entry: 1096880501
- Sigstore integration time:
-
Permalink:
IndigoCarmine/sp_fitting_models@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Branch / Tag:
refs/tags/1.3.4 - Owner: https://github.com/IndigoCarmine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sp_fitting_models-1.3.4-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: sp_fitting_models-1.3.4-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 125.6 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26f9b7899de7e17b05a9f72d8ac1714a32e728bb4bb67972b4ad6cd8ecbaf9ad
|
|
| MD5 |
ce7c9b818d7e73cf2bb4649e03bfde90
|
|
| BLAKE2b-256 |
88167f73f640bfc119658a5e6ba8415c0c3d8922dd1284f9bd08dc7653278158
|
Provenance
The following attestation bundles were made for sp_fitting_models-1.3.4-cp39-abi3-win_amd64.whl:
Publisher:
python-publish.yml on IndigoCarmine/sp_fitting_models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sp_fitting_models-1.3.4-cp39-abi3-win_amd64.whl -
Subject digest:
26f9b7899de7e17b05a9f72d8ac1714a32e728bb4bb67972b4ad6cd8ecbaf9ad - Sigstore transparency entry: 1096880504
- Sigstore integration time:
-
Permalink:
IndigoCarmine/sp_fitting_models@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Branch / Tag:
refs/tags/1.3.4 - Owner: https://github.com/IndigoCarmine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sp_fitting_models-1.3.4-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: sp_fitting_models-1.3.4-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 224.3 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea5c75e9bfecf8468bc577434867c0ef8c3dac5265bb36eff2e60c78d7189d93
|
|
| MD5 |
567f25e0c3395f9effad1297ffa5dbdb
|
|
| BLAKE2b-256 |
96343c948c986975c18bb0ed38e211a784a8dcadb2eea7d6715e097962f7682a
|
Provenance
The following attestation bundles were made for sp_fitting_models-1.3.4-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
python-publish.yml on IndigoCarmine/sp_fitting_models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sp_fitting_models-1.3.4-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
ea5c75e9bfecf8468bc577434867c0ef8c3dac5265bb36eff2e60c78d7189d93 - Sigstore transparency entry: 1096880513
- Sigstore integration time:
-
Permalink:
IndigoCarmine/sp_fitting_models@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Branch / Tag:
refs/tags/1.3.4 - Owner: https://github.com/IndigoCarmine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sp_fitting_models-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: sp_fitting_models-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 260.5 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afed15487ccb25f15f259ca88ad418444ab1fe3b50208c2eafe65dd2a06c3f34
|
|
| MD5 |
cff29a5b155217fb25675bc00f3ad058
|
|
| BLAKE2b-256 |
bfb661adb62a56fde9212a28515bfcf691b74e5f325238e21c07a1e69b3102d4
|
Provenance
The following attestation bundles were made for sp_fitting_models-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-publish.yml on IndigoCarmine/sp_fitting_models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sp_fitting_models-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
afed15487ccb25f15f259ca88ad418444ab1fe3b50208c2eafe65dd2a06c3f34 - Sigstore transparency entry: 1096880507
- Sigstore integration time:
-
Permalink:
IndigoCarmine/sp_fitting_models@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Branch / Tag:
refs/tags/1.3.4 - Owner: https://github.com/IndigoCarmine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@64939030bd2016e39ed9f9f3909e967e9ed50964 -
Trigger Event:
release
-
Statement type: