Skip to main content

Quasi-Steady State method for stiff ODE systems with focus on combustion chemistry

Project description

QSS Integrator: Quasi-Steady State Method for Stiff ODE Systems

Python License Build Status

A high-performance Python package implementing the Quasi-Steady State (QSS) method for solving stiff ordinary differential equations, with particular focus on combustion chemistry applications. This package provides a C++ backend with Python bindings for efficient integration of chemical kinetics systems.

What is the Quasi-Steady State (QSS) Method?

The Quasi-Steady State method is a specialized numerical technique designed for solving stiff ODE systems commonly found in chemical kinetics and combustion modeling. Unlike traditional methods that treat all species equally, QSS exploits the natural timescale separation in chemical systems.

Key Concepts

Stiff Systems: In combustion chemistry, different chemical species evolve on vastly different timescales. Some species (like radicals) react very quickly, while others (like stable molecules) change slowly. This creates a "stiff" system where traditional integrators struggle.

Timescale Separation: The QSS method identifies fast and slow species based on their characteristic timescales:

  • Fast species: React quickly and can be assumed to be in quasi-steady state
  • Slow species: Evolve on the timescale of interest and are integrated explicitly

Production-Destruction Splitting: The method splits the ODE into production (q) and destruction (d) terms:

dy/dt = q(y) - d(y)

where q represents production rates and d represents destruction rates.

Advantages

  1. Automatic stiffness handling: No need for manual species classification
  2. Large timesteps: Can take much larger steps than traditional methods
  3. Computational efficiency: Fewer function evaluations per timestep
  4. Robustness: Handles extreme stiffness ratios automatically

Installation

Prerequisites

  • Python 3.8 or higher
  • C++ compiler with C++17 support
  • CMake (for building from source)

Quick Install

pip install qss-integrator

Development Install

git clone https://github.com/elotech47/pyQSS.git
cd qss-integrator
pip install -e .

Cross-Platform Builds

This package uses cibuildwheel for robust cross-platform builds. The CI/CD pipeline automatically builds wheels for:

  • Linux: x86_64 (manylinux2014)
  • macOS: x86_64 and arm64 (universal2)
  • Windows: x86_64 (AMD64)

Python versions supported: 3.8, 3.9, 3.10, 3.11, 3.12

Local Testing

To test the build process locally:

# Test basic build
python test_local_build.py

# Test with cibuildwheel (if installed)
pip install cibuildwheel
cibuildwheel --platform linux

Dependencies

  • Required: numpy, pybind11
  • Optional: cantera (for combustion examples), matplotlib (for plotting)

Quick Start

Basic Usage

import numpy as np
import qss_py

# Define your ODE system
class MyODE(qss_py.QssOde):
    def odefun(self, t, y, q, d, corrector=False):
        # Split your ODE into production (q) and destruction (d) terms
        q[0] = 1.0  # production rate
        d[0] = y[0]  # destruction rate (proportional to y)
        # ... define for all species

# Create integrator
integrator = qss_py.QssIntegrator()
ode = MyODE()
integrator.setOde(ode)
integrator.initialize(n_species=1)

# Set initial conditions
y0 = [1.0]  # initial state
integrator.setState(y0, t0=0.0)

# Integrate to final time
result = integrator.integrateToTime(tf=1.0)
final_state = integrator.y

Combustion Example

import cantera as ct
import numpy as np
from qss_utils import create_qss_solver

# Setup combustion problem
gas = ct.Solution('gri30.yaml')
gas.set_equivalence_ratio(1.0, 'CH4:1', 'O2:1, N2:3.76')
gas.TP = 1000, ct.one_atm

# Create QSS solver
config = {
    'epsmin': 1e-2,
    'epsmax': 10.0,
    'dtmin': 1e-15,
    'dtmax': 1e-6,
    'itermax': 2,
    'abstol': 1e-8,
    'stabilityCheck': True
}

solver = create_qss_solver(gas, ct.one_atm, config)

# Initial state: [T, Y1, Y2, ...]
y0 = [gas.T] + list(gas.Y)
solver.setState(y0, 0.0)

# Integrate
result = solver.integrateToTime(1e-3)  # 1 ms
print(f"Final temperature: {solver.y[0]:.1f} K")

Configuration Parameters

The QSS integrator offers several parameters to control accuracy and performance:

Parameter Default Description
epsmin 1e-2 Minimum accuracy parameter
epsmax 20.0 Maximum correction tolerance
dtmin 1e-15 Minimum timestep
dtmax 1e-6 Maximum timestep
itermax 2 Maximum corrector iterations
abstol 1e-8 Absolute tolerance for convergence
stabilityCheck True Enable stability checking

Examples

1. Simple Chemical Kinetics

See examples/simple_kinetics.py for a basic example with a simple chemical mechanism.

2. Combustion Modeling

See examples/combustion.py for methane combustion using Cantera mechanisms.

3. Performance Comparison

See examples/benchmark.py for comparing QSS performance against traditional methods.

API Reference

Core Classes

QssIntegrator

Main integrator class for QSS method.

Methods:

  • setOde(ode): Set the ODE system to integrate
  • initialize(n): Initialize for n species
  • setState(y, t): Set initial state
  • integrateToTime(tf): Integrate to final time
  • integrateOneStep(tf): Take one integration step

Properties:

  • y: Current state vector
  • tn: Current time
  • gcount: Function evaluation count
  • rcount: Timestep repeat count

QssOde

Base class for defining ODE systems.

Methods:

  • odefun(t, y, q, d, corrector): Evaluate ODE splitting

Performance

The QSS method typically provides:

  • 2-10x speedup over traditional stiff solvers
  • Larger timesteps without loss of accuracy
  • Better stability for extremely stiff systems

See the benchmark results in examples/benchmark.py for detailed performance comparisons.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/elotech47/pyQSS.git
cd qss-integrator
pip install -e .[dev]

Running Tests

python -m pytest tests/

Citation

If you use this software in your research, please cite:

@software{qss_integrator,
  title={QSS Integrator: Quasi-Steady State Method for Stiff ODE Systems},
  author={Eloghosa Ikponmwoba},
  year={2024},
  url={https://github.com/elotech47/pyQSS.git}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Based on the CHEMEQ2 algorithm
  • Inspired by the Quasi-Steady-State method described in:

    Mott, D., Oran, E., & van Leer, B. (2000). A Quasi-Steady-State Solver for the Stiff Ordinary Differential Equations of Reaction Kinetics. Journal of Computational Physics, 164(2), 407-428. https://doi.org/10.1006/jcph.2000.6605

  • Built with pybind11 for Python-C++ integration

Support

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

qss_integrator-0.1.3.tar.gz (361.1 kB view details)

Uploaded Source

Built Distributions

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

qss_integrator-0.1.3-cp312-cp312-win_amd64.whl (101.8 kB view details)

Uploaded CPython 3.12Windows x86-64

qss_integrator-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (151.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

qss_integrator-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (110.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

qss_integrator-0.1.3-cp312-cp312-macosx_10_9_x86_64.whl (115.2 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

qss_integrator-0.1.3-cp311-cp311-win_amd64.whl (100.8 kB view details)

Uploaded CPython 3.11Windows x86-64

qss_integrator-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (150.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

qss_integrator-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (109.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

qss_integrator-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl (114.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

qss_integrator-0.1.3-cp310-cp310-win_amd64.whl (100.2 kB view details)

Uploaded CPython 3.10Windows x86-64

qss_integrator-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

qss_integrator-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (108.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

qss_integrator-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl (113.0 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

qss_integrator-0.1.3-cp39-cp39-win_amd64.whl (102.0 kB view details)

Uploaded CPython 3.9Windows x86-64

qss_integrator-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (150.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

qss_integrator-0.1.3-cp39-cp39-macosx_11_0_arm64.whl (108.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

qss_integrator-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl (113.1 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

qss_integrator-0.1.3-cp38-cp38-win_amd64.whl (99.8 kB view details)

Uploaded CPython 3.8Windows x86-64

qss_integrator-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (149.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

qss_integrator-0.1.3-cp38-cp38-macosx_11_0_arm64.whl (108.2 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

qss_integrator-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl (112.6 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file qss_integrator-0.1.3.tar.gz.

File metadata

  • Download URL: qss_integrator-0.1.3.tar.gz
  • Upload date:
  • Size: 361.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qss_integrator-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3962a36c04ba1ad0d1f433551d69d0d83644b5e493f798c43b1fdc9e60012eba
MD5 6ad2b2779e3e80e4d3e59350a0fddef9
BLAKE2b-256 862b4d1b86076d4a018ed45ca8ed4c336e1091dcdf92b9e64e44b7c813eacf19

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4a85c6e99bad27cd6fe3d3e4f3822add3fc109c897e46a47383a12a9a2ba1bc8
MD5 c483e0ef7eecd591a4ad712cd77974a9
BLAKE2b-256 d0b754a1a2e8bb2ca2a3279e1854caa2cbb5db68dd0c3fd2783ad87d4bb2591d

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5034c4909d03c92ff0552daa224b628eec87a3a8d475ac806076b9db7abb2f1a
MD5 337daa59821d9e2debacd8f5b6a46340
BLAKE2b-256 eaff90bb9a211d4b71dffb429894920ac52e0d07f924de56916c1cae28d934cc

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9469c0c7d160b65ef3f3fe719b29d18d73b16271b3255aeb3d47c923b3148a51
MD5 e44415dbec951eac70cb584f1ea14394
BLAKE2b-256 82c73065775d2d1e16526d32e95e3c64c4f8d94f65fb92f91c5099b1a993f9e6

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3ee27aaa0dc7b558fc5f0847367d63df05dac12b7d999de185c5e316c344d527
MD5 c138d9708d99d03aa0e4d6ed2b2973a5
BLAKE2b-256 1ec9a6c7310e9a5434fbaa7b377b9916c74e3b5c43372d72ab32642c54a3b576

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ba9f81b6de57e6b515e5f0cb3416c2fff2983934e101c9bd1153276bdca0adfa
MD5 848456325d9897d4c6f92f2c419fb4df
BLAKE2b-256 98d15c1b89814df9e927e5742c1a78b6f9e227bf0e69c532017d8ee6b116ca38

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d00f855375a7abfaea3a5fde0f0daf4b2ff550d0d585a17327bd7d28fe5cd7dc
MD5 3e1402e7d1b1e2b9b02ccf06ebec278d
BLAKE2b-256 bc1060959a1619343bbf529055896bd93012b0e3bd5964d4965f1617a11ec40d

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6710f6b556096128ea7b0723a435f4b641a64d58b5b4fcf7cd07f81df0e3cc8
MD5 6e7b4bf9abb377721075934f074f351a
BLAKE2b-256 506e41ccbae4d6e54b74b0b58c7ef680054b290e7d6d22469cc9de871c69e045

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3bf3461f034d49db6737e7f40a4098d588fd2ad7304da517d685f36f79ac5452
MD5 d59075f0ff4886bec6f22b7c51591a68
BLAKE2b-256 a08c3901a90e2012452c44e33825ab4bf7c48808465587e4532c5fd902416735

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5b6cfa26e5a9f6b1e17a2f023dbad3edf0df1d6242d60ef743e899655671376c
MD5 0ca01342ecd5b5fc1efd4dcdacfe38e6
BLAKE2b-256 94b509d5f6ce2e61ab470cd1f790b95cde1990e1aa0e9d34c99daa6cb230a1f2

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1b150506aee867f09eea7da403350b842f7ed58e3eac86923c9cb3cd6165f03
MD5 13cec8711479cf0fa497597abe3d1038
BLAKE2b-256 f7df4d94b5c179fee77b23b6dc915c420749855fe17aedd93246c2c1b2d9fa56

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7693fa8438bb47a23105d3a370af6de857cfd0152a9ceabfd5680ce874b9ddd
MD5 97ee9a1b97b009aa5b83be25b0474fbd
BLAKE2b-256 c255140a13ccfebf5eedc23ec8e34a82d7b6e227c1b428f86ad06c9a8ebbed49

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 83169a79c73727d323cc149a9061052b2f5b521e39c6f7f27f69017fd5b2656d
MD5 6e475cc1cb6c3cd996448ca3fd1b7da6
BLAKE2b-256 40b19ff69bc88f2ccbf1a646f700de37c629c93b93c71f33f1fc4d1e1ea11a4c

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 acb29952e3a034bbd0c95ab9c19ecc989b06efbc01353443e1685608ad023123
MD5 457d81a1f882d836f82f7d4d49f508ff
BLAKE2b-256 4457b6d50b5bd3643a8e56bad5401af2fbe11e2745ef7cbda4915f8107435e38

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce7812a7cb67d0dbe5c2f5bc76a0a51605c98abea78165564c8ec354c89ecc20
MD5 ac3af55a8fe573354203b1912b5db20f
BLAKE2b-256 604bd02bc1cf640299d04001a356da00f59566ab501daeb7b8dab756c64ec758

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b26484bfbba4ed6d8e4f110df353de71506f5a8e7ade579cc81890b439a6f4d6
MD5 b828307227c3469c8a5deb6b7435615e
BLAKE2b-256 3aff65865882d9c81b6fe7c4b54ab509f35142d59831aa34e08b32515cd5d8d2

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 20b4f49a9103ddfe6cf6f00f001f240979164a3bd11794cb0887053d59b72ec0
MD5 9f7b7330e08776766e69d341484de6ad
BLAKE2b-256 ff1e07aa3d14fa594aa52a086edf6df3e467235d0bdd6954b2c89d5d80fed61a

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 f74f8814547119f0627b0438bef372bfa9d50872944bd0db8869744e51305177
MD5 84689d521d023298ad4807d62d8f0bc1
BLAKE2b-256 791269464ccac1d56eea7998e591c9273901922c41f644132e8a243359b0acbb

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb1f347e2e2ed6e8e623b3179783743a0a1052efb495059d52d907c2ebafbbe5
MD5 e39da8d6b96f649aeaa62dcb275606e6
BLAKE2b-256 e74fc6324d617d1e443b5daf0012ecbeb1188a4d685a4af3df724f6701093dd6

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28f579fad8bd8c4c5a811515819e11b1b1ced088fb9f29b5090e4d45eba6ee5e
MD5 cd64fe94bd7022468500f1cb1ec321be
BLAKE2b-256 292c3d1c55b72308203bc81a84bc3ad66834d3ccf0f5d2dd7e4c3ad1d0944bc4

See more details on using hashes here.

File details

Details for the file qss_integrator-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for qss_integrator-0.1.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d4c37bbc66ff8f7eed6c1683080e562944eaa5c7ea19711ce2a284ec651059a0
MD5 e05e16fdb47287dc8ceba23916ab9c89
BLAKE2b-256 1e5422a018be5ddd1ab208a2fa5dacc8d802b5995d0c4c6d5572fa2b67dbacfb

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