MICM API#

namespace micm#

Typedefs

using DenseMatrixVector = VectorMatrix<Real, MICM_DEFAULT_VECTOR_SIZE>#
using SparseMatrixVector = SparseMatrix<Real, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
using DenseMatrixStandard = Matrix<Real>#
using SparseMatrixStandard = SparseMatrix<Real, SparseMatrixStandardOrdering>#
using VectorState = State<DenseMatrixVector, SparseMatrixVector>#
using StandardState = State<DenseMatrixStandard, SparseMatrixStandard>#
using RosenbrockVectorType = typename RosenbrockSolverParameters::template SolverType<ProcessSet<DenseMatrixVector, SparseMatrixVector>, LinearSolver<DenseMatrixVector, SparseMatrixVector, LuDecomposition<SparseMatrixVector>>, ConstraintSet<DenseMatrixVector, SparseMatrixVector>>#
using Rosenbrock = Solver<RosenbrockVectorType, State<DenseMatrixVector, SparseMatrixVector>>#
using RosenbrockStandardType = typename RosenbrockSolverParameters::template SolverType<ProcessSet<DenseMatrixStandard, SparseMatrixStandard>, LinearSolver<DenseMatrixStandard, SparseMatrixStandard, LuDecomposition<SparseMatrixStandard>>, ConstraintSet<DenseMatrixStandard, SparseMatrixStandard>>#
using RosenbrockStandard = Solver<RosenbrockStandardType, State<DenseMatrixStandard, SparseMatrixStandard>>#
using BackwardEulerVectorType = typename BackwardEulerSolverParameters::template SolverType<ProcessSet<DenseMatrixVector, SparseMatrixVector>, LinearSolver<DenseMatrixVector, SparseMatrixVector, LuDecomposition<SparseMatrixVector>>, ConstraintSet<DenseMatrixVector, SparseMatrixVector>>#
using BackwardEuler = Solver<BackwardEulerVectorType, State<DenseMatrixVector, SparseMatrixVector>>#
using BackwardEulerStandardType = typename BackwardEulerSolverParameters::template SolverType<ProcessSet<DenseMatrixStandard, SparseMatrixStandard>, LinearSolver<DenseMatrixStandard, SparseMatrixStandard, LuDecomposition<SparseMatrixStandard>>, ConstraintSet<DenseMatrixStandard, SparseMatrixStandard>>#
using BackwardEulerStandard = Solver<BackwardEulerStandardType, State<DenseMatrixStandard, SparseMatrixStandard>>#
using RosenbrockThreeStageBuilder = CpuSolverBuilder<RosenbrockSolverParameters, DenseMatrixVector, SparseMatrixVector>#
using BackwardEulerBuilder = CpuSolverBuilder<BackwardEulerSolverParameters, DenseMatrixVector, SparseMatrixVector, LuDecompositionDoolittle<SparseMatrixVector>>#
template<class SparseMatrixPolicy>
using CudaLuDecomposition = CudaLuDecompositionMozartInPlace<SparseMatrixPolicy>#

Alias for the default CUDA LU decomposition algorithm.

template<class SolverParametersPolicy, Index L = MICM_DEFAULT_VECTOR_SIZE>
using CudaSolverBuilderInPlace = SolverBuilder<SolverParametersPolicy, CudaDenseMatrix<Real, L>, CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, CudaProcessSet<CudaDenseMatrix<Real, L>, CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>, CudaLuDecompositionMozartInPlace<CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>, CudaLinearSolverInPlace<CudaDenseMatrix<Real, L>, CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, CudaLuDecompositionMozartInPlace<CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>>, CudaState<CudaDenseMatrix<Real, L>, CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, CudaLuDecompositionMozartInPlace<CudaSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>>>#

Builder of CUDA-based general solvers.

GPU solvers only work with vector-ordered matrices

Template Parameters:
  • SolverParametersPolicy – Policy for the ODE solver

  • L – Vector size

using CudaDenseMatrixVector = CudaDenseMatrix<Real, MICM_DEFAULT_VECTOR_SIZE>#
using CudaSparseMatrixVector = CudaSparseMatrix<Real, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
using GpuState = CudaState<CudaDenseMatrixVector, CudaSparseMatrixVector, CudaLuDecompositionMozartInPlace<CudaSparseMatrixVector>>#
using CudaRosenbrockVectorType = typename CudaRosenbrockSolverParameters::template SolverType<CudaProcessSet<CudaDenseMatrixVector, CudaSparseMatrixVector>, CudaLinearSolverInPlace<CudaDenseMatrixVector, CudaSparseMatrixVector>, ConstraintSet<CudaDenseMatrixVector, CudaSparseMatrixVector>>#
using CudaRosenbrock = Solver<CudaRosenbrockVectorType, GpuState>#
using GpuRosenbrockThreeStageBuilder = CudaSolverBuilderInPlace<CudaRosenbrockSolverParameters>#
using KokkosDenseReal = KokkosDenseMatrix<Real, MICM_DEFAULT_VECTOR_SIZE>#
using KokkosSparseReal = KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
using KokkosState = State<KokkosDenseReal, KokkosSparseReal, LuDecompositionMozartInPlace<KokkosSparseReal>>#
using KokkosRosenbrockType = typename RosenbrockSolverParameters::template SolverType<ProcessSet<KokkosDenseReal, KokkosSparseReal>, LinearSolverInPlace<KokkosDenseReal, KokkosSparseReal, LuDecompositionMozartInPlace<KokkosSparseReal>>, ConstraintSet<KokkosDenseReal, KokkosSparseReal>>#
using KokkosRosenbrock = Solver<KokkosRosenbrockType, KokkosState>#
using KokkosBackwardEulerType = typename BackwardEulerSolverParameters::template SolverType<ProcessSet<KokkosDenseReal, KokkosSparseReal>, LinearSolverInPlace<KokkosDenseReal, KokkosSparseReal, LuDecompositionMozartInPlace<KokkosSparseReal>>, ConstraintSet<KokkosDenseReal, KokkosSparseReal>>#
using KokkosBackwardEuler = Solver<KokkosBackwardEulerType, KokkosState>#
template<class SolverParametersPolicy, Index L = MICM_DEFAULT_VECTOR_SIZE>
using KokkosSolverBuilder = SolverBuilder<SolverParametersPolicy, KokkosDenseMatrix<Real, L>, KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, ProcessSet<KokkosDenseMatrix<Real, L>, KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>, LuDecompositionMozartInPlace<KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>, LinearSolverInPlace<KokkosDenseMatrix<Real, L>, KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, LuDecompositionMozartInPlace<KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>>, State<KokkosDenseMatrix<Real, L>, KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>, LuDecompositionMozartInPlace<KokkosSparseMatrix<Real, SparseMatrixVectorOrdering<L>>>>>#

Builder of Kokkos-backed solvers.

Template Parameters:
  • SolverParametersPolicy – Policy for the solver parameters struct

  • L – Vector dimension

using RateConstantVariant = std::variant<ArrheniusRateConstantParameters, TroeRateConstantParameters, TernaryChemicalActivationRateConstantParameters, BranchedRateConstantParameters, TunnelingRateConstantParameters, TaylorSeriesRateConstantParameters, ReversibleRateConstantParameters, UserDefinedRateConstantParameters, SurfaceRateConstantParameters, LambdaRateConstantParameters>#

Value-typed union of all supported rate constant parameter types. Stored by value in ChemicalReaction; consumed at store-build time by ReactionRateConstantStore::BuildFrom. Never sent to GPU.

template<class SparseMatrixPolicy>
using LuDecomposition = LuDecompositionDoolittle<SparseMatrixPolicy>#

Alias for the default LU decomposition algorithm.

template<class SparseMatrixPolicy>
using LuDecompositionInPlace = LuDecompositionMozartInPlace<SparseMatrixPolicy>#

Alias for the default in-place LU decomposition algorithm.

template<class SolverParametersPolicy, class DenseMatrixPolicy = Matrix<Real>, class SparseMatrixPolicy = SparseMatrix<Real, SparseMatrixStandardOrdering>, class LuDecompositionPolicy = LuDecomposition<SparseMatrixPolicy>>
using CpuSolverBuilder = SolverBuilder<SolverParametersPolicy, DenseMatrixPolicy, SparseMatrixPolicy, ProcessSet<DenseMatrixPolicy, SparseMatrixPolicy>, LuDecompositionPolicy, LinearSolver<DenseMatrixPolicy, SparseMatrixPolicy, LuDecompositionPolicy>, State<DenseMatrixPolicy, SparseMatrixPolicy, LuDecompositionPolicy>>#

Builder of CPU-based general solvers.

Template Parameters:
  • SolverParametersPolicy – Parameters for the ODE solver

  • DenseMatrixPolicy – Policy for dense matrices

  • SparseMatrixPolicy – Policy for sparse matrices

  • LuDecompositionPolicy – Policy for the LU decomposition

template<class SolverParametersPolicy, class DenseMatrix = Matrix<Real>, class SparseMatrixPolicy = SparseMatrix<Real, SparseMatrixStandardOrdering>, class LuDecompositionPolicy = LuDecompositionInPlace<SparseMatrixPolicy>>
using CpuSolverBuilderInPlace = SolverBuilder<SolverParametersPolicy, DenseMatrix, SparseMatrixPolicy, ProcessSet<DenseMatrix, SparseMatrixPolicy>, LuDecompositionPolicy, LinearSolverInPlace<DenseMatrix, SparseMatrixPolicy, LuDecompositionPolicy>, State<DenseMatrix, SparseMatrixPolicy, LuDecompositionPolicy>>#

Builder of CPU-based general solvers with in-place LU decomposition.

Template Parameters:
  • SolverParametersPolicy – Parameters for the ODE solver

  • DenseMatrixPolicy – Policy for dense matrices

  • SparseMatrixPolicy – Policy for sparse matrices

  • LuDecompositionPolicy – Policy for the LU decomposition

using Yield = StoichSpecies#

Deprecated:

micm::Yield has been renamed to micm::StoichSpecies; please use StoichSpecies instead

using StandardDenseMatrix = Matrix<Real>#
using StandardSparseMatrix = SparseMatrix<Real, SparseMatrixStandardOrdering>#
using SparseMatrixStandardOrdering = SparseMatrixStandardOrderingCompressedSparseRow#

Alias for the default sparse matrix standard ordering.

template<Index L = MICM_DEFAULT_VECTOR_SIZE>
using SparseMatrixVectorOrdering = SparseMatrixVectorOrderingCompressedSparseRow<L>#

Alias for the default sparse matrix vector ordering.

using DefaultVectorSparseMatrix = SparseMatrix<Real, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
using Real = double#
using Index = std::size_t#
using Bool = std::uint8_t#
template<typename T>
using ViewCategory_t = typename ViewCategory<std::remove_cvref_t<T>>::type#

Helper alias.

template<typename T>
using GroupingStrategy_t = typename GroupingStrategy<std::remove_cvref_t<T>>::type#

Helper alias.

Enums

enum class SolverState#

The final state the solver was in after the Solve function finishes.

Values:

enumerator NotYetCalled#

This is the initial value at the start of the Solve function.

enumerator Running#

This is only used for control flow in the Solve function.

enumerator Converged#

A successful integration will have this value.

enumerator ConvergenceExceededMaxSteps#

If the number of steps exceeds the maximum value on the solver parameter, this value will be returned.

enumerator StepSizeTooSmall#

Very stiff systems will likely result in a step size that is not useable for the solver.

enumerator RepeatedlySingularMatrix#

Matrices that are singular more than once will set this value. At present, this should never be returned.

enumerator NaNDetected#

Mostly this value is returned by systems that tend toward chemical explosions.

enumerator InfDetected#

Can happen when unititialized memory is used in the solver.

enumerator AcceptingUnconvergedIntegration#

Used for backward euler. This allows us to “succeed” in the same way that cam-chem does.

enumerator ConstraintInitializationFailed#

Newton iteration to initialize algebraic constraint variables failed to converge.

Functions

template<class FalloffParams> MICM_CONSTEXPR Real FalloffKernel (const FalloffParams &p, Real temperature, Real air_density, Real numerator_scale)

Shared falloff kernel for Troe and TernaryChemicalActivation. result = k0 * numerator_scale / (1 + ratio) * Fc^(N/(N + log10(ratio)^2)) Troe passes air_density as numerator_scale; Ternary passes 1.0.

MICM_CONSTEXPR Real CalculateArrhenius (const ArrheniusRateConstantParameters &p, Real temperature, Real pressure)

Calculate Arrhenius rate constant. k = A * exp(C/T) * (T/D)^B * (1 + E*P).

MICM_CONSTEXPR Real CalculateTroe (const TroeRateConstantParameters &p, Real temperature, Real air_density)

Calculate Troe rate constant.

MICM_CONSTEXPR Real CalculateTernaryChemicalActivation (const TernaryChemicalActivationRateConstantParameters &p, Real temperature, Real air_density)

Calculate Ternary Chemical Activation rate constant.

MICM_CONSTEXPR Real CalculateTunneling (const TunnelingRateConstantParameters &p, Real temperature)

Calculate Tunneling rate constant. k = A * exp(-B/T + C/T^3).

MICM_CONSTEXPR Real CalculateBranched (const BranchedRateConstantParameters &p, Real temperature, Real air_density)

Calculate Branched rate constant. Requires p.k0_ and p.z_ to be precomputed by ReactionRateConstantStore::BuildFrom.

MICM_CONSTEXPR Real CalculateTaylorSeries (const TaylorSeriesRateConstantParameters &p, Real temperature, Real pressure)

Calculate Taylor Series rate constant. k = (sum_{j=0}^{n-1} c_j * T^j) * A * exp(C/T) * (T/D)^B * (1 + E*P).

MICM_CONSTEXPR Real CalculateReversible (const ReversibleRateConstantParameters &p, Real temperature)

Calculate Reversible rate constant. k = A * exp(C/T) * k_r.

MICM_CONSTEXPR Real CalculateUserDefined (const UserDefinedRateConstantData &p, Real custom_param_value)

Calculate user-defined rate constant. k = custom_param_value * scaling_factor.

MICM_CONSTEXPR Real CalculateSurfaceOne (const SurfaceRateConstantData &p, Real temperature, Real radius, Real num_conc)

Calculate one surface rate constant given pre-fetched aerosol parameters.

Parameters:
  • radius – Aerosol effective radius [m]

  • num_conc – Particle number concentration [# m-3]

template<template<class> class MatrixPolicy>
std::vector<Index> DiagonalMarkowitzReorder(const MatrixPolicy<int> &matrix)#

Reorders a set of state variables using Diagonal Markowitz algorithm.

Parameters:

matrix – Original matrix non-zero elements

Returns:

Reordered mapping vector (reordered[i] = original[map[i]])

template<class MatrixPolicy>
inline std::vector<Index> DiagonalMarkowitzReorder(const MatrixPolicy &matrix)#
inline std::string SolverStateToString(const SolverState &state)#
template<class SparseMatrixPolicy>
SparseMatrixPolicy BuildJacobian(const std::set<std::pair<Index, Index>> &nonzero_jacobian_elements, Index number_of_grid_cells, Index state_size, bool indexing_only)#
template<class DenseMatrixPolicy, class ForcingFunc>
DenseMatrixPolicy FiniteDifferenceJacobian(ForcingFunc forcing_func, const DenseMatrixPolicy &base_variables, Index num_species, Real perturbation = std::is_same_v<Real, double> ? static_cast<Real>(1.0e-8) : static_cast<Real>(1.0e-3))#

Compute a dense finite-difference Jacobian approximation using central differences.

The forcing callable should have the signature: void(const DenseMatrixPolicy& variables, DenseMatrixPolicy& forcing) where variables has shape [num_blocks x num_species] and forcing has the same shape. Callers should bind any additional arguments (rate constants, state parameters, etc.) into the callable via a lambda capture.

Returns a DenseMatrixPolicy of shape [num_blocks x (num_species * num_species)] where element [block][row * num_species + col] = df_row/dx_col.

When a perturbation would push a variable below zero, one-sided differences are used instead.

template<class DenseMatrixPolicy, class SparseMatrixPolicy>
JacobianComparisonResult CompareJacobianToFiniteDifference(const SparseMatrixPolicy &analytical_jacobian, const DenseMatrixPolicy &fd_jacobian, Index num_species, Real atol = std::is_same_v<Real, double> ? static_cast<Real>(1.0e-7) : static_cast<Real>(1.0e-2), Real rtol = std::is_same_v<Real, double> ? static_cast<Real>(1.0e-7) : static_cast<Real>(1.0e-2))#

Compare an analytical sparse Jacobian (which stores -df/dx per MICM convention) against a finite-difference dense Jacobian (which stores +df/dx).

Uses a combined tolerance: |analytical - fd| < atol + rtol * max(|analytical|, |fd|)

Only non-zero elements in the sparse Jacobian are compared.

template<class DenseMatrixPolicy, class SparseMatrixPolicy>
JacobianComparisonResult CheckJacobianSparsityCompleteness(const SparseMatrixPolicy &analytical_jacobian, const DenseMatrixPolicy &fd_jacobian, Index num_species, Real threshold = std::is_same_v<Real, double> ? static_cast<Real>(1.0e-6) : static_cast<Real>(1.0e-2))#

Check that no significant Jacobian entry exists outside the declared sparsity pattern.

This catches missing NonZeroJacobianElements declarations. Any FD entry outside the sparsity pattern that exceeds the threshold indicates an undeclared dependency.

inline std::string GenerateRandomString()#
template<typename T>
Sum(T&) -> Sum<T>#
template<typename Scalar>
Sum(const Scalar&) -> Sum<typename Scalar::value_type>#
template<typename T>
Max(T&) -> Max<T>#
template<typename Scalar>
Max(const Scalar&) -> Max<typename Scalar::value_type>#
template<class MatrixPolicy>
void CheckCopyToDevice(MatrixPolicy &matrix)#
template<class MatrixPolicy>
void CheckCopyToHost(MatrixPolicy &matrix)#

Variables

template<typename T>
constexpr Index GROUP_VECTOR_SIZE_V = GroupVectorSize<T>::value#

Helper variable template.

template<class RatesPolicy, class LinearSolverPolicy, class ConstraintSetPolicy>
class AbstractBackwardEuler#
#include <micm/solver/backward_euler.hpp>

An implementation of the fully implicit backward euler method.

Public Types

using ParametersType = BackwardEulerSolverParameters#

Solver parameters typename.

Public Functions

inline AbstractBackwardEuler(LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, ConstraintSetPolicy &&constraints)#

Default constructor.

Parameters:
  • linear_solver – Linear solver

  • rates – Rates calculator

  • constraints – Algebraic constraints (not used by BackwardEuler, for API compatibility)

inline SolverResult Solve(Real time_step, StatePolicy &state, const BackwardEulerSolverParameters &parameters) const#

Advances the given step over the specified time step.

Parameters:
  • time_step – Time [s] to advance the state by

  • state – The state to advance

Returns:

result of the solver (success or failure, and statistics)

Public Static Functions

template<class DenseMatrixPolicy>
static inline void IsConverged(const BackwardEulerSolverParameters &parameters, const DenseMatrixPolicy &residual, const DenseMatrixPolicy &Yn1, const typename DenseMatrixPolicy::template VectorType<Real>::ConstViewType &absolute_tolerance, const Real relative_tolerance, typename DenseMatrixPolicy::template ScalarType<Bool> &is_converged)#

Determines whether the residual is small enough to stop the internal solver iteration.

Parameters:
  • residual – The residual to check

  • state – The current state being solved for

Returns:

true if the residual is small enough to stop the iteration

template<class RatesPolicy, class LinearSolverPolicy, class ConstraintSetPolicy, class Derived>
class AbstractRosenbrockSolver#
#include <micm/solver/rosenbrock.hpp>

An implementation of the Rosenbrock ODE solver.

This implements the Curiously Recurring Template Pattern to allow the AlphaMinusJacobian and NormalizedError functions to be implemented in extending classes and called from the base class Solve() function. https://en.cppreference.com/w/cpp/language/crtp

Template Parameters:
  • RatesPolicy – Calculator of forcing and Jacobian terms

  • LinearSolverPolicy – Linear solver

  • ConstraintSetPolicy – Constraint set for algebraic constraints

  • Derived – Implementation of the Rosenbock solver

Public Types

using ParametersType = RosenbrockSolverParameters#

Solver parameters typename.

Public Functions

inline AbstractRosenbrockSolver(LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, ConstraintSetPolicy &&constraints)#

Default constructor.

Parameters:
  • linear_solver – Linear solver

  • rates – Rates calculator

  • constraints – Algebraic constraints Note: This constructor is not intended to be used directly. Instead, use the SolverBuilder to create a solver

template<class StatePolicy>
inline SolverResult Solve(Real time_step, StatePolicy &state, const RosenbrockSolverParameters &parameters) const noexcept#

Advances the given step over the specified time step.

Parameters:

time_step – Time [s] to advance the state by

Returns:

A struct containing results and a status code

template<class StatePolicy>
inline SolverState InitializeConstraints(StatePolicy &state, const RosenbrockSolverParameters &parameters, SolverStats &stats) const noexcept#

Newton-iterate algebraic variables to satisfy G(y) = 0 before time integration.

Parameters:
  • state – The solver state

  • parameters – Solver parameters (provides max iterations and tolerance)

  • stats – Solver stats to update with iteration counts

Returns:

SolverState::Converged on success, or an error state on failure

template<class SparseMatrixPolicy, class StatePolicy>
inline void AlphaMinusJacobian(StatePolicy &state, const Real &alpha) const#

compute [alpha * I - dforce_dy]

Parameters:
  • jacobian – Jacobian matrix (dforce_dy)

  • alpha –

template<class StatePolicy>
inline void LinearFactor(const Real alpha, SolverStats &stats, StatePolicy &state) const#

Perform the LU decomposition of the matrix.

Parameters:
  • alpha – The alpha value

  • number_densities – The number densities

  • stats – The solver stats

  • state – The state

template<class DenseMatrixPolicy, class StatePolicy>
inline void NormalizedError(const DenseMatrixPolicy &y, const DenseMatrixPolicy &Ynew, const DenseMatrixPolicy &errors, const StatePolicy &state, typename DenseMatrixPolicy::template ScalarType<Real> &error) const#

Computes the scaled norm of the vector errors.

Parameters:
  • y – the original vector

  • y_new – the new vector

  • errors – The computed errors

Returns:

struct ArrheniusRateConstantParameters#

Public Members

Real A_ = {1}#

Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1].

Real B_ = {0}#

Unitless exponential factor.

Real C_ = {0}#

Activation threshold, expected to be the negative activation energy divided by the boltzman constant [-E_a / k_b), K].

Real D_ = {300}#

A factor that determines temperature dependence [K].

Real E_ = {0}#

A factor that determines pressure dependence [Pa-1].

struct BackwardEulerSolverParameters#
#include <micm/solver/backward_euler_solver_parameters.hpp>

Backward Euler solver parameters.

template<class DenseMatrixPolicy>
class BackwardEulerTemporaryVariables : public micm::TemporaryVariables#

Public Functions

inline virtual std::unique_ptr<TemporaryVariables> Clone() const override#

Clone this object, preserving the derived type.

struct BlockVariableTag#
#include <micm/util/view_category.hpp>

Tag for block variables (vector-like data holders).

struct BranchedRateConstantParameters#

Public Members

Branch branch_#

reaction branch

Real X_#

pre-exponential factor

Real Y_#

exponential factor

Real a0_#

branching factor

Index n_#

number of heavy atoms in the RO2 reacting species (excluding the peroxy moiety)

Real k0_ = {0.0}#

Precomputed low-pressure rate factor: 2e-22 * N_A * 1e-6 * exp(n_) Set by ReactionRateConstantStore::BuildFrom; do not set manually.

Real z_ = {0.0}#

Precomputed branching ratio factor: A(293, [M]_ref) * (1 - a0_) / a0_ Set by ReactionRateConstantStore::BuildFrom; do not set manually.

class ChemicalReaction#
#include <micm/process/chemical_reaction.hpp>

Represents a chemical reaction with reactants, products, rate constant and phase.

class ChemicalReactionBuilder#

Public Functions

inline ChemicalReactionBuilder &SetReactants(const std::vector<Species> &reactants)#

Sets the list of reactant species involved in the chemical reaction.

Parameters:

reactants – A list of Species objects representing the reactants

Returns:

Reference to the builder

inline ChemicalReactionBuilder &SetProducts(const std::vector<StoichSpecies> &products)#

Sets the list of product species and their yields for the chemical reaction.

Parameters:

products – A list of StoichSpecies objects representing the products

Returns:

Reference to the builder

template<class T>
inline ChemicalReactionBuilder &SetRateConstant(T &&rate_constant)#

Sets the rate constant from any supported parameter struct. Accepts any type that is a member of RateConstantVariant.

Parameters:

rate_constant – Parameter struct (e.g. ArrheniusRateConstantParameters)

Returns:

Reference to the builder

inline ChemicalReactionBuilder &SetPhase(const Phase &phase)#

Sets the phase in which the chemical reaction occurs (e.g., gas, aqueous).

Parameters:

phase – Phase object representing the reaction phase

Returns:

Reference to the builder

inline Process Build()#

Transfers ownership of all internally stored data into a ChemicalReaction, then wraps it into a Process using std::variant.

Throws:

MicmException – if the rate constant has not been set

Returns:

A Process containing the constructed ChemicalReaction

struct Conditions#
#include <micm/system/conditions.hpp>

Environemental conditions.

template<class DenseMatrixPolicy, class SparseMatrixPolicy>
class Constraint#
#include <micm/constraint/constraint.hpp>

This class uses std::variant to hold different constraint types. Each constraint provides:

  • A residual function G(y) that should equal zero when the constraint is satisfied

  • Jacobian entries dG/dy for each species the constraint depends on

Public Functions

inline std::string GetName() const#

Get the constraint name.

Returns:

Constraint name

inline std::vector<std::string> GetParameterNames() const#

Get the custom parameter names.

Returns:

A set of parameter names

inline const std::string &AlgebraicSpecies() const#

Returns the species whose state row should be replaced by this algebraic constraint.

Returns:

Algebraic species name

inline const std::vector<std::string> &SpeciesDependencies() const#

Get species dependencies.

Returns:

Vector of species names this constraint depends on

inline Index NumberOfDependencies() const#

Get the number of species this constraint depends on.

Returns:

Number of dependent species

inline void ApplyConstraintParameter(const ConstraintInfo &info, const typename DenseMatrixPolicy::template VectorType<Conditions> &conditions, DenseMatrixPolicy &state_param) const#

Apply constraint parameter update for all grid cells (e.g., temperature-dependent K_eq) Called directly from ConstraintSet::UpdateStateParameters.

inline void AddResidual(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, DenseMatrixPolicy &forcing) const#

Add constraint residual G to forcing vector for all grid cells Called directly from ConstraintSet::AddForcingTerms.

inline void SubtractJacobian(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, SparseMatrixPolicy &jacobian) const#

Subtract Jacobian partial derivatives from Jacobian matrix for all grid cells Called directly from ConstraintSet::SubtractJacobianTerms.

template<class InnerConstraints, class ...ExternalModels>
class ConstraintBundle#
#include <micm/solver/external_model_dispatcher.hpp>

Wraps an inner constraint set and a shared tuple of concrete external models.

Only models that both satisfy HasConstraints AND report a non-empty algebraic-variable set at build time contribute at solve time. The active_ mask is populated by the builder so runtime-configurable models (that opt out via empty names) are cheaply skipped.

Public Functions

inline Index Size() const#

Number of algebraic constraint rows (built-in + active external models).

template<class DenseMatrixPolicy>
inline void InitializeConstraintParameters(const DenseMatrixPolicy &state_variables, DenseMatrixPolicy &state_parameters) const#

Diagnose constraint parameters from state at the start of each Solve().

struct ConstraintInfo#
#include <micm/constraint/constraint_info.hpp>

Information for each constraint (built during ConstraintSet construction).

template<typename DenseMatrixPolicy, typename SparseMatrixPolicy>
class ConstraintSet#
#include <micm/constraint/constraint_set.hpp>

Manages a collection of algebraic constraints for DAE solvers ConstraintSet handles the computation of constraint residuals (forcing terms) and Jacobian contributions for a set of constraints. It follows the same pattern as ProcessSet for integration with the Rosenbrock solver.

Public Functions

ConstraintSet() = default#

Default constructor.

inline ConstraintSet(std::vector<Constraint<DenseMatrixPolicy, SparseMatrixPolicy>> &&constraints, const std::unordered_map<std::string, Index> &variable_map)#

Construct a ConstraintSet from constraints and variable mapping Constraints replace selected species rows in the state/Jacobian (DAE formulation).

Parameters:
  • constraints – Vector of constraints

  • variable_map – Map from species names to state variable indices

ConstraintSet(ConstraintSet &&other) noexcept = default#

Move constructor - default implementation.

ConstraintSet &operator=(ConstraintSet &&other) noexcept = default#

Move assignment operator.

ConstraintSet(const ConstraintSet&) = default#

Copy constructor.

ConstraintSet &operator=(const ConstraintSet&) = default#

Copy assignment.

inline Index Size() const#

Get the number of constraints.

inline const std::set<Index> &AlgebraicVariableIds() const#

Returns species ids whose rows are algebraic when constraints replace state rows.

Returns:

Set of variable ids for algebraic rows

inline void SetUniqueParameterNames()#

Deduplicates parameter names across all constraints in the set Ensures all constraint parameters have globally unique names by appending numeric suffixes (_1, _2, etc.) to duplicates. This should be called immediately after construction so that parameter names are finalized before the solver builder creates the parameter map. This logic is not part of the constructor because it mutates the constraint parameters, which is considered beyond the scope of construction.

inline std::unordered_set<std::string> GetParameterNames() const#

Returns all unique parameter names from all constraints in the set.

Returns:

Set of parameter names

inline void AddForcingTerms(const DenseMatrixPolicy &state_variables, const DenseMatrixPolicy &state_parameters, DenseMatrixPolicy &forcing) const#

Add constraint residuals to forcing vector (constraint rows) For each constraint G_i, writes or adds G_i(x) to forcing[constraint_row].

Parameters:
  • state_variables – Current species concentrations (grid cell, species)

  • state_parameters – Current state parameters (grid cell, parameter) - e.g., temperature-dependent K_eq values

  • forcing – Forcing terms (grid cell, state variable) - constraint rows will be modified

inline void SubtractJacobianTerms(const DenseMatrixPolicy &state_variables, const DenseMatrixPolicy &state_parameters, SparseMatrixPolicy &jacobian) const#

Subtract constraint Jacobian terms from Jacobian matrix For each constraint G_i, subtracts dG_i/dx_j from jacobian[constraint_row, j] (Subtraction matches the convention used by ProcessSet).

Parameters:
  • state_variables – Current species concentrations (grid cell, species)

  • state_parameters – Current state parameters (grid cell, parameter) - e.g., temperature-dependent K_eq values

  • jacobian – Sparse Jacobian matrix (grid cell, row, column)

inline void SetAlgebraicErrors(DenseMatrixPolicy &Yerror, const DenseMatrixPolicy &Y, const DenseMatrixPolicy &Ynew) const#

Set algebraic variable error estimates using step changes For each algebraic variable a: Yerror[a] = Ynew[a] - Y[a].

Parameters:
  • Yerror – Error vector — algebraic entries are overwritten with step changes

  • Y – State at beginning of step

  • Ynew – Proposed state at end of step (after constraint enforcement)

inline std::set<std::pair<Index, Index>> NonZeroJacobianElements() const#

Returns positions of all non-zero Jacobian elements for constraint rows.

Returns:

Set of (row, column) index pairs

template<typename OrderingPolicy>
inline void SetJacobianFlatIds(const SparseMatrix<Real, OrderingPolicy> &matrix)#

Computes and stores flat indices for Jacobian elements.

Parameters:

matrix – The sparse Jacobian matrix

inline void SetConstraintFunctions(const auto &state_parameter_indices)#

Sets up constraint indices and Jacobian metadata for direct-call execution. Must be called after SetJacobianFlatIds and before solver execution.

Parameters:

state_parameter_indices – Map from parameter names to state parameter indices

inline void UpdateStateParameters(const typename DenseMatrixPolicy::template VectorType<Conditions> &conditions, DenseMatrixPolicy &state_param) const#

Apply constraint parameter updates for all grid cells (e.g., temperature-dependent K_eq). Called directly from the solver’s UpdateStateParameters pipeline.

Parameters:
  • conditions – Per-grid-cell atmospheric conditions

  • state_param – State parameter matrix to update

inline void AddExternalAlgebraicVariableIds(const std::set<Index> &ids)#

Extend the algebraic variable set with rows contributed by external models. Called by SolverBuilder after collecting external algebraic-variable IDs so that Yerror handling covers external algebraic rows as well.

inline void FinalizeAlgebraicErrorFunction()#

Rebuilds the algebraic-variable id view used by SetAlgebraicErrors. Call after any external algebraic ids have been merged in.

template<class T, Index L = MICM_DEFAULT_VECTOR_SIZE>
class CudaDenseMatrix : public micm::VectorMatrix<T, MICM_DEFAULT_VECTOR_SIZE>#

Public Functions

inline void Axpy(const Real alpha, const CudaDenseMatrix<T, L> &x)#

For each element in the VectorMatrix x and y, perform y = alpha * x + y, where alpha is a scalar constant.

Parameters:
Returns:

0 if successful, otherwise an error code

inline void Max(const T x)#

For each element of the VectorMatrix, perform y = max(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline void Min(const T x)#

For each element of the VectorMatrix, perform y = min(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline void Fill(T val)#

Set every matrix element to a given value on the GPU.

Parameters:

val – Value to set each element to

template<class MatrixPolicy, class SparseMatrixPolicy, class LuDecompositionPolicy = CudaLuDecompositionMozartInPlace<SparseMatrixPolicy>>
class CudaLinearSolverInPlace : public micm::LinearSolverInPlace<MatrixPolicy, SparseMatrixPolicy, CudaLuDecompositionMozartInPlace<SparseMatrixPolicy>>#

Public Functions

CudaLinearSolverInPlace() = default#

This is the default constructor, taking no arguments;.

inline CudaLinearSolverInPlace(const SparseMatrixPolicy &matrix, typename SparseMatrixPolicy::value_type initial_value)#

This constructor takes two arguments: a sparse matrix and its values The base class here takes three arguments: the third argument is a lamda function that creates an instance of LuDecompositionPolicy; in this case, we will use the CudaLuDecompositionInPlace specified at line 13; See line 17 of “linear_solver_in_place.inl” for more details about how this lamda function works;

inline ~CudaLinearSolverInPlace()#

This is the destructor that will free the device memory of the constant data from the class “CudaLinearSolverInPlace”

Public Members

LinearSolverInPlaceParam devstruct_#

This is an instance of struct “LinearSolverInPlaceParam” that holds the constant data of “CudaLinearSolverInPlace” class on the device

template<class SparseMatrixPolicy>
class CudaLuDecompositionMozartInPlace : public micm::LuDecompositionMozartInPlace<SparseMatrixPolicy>#
#include <micm/cuda/solver/cuda_lu_decomposition_mozart_in_place.hpp>

This CudaLuDecompositionMozartInPlace class inherits everything from the base class “LuDecompositionMozartInPlace”.

Public Functions

CudaLuDecompositionMozartInPlace() = default#

This is the default constructor, taking no arguments;.

inline CudaLuDecompositionMozartInPlace(const SparseMatrixPolicy &matrix)#

This is the overloaded constructor that takes one argument called “matrix”; We need to specify the type (e.g., double, int, etc) and ordering (e.g., vector-stored, non-vector-stored, etc) of the “matrix”;

inline ~CudaLuDecompositionMozartInPlace()#

This is destructor that will free the device memory of the constant data from the class “CudaLuDecompositionMozartInPlace”

inline void Decompose(SparseMatrixPolicy &ALU) const#

This is the function to perform an LU decomposition on a given A matrix on the GPU.

Parameters:

ALU – Sparse matrix to decompose (will be overwritten with L and U matrices)

Public Members

LuDecomposeMozartInPlaceParam devstruct_#

This is an instance of struct “LuDecomposeMozartInPlaceParam” that holds the constant data of “CudaLuDecompositionMozartInPlace” class on the device

Public Static Functions

static inline CudaLuDecompositionMozartInPlace Create(const SparseMatrixPolicy &matrix)#

Create an LU decomposition algorithm for a given sparse matrix policy.

Parameters:

matrix – Sparse matrix

template<typename DenseMatrixPolicy, typename SparseMatrixPolicy>
class CudaProcessSet : public micm::ProcessSet<DenseMatrixPolicy, SparseMatrixPolicy>#
#include <micm/cuda/process/cuda_process_set.hpp>

A GPU-based implementation of ProcessSet.

Template Parameters:
  • DenseMatrixPolicy – Policy for dense matrices (must satisfy CudaMatrix concept)

  • SparseMatrixPolicy – Policy for sparse matrices (must satisfy CudaMatrix concept)

Public Functions

inline CudaProcessSet(const std::vector<Process> &processes, const std::unordered_map<std::string, Index> &variable_map)#

Create a process set calculator for a given set of processes.

Parameters:
  • processes – Processes to create calculator for

  • variable_map – A mapping of species names to concentration index

inline void BuildCudaStore(const ReactionRateConstantStore<DenseMatrixPolicy> &cpu_store)#

Upload all analytic parameter arrays from cpu_store to device memory. Called once by Solver after ReactionRateConstantStore is built.

template<class StatePolicy>
inline void GpuCalculateRateConstants(const ReactionRateConstantStore<DenseMatrixPolicy> &cpu_store, StatePolicy &state)#

GPU-accelerated rate constant calculation.

  1. Evaluate any lambda entries on CPU; upload rate_constants_ to device.

  2. Upload conditions and custom_rate_parameters_ to device.

  3. Evaluate parameterized multipliers on CPU; pack and upload to device.

  4. Launch CalculateRateConstantsKernel to fill analytic slots and apply multipliers.

After this call, device rate_constants_ is fully populated for the current step.

inline void SetJacobianFlatIds(const SparseMatrixPolicy &matrix)#

Set the indexes for the elements of Jacobian matrix before we could copy it to the device;.

this will override the “SetJacobianFlatIds” function from the “ProcessSet” class

Parameters:

matrix –

inline void SetAlgebraicVariableIds(const std::set<Index> &variable_ids)#

Marks species rows that should be treated as algebraic (constraints replace ODE rows). Updates algebraic variable IDs after ProcessSetParam construction. If algebraic variable IDs are not set post-construction, then this function may not be necessary.

Parameters:

variable_ids – Set of variable ids whose forcing/Jacobian rows should not receive kinetic contributions

Public Members

ProcessSetParam devstruct_#

This is an instance of struct “ProcessSetParam” that holds the constant data of “ProcessSet” class on the device

CudaReactionRateStore<DenseMatrixPolicy> cuda_rate_store_#

GPU-resident analytic rate constant parameter store (built once per solver build).

template<class DenseMatrixPolicy>
class CudaReactionRateStore#
#include <micm/cuda/process/cuda_reaction_rate_store.hpp>

GPU-resident mirror of ReactionRateConstantStore analytic data.

Constructed once per solver build; never modified during a run. The device conditions buffer grows on demand (amortised allocation).

Public Functions

inline void BuildFrom(const auto &cpu_store)#

Upload all analytic parameter arrays from cpu_store to device memory.

   Called once after the ReactionRateConstantStore is built in Solver's constructor.
   Any previous device allocations are freed before re-uploading.
inline const Real *UploadMultiplierValues(const auto &cpu_store, const auto &conditions, Index L)#

Evaluate parameterized multipliers on CPU, pack into interleaved layout, and upload. Layout: [group * n_mults * L + mult * L + lane].

Returns:

Device pointer to multiplier values, or nullptr if there are no multipliers.

inline const Conditions *UploadConditions(const auto &conditions)#

Upload the current conditions array to device, growing the buffer if needed.

Returns:

Device pointer valid until the next call to UploadConditions.

template<class RatesPolicy, class LinearSolverPolicy, class ConstraintSetPolicy>
class CudaRosenbrockSolver : public micm::AbstractRosenbrockSolver<RatesPolicy, LinearSolverPolicy, ConstraintSetPolicy, CudaRosenbrockSolver<RatesPolicy, LinearSolverPolicy, ConstraintSetPolicy>>#

Public Types

using ParametersType = CudaRosenbrockSolverParameters#

Default constructor.

Solver parameters typename

Public Functions

CudaRosenbrockSolver() = default#

Default constructor.

inline CudaRosenbrockSolver(LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, ConstraintSetPolicy &&constraints)#

Builds a CUDA Rosenbrock solver for the given system and solver parameters.

Parameters:
  • linear_solver – Linear solver

  • rates – Rates calculator

  • constraints – Algebraic constraints

~CudaRosenbrockSolver() = default#

This is the destructor that will free the device memory of the constant data from the class “CudaRosenbrockSolver”

template<class SparseMatrixPolicy>
inline void AlphaMinusJacobian(auto &state, const Real &alpha) const#

Computes [alpha * I - jacobian] on the GPU.

Template Parameters:

SparseMatrixPolicy –

Parameters:
  • jacobian – Jacobian matrix

  • jacobian_diagonal_elements – Diagonal elements of the Jacobian matrix, not used

  • alpha –

template<class DenseMatrixPolicy>
inline void NormalizedError(const DenseMatrixPolicy &y_old, const DenseMatrixPolicy &y_new, const DenseMatrixPolicy &errors, auto &state, typename DenseMatrixPolicy::template ScalarType<Real> &error) const#

Computes the scaled norm of the vector errors on the GPU; assume all the data are GPU resident already.

Template Parameters:

DenseMatrixPolicy –

Parameters:
  • y_old – the original vector

  • y_new – the new vector

  • errors – The computed errors

Returns:

The scaled norm of the errors

struct CudaRosenbrockSolverParameters : public micm::RosenbrockSolverParameters#
#include <micm/cuda/solver/cuda_solver_parameters.hpp>

Parameters for the CUDA Rosenbrock solver.

Public Functions

inline CudaRosenbrockSolverParameters(const RosenbrockSolverParameters &base)#

Constructor from base class.

Parameters:

base –

template<class T, class OrderingPolicy>
class CudaSparseMatrix : public micm::SparseMatrix<T, OrderingPolicy>#

Public Functions

inline void Fill(T val)#

Set every matrix element to a given value on the GPU.

Parameters:

val – Value to set each element to

template<class DenseMatrixPolicy, class SparseMatrixPolicy, class LuDecompositionPolicy>
struct CudaState : public micm::State<DenseMatrixPolicy, SparseMatrixPolicy, LuDecompositionPolicy>#
#include <micm/cuda/solver/cuda_state.hpp>

Construct a state variable for CUDA tests.

Public Functions

inline CudaState(const StateParameters &parameters, const Index number_of_grid_cells)#

Constructor which takes the state dimension information as input.

Parameters:
  • parameters – State dimension information

  • number_of_grid_cells – Number of grid cells

inline CudaState(CudaState &&other) noexcept#

Move constructor.

inline CudaState &operator=(CudaState &&other) noexcept#

Move assignment operator.

inline virtual void SetAbsoluteTolerances(const std::vector<Real> &absolute_tolerances) override#

Set the absolute tolerances per species.

Parameters:

absoluteTolerance – absolute tolerance

inline void SyncInputsToDevice()#

Copy input variables to the device.

   Rate constants are NOT copied here; they are computed directly on the
   GPU by Solver::UpdateStateParameters (via CudaProcessSet::GpuCalculateRateConstants).
inline void SyncOutputsToHost()#

Copy output variables to the host.

struct DenseMatrixColumnViewTag#
#include <micm/util/view_category.hpp>

Tag for dense matrix column views (have ColumnIndex + GetMatrix).

template<class DenseMatrixPolicy, class SparseMatrixPolicy>
class EquilibriumConstraint#
#include <micm/constraint/types/equilibrium_constraint.hpp>

Constraint for chemical equilibrium with temperature-dependent K_eq using Van’t Hoff equation For a reversible reaction: aA + bB <-> cC + dD The equilibrium constraint is: G = K_eq(T) * [A]^a * [B]^b - [C]^c * [D]^d = 0 where K_eq(T) = K_HLC_ref * exp((delta_H / R) * (1/T - 1/T_ref)).

Public Functions

EquilibriumConstraint() = default#

Default constructor.

inline EquilibriumConstraint(const std::string &name, const Species &algebraic_species, std::vector<StoichSpecies> reactants, std::vector<StoichSpecies> products, VantHoffParam vant_hoff_param)#

Construct an equilibrium constraint. Validates that equilibrium constraint > 0. Builds species_dependencies_ by concatenating reactants then products. Stores index mappings for efficient Jacobian computation. Stores a temperature-dependent equilibrium constant function.

Parameters:
  • name – Constraint identifier

  • algebraic_species – Species whose row is replaced by this algebraic constraint

  • reactants – Vector of StoichSpecies (species, stoichiometry) for reactants

  • products – Vector of StoichSpecies (species, stoichiometry) for products

  • vant_hoff_param – Parameters for Van’t Hoff equation

inline const std::string &AlgebraicSpecies() const#

Returns the species whose row should be replaced by this algebraic constraint.

Returns:

Species name of the explicitly set algebraic variable

inline void ApplyConstraintParameter(const ConstraintInfo &info, const typename DenseMatrixPolicy::template VectorType<Conditions> &conditions, DenseMatrixPolicy &state_param) const#

Apply temperature-dependent K_eq parameter update for each grid cell Computes K_eq(T) using the Van’t Hoff equation and writes to state_param[K_eq_idx]. Called directly from ConstraintSet::UpdateStateParameters before each solve.

Parameters:
  • info – Constraint information including state parameter indices

  • conditions – Per-grid-cell atmospheric conditions (temperature, pressure, etc.)

  • state_param – State parameter matrix to update

inline void AddResidual(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, DenseMatrixPolicy &forcing) const#

Create function object to compute equilibrium constraint residual for all grid cells Computes G = K_eq(T) * prod([reactants]^stoich) - prod([products]^stoich) for the algebraic constraint Called during solver build (SetConstraintFunctions) to pre-compile residual computation.

Add equilibrium constraint residual G to forcing vector for all grid cells Computes G = K_eq(T) * prod([reactants]^stoich) - prod([products]^stoich) Called directly from ConstraintSet::AddForcingTerms.

Parameters:
  • info – Constraint information including row index, species indices, and parameter indices

  • info – Constraint information including row index and parameter indices

  • state – Current species concentrations

  • state_param – Current state parameters (contains K_eq column)

  • forcing – Forcing terms — constraint row is overwritten with residual G

inline void SubtractJacobian(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, SparseMatrixPolicy &jacobian) const#

Subtract Jacobian partial derivatives dG/d[species] from Jacobian matrix for all grid cells Called directly from ConstraintSet::SubtractJacobianTerms.

Parameters:
  • info – Constraint information including row index and parameter indices

  • state – Current species concentrations

  • state_param – Current state parameters (contains K_eq column)

  • jacobian – Sparse Jacobian matrix to update

Public Members

std::string name_#

Name of the constraint, used when generating state parameter name.

Species algebraic_species_#

Algebraic species.

std::vector<std::string> species_dependencies_#

Names of species this constraint depends on.

std::vector<StoichSpecies> reactants_#

Reactant species and their stoichiometric coefficients.

std::vector<StoichSpecies> products_#

Product species and their stoichiometric coefficients.

std::vector<std::string> parameters_#

For equilibrium constraints, this contains a single parameter K_eq.

struct VantHoffParam#
#include <micm/constraint/types/equilibrium_constraint.hpp>

Define parameters for Van’t Hoff equation.

struct Views#
template<typename DenseMatrixPolicy, typename SparseMatrixPolicy>
struct ExternalModelConstraintSet#
#include <micm/external_model.hpp>

Type-erased build-time wrapper carrying an external model’s constraint-definition queries.

Populated for models that satisfy HasConstraints. Only build-time queries are wrapped; solve-time residual/Jacobian/update calls are made directly on the concrete model held in the builder / solver tuple.

Public Members

std::function<std::set<std::string>()> initialize_constraint_parameter_names_func_#

Empty when the model does not need state-diagnosed constraint parameters.

std::size_t model_index_ = 0#

Position of the source model in the builder’s ExternalModels pack.

template<typename DenseMatrixPolicy, typename SparseMatrixPolicy>
struct ExternalModelProcessSet#
#include <micm/external_model.hpp>

Type-erased build-time wrapper carrying an external model’s process-definition queries.

Populated for models that satisfy HasProcesses. Only build-time queries (species used and Jacobian sparsity) are wrapped here. solve-time forcing/Jacobian calls are made directly on the concrete model held in the builder / solver tuple.

struct ExternalModelSystem#
#include <micm/external_model.hpp>

Type-erased build-time wrapper carrying an external model’s state-definition queries.

Populated by SolverBuilder::AddExternalModel() for models that satisfy HasState. Only build-time queries are wrapped here; solve-time work is dispatched directly on the concrete model held in the builder / solver tuple.

struct GroupedDenseMatrixColumnViewTag#
#include <micm/util/view_category.hpp>

Tag for dense matrix column views obtained from a GroupView. These carry a precomputed base pointer into the current group’s slice of the underlying storage, so element access reduces to base[block_in_group] instead of recomputing (group * y_dim + column) * L + block_in_group per element.

struct GroupedSparseMatrixBlockViewTag#
#include <micm/util/view_category.hpp>

Tag for sparse matrix block views obtained from a GroupView. Carry a precomputed base pointer to the current group’s slice of the sparse data vector, so element access is group_base[block_offset_ + block_in_group].

template<typename T>
struct GroupingStrategy#

Determines the grouping strategy of a matrix type (no default - must be specialized).

template<typename T>
struct GroupingStrategy
#include <micm/util/matrix.hpp>

Matrix always uses simple grouping (L==1).

template<typename T, Index L>
struct GroupingStrategy#
#include <micm/util/vector_matrix.hpp>

VectorMatrix uses simple grouping when L==1, tiered grouping when L>1.

template<typename T>
struct GroupVectorSize : public std::integral_constant<Index, 1>#
#include <micm/util/sparse_matrix.hpp>

Type trait to extract GroupVectorSize (L) from matrix types at compile-time Default: L=1 for types without GroupVectorSize.

template<typename T>
struct GroupVectorSize : public std::integral_constant<Index, 1>, public std::integral_constant<Index, T::GroupVectorSize()>
#include <micm/util/sparse_matrix.hpp>

Specialization for types with static GroupVectorSize method.

template<typename T, typename = void>
struct HasCategory : public std::false_type#
#include <micm/util/view_category.hpp>

Helper to check if a type has a nested ‘category’ type.

template<typename T>
struct HasCategory : public std::false_type, public std::true_type#
struct IndexPair#
#include <micm/util/types.hpp>

A device-compatible struct for holding pairs of indices.

struct IndexTrio#
#include <micm/util/types.hpp>

A device-compatible struct for holding three indices.

struct JacobianComparisonResult#
#include <micm/util/jacobian_verification.hpp>

Result of comparing an analytical Jacobian against a finite-difference approximation.

template<class T, Index L>
class KokkosBlockVariable#
#include <micm/kokkos/util/kokkos_views.hpp>

A block-local temporary variable with its own device-callable storage.

Mirrors the ordering policy’s BlockVariable: a Kokkos::Array<T, L> when blocks are grouped (L > 1), or a bare scalar T for standard ordering (L == 1). Accessors are KOKKOS_INLINE_FUNCTION so instances can be constructed and used inside a KOKKOS_LAMBDA.

template<class T, Index L>
class KokkosBlockView#
#include <micm/kokkos/util/kokkos_views.hpp>

Device-callable, ungrouped block view for a Kokkos-backed sparse matrix.

Mirrors SparseMatrix::BlockView/ConstBlockView, but stores a raw pointer directly into the matrix’s flat storage (the Kokkos::View’s data pointer) instead of a pointer back to the host matrix object, so it can be captured by value into a KOKKOS_LAMBDA.

L is the block-group size (the sparse ordering policy’s GroupVectorSize()). Given a block index b, the corresponding element lives at data_[(b / L) * flat_block_size_ * L + element_position_ + b % L], where element_position_ is the block-relative offset for this (row, column) returned by the ordering policy (the same value SparseMatrix::ElementPosition() exposes on the host).

template<class T, Index L>
class KokkosColumnView#
#include <micm/kokkos/util/kokkos_views.hpp>

Device-callable, ungrouped column view for a Kokkos-backed dense matrix.

Mirrors VectorMatrix::ColumnView, but stores a raw pointer directly into the matrix’s flat storage (the Kokkos::View’s data pointer) instead of a pointer back to the host matrix object. This makes it trivially copyable into a KOKKOS_LAMBDA, where dereferencing a host object pointer would be unsafe.

L is the row-group size (VectorMatrix’s tiered grouping factor). Given a group index g and row_in_group, the corresponding element lives at data_[(g * y_dim_ + column_index_) * L + row_in_group] – the same layout VectorMatrix uses.

template<class T, Index L = MICM_DEFAULT_VECTOR_SIZE>
class KokkosDenseMatrix : public micm::VectorMatrix<T, MICM_DEFAULT_VECTOR_SIZE>#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Provides a Kokkos implementation to the VectorMatrix functionality.

Inherits from VectorMatrix (the MICM host-side data layout) and maintains a Kokkos::View as a device-side mirror. The caller must explicitly call CopyToDevice() / CopyToHost() to synchronize, matching the CUDA matrix pattern.

Public Functions

inline void CopyToDevice()#

Copy host data (MICM’s data_) to the device view.

inline void CopyToHost()#

Copy device view data back to host (MICM’s data_).

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size (excluding padding)

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

template<class ScaT>
inline ScalarType<ScaT> CompatibleScalar(ScaT init = ScaT{}) const#

Creates a scalar usable with this matrix type in Function lambda captures.

Parameters:

init – initial value for scalar

Returns:

scalar usable in Function() lambda captures

inline void Fill(T val)#

Set every element on the device to a given value.

inline void Axpy(const Real &alpha, const KokkosDenseMatrix &x)#

For each element in the KokkosDenseMatrix x and y, perform y = alpha * x + y, where alpha is a scalar constant. Runs on-device.

Only touches the matrix’s real (non-padding) cells.

Parameters:
inline void Max(const T &x)#

For each element of the matrix, perform y = max(y, x), where x is a scalar constant.

Touches every stored cell, including any trailing padding cells.

inline void Min(const T &x)#

For each element of the matrix, perform y = min(y, x), where x is a scalar constant.

Touches every stored cell, including any trailing padding cells.

inline void Copy(const KokkosDenseMatrix &other)#

Copy the device data from the other Kokkos dense matrix into this one.

inline void Swap(KokkosDenseMatrix &other)#

Swap the device data from the other Kokkos dense matrix into this one.

template<typename Func>
inline void ForEach(Func &&f, const KokkosDenseMatrix &a)#

Apply a two-argument element-wise function on-device.

Only touches real (non-padding) cells.

template<typename Func>
inline void ForEach(Func &&f, const KokkosDenseMatrix &a, const KokkosDenseMatrix &b)#

Apply a three-argument element-wise function on-device.

Only touches real (non-padding) cells; see Axpy() note.

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args)#

Apply a function to each row of the matrix, executing on-device using team parallelism (one team per row-group of L rows).

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the column view / vector arguments

Parameters:
  • func – The function to apply to each row

  • args – Column views, row variables, or vectors

Public Static Functions

template<typename Func, typename ...Args>
static inline auto Function(Func &&func, Args&... args)#

Create a function that can be applied to Kokkos dense matrices and vectors, executing on-device using team parallelism.

template<DenseMatrixColumnView Arg>
static inline KOKKOS_INLINE_FUNCTION decltype(auto) GetTopLevelRowElement(KokkosViewType, Index, Index row, Arg &&arg)#

Get an element reference for a row at the (ungrouped) matrix level. Used by the matrix-level ForEachRow() override.

template<class U>
class GroupView#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

GroupView provides a team-parallel view of a single group of L rows for iteration on-device.

Public Functions

inline KOKKOS_INLINE_FUNCTION void Fill (GroupedColumnView view, const T value) const

Assign value to view.

template<GroupedDenseMatrixColumnView Src> inline KOKKOS_INLINE_FUNCTION void Copy (GroupedColumnView dst_view, Src &&src_view) const

Copy src column into dst_view.

template<KokkosVectorLike Src> inline KOKKOS_INLINE_FUNCTION void Copy (GroupedColumnView dst_view, Src &&src) const

Copy src into dst_view.

template<BlockVariableView Dst> inline KOKKOS_INLINE_FUNCTION void Fill (Dst &&dst, const T value) const

Assign value to dst.

template<BlockVariableView Dst, GroupedDenseMatrixColumnView Src> inline KOKKOS_INLINE_FUNCTION void Copy (Dst &&dst, Src &&src) const

Copy src into dst.

template<KokkosVectorLike Vec> inline KOKKOS_INLINE_FUNCTION void Fill (Vec &vec, const T value) const

Assign value to all vec elements.

template<KokkosVectorLike Vec, GroupedDenseMatrixColumnView Src> inline KOKKOS_INLINE_FUNCTION void Copy (Vec &vec, Src &&src) const

Copy src into vec.

template<typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ForEachRow (Func &&func, Args &&... args) const

Apply the provided function to every row in the matrix.

template<typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ForEachRowStrict (Func &&func, Args &&... args) const

Same as ForEachRow but guaranteed to skip padding rows.

template<typename Reducer, typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void Reduce (const Reducer &reducer, Func &&func, Args &&... args) const

Apply a reduction to each row in this group, on-device via team parallelism. See ConstGroupView::Reduce for details.

template<typename Reducer, typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ReduceStrict (const Reducer &reducer, Func &&func, Args &&... args) const

Same as Reduce but guaranteed to skip padding rows.

struct DenseMatrixHandle#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Device-safe handle for a mutable KokkosDenseMatrix argument to Function()/ForEachRow().

struct ConstDenseMatrixHandle#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Const variant of DenseMatrixHandle. See DenseMatrixHandle for details.

template<typename Func, typename HandlesTuple>
struct FunctionMainFunctor#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching Function() over complete groups (size L). Avoids NVHPC restrictions on extended lambdas inside generic lambdas and parameter-pack capture in device lambdas.

template<typename Func, typename HandlesTuple>
struct FunctionTailFunctor#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching Function() over the tail group (size < L).

template<typename Func, typename ArgsTuple>
struct ForEachRowRangeFunctor#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching ForEachRow() via RangePolicy (L == 1).

template<typename Func, typename ArgsTuple>
struct ForEachRowTeamFunctor#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching ForEachRow() over complete groups via TeamPolicy.

template<typename Func, typename ArgsTuple>
struct ForEachRowTailFunctor#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching ForEachRow() over the tail group via TeamPolicy.

template<typename Func>
struct ForEachFunctor2#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching 2-arg flat ForEach() over the main range.

template<typename Func>
struct ForEachTailFunctor2#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching 2-arg flat ForEach() over the tail range.

template<typename Func>
struct ForEachFunctor3#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching 3-arg flat ForEach() over the main range.

template<typename Func>
struct ForEachTailFunctor3#
#include <micm/kokkos/util/kokkos_dense_matrix.hpp>

Kokkos functor for dispatching 3-arg flat ForEach() over the tail range.

template<class T>
struct KokkosGroupedBlockView#
#include <micm/kokkos/util/kokkos_views.hpp>

Enriched mutable block view for a single block-group of a Kokkos-backed sparse matrix.

Carries a precomputed group_base_ pointer at the start of the group’s slice of the sparse data vector, so element access within the group is the contiguous group_base_[block_offset_ + block_in_group] instead of recomputing the flat index per element. Mirrors the ordering policy’s GroupView::GroupedBlockView.

template<class T>
struct KokkosGroupedColumnView#
#include <micm/kokkos/util/kokkos_views.hpp>

Enriched mutable column view for a single row-group of a Kokkos-backed dense matrix.

Carries a precomputed base_ pointer at the first row of the group’s L-row block for a given column, so element access within the group is the contiguous base_[row_in_group] instead of recomputing (group * y_dim + column) * L + row_in_group per element. Mirrors VectorMatrix::GroupView::GroupedColumnView.

template<class T>
struct KokkosGroupedConstBlockView#
#include <micm/kokkos/util/kokkos_views.hpp>

Const variant of KokkosGroupedBlockView. See KokkosGroupedBlockView for details.

struct KokkosLAnd#
#include <micm/kokkos/util/kokkos_reducers.hpp>

Logical Or reducer (acc = acc && x).

struct KokkosLOr#
#include <micm/kokkos/util/kokkos_reducers.hpp>

Logical And redicer (acc = acc || x).

template<typename T>
struct KokkosMax#
#include <micm/kokkos/util/kokkos_reducers.hpp>

Max reduction (acc = std::max(acc, x)).

template<class T, Index L>
class KokkosPaddedVector#

Public Functions

inline void CopyToDevice() const#

Copy host data to the device view.

inline void CopyToHost() const#

Copy device data to the host vector.

template<class U>
struct DeviceView#
template<class T, Index L>
class KokkosRowVariable#
#include <micm/kokkos/util/kokkos_views.hpp>

A row-local temporary variable with its own device-callable storage.

Mirrors VectorMatrix::RowVariable, but uses Kokkos::Array rather than std::array for the backing storage, and marks its accessors KOKKOS_INLINE_FUNCTION so instances can be constructed and used inside a KOKKOS_LAMBDA (including on GPU backends).

template<class T>
class KokkosScalarView#
#include <micm/kokkos/util/kokkos_scalar_view.hpp>

A scalar view class for use in Matrix::Function lambdas.

template<class U>
struct View#
template<class T = double, class OrderingPolicy = SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>
class KokkosSparseMatrix : public micm::SparseMatrix<double, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Provides a Kokkos implementation to the SparseMatrix functionality.

Inherits from SparseMatrix (the MICM host-side data layout) and maintains a Kokkos::View as a device-side mirror. The caller must explicitly call CopyToDevice() / CopyToHost() to synchronize, matching the CUDA matrix pattern.

Public Functions

inline void CopyToDevice()#

Copy host data (MICM’s data_) to the device view.

inline void CopyToHost()#

Copy device view data back to host (MICM’s data_).

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size (excluding padding)

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

template<class ScaT>
inline ScalarType<ScaT> CompatibleScalar(ScaT init = ScaT{}) const#

Creates a scalar usable with this matrix type in Function lambda captures.

Parameters:

init – Initial value for scalar

Returns:

scalar usable in Function() lambda captures

inline void Fill(T val)#

Set every element on the device to a given value.

inline void AddToDiagonal(T value)#

Add a value to every diagonal element of every block, on-device.

inline KOKKOS_INLINE_FUNCTION KokkosBlockView< T, L > GetBlockView (Index vector_index) const

Access the non-zero element at a precomputed flat index (from VectorIndex(0, row, col)) in every block, for direct on-device modification via ForEachBlock().

inline KOKKOS_INLINE_FUNCTION KokkosBlockView< const T, L > GetConstBlockView (Index vector_index) const

Const variant of GetBlockView(vector_index). See GetBlockView for details.

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args)#

Apply a function to each block of the matrix.

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the block view / block variable / vector arguments

Parameters:
  • func – The function to apply to each block

  • args – Block views, block variables, or vectors

Public Static Functions

template<typename Func, typename ...Args>
static inline auto Function(Func &&func, Args&... args)#

Create a function that can be applied to Kokkos sparse and dense matrices and vectors, executing on-device using team parallelism.

template<SparseMatrixBlockView Arg>
static inline KOKKOS_INLINE_FUNCTION decltype(auto) GetTopLevelBlockElement(KokkosViewType, Index, Index block, Arg &&arg)#

Get an element reference for a block at the (ungrouped) matrix level. Used by the matrix-level ForEachBlock() override.

template<class U>
class GroupView#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

GroupView provides a team-parallel mutable view of a single block-group of L blocks for iteration on-device.

Public Functions

inline KOKKOS_INLINE_FUNCTION void Fill (GroupedBlockView view, const T value) const

Assign value to every cell of a grouped block view.

template<GroupedSparseMatrixBlockView Src> inline KOKKOS_INLINE_FUNCTION void Copy (GroupedBlockView dst_view, Src &&src_view) const

Copy src into dst_view.

template<KokkosVectorLike Src> inline KOKKOS_INLINE_FUNCTION void Copy (GroupedBlockView dst_view, Src &&src) const

Copy src into dst_view.

template<BlockVariableView Dst> inline KOKKOS_INLINE_FUNCTION void Fill (Dst &&dst, const T value) const

Assign value to every cell of dst.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src> inline KOKKOS_INLINE_FUNCTION void Copy (Dst &&dst, Src &&src) const

Copy a sparse-block value into the caller-owned block-variable temp.

template<KokkosVectorLike Vec> inline KOKKOS_INLINE_FUNCTION void Fill (Vec &vec, const T value) const

Assign value to every element of vec.

template<KokkosVectorLike Vec, GroupedSparseMatrixBlockView Src> inline KOKKOS_INLINE_FUNCTION void Copy (Vec &vec, Src &&src) const

Copy src into vec.

template<typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ForEachBlock (Func &&func, Args &&... args) const

Apply the provided function to every block in this group, including any trailing padding blocks.

template<typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ForEachBlockStrict (Func &&func, Args &&... args) const

Same as ForEachBlock but guaranteed to skip padding blocks.

template<typename Reducer, typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void Reduce (Reducer reducer, Func &&func, Args &&... args) const

Apply a reduction to each row in this group, on-device via team parallelism. The user’s function receives its column-view / row-variable arguments plus a trailing reference to a per-thread accumulator, and accumulates into it (e.g. acc += x*x, acc = std::max(acc, x)). The micm reducer type (Sum/Max/LOr/LAnd) is translated to the matching Kokkos reducer, which handles the inter-thread join and writes the final result back to reducer.Reference().

template<typename Reducer, typename Func, typename... Args> inline KOKKOS_INLINE_FUNCTION void ReduceStrict (Reducer reducer, Func &&func, Args &&... args) const

Same as Reduce but guaranteed to skip padding rows.

struct SparseMatrixHandle#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Device-safe handle for a mutable KokkosSparseMatrix argument to Function()/ForEachBlock().

struct ConstSparseMatrixHandle#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Const variant of SparseMatrixHandle. See SparseMatrixHandle for details.

struct DenseMatrixArgHandle#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Device-safe handle for a KokkosDenseMatrix argument mixed into a call to Function().

See SparseMatrixHandle for why only the view + column count are captured.

struct ConstDenseMatrixArgHandle#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Const variant of DenseMatrixArgHandle. See DenseMatrixArgHandle for details.

template<typename Func, typename HandlesTuple>
struct FunctionMainFunctor#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Kokkos functor for dispatching Function() over complete groups (size L). See KokkosDenseMatrix::FunctionMainFunctor for rationale.

template<typename Func, typename HandlesTuple>
struct FunctionTailFunctor#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Kokkos functor for dispatching Function() over the tail group (size < L).

template<typename Func, typename ArgsTuple>
struct ForEachBlockRangeFunctor#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Kokkos functor for dispatching ForEachBlock() via RangePolicy (L == 1).

template<typename Func, typename ArgsTuple>
struct ForEachBlockTeamFunctor#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Kokkos functor for dispatching ForEachBlock() over complete groups via TeamPolicy.

template<typename Func, typename ArgsTuple>
struct ForEachBlockTailFunctor#
#include <micm/kokkos/util/kokkos_sparse_matrix.hpp>

Kokkos functor for dispatching ForEachBlock() over the tail group via TeamPolicy.

template<typename T>
struct KokkosSum#
#include <micm/kokkos/util/kokkos_reducers.hpp>

Sum reduction (acc += x).

struct LambdaRateConstantParameters#

Public Members

std::string label_#

Label for the reaction used to identify user-defined parameters.

std::function<Real(const Conditions&)> lambda_function_#

Lambda function for calculating the rate constant.

struct LAnd#
#include <micm/util/reducers.hpp>

Logical-AND reduction (acc = acc && x).

template<class DenseMatrixPolicy, class SparseMatrixPolicy>
class LinearConstraint#
#include <micm/constraint/types/linear_constraint.hpp>

Constraint for linear relationships: sum(coeff[i] * [species[i]]) = constant For example: A + B + C = 1.0 represents a conservation law The linear constraint is: G = c1*[A] + c2*[B] + c3*[C] - constant = 0.

Public Functions

LinearConstraint() = default#

Default constructor.

inline LinearConstraint(std::string name, const Species &algebraic_species, const std::vector<StoichSpecies> &terms, Real constant)#

Construct a linear constraint Validates that terms are non-empty Builds species_dependencies_ from terms.

Parameters:
  • name – Constraint identifier

  • algebraic_species – Species whose row is replaced by this algebraic constraint

  • terms – Vector of StoichSpecies (species, coefficient) in the linear sum

  • constant – The value that sum(coeff[i] * [species[i]]) should equal

inline const std::string &AlgebraicSpecies() const#

Returns the species whose row should be replaced by this algebraic constraint.

Returns:

Species name of the explicitly set algebraic variable

inline void ApplyConstraintParameter(const ConstraintInfo&, const typename DenseMatrixPolicy::template VectorType<Conditions>&, DenseMatrixPolicy&) const#

Apply constraint parameter update (no-op for linear constraints) Linear constraints have no temperature-dependent parameters.

inline void AddResidual(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, DenseMatrixPolicy &forcing) const#

Add linear constraint residual G to forcing vector for all grid cells Computes G = sum(coeff[i] * [species[i]]) - constant Called directly from ConstraintSet::AddForcingTerms.

inline void SubtractJacobian(const ConstraintInfo &info, const DenseMatrixPolicy &state, const DenseMatrixPolicy &state_param, SparseMatrixPolicy &jacobian) const#

Subtract linear constraint Jacobian terms from Jacobian matrix for all grid cells dG/d[species[i]] = coeff[i], subtracted matching SubtractJacobianTerms convention. Called directly from ConstraintSet::SubtractJacobianTerms.

Public Members

std::string name_#

Name of the constraint.

Species algebraic_species_#

Algebraic species.

std::vector<std::string> species_dependencies_#

Names of species this constraint depends on.

std::vector<StoichSpecies> terms_#

Species and their coefficients in the linear sum.

Real constant_#

The constant value the linear sum should equal.

std::vector<std::string> parameters_#

Parameter set (unused for this class, always empty).

struct Views#
template<class MatrixPolicy, class SparseMatrixPolicy, class LuDecompositionPolicy = LuDecomposition<SparseMatrixPolicy>>
class LinearSolver#
#include <micm/solver/linear_solver.hpp>

A general-use block-diagonal sparse-matrix linear solver.

The sparsity pattern of each block in the block diagonal matrix is the same.

Public Functions

LinearSolver() = default#

default constructor

inline LinearSolver(const SparseMatrixPolicy &matrix, typename SparseMatrixPolicy::value_type initial_value)#

Constructs a linear solver for the sparsity structure of the given matrix.

Parameters:
  • matrix – Sparse matrix

  • initial_value – Initial value for matrix elements

inline LinearSolver(const SparseMatrixPolicy &matrix, typename SparseMatrixPolicy::value_type initial_value, const std::function<LuDecompositionPolicy(const SparseMatrixPolicy&)> &create_lu_decomp)#

Constructs a linear solver for the sparsity structure of the given matrix.

Parameters:
  • matrix – Sparse matrix

  • initial_value – Initial value for matrix elements

  • create_lu_decomp – Function to create an LU Decomposition object that adheres to LuDecompositionPolicy

inline void Factor(const SparseMatrixPolicy &matrix, SparseMatrixPolicy &lower_matrix, SparseMatrixPolicy &upper_matrix) const#

Decompose the matrix into upper and lower triangular matrices.

Parameters:

matrix – Matrix to decompose into lower and upper triangular matrices

inline void Solve(MatrixPolicy &x, const SparseMatrixPolicy &lower_matrix, const SparseMatrixPolicy &upper_matrix) const#

Solve for x in Ax = b. x should be a copy of b and after Solve finishes x will contain the result.

struct Views#
template<class MatrixPolicy, class SparseMatrixPolicy, class LuDecompositionPolicy = LuDecompositionInPlace<SparseMatrixPolicy>>
class LinearSolverInPlace#
#include <micm/solver/linear_solver_in_place.hpp>

A general-use block-diagonal sparse-matrix linear solver.

The sparsity pattern of each block in the block diagonal matrix is the same. The L and U matrices are decomposed in-place over the original A matrix.

Subclassed by micm::CudaLinearSolverInPlace< MatrixPolicy, SparseMatrixPolicy, LuDecompositionPolicy >

Public Functions

LinearSolverInPlace() = default#

default constructor

inline LinearSolverInPlace(const SparseMatrixPolicy &matrix, typename SparseMatrixPolicy::value_type initial_value)#

Constructs a linear solver for the sparsity structure of the given matrix.

Parameters:
  • matrix – Sparse matrix

  • initial_value – Initial value for matrix elements

inline LinearSolverInPlace(const SparseMatrixPolicy &matrix, typename SparseMatrixPolicy::value_type initial_value, const std::function<LuDecompositionPolicy(const SparseMatrixPolicy&)> &create_lu_decomp)#

Constructs a linear solver for the sparsity structure of the given matrix.

Parameters:
  • matrix – Sparse matrix

  • initial_value – Initial value for matrix elements

  • create_lu_decomp – Function to create an LU Decomposition object that adheres to LuDecompositionPolicy

inline void Factor(SparseMatrixPolicy &matrix) const#

Decompose the matrix into upper and lower triangular matrices (matrix will be overwritten).

Parameters:

matrix – Matrix to decompose in-place into lower and upper triangular matrices

inline void Solve(MatrixPolicy &x, const SparseMatrixPolicy &lu_matrix) const#

Solve for x in Ax = b. x should be a copy of b and after Solve finishes x will contain the result.

Parameters:
  • x – The solution vector

  • LU – The LU decomposition of the matrix as a square sparse matrix

struct Views#
struct LOr#
#include <micm/util/reducers.hpp>

Logical-OR reduction (acc = acc || x).

template<class SparseMatrixPolicy>
class LuDecompositionDoolittle#
#include <micm/solver/lu_decomposition_doolittle.hpp>

LU decomposer for SparseMatrix following the Doolittle algorithm.

The LU decomposition uses the Doolittle algorithm following the naming used here: https://www.geeksforgeeks.org/doolittle-algorithm-lu-decomposition/

The sudo-code for the corresponding dense matrix algorithm for matrix A and lower (upper) triangular matrix L(U) would be:

for i = 0…n-1 // Outer loop over rows (columns) for upper (lower) triangular matrix for k = i…n-1 // Middle loop over columns for upper triangular matrix sum = 0 for j = 0…i-1 // Inner loop over columns (rows) for lower (upper) triangular matrix sum += L[i][j] * U[j][k] U[i][k] = A[i][k] - sum L[i][i] = 1 // Lower triangular matrix is 1 along the diagonal for k = i+1…n-1 // Middle loop over rows for lower triangular matrix sum = 0 for j = 0…i-1 // Inner loop over columns (rows) for lower (upper) triangular matrix sum += L[k][j] * U[j][i]; L[k][i] = (A[k][i] - sum) / U[i][i]

For the sparse matrix algorithm, the indices of non-zero terms are stored in several arrays during construction. These arrays are iterated through during calls to Decompose to do the actual decomposition. Our LU Decomposition only assigns the values of the jacobian to the LU matrices when the jacobian is nonzero. However, the sparsity pattern of the jacobian doesn’t necessarily match that of the LU matrices. There can be more nonzero elements in the LU matrices than in the jacobian. When this happens, we still need to assign the value of the jacobian matrix to the LU matrix. This value is implicitly zero when the sparsity pattern differs. The Fill values here do this implicit assignment More detail in this issue: NCAR/micm#625

Public Functions

inline LuDecompositionDoolittle()#

default constructor

inline LuDecompositionDoolittle(const SparseMatrixPolicy &matrix)#

Construct an LU decomposition algorithm for a given sparse matrix.

Parameters:

matrix – Sparse matrix

inline void Decompose(const SparseMatrixPolicy &A, SparseMatrixPolicy &L, SparseMatrixPolicy &U) const#

Perform an LU decomposition on a given A matrix.

Parameters:
  • A – Sparse matrix to decompose

  • L – The lower triangular matrix created by decomposition

  • U – The upper triangular matrix created by decomposition

Public Static Functions

static inline LuDecompositionDoolittle Create(const SparseMatrixPolicy &matrix)#

Create an LU decomposition algorithm for a given sparse matrix policy.

Parameters:

matrix – Sparse matrix

static inline std::pair<SparseMatrixPolicy, SparseMatrixPolicy> GetLUMatrices(const SparseMatrixPolicy &A, typename SparseMatrixPolicy::value_type initial_value, bool indexing_only = false)#

Create sparse L and U matrices for a given A matrix.

Parameters:

A – Sparse matrix that will be decomposed

Returns:

L and U Sparse matrices

struct Views#
template<class SparseMatrixPolicy>
class LuDecompositionDoolittleInPlace#
#include <micm/solver/lu_decomposition_doolittle_in_place.hpp>

LU decomposer for SparseMatrix following the Doolittle algorithm.

The LU decomposition uses the Doolittle algorithm following the naming used here: https://www.geeksforgeeks.org/doolittle-algorithm-lu-decomposition/

The sudo-code for the corresponding dense matrix algorithm for matrix A (in-line) would be:

for i = 0…n-1 // Outer loop over rows (columns) for upper (lower) triangular matrix for k = i…n-1 // Middle loop over columns for upper triangular matrix for j = 0…i-1 // Inner loop over columns (rows) for lower (upper) triangular matrix A[i][k] -= A[i][j] * A[j][k] for k = i+1…n-1 // Middle loop over rows for lower triangular matrix for j = 0…i-1 // Inner loop over columns (rows) for lower (upper) triangular matrix A[k][i] -= A[k][j] * A[j][i]; A[k][i] /= A[i][i]

For the sparse matrix algorithm, the indices of non-zero terms are stored in several arrays during construction. These arrays are iterated through during calls to Decompose to do the actual decomposition. Our LU Decomposition only assigns the values of the jacobian to the LU matrices when the jacobian is nonzero. However, the sparsity pattern of the jacobian doesn’t necessarily match that of the LU matrices. There can be more nonzero elements in the LU matrices than in the jacobian. It is expected that the elements of the L and U matrices that are zero in the A matrix will be set to zero before the combined matrix is passed to the decomposition function.

Public Functions

inline LuDecompositionDoolittleInPlace()#

default constructor

inline LuDecompositionDoolittleInPlace(const SparseMatrixPolicy &matrix)#

Construct an LU decomposition algorithm for a given sparse matrix.

Parameters:

matrix – Sparse matrix

inline void Decompose(SparseMatrixPolicy &ALU) const#

Perform an LU decomposition on a given A matrix.

Parameters:
  • A – Sparse matrix to decompose

  • L – The lower triangular matrix created by decomposition

  • U – The upper triangular matrix created by decomposition

Public Static Functions

static inline LuDecompositionDoolittleInPlace Create(const SparseMatrixPolicy &matrix)#

Create an LU decomposition algorithm for a given sparse matrix policy.

Parameters:

matrix – Sparse matrix

static inline SparseMatrixPolicy GetLUMatrix(const SparseMatrixPolicy &A, typename SparseMatrixPolicy::value_type initial_value, bool indexing_only = false)#

Create sparse L and U matrices for a given A matrix.

Parameters:

A – Sparse matrix that will be decomposed

Returns:

L and U Sparse matrices

struct Views#
template<class SparseMatrixPolicy>
class LuDecompositionMozart#
#include <micm/solver/lu_decomposition_mozart.hpp>

LU decomposer for SparseMatrix following the algorithm from the MOZART model.

This LU decomposition uses the algorithm from the MOZART chemistry preprocessor at: ESCOMP/CHEM_PREPROCESSOR

The MOZART function overwrote the A matrix with the L and U matrices. The pseudo-code in C++ for the corresponding dense matrix algorithm for matrix A (inline change) would be:

for i = 0…n-1 // Outer loop over columns of the sparse matrix A for j = i+1…n-1 // Multiply column below diagonal A[j][i] = A[j][i] / A[i][i] for k = i+1…n-1 // Modify sub-matrix for j = i+1…n-1 A[j][k] = A[j][k] – A[j][i] * A[i][k]

The pseudo-code in C++ for the corresponding dense matrix algorithm for matrix A and separate lower (upper) triangular matrix L(U) would be:

for i = 0…n-1 // Initialize U and L matrices to the A values for j = 0…i // Initialize U matrix including diagonal U[j][i] = A[j][i] L[i][i] = 1 // Lower triangular matrix is 1 along the diagonal for j = i+1…n-1 // Initialize L matrix excluding diagonal L[j][i] = A[j][i] for i = 0…n-1 for j = i+1…n-1 // Multiply column below diagonal L[j][i] = L[j][i] / U[i][i] for k = i+1…n-1 // Modify sub-matrix for j = i+1…k U[j][k] = U[j][k] - L[j][i] * U[i][k] for j = k+1…n-1 L[j][k] = L[j][k] - L[j][i] * U[i][k]

For the sparse matrix algorithm, the indices of non-zero terms are stored in several arrays during construction. These arrays are iterated through during calls to Decompose to do the actual decomposition. Our LU Decomposition only assigns the values of the jacobian to the LU matrices when the jacobian is nonzero. However, the sparsity pattern of the jacobian doesn’t necessarily match that of the LU matrices. There can be more nonzero elements in the LU matrices than in the jacobian. When this happens, we still need to assign the value of the jacobian matrix to the LU matrix. This value is implicitly zero when the sparsity pattern differs. The Fill values here do this implicit assignment More detail in this issue: NCAR/micm#625

Public Functions

inline LuDecompositionMozart()#

default constructor

inline LuDecompositionMozart(const SparseMatrixPolicy &matrix)#

Construct an LU decomposition algorithm for a given sparse matrix.

Parameters:

matrix – Sparse matrix

inline void Decompose(const SparseMatrixPolicy &A, SparseMatrixPolicy &L, SparseMatrixPolicy &U) const#

Perform an LU decomposition on a given A matrix.

Parameters:
  • A – Sparse matrix to decompose

  • L – The lower triangular matrix created by decomposition

  • U – The upper triangular matrix created by decomposition

Public Static Functions

static inline LuDecompositionMozart Create(const SparseMatrixPolicy &matrix)#

Create an LU decomposition algorithm for a given sparse matrix policy.

Parameters:

matrix – Sparse matrix

static inline std::pair<SparseMatrixPolicy, SparseMatrixPolicy> GetLUMatrices(const SparseMatrixPolicy &A, typename SparseMatrixPolicy::value_type initial_value, bool indexing_only = false)#

Create sparse L and U matrices for a given A matrix.

Parameters:

A – Sparse matrix that will be decomposed

Returns:

L and U Sparse matrices

struct Views#
template<class SparseMatrixPolicy>
class LuDecompositionMozartInPlace#
#include <micm/solver/lu_decomposition_mozart_in_place.hpp>

LU decomposer for SparseMatrix following the algorithm from the MOZART model.

This LU decomposition uses the algorithm from the MOZART chemistry preprocessor at: ESCOMP/CHEM_PREPROCESSOR

The MOZART function overwrote the A matrix with the L and U matrices. The pseudo-code in C++ for the corresponding dense matrix algorithm for matrix A (inline change) would be:

for i = 0…n-1 // Outer loop over columns of the sparse matrix A for j = i+1…n-1 // Multiply column below diagonal A[j][i] = A[j][i] / A[i][i] for k = i+1…n-1 // Modify sub-matrix for j = i+1…n-1 A[j][k] = A[j][k] – A[j][i] * A[i][k]

For the sparse matrix algorithm, the indices of non-zero terms are stored in several arrays during construction. These arrays are iterated through during calls to Decompose to do the actual decomposition.

The GetLUMatrices function creates a new sparse matrix that includes the superset of the non-zero elements in the L and U matrices. It is expected that the elements of the L and U matrices that are zero in the A matrix will be set to zero before the combined matrix is passed to the decomposition function.

Subclassed by micm::CudaLuDecompositionMozartInPlace< SparseMatrixPolicy >

Public Functions

inline LuDecompositionMozartInPlace()#

default constructor

inline LuDecompositionMozartInPlace(const SparseMatrixPolicy &matrix)#

Construct an LU decomposition algorithm for a given sparse matrix.

Parameters:

matrix – Sparse matrix

inline void Decompose(SparseMatrixPolicy &ALU) const#

Perform an LU decomposition on a given A matrix. All elements of L and U that are zero in A should be set to zero before calling this function.

Parameters:

ALU – Sparse matrix to decompose (will be overwritten with L and U matrices)

Public Static Functions

static inline LuDecompositionMozartInPlace Create(const SparseMatrixPolicy &matrix)#

Create an LU decomposition algorithm for a given sparse matrix policy.

Parameters:

matrix – Sparse matrix

static inline SparseMatrixPolicy GetLUMatrix(const SparseMatrixPolicy &A, typename SparseMatrixPolicy::value_type initial_value, bool indexing_only = false)#

Create a combined sparse L and U matrix for a given A matrix.

Parameters:

A – Sparse matrix that will be decomposed

Returns:

combined L and U Sparse matrices

struct Views#
template<class T = Real>
class Matrix#
#include <micm/util/matrix.hpp>

A 2D array class with contiguous memory.

Public Functions

inline Index RowStride() const#

Get the number of elements in the underlying vector between adjacent rows for the same column.

Returns:

The number of elements in the underlying vector between adjacent rows for the same column

inline Index ColumnStride() const#

Get the number of elements in the underlying vector between adjacent columns for the same row.

Returns:

The number of elements in the underlying vector between adjacent columns for the same row

inline void Fill(T val)#

Set every matrix element to a given value.

Parameters:

val – Value to set each element to

inline void CopyToDevice() const#

No-op host-to-device sync hook.

GPU-backed matrix policies (e.g. KokkosDenseMatrix, CudaDenseMatrix) override this to copy host data to a device mirror. Defined here as a no-op so shared MatrixPolicy tests and solver code can call it unconditionally regardless of which matrix policy is in use.

inline void CopyToHost() const#

No-op device-to-host sync hook. See CopyToDevice().

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

template<class ScaT>
inline ScalarType<ScaT> CompatibleScalar(ScaT init = ScaT{}) const#

Creates a scalar usable with this matrix type in Function lambda captures.

Parameters:

init – initial value for scalar

Returns:

scalar usable in Function() lambda captures

inline void Axpy(const Real &alpha, const Matrix &x)#

For each element in the Matrix x and y, perform y = alpha * x + y, where alpha is a scalar constant.

Parameters:
  • alpha – The scaling scalar to apply to the Matrix x

  • x – The input Matrix

inline void Max(const T &x)#

For each element of the matrix, perform y = max(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline void Min(const T &x)#

For each element of the matrix, perform y = min(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline ConstColumnView GetConstColumnView(Index column_index) const#

Create a const column view for accessing a column.

Parameters:

column_index – The index of the column

Returns:

A ConstColumnView descriptor

inline ColumnView GetColumnView(Index column_index) const#

Create a mutable column view for accessing a column.

Parameters:

column_index – The index of the column

Returns:

A ColumnView descriptor

inline RowVariable GetRowVariable() const#

Get a row variable with persistent storage for temporary values (const version).

Returns:

A RowVariable with stack-allocated storage

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args)#

Apply a function to each row of the matrix.

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the column view arguments

Parameters:
  • func – The function to apply to each row

  • args – Column views or row variables

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args) const#

Apply a function to each row of the matrix (const version).

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the column view arguments

Parameters:
  • func – The function to apply to each row

  • args – Column views or row variables

Public Static Functions

template<bool UseView = true, typename Func, typename ...Args>
static inline auto Function(Func &&func, Args&... args)#

Create a function that can be applied to matrices and vectors.

Creates a reusable callable that validates matrix dimensions and applies a user function row-by-row. For standard Matrix (L=1), each row is processed individually.

Note

Validation occurs in two phases:

  1. At function creation: Validates row counts match across all matrices and vector sizes

  2. At invocation: Re-validates dimensions in case matrices/vectors were resized

Note

Column view creation happens inside user lambda and is validated at invocation time, not at function creation time. Ensure all column indices are within matrix bounds to avoid runtime errors.

Template Parameters:
  • Func – The lambda/function type

  • Args – The matrix and vector types

Parameters:
  • func – The function to wrap - receives GroupView objects for matrices and vectors

  • args – The matrices and vectors to validate and capture dimensions from

Throws:

std::system_error – if column counts don’t match at creation, vectors have wrong sizes at creation, or if at invocation time: matrices/vectors have mismatched row counts, column counts don’t match creation, or column indices are out of bounds

Returns:

A callable that validates dimensions and applies the function

class ConstColumnView#
#include <micm/util/matrix.hpp>

A lightweight descriptor for a const column in a matrix.

class ColumnView#
#include <micm/util/matrix.hpp>

A lightweight descriptor for a mutable column in a matrix.

class RowVariable#
#include <micm/util/matrix.hpp>

A row-local temporary variable with its own storage.

class ConstGroupView#
#include <micm/util/matrix.hpp>

ConstGroupView provides a const view of a single row (group of size 1) for iteration.

Public Functions

inline GroupedConstColumnView GetConstColumnView(Index column_index) const#

Returns a grouped const column view whose element base_ pointer is precomputed for this ConstGroupView’s row.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned row-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[row_] of an external vector.

template<BlockVariableView Dst, GroupedDenseMatrixColumnView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy src column into the caller-owned row-variable temp.

template<VectorLike Vec, GroupedDenseMatrixColumnView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy src column into vec[row_] of an external vector. Inverse of Copy(GroupedColumnView, VectorLike).

template<typename Func, typename ...Args>
inline void ForEachRowStrict(Func &&func, Args&&... args) const#

Same as ForEachRow but guaranteed to skip padding rows. For standard-ordered matrices, there is no padding, so this is identical to ForEachRow.

template<typename Reducer, typename Func, typename ...Args>
inline void Reduce(Reducer reducer, Func &&func, Args&&... args) const#

Apply a reduction to the single row in this group. The user’s function receives its column-view/row-variable arguments plus a trailing reference to reducer.Reference() as an accumulator. For standard Matrix (L=1) this is just one function call.

template<typename Reducer, typename Func, typename ...Args>
inline void ReduceStrict(Reducer reducer, Func &&func, Args&&... args) const#

Same as Reduce but guaranteed to skip padding rows. For standard Matrix (L=1) there is no padding, so this is identical to Reduce.

struct GroupedConstColumnView#
#include <micm/util/matrix.hpp>

Enriched column view returned by GetConstColumnView on a ConstGroupView.

Carries a precomputed base_ pointer into the group’s slice of the underlying storage. For standard-ordered matrices, base_ points at the single element that row_ intersects with column_index_. Element access via GetRowElement is then arg.base_[0], avoiding the row_ * y_dim_ + column_index recomputation the raw Matrix::ConstColumnView requires.

class GroupView#
#include <micm/util/matrix.hpp>

GroupView provides a view of a single row (group of size 1) for iteration.

Public Functions

inline GroupedConstColumnView GetConstColumnView(Index column_index) const#

Returns a grouped const column view whose element base_ pointer is precomputed for this GroupView’s row.

inline GroupedColumnView GetColumnView(Index column_index) const#

Returns a grouped mutable column view whose element base_ pointer is precomputed for this GroupView’s row.

inline void Fill(GroupedColumnView view, T value) const#

Assign value to the (single) cell of the column within this group.

template<GroupedDenseMatrixColumnView Src>
inline void Copy(GroupedColumnView dst, Src &&src) const#

Copy src column into dst column within this group.

template<VectorLike Src>
inline void Copy(GroupedColumnView dst, Src &&src) const#

Copy a per-row vector into dst column within this group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned row-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[row_] of an external vector.

template<BlockVariableView Dst, GroupedDenseMatrixColumnView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy src column into the caller-owned row-variable temp.

template<VectorLike Vec, GroupedDenseMatrixColumnView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy src column into vec[row_] of an external vector.

template<typename Func, typename ...Args>
inline void ForEachRowStrict(Func &&func, Args&&... args) const#

Same as ForEachRow but guaranteed to skip padding rows. For standard-ordered matrices there is no padding, so this is identical to ForEachRow. See ConstGroupView::ForEachRowStrict for details.

template<typename Reducer, typename Func, typename ...Args>
inline void Reduce(Reducer reducer, Func &&func, Args&&... args) const#

Apply a reduction to the single row in this group. See ConstGroupView::Reduce for details.

template<typename Reducer, typename Func, typename ...Args>
inline void ReduceStrict(Reducer reducer, Func &&func, Args&&... args) const#

Same as Reduce but guaranteed to skip padding rows. For standard Matrix (L=1) this is identical to Reduce.

struct GroupedColumnView#
#include <micm/util/matrix.hpp>

Enriched mutable column view returned by GetColumnView on a GroupView. See ConstGroupView::GroupedConstColumnView for rationale.

struct GroupedConstColumnView#
#include <micm/util/matrix.hpp>

Const variant, for GetConstColumnView on a mutable GroupView.

template<typename T>
struct Max
#include <micm/util/reducers.hpp>

Max reduction (acc = max(acc, x)).

struct MicmException : public std::runtime_error#
template<class T, Index L>
class PaddedVector#
#include <micm/util/padded_vector.hpp>

A vector class with padded cells for use in Matrix::Function lambdas.

struct ConstView#
struct View#
struct PaddedVectorTag#
#include <micm/util/view_category.hpp>

Tag for padded vectors (size = ceil(N/L)*L).

struct ParameterizedFunction#
#include <micm/util/parameterized_function.hpp>

Linear parameterization result = c0_ + c_T_ * T + c_P_ * P + c_rho_ * air_density.

class Phase#
#include <micm/system/phase.hpp>

Represents a chemical phase (e.g., gaseous, aqueous) Each phase defines a set of species that participate in chemical reactions within that phase.

Public Functions

Phase() = default#

Defaulted constructors and assignment operators.

inline Phase(std::string name, const std::vector<PhaseSpecies> &phase_species)#

Create a phase with a name and a set of species.

inline Index StateSize() const#

Returns the number of non-parameterized species.

inline std::vector<std::string> UniqueNames() const#

Returns a set of unique names for each non-parameterized species.

inline std::vector<std::string> SpeciesNames() const#

Returns a set of unique names for each non-parameterized species (excludes phase name prefix).

Public Members

std::vector<PhaseSpecies> phase_species_#

The list of phase-specific species.

class PhaseSpecies#
#include <micm/system/phase.hpp>

Represents a chemical species within a specific phase, storing the species information and its optional diffusion coefficient.

class Process#
template<typename DenseMatrixPolicy, typename SparseMatrixPolicy>
class ProcessSet#
#include <micm/process/process_set.hpp>

Solver function calculators for a collection of processes.

Template Parameters:
  • DenseMatrixPolicy – Policy for dense matrices

  • SparseMatrixPolicy – Policy for sparse matrices

Subclassed by micm::CudaProcessSet< DenseMatrixPolicy, SparseMatrixPolicy >

Public Functions

ProcessSet() = default#

Default constructor.

inline ProcessSet(const std::vector<Process> &processes, const std::unordered_map<std::string, Index> &variable_map)#

Constructs a ProcessSet by mapping species in each process to their corresponding indices Initializes internal data structures related to a set of processes, mapping them to variable indices using a provided variable_map. Also prepares the data needed for computing Jacobian contributions.

Parameters:
  • processes – A list of processes, each with reactants and products

  • variable_map – A map from species names to their corresponding index in the solver’s state

Throws:

std::system_error – If a reactant or product name in a process is not found in variable_map

inline std::set<std::pair<Index, Index>> NonZeroJacobianElements() const#

Returns the positions of all non-zero Jacobian elements.

Returns:

A set of (row, column) index pairs, each representing a non-zero entry

inline void SetJacobianFlatIds(const SparseMatrixPolicy &matrix)#

Computes and stores flat (1D) indices for non-zero Jacobian elements Stores combination of process ids and reactant ids to support column-wise Jacobian updates.

Parameters:

matrix – The sparse Jacobian matrix used to compute flat indices.

inline void SetAlgebraicVariableIds(const std::set<Index> &variable_ids)#

Marks species rows that should be treated as algebraic (constraints replace ODE rows).

Parameters:

variable_ids – Set of variable ids whose forcing/Jacobian rows should not receive kinetic contributions

template<class StatePolicy>
inline void AddForcingTerms(const StatePolicy &state, const DenseMatrixPolicy &state_variables, DenseMatrixPolicy &forcing) const#

Adds forcing terms for the set of processes for the current conditions.

Parameters:
  • state – Current state containing rate constants and other relevant data

  • state_variables – Current state variable values (grid cell, state variable)

  • forcing – Forcing terms for each state variable (grid cell, state variable)

template<class StatePolicy>
inline void SubtractJacobianTerms(const StatePolicy &state, const DenseMatrixPolicy &state_variables, SparseMatrixPolicy &jacobian) const#

Subtracts Jacobian terms for the set of processes for the current conditions.

Parameters:
  • state – Current state containing rate constants and other relevant data

  • state_variables – Current state variable values (grid cell, state variable)

  • jacobian – Jacobian matrix for the system (grid cell, dependent variable, independent variable)

inline std::set<std::string> SpeciesUsed(const std::vector<Process> &processes) const#

Extracts all species involved in the given processes.

Parameters:

processes – A list of Process objects, each with reactants and products

Returns:

A set of species names

struct ProcessInfo#
#include <micm/process/process_set.hpp>

Process information for use in setting Jacobian elements.

struct Views#
template<class InnerRates, class ...ExternalModels>
class RatesBundle#
#include <micm/solver/external_model_dispatcher.hpp>

Wraps an inner rates policy and a shared tuple of concrete external models.

Solve-time methods first delegate to the inner (built-in) rates policy, then dispatch directly on each external model that satisfies HasProcesses.

Public Functions

template<class ConditionsVector, class DenseMatrixPolicy>
inline void UpdateStateParameters(const ConditionsVector &conditions, DenseMatrixPolicy &state_parameters) const#

Called before each solve to refresh temperature-/pressure-dependent parameters.

template<class Store>
inline void BuildCudaStore(const Store &store)#

Forward CUDA store upload to the inner rates policy when it supports it.

template<class DenseMatrixPolicy>
struct ReactionRateConstantStore#
#include <micm/process/reaction_rate_store.hpp>

Structure-of-arrays store for all reaction rate constant parameters.

Processes must be sorted by RateConstantTypeOrder before BuildFrom is called. Templated on DenseMatrixPolicy to pick up VectorType<T> — for Kokkos builds this is KokkosPaddedVector<T> which has CopyToDevice()/GetView() device support, matching the same Vector/VectorView pattern used in the LU decomposers.

Public Static Functions

static inline ReactionRateConstantStore<DenseMatrixPolicy> BuildFrom(std::vector<Process> &processes)#

Build a ReactionRateConstantStore from a sorted process list.

Parameters:

processes – Non-const ref so LambdaRateConstantParameters pointers remain mutable at runtime.

template<class StatePolicy>
static inline void CalculateCpuRateConstants(const ReactionRateConstantStore<DenseMatrixPolicy> &store, StatePolicy &state)#

Evaluate all lambda rate constants into state.rate_constants_. Called prior to calculating device-compatible rate constants.

template<class StatePolicy>
static inline void CalculateRateConstants(const ReactionRateConstantStore<DenseMatrixPolicy> &store, StatePolicy &state)#

Calculate all analytic rate constants into state.rate_constants_. Lambda entries are untouched; parameterized multipliers applied last. Uses DenseMatrixPolicy::Function so a single implementation handles both Matrix (scalar) and VectorMatrix (interleaved) layouts. Each reaction type is computed across all cells at once via ForEachRow, which is more SIMD-friendly than the previous per-cell loop.

struct ParameterizedMultiplier#
#include <micm/process/reaction_rate_store.hpp>

One entry per reaction with at least one parameterized reactant. Trivially copyable so it can live in a device Kokkos::View.

Public Static Attributes

static constexpr Index kMaxFuncs = 4#

Maximum number of parameterized reactants supported in a single reaction. If a reaction exceeds this, BuildFrom throws.

struct Views#
struct LambdaEntry#

Public Members

LambdaRateConstantParameters *source_#

Non-owning; valid for the lifetime of the owning Solver.

Index rc_index_#

Column index in state.rate_constants_[cell].

struct ReversibleRateConstantParameters#

Public Members

Real A_ = {1}#

Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1].

Real C_ = {0}#

Activation threshold [K].

Real k_r_ = {0}#

Reverse rate constant [s−1], indicating how fast the species leaves the condensed phase to return to the gas phase.

template<class RatesPolicy, class LinearSolverPolicy, class ConstraintSetPolicy>
class RosenbrockSolver : public micm::AbstractRosenbrockSolver<RatesPolicy, LinearSolverPolicy, ConstraintSetPolicy, RosenbrockSolver<RatesPolicy, LinearSolverPolicy, ConstraintSetPolicy>>#

Public Functions

inline RosenbrockSolver(LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, ConstraintSetPolicy &&constraints)#

Default constructor.

Note: This constructor is not intended to be used directly. Instead, use the SolverBuilder to create a solver

Parameters:
  • linear_solver – Linear solver

  • rates – Rates calculator

  • constraints – Algebraic constraints

struct RosenbrockSolverParameters#
#include <micm/solver/rosenbrock_solver_parameters.hpp>

Rosenbrock solver parameters.

Subclassed by micm::CudaRosenbrockSolverParameters

Public Static Functions

static inline RosenbrockSolverParameters TwoStageRosenbrockParameters()#

an L-stable method, 2 stages, order 2

Returns:

static inline RosenbrockSolverParameters ThreeStageRosenbrockParameters()#

an L-stable method, 3 stages, order 3, 2 function evaluations

Parameters:

reorder_state –

Returns:

static inline RosenbrockSolverParameters FourStageRosenbrockParameters()#

L-stable rosenbrock method of order 4, with 4 stages.

Returns:

static inline RosenbrockSolverParameters FourStageDifferentialAlgebraicRosenbrockParameters()#

A stiffly-stable method, 4 stages, order 3.

Returns:

static inline RosenbrockSolverParameters SixStageDifferentialAlgebraicRosenbrockParameters()#

stiffly-stable rosenbrock method of order 4, with 6 stages

Returns:

template<class DenseMatrixPolicy>
class RosenbrockTemporaryVariables : public micm::TemporaryVariables#

Public Functions

inline virtual std::unique_ptr<TemporaryVariables> Clone() const override#

Clone this object, preserving the derived type.

struct SimpleGroupingTag#
#include <micm/util/view_category.hpp>

Simple grouping: L==1, group index directly maps to element Used by: Matrix (always), VectorMatrix (when L==1), Standard ordering sparse (always), Vector ordering sparse (when L==1).

template<class SolverPolicy, class StatePolicy>
class Solver#

Public Functions

inline Index MaximumNumberOfGridCells() const#

Returns the maximum number of grid cells per state.

This is the maximum number of grid cells that can fit within one group for vectorized solvers. For non-vectorized solvers, there is no limit other than the maximum size of a std::size_t.

Returns:

Number of grid cells

inline void UpdateStateParameters(StatePolicy &state)#

Update state parameters based on current conditions (temperature, pressure, etc.) Invokes rate-parameter updates registered by external models (via the RatesBundle) and constraint parameter updates (via the ConstraintBundle), then recomputes rate constants. Should be called before solving if conditions have changed.

Parameters:

state – State object containing conditions and custom_rate_parameters to be updated

inline void PostSolveClamp(StatePolicy &state)#

Clamp state variables to non-negative after a solve For DAE systems, only ODE variables are clamped; algebraic variables are left unclamped.

template<class SolverParametersPolicy, class DenseMatrixPolicy, class SparseMatrixPolicy, class RatesPolicy, class LuDecompositionPolicy, class LinearSolverPolicy, class StatePolicy, class ...ExternalModels>
class SolverBuilder#
#include <micm/solver/solver_builder.hpp>

Builder of general solvers.

Template Parameters:
  • SolverParametersPolicy – Policy for the ODE solver

  • DenseMatrixPolicy – Policy for dense matrices

  • SparseMatrixPolicy – Policy for sparse matrices

  • RatesPolicy – Calculator of forcing and Jacobian terms

  • LinearSolverPolicy – Policy for the linear solver

  • ExternalModels – Concrete external model types added via AddExternalModel()

Public Functions

inline SolverBuilder &SetSystem(const System &system)#

Set the chemical system.

Parameters:

system – The chemical system

Returns:

Updated SolverBuilder

inline SolverBuilder &SetReactions(const std::vector<Process> &reactions)#

Set the reactions.

Parameters:

reactions – The reactions

Returns:

Updated SolverBuilder

inline SolverBuilder &SetConstraints(std::vector<Constraint<DenseMatrixPolicy, SparseMatrixPolicy>> &&constraints)#

Set algebraic constraints for DAE solving.

Parameters:

constraints – Vector of constraints

Returns:

Updated SolverBuilder

inline SolverBuilder &SetIgnoreUnusedSpecies(bool ignore_unused_species)#

Set whether to ignore unused species.

Parameters:

ignore_unused_species – True if unused species should be ignored

Returns:

Updated SolverBuilder

inline SolverBuilder &SetReorderState(bool reorder_state)#

Set whether to reorder the state to optimize the LU decomposition.

Parameters:

reorder_state – True if the state should be reordered

Returns:

Updated SolverBuilder

template<class ExternalModel>
inline auto AddExternalModel(ExternalModel model)#

Add an external model (state variables, processes, and/or constraints).

Returns a new builder whose template parameter pack is extended with ExternalModel. The concrete model is stored by value in a std::tuple that flows through Build() into the constructed Solver, which invokes the model’s solve-time methods directly.

If the model satisfies HasState, its state variables and parameters are registered. The model must satisfy at least one of HasProcesses or HasConstraints.

The returned builder takes the configuration of this builder. Use the returned builder, because this builder is left in a moved-from state.

inline auto Build()#

Creates an instance of Solver with a properly configured ODE solver.

Returns:

An instance of Solver

struct SolverResult#

Public Members

SolverState state_ = SolverState::NotYetCalled#

The final state the solver was in.

SolverStats stats_ = {}#

A collection of runtime state for this call of the solver.

struct SolverStats#

Public Members

Index function_calls_ = {}#

The number of forcing function calls.

Index jacobian_updates_ = {}#

The number of jacobian function calls.

Index number_of_steps_ = {}#

The total number of internal time steps taken.

Index accepted_ = {}#

The number of accepted integrations.

Index rejected_ = {}#

The number of rejected integrations.

Index decompositions_ = {}#

The number of LU decompositions.

Index solves_ = {}#

The number of linear solves.

Index constraint_init_iterations_ = {}#

The number of constraint initialization iterations performed.

Real final_time_ = {}#

The final time the solver iterated to.

template<class T = Real, class OrderingPolicy>
class SparseMatrix : public OrderingPolicy#
#include <micm/util/sparse_matrix.hpp>

A sparse block-diagonal 2D matrix class with contiguous memory.

Each block sub-matrix is square and has the same structure of non-zero elements

The template parameters are the type of the matrix elements and a class that defines the sizing and ordering of the data elements

Subclassed by micm::KokkosSparseMatrix< T, OrderingPolicy >

Public Types

using BlockVariable = typename OrderingPolicy::template BlockVariable<T>#

Alias for the ordering policy’s BlockVariable type.

using ConstGroupView = typename OrderingPolicy::template ConstGroupView<SparseMatrix>#

Alias for the ordering policy’s ConstGroupView type.

using GroupView = typename OrderingPolicy::template GroupView<SparseMatrix>#

Alias for the ordering policy’s GroupView type.

Public Functions

inline SparseMatrix(const SparseMatrixBuilder<T, OrderingPolicy> &builder, bool indexing_only = false)#

Constructs a SparseMatrix from a given builder and optional indexing mode. Initializes the SparseMatrix using the provided SparseMatrixBuilder, which defines the matrix structure, block size, and non-zero elements. Optionally, the constructor can be used in “indexing only” mode, where the data storage is not allocated.

Template Parameters:
  • T – The type of the matrix elements.

  • OrderingPolicy – The policy class that defines the ordering and storage of elements.

Parameters:
  • builder – The builder object containing matrix configuration and initial values.

  • indexing_only – If true, only indexing structures are initialized and data storage is omitted.

inline void Fill(T val)#

Set every matrix element to a given value.

Parameters:

val – Value to set each element to

inline void CopyToDevice() const#

No-op host-to-device sync hook.

GPU-backed matrix policies (e.g. KokkosSparseMatrix, CudaSparseMatrix) override this to copy host data to a device mirror. Defined here as a no-op so shared MatrixPolicy tests and solver code can call it unconditionally regardless of which matrix policy is in use.

inline void CopyToHost() const#

No-op device-to-host sync hook. See CopyToDevice().

template<class ScaT>
inline ScalarType<ScaT> CompatibleScalar(ScaT init = ScaT{}) const#

Creates a scalar usable with this matrix type in Function lambda captures.

Parameters:

init – initial value for scalar

Returns:

scalar usable in Function() lambda captures

inline void PrintNonZeroElements(std::ostream &os) const#

Print the sparse matrix with row index, column index, and non-zero value; useful to test other linear algebra libraries.

Parameters:

os – Output stream to print to, defaults to std::cout

inline ConstBlockView GetConstBlockView(Index vector_index) const#

Create a const block view for accessing the nth non-zero element.

Parameters:

vector_index – The data array index from VectorIndex(0, row, col) for the element

Returns:

A ConstBlockView descriptor

inline BlockView GetBlockView(Index vector_index) const#

Create a mutable block view for accessing the nth non-zero element.

Parameters:

vector_index – The data array index from VectorIndex(0, row, col) for the element

Returns:

A BlockView descriptor

inline BlockVariable GetBlockVariable() const#

Get a block variable with persistent storage for temporary values.

Returns:

A BlockVariable with stack-allocated storage

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Apply a function to each block of the matrix.

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the block view arguments

Parameters:
  • func – The function to apply to each block

  • args – Block views or block variables

Public Static Functions

template<typename Func, typename ...Args>
static inline auto Function(Func &&func, Args&... args)#

Create a function that can be applied to sparse matrices and vectors.

Creates a reusable callable that validates dimensions and applies a user function across block groups. The function iterates over groups of L blocks at a time, where L is determined by the OrderingPolicy::GroupVectorSize(). Supports mixing sparse matrices, dense matrices, and vector-like types.

Note

Validation occurs in two phases:

  1. At function creation: Validates matrix dimensions, vector sizes, and ordering compatibility

  2. At invocation: Re-validates dimensions in case matrices/vectors were resized

Note

Column/Block view creation happens inside user lambda and is validated at invocation time, not at function creation time. Ensure all view indices are within matrix bounds to avoid runtime errors.

Template Parameters:
Parameters:
  • func – The function to wrap - receives GroupView objects for matrices and forwarded vectors

  • args – The matrices and vectors to validate and capture dimensions from

Throws:

std::system_error – if matrices have incompatible orderings (different L values), mismatched block counts, or vectors have wrong sizes

Returns:

A callable that validates dimensions and applies the function

class ConstBlockView#
#include <micm/util/sparse_matrix.hpp>

A lightweight descriptor for a const block element in a sparse matrix.

class BlockView#
#include <micm/util/sparse_matrix.hpp>

A lightweight descriptor for a mutable block element in a sparse matrix.

struct SparseMatrixBlockViewTag#
#include <micm/util/view_category.hpp>

Tag for sparse matrix block views (have RowIndex + ColumnIndex).

template<class T, class OrderingPolicy = SparseMatrixStandardOrdering>
class SparseMatrixBuilder#
class SparseMatrixStandardOrderingCompressedSparseColumn#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

Defines the ordering of SparseMatrix object data in Compressed Sparse Column format.

Data is stored with blocks in the block diagonal matrix as the highest level structure, then by column, then by non-zero rows in each column.

Public Functions

inline Index GroupSize(Index number_of_non_zero_elements) const#

Returns the size of each group of blocks in the compressed data vector.

Returns:

Size of each group of blocks

inline Index NumberOfGroups(Index number_of_blocks) const#

Returns the total number of groups of blocks in the compressed data.

Parameters:

number_of_blocks – Total number of block sub-matrices in the overall matrix

Returns:

Number of groups of blocks (equal to number_of_blocks for standard ordering)

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

inline bool IsZero(Index row, Index column) const#

Returns whether a particular element is always zero.

Parameters:
  • row – Row index

  • column – Column index

Returns:

true if the element is always zero, false otherwise

Public Static Functions

static inline constexpr Index GroupVectorSize()#

Returns the number of blocks included in each group of blocks.

Returns:

Number of blocks in each group (1 for standard ordering)

template<typename T>
class BlockVariable#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

A block-local temporary variable with its own storage For standard ordering: single value.

template<typename SparseMatrixType>
class ConstGroupView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

ConstGroupView provides a const view of a single group of blocks for iteration For standard ordering: L=1, so each group contains 1 block.

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this ConstGroupView’s group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned block-variable temp. Dispatches on whether Dst::Get() returns something subscriptable.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block value into the caller-owned block-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_] (L=1).

template<VectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block value into vec[group_].

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. For standard ordering there is no padding, so this is identical to ForEachBlock.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

Enriched const block view returned by GetConstBlockView on a ConstGroupView. See CSR variant for rationale.

template<typename SparseMatrixType>
class GroupView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

GroupView provides a view of a single group of blocks for iteration For standard ordering: L=1, so each group contains 1 block.

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this GroupView’s group.

inline GroupedBlockView GetBlockView(Index vector_index) const#

Returns a grouped mutable block view whose group base_ pointer is precomputed for this GroupView’s group.

inline void Fill(GroupedBlockView view, T value) const#

Assign value to the (single) cell of the block within this group.

template<GroupedSparseMatrixBlockView Src>
inline void Copy(GroupedBlockView dst, Src &&src) const#

Copy src block value into dst block value within this group.

template<VectorLike Src>
inline void Copy(GroupedBlockView dst, Src &&src) const#

Copy src[group_] from a caller-owned vector into dst block.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned block-variable temp.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block value into the caller-owned block-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_] (L=1).

template<VectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block value into vec[group_].

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. See ConstGroupView::ForEachBlockStrict for details.

struct GroupedBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

Enriched mutable block view returned by GetBlockView on a GroupView. See CSR variant for rationale.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_column.hpp>

Const variant, for GetConstBlockView on a mutable GroupView.

class SparseMatrixStandardOrderingCompressedSparseRow#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

Defines the ordering of SparseMatrix object data in Compressed Sparse Row format.

Data is stored with blocks in the block diagonal matrix as the highest level structure, then by row, then by non-zero columns in each row.

Subclassed by micm::SparseMatrix< Real, SparseMatrixStandardOrdering >

Public Functions

inline Index GroupSize(Index number_of_non_zero_elements) const#

Returns the size of each group of blocks in the compressed data vector.

Returns:

Size of each group of blocks

inline Index NumberOfGroups(Index number_of_blocks) const#

Returns the total number of groups of blocks in the compressed data.

Parameters:

number_of_blocks – Total number of block sub-matrices in the overall matrix

Returns:

Number of groups of blocks (equal to number_of_blocks for standard ordering)

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

inline bool IsZero(Index row, Index column) const#

Returns whether a particular element is always zero.

Parameters:
  • row – Row index

  • column – Column index

Returns:

true if the element is always zero, false otherwise

Public Static Functions

static inline constexpr Index GroupVectorSize()#

Returns the number of blocks included in each group of blocks.

Returns:

Number of blocks in each group (1 for standard ordering)

template<typename T>
class BlockVariable#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

A block-local temporary variable with its own storage For standard ordering: single value.

template<typename SparseMatrixType>
class ConstGroupView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

ConstGroupView provides a const view of a single group of blocks for iteration For standard ordering: L=1, so each group contains 1 block.

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this ConstGroupView’s group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned block-variable temp. Dispatches on whether Dst::Get() returns something subscriptable (dense L=1 uses std::array<T,1>&; sparse L=1 uses T&).

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block value into the caller-owned block-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_].

template<VectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block value into vec[group_].

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. For standard ordering there is no padding, so this is identical to ForEachBlock.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

Enriched const block view returned by GetConstBlockView on a ConstGroupView.

Carries a precomputed base_ pointer into this group’s slice of the sparse data vector (matrix.data() + group * FlatBlockSize() for standard ordering). Element access via GetBlockElement is group_base_[block_offset_].

template<typename SparseMatrixType>
class GroupView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

GroupView provides a view of a single group of blocks for iteration For standard ordering: L=1, so each group contains 1 block.

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this GroupView’s group.

inline GroupedBlockView GetBlockView(Index vector_index) const#

Returns a grouped mutable block view whose group base_ pointer is precomputed for this GroupView’s group.

inline void Fill(GroupedBlockView view, T value) const#

Assign value to the (single) cell of the block within this group.

template<GroupedSparseMatrixBlockView Src>
inline void Copy(GroupedBlockView dst, Src &&src) const#

Copy src block value into dst block value within this group.

template<VectorLike Src>
inline void Copy(GroupedBlockView dst, Src &&src) const#

Copy src[group_] from a caller-owned vector into dst block.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to the caller-owned block-variable temp. See ConstGroupView::Fill(Dst&&, T) for details.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block value into the caller-owned block-variable temp.

template<VectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_].

template<VectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block value into vec[group_].

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. See ConstGroupView::ForEachBlockStrict for details.

struct GroupedBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

Enriched mutable block view returned by GetBlockView on a GroupView. See ConstGroupView::GroupedConstBlockView for rationale.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_standard_ordering_compressed_sparse_row.hpp>

Const variant, for GetConstBlockView on a mutable GroupView.

template<Index L = MICM_DEFAULT_VECTOR_SIZE>
class SparseMatrixVectorOrderingCompressedSparseColumn#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

Defines the ordering of SparseMatrix object data in Compressed Sparse Column format into blocks of rows to encourage vectorization.

Data is stored with sets of blocks in the block diagonal matrix as the highest level structure, then by column, then by non-zero rows in each column, then by individual blocks in the set of blocks.

The template argument is the number of blocks per set of blocks and should be approximately the size of the vector register.

Public Functions

inline Index GroupSize() const#

Returns the size of each group of blocks in the compressed data vector.

Parameters:

number_of_non_zero_elements – Number of non-zero elements in the matrix

Returns:

Size of each group of blocks

inline Index NumberOfGroups(Index number_of_blocks) const#

Returns the total number of groups of blocks in the compressed data vector, including any partial groups.

Parameters:

number_of_blocks – Total number of block sub-matrices in the overall matrix

Returns:

Number of groups of blocks

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size (excluding padding)

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

inline bool IsZero(const Index row, const Index column) const#

Returns whether a given row and column index is a zero element.

Parameters:
  • row – Index of the row

  • column – Index of the column

Returns:

True if the element is zero, false otherwise

Public Static Functions

static inline constexpr Index GroupVectorSize()#

Returns the number of blocks included in each group of blocks.

Returns:

Number of blocks per group

template<typename T>
class BlockVariable#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

A block-local temporary variable with its own storage For vector ordering: array of L values when L>1, single value when L=1.

template<typename SparseMatrixType>
class ConstGroupView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

ConstGroupView provides a const view of a single group of blocks for iteration For vector ordering: each group contains L blocks (except possibly the last group).

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this ConstGroupView’s group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned block-variable temp.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block into the caller-owned block-variable temp.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec.

template<PaddedVectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block into vec.

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix Vector-ordered matrix storage is padded to ceil(N/L)*L cells. This function should only be used whent it is safe to operate on padded blocks. Use ForEachBlockStrict when it is not safe to do so.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. Use ForEachBlock when operations on padded blocks are safe (better performance).

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

Enriched const block view returned by GetConstBlockView on a ConstGroupView. See CSR variant for rationale.

template<typename SparseMatrixType>
class GroupView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

GroupView provides a view of a single group of blocks for iteration For vector ordering: each group contains L blocks (except possibly the last group).

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this GroupView’s group.

inline GroupedBlockView GetBlockView(Index vector_index) const#

Returns a grouped mutable block view whose group base_ pointer is precomputed for this GroupView’s group.

inline void Fill(GroupedBlockView view, T value) const#

Assign value to every cell of the block within this group. Semantically equivalent to ForEachBlock([&](T& x){ x = value; }, view) but bulk-writes a contiguous block.

template<GroupedSparseMatrixBlockView Src>
inline void Copy(GroupedBlockView dst_view, Src &&src_view) const#

Copy src block into dst block within this group. Semantically equivalent to ForEachBlock([](T& d, const T& s){ d = s; }, dst, src) but bulk-copies contiguous storage.

template<PaddedVectorLike Src>
inline void Copy(GroupedBlockView dst_view, Src &&src) const#

Copy src[group_*L + i] from a caller-owned vector into dst block.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned block-variable temp.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block into the caller-owned block-variable temp.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_*L .. group_*L + num_blocks_in_group_).

template<PaddedVectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block into vec.

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. Use ForEachBlock when operations on padded blocks are safe (better performance).

struct GroupedBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

Enriched mutable block view returned by GetBlockView on a GroupView. See ConstGroupView::GroupedConstBlockView for rationale.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_column.hpp>

Const variant, for GetConstBlockView on a mutable GroupView.

template<Index L = MICM_DEFAULT_VECTOR_SIZE>
class SparseMatrixVectorOrderingCompressedSparseRow#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

Defines the ordering of SparseMatrix object data in Compressed Sparse Row format into blocks of rows to encourage vectorization.

Data is stored with sets of blocks in the block diagonal matrix as the highest level structure, then by row, then by non-zero columns in each row, then by individual blocks in the set of blocks.

The template argument is the number of blocks per set of blocks and should be approximately the size of the vector register.

Public Functions

inline Index GroupSize() const#

Returns the size of each group of blocks in the compressed data vector.

Parameters:

number_of_non_zero_elements – Number of non-zero elements in the matrix

Returns:

Size of each group of blocks

inline Index NumberOfGroups(Index number_of_blocks) const#

Returns the total number of groups of blocks in the compressed data vector, including any partial groups.

Parameters:

number_of_blocks – Total number of block sub-matrices in the overall matrix

Returns:

Number of groups of blocks

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size (excluding padding)

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

inline bool IsZero(Index row, Index column) const#

Returns whether a particular element is always zero.

Parameters:
  • row – Row index

  • column – Column index

Returns:

true if the element is always zero, false otherwise

Public Static Functions

static inline constexpr Index GroupVectorSize()#

Returns the number of blocks included in each group of blocks.

Returns:

Number of blocks in each group

template<typename T>
class BlockVariable#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

A block-local temporary variable with its own storage For vector ordering: array of L values when L>1, single value when L=1.

template<typename SparseMatrixType>
class ConstGroupView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

ConstGroupView provides a const view of a single group of blocks for iteration For vector ordering: each group contains L blocks (except possibly the last group).

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this ConstGroupView’s group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned block-variable temp. Dispatches on whether Dst::Get() returns something subscriptable (dense/sparse L>1 use array storage; sparse L=1 uses scalar).

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block into the caller-owned block-variable temp.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec.

template<PaddedVectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block into vec.

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix Vector-ordered matrix storage is padded to ceil(N/L)*L cells. This function should only be used whent it is safe to operate on padded blocks. Use ForEachBlockStrict when it is not safe to do so.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. Use ForEachBlock when operations on padded blocks are safe (better performance).

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

Enriched const block view returned by GetConstBlockView on a ConstGroupView.

Carries a precomputed base_ pointer into this group’s slice of the sparse data vector (matrix.data() + group * FlatBlockSize() * L). Element access via GetBlockElement is group_base_[block_offset_ + block_in_group] (contiguous), avoiding the group * num_non_zero * L + elem_position * L + block_in_group recomputation the raw ConstBlockView requires.

template<typename SparseMatrixType>
class GroupView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

GroupView provides a view of a single group of blocks for iteration For vector ordering: each group contains L blocks (except possibly the last group).

Public Functions

inline GroupedConstBlockView GetConstBlockView(Index vector_index) const#

Returns a grouped const block view whose group base_ pointer is precomputed for this GroupView’s group.

inline GroupedBlockView GetBlockView(Index vector_index) const#

Returns a grouped mutable block view whose group base_ pointer is precomputed for this GroupView’s group.

inline void Fill(GroupedBlockView view, T value) const#

Assign value to every cell of the block within this group. Semantically equivalent to ForEachBlock([&](T& x){ x = value; }, view) but bulk-writes a contiguous block.

template<GroupedSparseMatrixBlockView Src>
inline void Copy(GroupedBlockView dst_view, Src &&src_view) const#

Copy src block into dst block within this group. Semantically equivalent to ForEachBlock([](T& d, const T& s){ d = s; }, dst, src) but bulk-copies contiguous storage.

template<PaddedVectorLike Src>
inline void Copy(GroupedBlockView dst_view, Src &&src) const#

Copy src[group_*L + i] from a caller-owned vector into dst block.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned block-variable temp. See ConstGroupView::Fill(Dst&&, T) for dispatch rationale.

template<BlockVariableView Dst, GroupedSparseMatrixBlockView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy a sparse-block into the caller-owned block-variable temp.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec.

template<PaddedVectorLike Vec, GroupedSparseMatrixBlockView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy a sparse-block into vec.

template<typename Func, typename ...Args>
inline void ForEachBlock(Func &&func, Args&&... args) const#

Execute a function for every block in the matrix.

template<typename Func, typename ...Args>
inline void ForEachBlockStrict(Func &&func, Args&&... args) const#

Same as ForEachBlock but guaranteed to skip padding blocks. Use ForEachBlock when operations on padded blocks are safe (better performance).

struct GroupedBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

Enriched mutable block view returned by GetBlockView on a GroupView. See ConstGroupView::GroupedConstBlockView for rationale.

struct GroupedConstBlockView#
#include <micm/util/sparse_matrix_vector_ordering_compressed_sparse_row.hpp>

Const variant, for GetConstBlockView on a mutable GroupView.

class Species#
#include <micm/system/species.hpp>

A representation of a chemcial species.

Public Functions

Species() = default#

Default constructor.

inline Species &operator=(const Species &other)#

Copy assignment.

Parameters:

other – species to copy

inline Species(const Species &other)#

Copy Constructor.

Parameters:

other –

inline Species(std::string name)#

Construct a species by name only.

Parameters:

name – The name of the species

inline Species(std::string name, const std::map<std::string, Real> &properties)#

Construct a species by name and properties.

Parameters:
  • name – The name of the species

  • properties – The properties of the species

inline bool IsParameterized() const#

Returns whether a species is parameterized.

inline void SetThirdBody()#

Set a Species instance parameterized on air density.

template<class T>
inline T GetProperty(const std::string &key) const#

Return the value of a species property.

template<class T>
inline void SetProperty(const std::string &key, T value)#

Set the value of a species property.

Public Members

std::string name_#

The name of this species.

std::map<std::string, std::string> properties_string_#

A list of properties of this species.

ParameterizedFunction parameterize_ = {}#

A parameterization that, if provided, is used to compute the concentration of this species during solving. Species with this parameterization defined will be excluded from the solver state.

This is a POD (see ParameterizedFunction) so it can be copied to a CUDA/HIP device. Set has_value_ = true and populate the c0_/c_T_/c_P_/c_rho_ coefficients to enable it.

template<class DenseMatrixPolicy = StandardDenseMatrix, class SparseMatrixPolicy = StandardSparseMatrix, class LuDecompositionPolicy = LuDecomposition<SparseMatrixPolicy>>
struct State#

Subclassed by micm::CudaState< CudaDenseMatrixVector, CudaSparseMatrixVector, CudaLuDecompositionMozartInPlace< CudaSparseMatrixVector > >

Public Types

using DenseMatrixPolicyType = DenseMatrixPolicy#

Type of the DenseMatrixPolicy.

Public Functions

inline State()#

Default constructor Only defined to be used to create default values in types, but a default constructed state is not useable.

inline State(const StateParameters &parameters, const Index number_of_grid_cells)#

Constructor with parameters.

Parameters:

parameters – State dimension information

inline State(const State &other)#

Copy constructor.

Parameters:

other – The state object to be copied

inline State &operator=(const State &other)#

Assignment operator.

Parameters:

other – The state object to be assigned

Returns:

Reference to the assigned state object

inline State(State &&other) noexcept#

Move constructor.

Parameters:

other – The state object to be moved

inline State &operator=(State &&other) noexcept#

Move assignment operator.

Parameters:

other – The state object to be moved

Returns:

Reference to the moved state object

inline Index NumberOfGridCells() const#

Get the number of grid cells.

Returns:

The number of grid cells

inline VariableProxy operator[](Index index)#

Square-bracket access operator for state variable index.

Parameters:

index – The index of the variable to access

Returns:

Reference to the variable matrix column corresponding to the given index

inline ConstVariableProxy operator[](Index index) const#

Square-bracket access operator for state variable index (const version).

Parameters:

index – The index of the variable to access

Returns:

Const reference to the variable matrix column corresponding to the given index

inline VariableProxy operator[](const std::string &name)#

Square-bracket access operator for unique variable name.

Parameters:

name – The unique name of the variable to access

Returns:

VariableProxy proxy object providing access to the values of the named variable (e.g., its concentration) across grid cells. This is a proxy, not a direct reference to an internal matrix column; see VariableProxy documentation for details on single- vs multi-cell access patterns.

inline ConstVariableProxy operator[](const std::string &name) const#

Square-bracket access operator for unique variable name (const version).

Parameters:

name – The unique name of the variable to access

Returns:

ConstVariableProxy proxy object providing read-only access to the values of the named variable across grid cells. This is a proxy, not a direct reference to an internal matrix column; see ConstVariableProxy documentation for details on single- vs multi-cell access patterns.

inline VariableProxy operator[](const Species &species)#

Square-bracket access operator for species object.

Parameters:

species – The species object corresponding to the variable to access

Returns:

VariableProxy proxy object providing access to the values of the given species across grid cells. This is a proxy, not a direct reference to an internal matrix column; see VariableProxy documentation for details on single- vs multi-cell access patterns.

inline ConstVariableProxy operator[](const Species &species) const#

Square-bracket access operator for species object (const version).

Parameters:

species – The species object corresponding to the variable to access

Returns:

ConstVariableProxy proxy object providing read-only access to the values of the given species across grid cells. This is a proxy, not a direct reference to an internal matrix column; see ConstVariableProxy documentation for details on single- vs multi-cell access patterns.

inline void SetConcentrations(const std::unordered_map<std::string, std::vector<Real>> &species_to_concentration)#

Set species’ concentrations.

Parameters:

species_to_concentration –

inline void SetConcentration(const Species &species, Real concentration)#

Set a single species concentration.

Deprecated:

This method is deprecated in favor of using the operator[] with species or name to set concentrations, e.g., state[species] = concentration or state[“species_name”] = concentration

Parameters:
  • species – the species to set the concentration for

  • concentration – concentration [mol m-3]

inline void SetConcentration(const Species &species, const std::vector<Real> &concentration)#

Set concentrations for a single species across multiple grid cells.

Deprecated:

This method is deprecated in favor of using the operator[] with species or name to set concentrations, e.g., state[species] = concentrations or state[“species_name”] = concentrations

Parameters:
  • species – the species to set the concentrations for

  • concentration – vector of concentrations [mol m-3], one per grid cell

inline void SetConcentration(const std::string &element, Real concentration)#

Set the concentration for a named element (species or other variable).

Deprecated:

This method is deprecated in favor of using the operator[] with species or name to set concentrations, e.g., state[species] = concentration or state[“species_name”] = concentration

Parameters:
  • species – the name of the element (can be a non-species variable, e.g., number_concentration)

  • concentration – concentration value [mol m-3]

inline void SetConcentration(const std::string &element, const std::vector<Real> &concentration)#

Set concentrations for a named element (species or other variable) across multiple grid cells.

Deprecated:

This method is deprecated in favor of using the operator[] with species or name to set concentrations, e.g., state[species] = concentrations or state[“species_name”] = concentrations

Parameters:
  • species – the name of the element (can be a non-species variable, e.g., number_concentration)

  • concentration – vector of concentrations [mol m-3], one per grid cell

inline void UnsafelySetCustomRateParameters(const std::vector<std::vector<Real>> &parameters)#

Set custom parameters assuming the values are properly ordered.

Parameters:

parameters – map of custom rate parameters

inline void SetCustomRateParameters(const std::unordered_map<std::string, std::vector<Real>> &parameters)#

Set custom parameters for rate constant calculations by label.

Parameters:

parameters – map of custom rate parameters

inline void SetCustomRateParameter(const std::string &label, Real value)#

Set a single custom rate constant parameter.

Parameters:
  • label – parameter label

  • value – new parameter value

inline void SetRelativeTolerance(Real relative_tolerance)#

Set the relative tolerances.

Parameters:

relativeTolerance – relative tolerance

inline virtual void SetAbsoluteTolerances(const std::vector<Real> &absolute_tolerances)#

Set the absolute tolerances per species.

Parameters:

absoluteTolerance – absolute tolerance

inline void PrintHeader()#

Print a header of species to display concentrations with respect to time.

inline void PrintState(Real time)#

Print state (concentrations) at the given time.

Parameters:

time – solving time

Public Members

Index number_of_grid_cells_ = {1}#

The number of grid cells stored in the state.

DenseMatrixPolicy variables_#

The concentration of chemicals, varies through time.

DenseMatrixPolicy custom_rate_parameters_#

Rate parameters particular to user-defined rate constants, may vary in time.

DenseMatrixPolicy rate_constants_#

The reaction rates, may vary in time.

DenseMatrixPolicy::template VectorType<Conditions> conditions_#

Atmospheric conditions, varies in time.

Vector<Real> upper_left_identity_diagonal_#

The block matrix with an upper left identity, zeros elsewhere.

SparseMatrixPolicy jacobian_#

The jacobian structure, varies for each solve.

std::unordered_map<std::string, Index> variable_map_#

Immutable data required for the state.

struct Views#
class VariableProxy#
class ConstVariableProxy#
struct StateParameters#
#include <micm/solver/state.hpp>

Invariants that can be used to construct a state.

struct StoichSpecies#
#include <micm/system/stoich_species.hpp>

Represents a species in a chemical reaction, defined by its stoichiometric coefficient.

template<typename T>
struct Sum
#include <micm/util/reducers.hpp>

Sum reduction (acc += x).

struct SurfaceRateConstantData#
#include <micm/process/rate_constant/surface_rate_constant.hpp>

GPU-safe calculation data for a surface reaction. Populated by ReactionRateConstantStore::BuildFrom from SurfaceRateConstantParameters; do not construct directly.

Public Members

Real diffusion_coefficient_#

Gas-phase diffusion coefficient for the reacting species [m2 s-1].

Real mean_free_speed_factor_#

Precomputed factor for mean free speed: 8 * R / (pi * Mw) [K-1 m2 s-2].

Real reaction_probability_#

Reaction probability (0-1) [unitless].

Index custom_param_base_index_#

Index into custom_rate_parameters_[cell] for aerosol effective radius [m]; particle number concentration [# m-3] is at custom_param_base_index_ + 1.

struct SurfaceRateConstantParameters#

Public Members

std::string label_#

Label for the reaction used to identify user-defined parameters.

PhaseSpecies phase_species_#

Gas-phase species reacting on surface.

Real reaction_probability_ = {1.0}#

Reaction probability (0-1) [unitless].

class System#
#include <micm/system/system.hpp>

Defines the gas-phase species available in the chemical system.

Public Functions

inline Index StateSize() const#

Returns the number of gas-phase state variables.

inline std::vector<std::string> UniqueNames() const#

Returns the unique gas-phase species names.

Returns:

vector of unique state variable names

inline std::vector<std::string> UniqueNames(const std::function<std::string(const std::vector<std::string> &variables, const Index i)> &f) const#

Returns the unique gas-phase species names, optionally reordered.

Parameters:

f – Function used to apply a specific order to unique names

Returns:

vector of unique state variable names

Public Members

Phase gas_phase_#

The gas phase, defining a set of species present in the system.

struct TaylorSeriesRateConstantParameters#

Public Members

Real A_ = {1}#

Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1].

Real B_ = {0}#

Unitless exponential factor.

Real C_ = {0}#

Activation threshold, expected to be the negative activation energy divided by the boltzman constant [-E_a / k_b), K].

Real D_ = {300}#

A factor that determines temperature dependence [K].

Real E_ = {0}#

A factor that determines pressure dependence [Pa-1].

Real coefficients_[MAX_COEFFICIENTS] = {1.0}#

Taylor coefficients for the series expansion. Only the first n_coefficients_ entries are used.

Index n_coefficients_ = {1}#

Number of active Taylor coefficients [1, MAX_COEFFICIENTS].

Public Static Attributes

static constexpr Index MAX_COEFFICIENTS = 16#

Maximum number of Taylor series coefficients supported.

class TemporaryVariables#
#include <micm/solver/temporary_variables.hpp>

This is the base class for temporary variables; currently it is empty and will be expanded by a specific solver later.

Subclassed by micm::BackwardEulerTemporaryVariables< DenseMatrixPolicy >, micm::RosenbrockTemporaryVariables< DenseMatrixPolicy >

Public Functions

virtual std::unique_ptr<TemporaryVariables> Clone() const = 0#

Clone this object, preserving the derived type.

struct TernaryChemicalActivationRateConstantParameters#

Public Members

Real k0_A_ = 1.0#

low-pressure pre-exponential factor

Real k0_B_ = 0.0#

low-pressure temperature-scaling parameter

Real k0_C_ = 0.0#

low-pressure exponential factor

Real kinf_A_ = 1.0#

high-pressure pre-exponential factor

Real kinf_B_ = 0.0#

high-pressure temperature-scaling parameter

Real kinf_C_ = 0.0#

high-pressure exponential factor

Real Fc_ = 0.6#

TernaryChemicalActivation F_c parameter.

Real N_ = 1.0#

TernaryChemicalActivation N parameter.

struct TieredGroupingTag#
#include <micm/util/view_category.hpp>

Tiered grouping: L>1, groups contain L elements, need block_in_group offset Used by: VectorMatrix (when L>1), Vector ordering sparse (when L>1).

struct TroeRateConstantParameters#

Public Members

Real k0_A_ = 1.0#

low-pressure pre-exponential factor

Real k0_B_ = 0.0#

low-pressure temperature-scaling parameter

Real k0_C_ = 0.0#

low-pressure exponential factor

Real kinf_A_ = 1.0#

high-pressure pre-exponential factor

Real kinf_B_ = 0.0#

high-pressure temperature-scaling parameter

Real kinf_C_ = 0.0#

high-pressure exponential factor

Real Fc_ = 0.6#

Troe F_c parameter.

Real N_ = 1.0#

Troe N parameter.

struct TunnelingRateConstantParameters#

Public Members

Real A_ = 1.0#

Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1].

Real B_ = 0.0#

Linear temperature-dependent parameter [K].

Real C_ = 0.0#

Cubed temperature-dependent parameter [K^3].

struct UserDefinedRateConstantData#
#include <micm/process/rate_constant/user_defined_rate_constant.hpp>

GPU-safe calculation data for a user-defined rate constant. Populated by ReactionRateConstantStore::BuildFrom from UserDefinedRateConstantParameters; do not construct directly.

Public Members

Real scaling_factor_ = {1.0}#

Scaling factor applied to the user-provided rate constant value.

Index custom_param_index_ = {0}#

Index into custom_rate_parameters_[cell] holding the rate constant value.

struct UserDefinedRateConstantParameters#

Public Members

std::string label_#

Label for the reaction used to identify user-defined parameters.

Real scaling_factor_ = {1.0}#

Scaling factor to apply to user-provided rate constants.

template<class T, Index L = MICM_DEFAULT_VECTOR_SIZE>
class VectorMatrix#
#include <micm/util/vector_matrix.hpp>

A 2D array class with contiguous memory structured to encourage vectorization.

The memory layout groups rows into groups whose size can be set such that for a single column, the group of rows can fit in the vector register.

The template arguments are the type of the matrix elements and the size of the number of rows per group.

Subclassed by micm::CudaDenseMatrix< Real, MICM_DEFAULT_VECTOR_SIZE >, micm::KokkosDenseMatrix< Real, MICM_DEFAULT_VECTOR_SIZE >

Public Functions

inline Index RowStride() const#

Get the number of elements in the underlying vector between adjacent rows for the same column.

Returns:

The number of elements in the underlying vector between adjacent rows for the same column

inline Index ColumnStride() const#

Get the number of elements in the underlying vector between adjacent columns for the same row.

Returns:

The number of elements in the underlying vector between adjacent columns for the same row

inline void Fill(T val)#

Set every matrix element to a given value.

Parameters:

val – Value to set each element to

inline void CopyToDevice() const#

No-op host-to-device sync hook.

GPU-backed matrix policies (e.g. KokkosDenseMatrix, CudaDenseMatrix) override this to copy host data to a device mirror. Defined here as a no-op so shared MatrixPolicy tests and solver code can call it unconditionally regardless of which matrix policy is in use.

inline void CopyToHost() const#

No-op device-to-host sync hook. See CopyToDevice().

template<class VecT>
inline VectorType<VecT> CompatibleVector(Index n, VecT init = VecT{}) const#

Creates a vector usable with this matrix type in Function() lambdas.

Parameters:
  • n – vector size (excluding padding)

  • init – initial value for vector elements

Returns:

vector usable in Function() lambdas

template<class ScaT>
inline ScalarType<ScaT> CompatibleScalar(ScaT init = ScaT{}) const#

Creates a scalar usable with this matrix type in Function lambda captures.

Parameters:

init – initial value for scalar

Returns:

scalar usable in Function() lambda captures

inline void Axpy(const Real &alpha, const VectorMatrix &x)#

For each element in the VectorMatrix x and y, perform y = alpha * x + y, where alpha is a scalar constant.

Parameters:
inline void Max(const T &x)#

For each element of the VectorMatrix, perform y = max(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline void Min(const T &x)#

For each element of the VectorMatrix, perform y = min(y, x), where x is a scalar constant.

Parameters:

x – The scalar constant to compare against

inline ConstColumnView GetConstColumnView(Index column_index) const#

Create a const column view for accessing a column.

Parameters:

column_index – The index of the column

Returns:

A ConstColumnView descriptor

inline ColumnView GetColumnView(Index column_index) const#

Create a mutable column view for accessing a column.

Parameters:

column_index – The index of the column

Returns:

A ColumnView descriptor

inline RowVariable GetRowVariable() const#

Get a row variable with persistent storage for temporary values (const version).

Returns:

A RowVariable with stack-allocated storage

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args)#

Apply a function to each row of the matrix (processes L rows at a time).

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the column view arguments

Parameters:
  • func – The function to apply to each row

  • args – Column views or row variables

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args) const#

Apply a function to each row of the matrix (const version).

Template Parameters:
  • Func – The lambda/function type

  • Args – The types of the column view arguments

Parameters:
  • func – The function to apply to each row

  • args – Column views or row variables

Public Static Functions

template<bool UseView = true, typename Func, typename ...Args>
static inline auto Function(Func &&func, Args&... args)#

Create a function that can be applied to vector matrices and vectors.

Creates a reusable callable that validates matrix dimensions and applies a user function across row groups. The function iterates over groups of L rows at a time for vectorization, where L is the compile-time template parameter.

Note

Validation occurs in two phases:

  1. At function creation: Validates row counts match across all matrices and vector sizes

  2. At invocation: Re-validates dimensions in case matrices/vectors were resized

Note

Column view creation happens inside user lambda and is validated at invocation time, not at function creation time. Ensure all column indices are within matrix bounds to avoid runtime errors.

Template Parameters:
  • Func – The lambda/function type

  • Args – The matrix and vector types

  • UseView – When true (default), vector args are converted to their View/ConstView via arg.GetView() before being handed to the lambda so lambdas whose parameter is declared Vector::ViewType/Vector::ConstViewType see a lightweight view (mirrors the Kokkos MakeHandle path). When false, vector args are passed through unchanged; use this for HostFunction where the arg may be a KokkosPaddedVector whose GetView() returns a device view unusable on host. Both host PaddedVector and KokkosPaddedVector satisfy PaddedVectorLike (operator[], size, PaddedSize), so GroupView::GetRowElement handles both.

Parameters:
  • func – The function to wrap - receives GroupView objects for matrices and vectors

  • args – The matrices and vectors to validate and capture dimensions from

Throws:

std::system_error – if column counts don’t match at creation, or if at invocation time: matrices/vectors have mismatched row counts, column counts don’t match creation, or dimensions mismatch

Returns:

A callable that validates dimensions and applies the function

class ConstColumnView#
#include <micm/util/vector_matrix.hpp>

A lightweight descriptor for a const column in a matrix.

class ColumnView#
#include <micm/util/vector_matrix.hpp>

A lightweight descriptor for a mutable column in a matrix.

class RowVariable#
#include <micm/util/vector_matrix.hpp>

A row-local temporary variable with its own storage.

class ConstGroupView#
#include <micm/util/vector_matrix.hpp>

ConstGroupView provides a const view of a single group of L rows for iteration.

Public Functions

inline ConstGroupView(const VectorMatrix &matrix, Index group)#

Constructor that calculates num_rows_in_group from matrix dimensions.

inline ConstGroupView(const VectorMatrix &matrix, Index group, Index num_rows_in_group)#

Constructor with explicit num_rows_in_group.

inline GroupedConstColumnView GetConstColumnView(Index column_index) const#

Returns a grouped const column view whose element base_ pointer is precomputed for this ConstGroupView’s group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned row-variable temp. Handles both flavors of BlockVariable::Get():

  • Array-like (dense RowVariable, and sparse L>1 BlockVariable): Get() returns std::array<T, L>&, so we index it.

  • Scalar (sparse L=1 BlockVariable): Get() returns T&, so we assign directly. Only meaningful when this GroupView’s L=1.

template<BlockVariableView Dst, GroupedDenseMatrixColumnView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy src column into the caller-owned row-variable temp. See Fill above for the two Get() flavors this dispatches over.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_*L + i] for every row in this group.

template<PaddedVectorLike Vec, GroupedDenseMatrixColumnView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy src column into vec[group_*L .. group_*L + num_rows_in_group_).

template<typename Func, typename ...Args>
inline void ForEachRow(Func &&func, Args&&... args) const#

Calls a lambda function for every row in the group (including padded rows).

template<typename Func, typename ...Args>
inline void ForEachRowStrict(Func &&func, Args&&... args) const#

Same as ForEachRow but guaranteed to skip padding rows.

template<typename Reducer, typename Func, typename ...Args>
inline void Reduce(Reducer reducer, Func &&func, Args&&... args) const#

Apply a reduction to each row in this group. The user’s function receives its column-view/row-variable arguments plus a trailing reference to reducer.Reference() as an accumulator, and accumulates into it (e.g. acc += x*x for a sum, acc = std::max(acc, x) for a max). Matches ForEachRow’s group-iteration shape, including operating on padded rows.

template<typename Reducer, typename Func, typename ...Args>
inline void ReduceStrict(Reducer reducer, Func &&func, Args&&... args) const#

Same as Reduce but guaranteed to skip padding rows.

struct GroupedConstColumnView#
#include <micm/util/vector_matrix.hpp>

Enriched column view returned by GetConstColumnView on a ConstGroupView.

Carries a precomputed base_ pointer into this ConstGroupView’s slice of the underlying storage. For VectorMatrix, base_ points at the first row of the group’s L-row block for column_index, so element access is arg.base_[row_in_group] (contiguous) instead of recomputing (group * y_dim + column) * L + row_in_group per element.

class GroupView#
#include <micm/util/vector_matrix.hpp>

GroupView provides a view of a single group of L rows for iteration.

Public Functions

inline GroupView(VectorMatrix &matrix, Index group)#

Constructor that calculates num_rows_in_group from matrix dimensions.

inline GroupView(VectorMatrix &matrix, Index group, Index num_rows_in_group)#

Constructor with explicit num_rows_in_group.

inline GroupedConstColumnView GetConstColumnView(Index column_index) const#

Returns a grouped const column view whose element base_ pointer is precomputed for this GroupView’s group.

inline GroupedColumnView GetColumnView(Index column_index) const#

Returns a grouped mutable column view whose element base_ pointer is precomputed for this GroupView’s group.

template<PaddedVectorLike Src>
inline void Copy(GroupedColumnView dst_view, Src &&src) const#

Copy a per-row vector into dst column within this group.

template<BlockVariableView Dst>
inline void Fill(Dst &&dst, T value) const#

Assign value to every cell of the caller-owned row-variable temp. See ConstGroupView::Fill(Dst&&, T) for the array-vs-scalar dispatch rationale.

template<BlockVariableView Dst, GroupedDenseMatrixColumnView Src>
inline void Copy(Dst &&dst, Src &&src) const#

Copy src column into the caller-owned row-variable temp. See ConstGroupView::Copy(Dst&&, Src&&) for the array-vs-scalar dispatch rationale.

template<PaddedVectorLike Vec>
inline void Fill(Vec &vec, T value) const#

Assign value to vec[group_*L + i] for every real row in this group.

template<PaddedVectorLike Vec, GroupedDenseMatrixColumnView Src>
inline void Copy(Vec &vec, Src &&src) const#

Copy src column into vec[group_*L .. group_*L + num_rows_in_group_).

template<typename Func, typename ...Args>
inline void ForEachRowStrict(Func &&func, Args&&... args) const#

Same as ForEachRow but guaranteed to skip padding rows. See ConstGroupView::ForEachRowStrict for details.

template<typename Reducer, typename Func, typename ...Args>
inline void Reduce(Reducer reducer, Func &&func, Args&&... args) const#

Apply a reduction to each row in this group. See ConstGroupView::Reduce for details.

template<typename Reducer, typename Func, typename ...Args>
inline void ReduceStrict(Reducer reducer, Func &&func, Args&&... args) const#

Same as Reduce but guaranteed to skip padding rows.

struct GroupedColumnView#
#include <micm/util/vector_matrix.hpp>

Enriched mutable column view returned by GetColumnView on a GroupView. See ConstGroupView::GroupedConstColumnView for rationale.

struct GroupedConstColumnView#
#include <micm/util/vector_matrix.hpp>

Const variant, for GetConstColumnView on a mutable GroupView.

template<typename T, typename = void>
struct ViewCategory#
#include <micm/util/view_category.hpp>

Determines the category of a view type (checks for nested ‘category’ type first) Primary template: fallback for types without a nested ‘category’ type (e.g., std::vector) This enables SFINAE to work correctly in concepts like VectorLike.

template<typename T>
struct ViewCategory#
#include <micm/util/view_category.hpp>

If type has a nested ‘category’ type, use it.

namespace constants#

Variables

static constexpr Real BOLTZMANN_CONSTANT = 1.380649e-23#
static constexpr Real AVOGADRO_CONSTANT = 6.02214076e23#
static constexpr Real GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT#
namespace cuda#

Functions

template<typename T>
inline cublasStatus_t CublasAxpy(cublasHandle_t handle, int n, const T *alpha, const T *x, int incx, T *y, int incy)#
namespace detail#

Functions

template<Index I, typename T>
KOKKOS_INLINE_FUNCTION auto &DeviceTupleGet(DTupleElem<I, T> &elem) noexcept#
template<Index I, typename T> KOKKOS_INLINE_FUNCTION const T & DeviceTupleGet (const DTupleElem< I, T > &elem) noexcept
template<typename... Ts> KOKKOS_INLINE_FUNCTION DeviceTuple< std::decay_t< Ts >... > MakeDeviceTuple (Ts &&... ts)
template<Index L, typename Functor>
int TeamSizeForL(const Functor &team_functor)#

Team size for a launch whose intra-team loop is TeamThreadRange(team, L).

Template Parameters:

L – Trip count of the intra-team loop

Parameters:

team_functor – The functor the team policy will be launched with

Returns:

A team size to hand to Kokkos::TeamPolicy

template<Index I, typename T>
struct DTupleElem#
template<typename Seq, typename ...Ts>
struct DTupleBase#
template<Index... Is, typename ...Ts>
struct DTupleBase : public micm::detail::DTupleElem<Is, Ts>#
template<typename ...Ts>
struct DeviceTuple : public micm::detail::DTupleBase<std::index_sequence_for<Ts...>, Ts...>#
namespace property_keys#

Variables

static constexpr const char *DIFFUSION_COEFFICIENT = "diffusion coefficient [m2 s-1]"#
static constexpr const char *MOLECULAR_WEIGHT = "molecular weight [kg mol-1]"#