API Reference

This page provides detailed API documentation for all KINTERA classes and functions.

Core Classes

ThermoX

class kintera.ThermoX

Main thermodynamics computation class for equilibrium calculations.

Parameters:

options (ThermoOptions) – Configuration options for thermodynamics

forward(temp: torch.Tensor, pres: torch.Tensor, xfrac: torch.Tensor) None

Compute equilibrium composition at given temperature and pressure. Modifies xfrac in-place.

Parameters:
  • temp – Temperature (K)

  • pres – Pressure (Pa)

  • xfrac – Mole fractions (modified in-place)

compute(mode: str, state: list[torch.Tensor]) torch.Tensor

Convert between different state representations.

Parameters:
  • mode – Conversion mode (e.g., “TPX->V”, “TPV->S”)

  • state – List of state tensors [temp, pres, composition]

Returns:

Computed property tensor

Available modes:

  • "TPX->V": Mole fractions to concentrations

  • "TPV->S": State to entropy

  • "TPV->U": State to internal energy

  • "TPV->H": State to enthalpy

extrapolate_ad(temp: torch.Tensor, pres: torch.Tensor, xfrac: torch.Tensor, *args) None

Perform adiabatic extrapolation.

Using pressure coordinate:

Parameters:
  • temp – Temperature (modified in-place)

  • pres – Pressure (modified in-place)

  • xfrac – Mole fractions (modified in-place)

  • dlnp – Change in log(pressure)

Using height coordinate:

Parameters:
  • temp – Temperature (modified in-place)

  • pres – Pressure (modified in-place)

  • xfrac – Mole fractions (modified in-place)

  • grav – Gravitational acceleration (m/s²)

  • dz – Height increment (m)

get_buffer(name: str) torch.Tensor

Get internal buffer by name.

Parameters:

name – Buffer name (e.g., “stoich”)

Returns:

Buffer tensor

options

The ThermoOptions configuration object.

ThermoY

class kintera.ThermoY

Alternative thermodynamics class (implementation may vary from ThermoX). See ThermoX for method documentation.

Configuration Classes

ThermoOptions

class kintera.ThermoOptions

Configuration options for thermodynamic calculations. Inherits from SpeciesThermo.

__init__() ThermoOptions

Create a new ThermoOptions object.

classmethod from_yaml(filename: str) ThermoOptions

Load configuration from YAML file.

Parameters:

filename – Path to YAML configuration file

Returns:

Configured ThermoOptions object

max_iter(value: int) ThermoOptions

Set maximum number of iterations for solver.

Parameters:

value – Maximum iterations

Returns:

Self for method chaining

ftol(value: float) ThermoOptions

Set convergence tolerance.

Parameters:

value – Tolerance value

Returns:

Self for method chaining

Tref(value: float) ThermoOptions

Set reference temperature.

Parameters:

value – Reference temperature (K)

Returns:

Self for method chaining

Pref(value: float) ThermoOptions

Set reference pressure.

Parameters:

value – Reference pressure (Pa)

Returns:

Self for method chaining

nucleation(value: NucleationOptions) ThermoOptions

Set nucleation/phase transition options.

Parameters:

value – NucleationOptions object

Returns:

Self for method chaining

species() list[str]

Get list of species names.

Returns:

List of species names

SpeciesThermo

class kintera.SpeciesThermo

Base class for species thermodynamic properties.

__init__() SpeciesThermo

Create a new SpeciesThermo object.

species() list[str]

Get the list of species names.

Returns:

List of species names

vapor_ids(value: list[int] = None) list[int] | SpeciesThermo

Get or set vapor species IDs.

Parameters:

value – List of vapor species IDs (optional)

Returns:

List of IDs if no argument, self if setting

cloud_ids(value: list[int] = None) list[int] | SpeciesThermo

Get or set cloud species IDs.

Parameters:

value – List of cloud species IDs (optional)

Returns:

List of IDs if no argument, self if setting

cref_R(value: list[float] = None) list[float] | SpeciesThermo

Get or set specific heat capacity reference values (normalized by R).

Parameters:

value – List of specific heat values (optional)

Returns:

List of values if no argument, self if setting

uref_R(value: list[float] = None) list[float] | SpeciesThermo

Get or set internal energy reference values (normalized by R).

Parameters:

value – List of internal energy values (optional)

Returns:

List of values if no argument, self if setting

sref_R(value: list[float] = None) list[float] | SpeciesThermo

Get or set entropy reference values (normalized by R).

Parameters:

value – List of entropy values (optional)

Returns:

List of values if no argument, self if setting

NucleationOptions

class kintera.NucleationOptions

Configuration for phase transition (nucleation/condensation).

__init__() NucleationOptions

Create a new NucleationOptions object.

reactions(value: list[Reaction]) NucleationOptions

Set phase transition reactions.

Parameters:

value – List of Reaction objects

Returns:

Self for method chaining

minT(value: list[float]) NucleationOptions

Set minimum temperatures for each reaction.

Parameters:

value – List of minimum temperatures (K)

Returns:

Self for method chaining

maxT(value: list[float]) NucleationOptions

Set maximum temperatures for each reaction.

Parameters:

value – List of maximum temperatures (K)

Returns:

Self for method chaining

set_logsvp(models: list[str]) NucleationOptions

Set saturation vapor pressure models.

Parameters:

models – List of model names (e.g., [“h2o_ideal”])

Returns:

Self for method chaining

Reaction Classes

Reaction

class kintera.Reaction

Represents a chemical reaction.

__init__(equation: str = '') Reaction

Create a reaction from equation string.

Parameters:

equation – Chemical equation (e.g., “H2 + O2 => H2O2”)

equation() str

Get the chemical equation.

Returns:

Equation string

reactants(value: dict[str, float] = None) dict[str, float] | Reaction

Get or set reactants with stoichiometric coefficients.

Parameters:

value – Dictionary of reactants (optional)

Returns:

Reactants dict if no argument, self if setting

products(value: dict[str, float] = None) dict[str, float] | Reaction

Get or set products with stoichiometric coefficients.

Parameters:

value – Dictionary of products (optional)

Returns:

Products dict if no argument, self if setting

Kinetics Classes

Kinetics

class kintera.Kinetics

Chemical kinetics solver for time-dependent chemistry.

__init__(options: KineticsOptions) Kinetics

Create kinetics solver with configuration.

Parameters:

options – KineticsOptions object

KineticsOptions

class kintera.KineticsOptions

Configuration for chemical kinetics calculations. Inherits from SpeciesThermo.

ArrheniusOptions

class kintera.ArrheniusOptions

Configuration for Arrhenius rate expressions. Inherits from SpeciesThermo.

Arrhenius

class kintera.Arrhenius

Arrhenius rate constant: k = A * T^b * exp(-Ea/RT)

A(value: float = None) float | Arrhenius

Get or set pre-exponential factor.

Parameters:

value – Pre-exponential factor (optional)

Returns:

Value if no argument, self if setting

b(value: float = None) float | Arrhenius

Get or set temperature exponent.

Parameters:

value – Temperature exponent (optional)

Returns:

Value if no argument, self if setting

Ea(value: float = None) float | Arrhenius

Get or set activation energy.

Parameters:

value – Activation energy in J/mol (optional)

Returns:

Value if no argument, self if setting

CoagulationOptions

class kintera.CoagulationOptions

Configuration for coagulation processes. Inherits from ArrheniusOptions.

Evaporation Classes

Evaporation

class kintera.Evaporation

Evaporation rate calculations.

EvaporationOptions

class kintera.EvaporationOptions

Configuration for evaporation calculations. Inherits from NucleationOptions.

Module-Level Functions

Species Management

kintera.species_names() list[str]

Get current global species names.

Returns:

List of species names

kintera.set_species_names(names: list[str]) list[str]

Set global species names.

Parameters:

names – List of species names

Returns:

Updated list of species names

kintera.species_weights() list[float]

Get current global species molecular weights.

Returns:

List of molecular weights (kg/mol)

kintera.set_species_weights(weights: list[float]) list[float]

Set global species molecular weights.

Parameters:

weights – List of molecular weights (kg/mol)

Returns:

Updated list of molecular weights

kintera.species_cref_R() list[float]

Get global species specific heat capacity reference values.

Returns:

List of cref/R values

kintera.set_species_cref_R(cref_R: list[float]) list[float]

Set global species specific heat capacity reference values.

Parameters:

cref_R – List of cref/R values

Returns:

Updated list

kintera.species_uref_R() list[float]

Get global species internal energy reference values.

Returns:

List of uref/R values

kintera.set_species_uref_R(uref_R: list[float]) list[float]

Set global species internal energy reference values.

Parameters:

uref_R – List of uref/R values

Returns:

Updated list

kintera.species_sref_R() list[float]

Get global species entropy reference values.

Returns:

List of sref/R values

kintera.set_species_sref_R(sref_R: list[float]) list[float]

Set global species entropy reference values.

Parameters:

sref_R – List of sref/R values

Returns:

Updated list

Resource Management

kintera.get_search_paths() str

Get current resource search paths.

Returns:

Colon-separated path string

kintera.set_search_paths(path: str) str

Set resource search paths.

Parameters:

path – Colon-separated path string

Returns:

Updated path string

kintera.add_resource_directory(path: str, prepend: bool = True) str

Add a directory to resource search paths.

Parameters:
  • path – Directory path to add

  • prepend – If True, add to front of search path

Returns:

Updated path string

kintera.find_resource(filename: str) str

Find a resource file in search paths.

Parameters:

filename – Filename to find

Returns:

Full path to resource file

Utility Functions

kintera.relative_humidity(temp: torch.Tensor, conc: torch.Tensor, stoich: torch.Tensor, nucleation: NucleationOptions) torch.Tensor

Calculate relative humidity.

Parameters:
  • temp – Temperature tensor (K)

  • conc – Concentration tensor

  • stoich – Stoichiometry tensor

  • nucleation – NucleationOptions with phase transition info

Returns:

Relative humidity tensor (0-1)

kintera.evolve_implicit(...)

Implicit time evolution for chemical kinetics.

(Parameters depend on specific usage - see source for details)

Constants

class kintera.constants

Physical and chemical constants.

Common constants include:

  • Gas constant

  • Boltzmann constant

  • Avogadro’s number

  • Universal constants used in calculations

Access constants as attributes of this class.

Type Aliases

Composition = dict[str, float]

Dictionary mapping species names to their stoichiometric coefficients or mole fractions.