Skip to main content

Kintera: Atmospheric Chemistry and Thermodynamics Library

KINTERA is a library for atmospheric chemistry and equation of state calculations, combining C++ performance with Python accessibility through pybind11 bindings.

Table of Contents

Overview

KINTERA provides efficient implementations of:

  • Chemical kinetics calculations (Arrhenius, coagulation, evaporation)
  • Photochemistry and photolysis reactions
  • Thermodynamic equation of state
  • Phase equilibrium computations
  • Atmospheric chemistry models

Multiphase Equilibrium

EquilibriumTP is a fixed-temperature, fixed-pressure constrained chemistry solver. The C++/CUDA core accepts component moles and precomputed logarithmic equilibrium constants; the module derives phase membership and stoichiometry from its options. Case-specific thermodynamics remains in Python under kintera.equilibrium.

Equilibrium networks use the repository's top-level phases, species, and reactions YAML layout. Phase species determine component ordering, species compositions validate elemental balance, and reactions with type: equilibrium generate the module's stoichiometric buffer:

from kintera import EquilibriumOptions, EquilibriumTP

options = EquilibriumOptions.from_yaml("equilibrium.yaml")
solver = EquilibriumTP(options)

Nasa9LogK evaluates ideal-gas equilibrium constants from the bundled NASA-9 database. See examples/equilibrium_nasa9.yaml and examples/equilibrium_nasa9.py for a complete YAML-defined sample:

python examples/equilibrium_nasa9.py

The library is written in C++17 with Python bindings, leveraging PyTorch for tensor operations and providing GPU acceleration support via CUDA.

Features

  • High Performance: C++17 core with optional CUDA support
  • Python Interface: Full Python API via pybind11
  • PyTorch Integration: Native tensor operations using PyTorch
  • Chemical Kinetics: Comprehensive reaction mechanism support
  • Photochemistry: Wavelength-dependent photolysis with multi-branch products
  • Thermodynamics: Advanced equation of state calculations
  • Cloud Physics: Nucleation and condensation modeling

Prerequisites

System Requirements

  • C++ Compiler: Support for C++17 (GCC 9+, Clang 5+, or MSVC 2017+)
  • CMake: Version 3.18 or higher
  • Python: Version 3.10 or higher
  • NetCDF: NetCDF C library

Python Dependencies

  • numpy
  • torch (version 2.10.0)
  • pyharp (version 2.2.0+
  • pytest (for testing)

Platform-Specific Setup

Linux (Ubuntu/Debian)

sudo apt-get update
sudo apt-get install -y build-essential cmake libnetcdf-dev

macOS

brew update
brew install cmake netcdf

Installation

Quick Start

# 1. Install Python dependencies
pip install numpy 'torch==2.10.0' 'pyharp>=2.2.0'

# 2. Clone the repository
git clone https://github.com/chengcli/kintera.git
cd kintera

# 3. Configure and build the C++ library
cmake -B build
cmake --build build --parallel

# 4. Install the Python toolkit
pip install .

Photochemistry Module

KINTERA includes a complete photochemistry module for modeling photolysis reactions in planetary atmospheres.

Architecture

src/photolysis/
├── photolysis.hpp           # PhotolysisOptions and PhotolysisImpl definitions
├── photolysis.cpp           # Implementation with YAML parsing and rate computation
├── actinic_flux.hpp         # Actinic flux helper functions
├── load_xsection_kin7.cpp   # KINETICS7 cross-section loader
├── load_xsection_yaml.cpp   # YAML cross-section loader
├── jacobian_photolysis.hpp  # Photolysis Jacobian declarations
└── jacobian_photolysis.cpp  # Species-space Jacobian helper implementation

Key Components

Component Description
PhotolysisOptions Configuration: wavelength grid, cross-sections, branches
Photolysis PyTorch module computing rates via wavelength integration
actinic_flux.hpp helpers Flux construction and wavelength interpolation helpers
jacobian_photolysis_species() Species-space Jacobian helper for implicit solvers

Thermochemistry Data

NASA-9 polynomial data is stored with SpeciesThermoImpl as structured per-species coefficient tables and converted to tensors on demand when reversible kinetics needs equilibrium constants. KineticsImpl no longer owns separate cached NASA-9 buffers.

Kinetics Species Layout

KineticsOptions.from_yaml(...) registers kinetics species using reaction-active vapors plus cloud species, rather than every species listed in the YAML file. In practice this means inert dry carrier species are not included in the concentration tensor passed to Kinetics.forward(...) or Kinetics.forward_nogil(...) unless they also participate in the reaction mechanism. Callers that derive kinetics concentrations from a larger thermo state should narrow or reorder species explicitly to the kinetics species list.

Rate Calculation

Photolysis rates are computed by integrating cross-sections weighted by actinic flux:

k = ∫ σ(λ,T) · F(λ) dλ

where σ is the cross-section [cm² molecule⁻¹], F is the actinic flux [photons cm⁻² s⁻¹ nm⁻¹], and λ is wavelength [nm].

YAML Configuration

Photolysis reactions are defined in YAML format:

reactions:
- equation: CH4 => CH3 + H + (1)CH2 + H2
  type: photolysis
  branches:
    - "CH4:1"           # photoabsorption
    - "CH3:1 H:1"       # CH3 + H branch
    - "(1)CH2:1 H2:1"   # singlet CH2 + H2 branch
  cross-section:
    - format: KINETICS7
      filename: "CH4.dat2"
    # Or inline YAML format:
    - format: YAML
      temperature: 300.
      data:
        - [100., 1.e-18, 0.5e-18]
        - [150., 2.e-18, 1.0e-18]

C++ Usage

#include <kintera/photolysis/photolysis.hpp>
#include <kintera/photolysis/actinic_flux.hpp>

// Create options
auto opts = PhotolysisOptionsImpl::create();
opts->wavelength() = {100., 150., 200.};
opts->reactions().push_back(Reaction("N2 => N2"));
opts->cross_section() = {1.e-18, 2.e-18, 1.e-18};

// Create module and move to GPU
Photolysis module(opts);
module->to(torch::kCUDA, torch::kFloat64);

auto temp = torch::tensor({300.0}, module->wavelength.options());

// Create actinic flux on the module wavelength grid
auto flux = create_solar_flux(module->wavelength, 1.e14);

// Refresh the temperature-dependent cache before forward()
module->update_xs_diss_stacked(temp);
auto rate = module->forward(temp, flux);

Python Usage

from kintera import (
    PhotolysisOptions, Photolysis, Reaction,
    create_solar_flux, set_species_names
)
import torch

# Initialize species list
set_species_names(["N2", "O2", "CH4"])

# Configure photolysis
opts = PhotolysisOptions()
opts.wavelength([100., 150., 200.])
opts.reactions([Reaction("N2 => N2")])
opts.cross_section([1e-18, 2e-18, 1e-18])

# Create module
module = Photolysis(opts)

temp = torch.tensor([300.0], dtype=module.wavelength.dtype,
                    device=module.wavelength.device)

# Create flux on the module wavelength grid and compute rates
flux = create_solar_flux(module.wavelength, 1e14)
module.update_xs_diss_stacked(temp)
rate = module.forward(temp, flux)

Cross-Section File Formats

The module supports multiple cross-section formats:

Format Description
YAML Inline wavelength/cross-section data
KINETICS7 NCAR KINETICS7 format files
VULCAN VULCAN photochemistry format

Testing

KINTERA includes comprehensive C++ and Python tests.

Running All Tests

ctest --test-dir build/tests --output-on-failure

Photochemistry Tests

Run photochemistry-specific tests:

# Focused C++ tests
./build/tests/test_photolysis_options.release
./build/tests/test_ch4_photolysis.release

# Python tests
pytest tests/test_photolysis.py -v

Device Coverage

Parameterized C++ tests are generated for CPU and CUDA builds. MPS test instantiations have been removed from the default test matrix.

Test Coverage

Test File Coverage
test_photolysis_options.cpp YAML parsing, cross-section loading
test_photolysis_kinetics.cpp Kinetics integration, stoichiometry
test_actinic_flux.cpp Flux interpolation, tensor shapes
test_ch4_photolysis.cpp End-to-end CH4 photolysis, Jacobian
test_photolysis.py Python bindings integration

Documentation

Full documentation is available at: https://kintera.readthedocs.io

To build documentation locally:

cd docs
pip install -r requirements.txt
make html

Dependency Cache

A successful build saves cache files in .cache/. To force a clean rebuild:

rm -rf .cache build

Development

Project Structure

kintera/
├── src/
│   ├── kinetics/       # Kinetics modules (Arrhenius, falloff, three-body, etc.)
│   ├── photolysis/     # Photolysis, actinic flux, and Jacobian helpers
│   ├── diffusion/      # Diffusion operators
│   ├── units/          # Unit conversion helpers
│   ├── thermo/         # Thermodynamics
│   └── math/           # Interpolation utilities
├── python/
│   ├── csrc/           # pybind11 bindings
│   ├── kintera.pyi     # Type stubs
│   └── py.typed        # PEP 561 marker
├── tests/              # C++ and Python tests
├── examples/           # Usage examples
└── data/               # Test data (cross-sections, YAML configs)

Code Style

pip install pre-commit
pre-commit install
pre-commit run --all-files

Type Hints

KINTERA provides full type hint support through Python stub files:

  • IDE autocomplete in VS Code, PyCharm
  • Type checking with mypy or pyright

See python/STUB_FILES.md for details.

Continuous Integration

GitHub Actions CI pipeline:

  1. Pre-commit checks (formatting, linting)
  2. Build on Linux and macOS
  3. Run all C++ and Python tests

License

See LICENSE file for details.

Authors

Metadata

Release files for kintera 2.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for kintera 2.6.4
File
kintera-2.6.4-cp313-cp313-manylinux_2_27_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64 Details
kintera-2.6.4-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
kintera-2.6.4-cp312-cp312-manylinux_2_27_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64 Details
kintera-2.6.4-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
kintera-2.6.4-cp311-cp311-manylinux_2_27_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64 Details
kintera-2.6.4-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
kintera-2.6.4-cp310-cp310-manylinux_2_27_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64 Details
kintera-2.6.4-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details

Total release size: 198.0 MB

Release files / kintera-2.6.4-cp313-cp313-manylinux_2_27_x86_64.whl

Download URL kintera-2.6.4-cp313-cp313-manylinux_2_27_x86_64.whl
Size 45.3 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
a0d7b647bce9a781ff3261297f55a584fb5d8811c1882420d07510e40988a6bf
BLAKE2b-256 checksum
How to use checksums
f965f767716e65cc6790dae115d89ee4ede80773f9e919eb49428c433b8df237
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp313-cp313-macosx_15_0_arm64.whl

Download URL kintera-2.6.4-cp313-cp313-macosx_15_0_arm64.whl
Size 4.3 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
dbf5ba0a673a5d9b3f8b293e84696d021d6ada7416827897a8a2672889705a1a
BLAKE2b-256 checksum
How to use checksums
83160a78206227c5bdeb5fd4a2690e3bd896fef265459e82bc1641b5c68a07ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp312-cp312-manylinux_2_27_x86_64.whl

Download URL kintera-2.6.4-cp312-cp312-manylinux_2_27_x86_64.whl
Size 45.3 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
c3c5d25789b0ee5e17e39c81d1fd6c22574f56c2bdf570877ed452ba37ec8af7
BLAKE2b-256 checksum
How to use checksums
8536f401a60856993ffba80822295f9f1eb55d8d4e653fac21396e9c9fc8ff42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp312-cp312-macosx_15_0_arm64.whl

Download URL kintera-2.6.4-cp312-cp312-macosx_15_0_arm64.whl
Size 4.3 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
122b269097fb42c3c79b023bf23af6fe53ef443fa1b05b1d9b551d6827719136
BLAKE2b-256 checksum
How to use checksums
332b3a42f57b6d87250ce80899020db68a5c06aac2bb74e35d51ecf0e366c3dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp311-cp311-manylinux_2_27_x86_64.whl

Download URL kintera-2.6.4-cp311-cp311-manylinux_2_27_x86_64.whl
Size 45.1 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
fcda1068ac2412ba64fa4e1e4b604fd29636fc5cbba9ac39c7d268e92cd0ae64
BLAKE2b-256 checksum
How to use checksums
577fa8a3b031e25eb6b16703c6b117f75767b003b6a90de9ccefb174b152db3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp311-cp311-macosx_15_0_arm64.whl

Download URL kintera-2.6.4-cp311-cp311-macosx_15_0_arm64.whl
Size 4.3 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
e66610841f960f00253c27f0673def57beb651db3acf731fe48f9a53690b7bf2
BLAKE2b-256 checksum
How to use checksums
0f7e31e946219a07744f3962e4c73eac3a9a22266fad0503cfa951bd4a3e17b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp310-cp310-manylinux_2_27_x86_64.whl

Download URL kintera-2.6.4-cp310-cp310-manylinux_2_27_x86_64.whl
Size 45.0 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64
SHA-256 checksum
How to use checksums
2cf3a16dc71ab4ba855f081247ee5251721d92367b95e1eb0107a398e23f9be6
BLAKE2b-256 checksum
How to use checksums
24a5c0350cb9b03cbe184fb950eceb3c67582abcc08a430dfefbace929c81438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / kintera-2.6.4-cp310-cp310-macosx_15_0_arm64.whl

Download URL kintera-2.6.4-cp310-cp310-macosx_15_0_arm64.whl
Size 4.3 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
f2b0850388e4a33744cb0b10b2d8834d98a88f86a35f81ae25f16fc883754abe
BLAKE2b-256 checksum
How to use checksums
fc6c5e25c0b228b7496fb3eab2ea2e383f6ccb1f861651161aa6e0e8c10368e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

2.6.4 This release

8 release files

2.6.2

8 release files

2.6.1

8 release files

2.6.0

8 release files

2.5.13

8 release files

2.5.11

8 release files

2.5.0

8 release files

2.4.8

8 release files

2.4.7

8 release files

2.4.6

8 release files

2.4.5

8 release files

2.4.3

8 release files

2.4.2

6 release files

2.4.1

4 release files

2.4.0

8 release files

2.3.6

8 release files

2.3.5

8 release files

2.3.4

8 release files

2.3.3

8 release files

2.3.2

8 release files

2.3.1

5 release files

2.2.0

8 release files

2.1.1

8 release files

2.1.0

8 release files

1.4.0

8 release files

1.3.2

10 release files

1.3.1

10 release files

1.2.9

10 release files

1.2.7

10 release files

1.2.6

10 release files

1.2.3

10 release files

1.1.1

10 release files

1.1.0

10 release files

1.0.1

10 release files

1.0.0

10 release files

0.9.6

10 release files

0.9.4

5 release files

0.9.3

5 release files

0.9.1

5 release files

0.8.7

10 release files

0.8.6

10 release files

0.8.5

10 release files

0.8.4

10 release files

0.8.3

10 release files

0.8.2

10 release files

0.8.1

10 release files

0.8.0

10 release files

0.7.9

10 release files

0.7.8

10 release files

0.7.7

10 release files

0.7.6

10 release files

0.7.5

10 release files

0.7.4

10 release files

0.7.2

10 release files

0.7.1

10 release files

0.7.0

5 release files

0.5.1

10 release files

0.5.0

10 release files

0.3.0

10 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page