MICM API#
-
namespace micm#
Typedefs
-
template<class SolverParametersPolicy, std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
using CudaSolverBuilder = SolverBuilder<SolverParametersPolicy, CudaDenseMatrix<double, L>, CudaSparseMatrix<double, SparseMatrixVectorOrdering<L>>, CudaProcessSet, CudaLinearSolver<CudaSparseMatrix<double, SparseMatrixVectorOrdering<L>>, CudaDoolittleLuDecomposition>, CudaState<CudaDenseMatrix<double, L>, CudaSparseMatrix<double, 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
-
template<class SolverParametersPolicy, std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
using JitSolverBuilder = SolverBuilder<SolverParametersPolicy, VectorMatrix<double, L>, SparseMatrix<double, SparseMatrixVectorOrdering<L>>, JitProcessSet<L>, JitLinearSolver<L, SparseMatrix<double, SparseMatrixVectorOrdering<L>>, JitDoolittleLuDecomposition<L>>, State<VectorMatrix<double, L>, SparseMatrix<double, SparseMatrixVectorOrdering<L>>>># Builder of CPU-based solvers optimized for a particular chemical system using JIT compilation.
JIT-compiled solvers only work with vector-ordered matrices
- Template Parameters:
SolverParametersPolicy – Policy for the ODE solver
L – Vector size
-
using FloatingPointMicroseconds = std::chrono::duration<double, std::micro>#
-
template<class SolverParametersPolicy, class DenseMatrixPolicy = Matrix<double>, class SparseMatrixPolicy = SparseMatrix<double, SparseMatrixStandardOrdering>>
using CpuSolverBuilder = SolverBuilder<SolverParametersPolicy, DenseMatrixPolicy, SparseMatrixPolicy, ProcessSet, LinearSolver<SparseMatrixPolicy, DoolittleLuDecomposition>, State<DenseMatrixPolicy, SparseMatrixPolicy>># Builder of CPU-based general solvers.
- Template Parameters:
SolverParametersPolicy – Parameters for the ODE solver
DenseMatrixPolicy – Policy for dense matrices
SparseMatrixPolicy – Policy for sparse matrices
-
using StandardSparseMatrix = SparseMatrix<double, SparseMatrixStandardOrdering>#
-
using DefaultVectorSparseMatrix = SparseMatrix<double, SparseMatrixVectorOrdering<MICM_DEFAULT_VECTOR_SIZE>>#
Enums
-
enum class JitType#
Types used in JIT functions.
Values:
-
enumerator Int32#
-
enumerator Int32Ptr#
-
enumerator Int64#
-
enumerator Int64Ptr#
-
enumerator Float#
-
enumerator FloatPtr#
-
enumerator Double#
-
enumerator DoublePtr#
-
enumerator Bool#
-
enumerator Void#
-
enumerator Int32#
-
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 NotYetCalled#
Functions
-
template<template<class> class MatrixPolicy>
std::vector<std::size_t> 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<std::size_t> DiagonalMarkowitzReorder(const MatrixPolicy &matrix)#
-
inline std::string SolverStateToString(const SolverState &state)#
-
inline void ThrowInternalError(MicmInternalErrc e, const char *file, int line, const char *msg)#
-
template<class SparseMatrixPolicy>
SparseMatrixPolicy BuildJacobian(const std::set<std::pair<std::size_t, std::size_t>> &nonzero_jacobian_elements, std::size_t number_of_grid_cells, std::size_t state_size)#
-
std::string GenerateRandomString()#
Variables
-
constexpr double MOLES_M3_TO_MOLECULES_CM3 = 1.0e-6 * 6.02214076e23#
-
template<class RatesPolicy, class LinearSolverPolicy, class Dervied>
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
Derived – Implementation of the Rosenbock solver
Public Types
-
using ParametersType = RosenbrockSolverParameters#
Solver parameters typename.
Public Functions
-
inline AbstractRosenbrockSolver(const RosenbrockSolverParameters ¶meters, LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, auto &jacobian)#
Default constructor.
Note: This constructor is not intended to be used directly. Instead, use the SolverBuilder to create a solver
- Parameters:
parameters – Solver parameters
linear_solver – Linear solver
rates – Rates calculator
jacobian – Jacobian matrix
-
inline SolverResult Solve(double time_step, auto &state) 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 SparseMatrixPolicy>
inline void AlphaMinusJacobian(SparseMatrixPolicy &jacobian, const double &alpha) const# compute [alpha * I - dforce_dy]
- Parameters:
jacobian – Jacobian matrix (dforce_dy)
alpha –
-
inline void LinearFactor(double &H, const double gamma, const auto &number_densities, SolverStats &stats, auto &state) const#
Perform the LU decomposition of the matrix.
- Parameters:
H – The time step
gamma – The gamma value
number_densities – The number densities
stats – The solver stats
state – The state
-
template<class DenseMatrixPolicy>
inline double NormalizedError(const DenseMatrixPolicy &y, const DenseMatrixPolicy &y_new, const DenseMatrixPolicy &errors) const# Computes the scaled norm of the vector errors.
- Parameters:
y – the original vector
y_new – the new vector
errors – The computed errors
- Returns:
-
class ArrheniusRateConstant : public micm::RateConstant#
- #include <micm/process/arrhenius_rate_constant.hpp>
An arrhenius rate constant dependent on temperature and pressure.
Public Functions
-
inline ArrheniusRateConstant()#
Default constructor.
-
inline ArrheniusRateConstant(const ArrheniusRateConstantParameters ¶meters)#
An explicit constructor where each term can be set. Set B and E to zero to get the common form of the Arrhenius equation.
- Parameters:
parameters – A set of arrhenius rate constants
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline ArrheniusRateConstant()#
-
struct ArrheniusRateConstantParameters#
Public Members
-
double A_ = {1}#
Pre-exponential factor [(mol m−3)^(−(𝑛−1)) s−1].
-
double B_ = {0}#
Unitless exponential factor.
-
double C_ = {0}#
Activation threshold, expected to be the negative activation energy divided by the boltzman constant [-E_a / k_b), K].
-
double D_ = {300}#
A factor that determines temperature dependence [K].
-
double E_ = {0}#
A factor that determines pressure dependence [Pa-1].
-
double A_ = {1}#
-
template<class RatesPolicy, class LinearSolverPolicy>
class BackwardEuler# - #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 BackwardEuler(const BackwardEulerSolverParameters ¶meters, LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, auto &jacobian)#
Default constructor.
- Parameters:
parameters – Solver parameters
linear_solver – Linear solver
rates – Rates calculator
jacobian – Jacobian matrix
-
inline SolverResult Solve(double time_step, auto &state) 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 bool IsConverged(const BackwardEulerSolverParameters ¶meters, const DenseMatrixPolicy &residual, const DenseMatrixPolicy &state)# Determines whether the residual is small enough to stop the internal solver iteration.
- Parameters:
parameters – Solver 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
-
using ParametersType = BackwardEulerSolverParameters#
-
struct BackwardEulerSolverParameters#
- #include <micm/solver/backward_euler_solver_parameters.hpp>
BackwardEuler solver parameters.
-
template<class DenseMatrixPolicy>
class BackwardEulerTemporaryVariables : public micm::TemporaryVariables#
-
class BranchedRateConstant : public micm::RateConstant#
- #include <micm/process/branched_rate_constant.hpp>
A Branched rate constant.
Public Functions
-
inline BranchedRateConstant()#
Default constructor.
-
inline BranchedRateConstant(const BranchedRateConstantParameters ¶meters)#
An explicit constructor.
- Parameters:
parameters – A set of branched rate constant parameters
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline double Calculate(const double &temperature, const double &air_number_density) const#
Calculate the rate constant.
- Parameters:
temperature – Temperature in [K]
air_number_density – Number density in [mol m-3]
- Returns:
-
inline double A(const double &temperature, const double &air_number_density) const#
Calculate A(T,[M],n)
- Parameters:
temperature – Temperature in [K]
air_number_density – Number density of air in [mol m-3]
-
inline BranchedRateConstant()#
-
struct BranchedRateConstantParameters#
-
struct Conditions#
- #include <micm/system/conditions.hpp>
Environemental conditions.
-
class ConfigReaderPolicy#
Subclassed by micm::SolverConfig< ConfigTypePolicy >
Public Functions
-
inline void Parse(const std::filesystem::path &config_path)#
Parse configures.
- Parameters:
config_path – Path to a the CAMP configuration directory or file
-
inline void Parse(const std::filesystem::path &config_path)#
-
template<class T, std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class CudaDenseMatrix : public micm::VectorMatrix<T, MICM_DEFAULT_VECTOR_SIZE># Public Functions
-
inline void Axpy(const double 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:
alpha – The scaling scalar to apply to the VectorMatrix x
x – The input VectorMatrix
- Returns:
0 if successful, otherwise an error code
-
inline void Axpy(const double alpha, const CudaDenseMatrix<T, L> &x)#
-
class CudaDoolittleLuDecomposition : public micm::DoolittleLuDecomposition#
- #include <micm/cuda/solver/cuda_doolittle_lu_decomposition.hpp>
This CudaDoolittleLuDecomposition class inherits everything from the base class “LuDecomposition”.
Public Functions
-
inline CudaDoolittleLuDecomposition()#
This is the default constructor, taking no arguments;.
-
template<class SparseMatrixPolicy>
inline CudaDoolittleLuDecomposition(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 ~CudaDoolittleLuDecomposition()#
This is destructor that will free the device memory of the constant data from the class “CudaDoolittleLuDecomposition”
-
template<class SparseMatrixPolicy>
void Decompose(const SparseMatrixPolicy &A, SparseMatrixPolicy &L, SparseMatrixPolicy &U) const# This is the function to perform an LU decomposition on a given A matrix on the GPU.
- Parameters:
A – is the sparse matrix to decompose
L – is the lower triangular matrix created by decomposition
U – is the upper triangular matrix created by decomposition
Public Members
-
LuDecomposeParam devstruct_#
This is an instance of struct “LuDecomposeParam” that holds the constant data of “CudaDoolittleLuDecomposition” class on the device
-
inline CudaDoolittleLuDecomposition()#
-
template<class SparseMatrixPolicy, class LuDecompositionPolicy = CudaDoolittleLuDecomposition>
class CudaLinearSolver : public micm::LinearSolver<SparseMatrixPolicy, CudaDoolittleLuDecomposition># Public Functions
-
inline CudaLinearSolver()#
This is the default constructor, taking no arguments;.
-
inline CudaLinearSolver(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 CudaDoolittleLuDecomposition specified at line 15; See line 62 of “linear_solver.inl” for more details about how this lamda function works;
-
inline ~CudaLinearSolver()#
This is the destructor that will free the device memory of the constant data from the class “CudaLinearSolver”
Public Members
-
LinearSolverParam devstruct_#
This is an instance of struct “LinearSolverParam” that holds the constant data of “CudaLinearSolver” class on the device
-
inline CudaLinearSolver()#
-
class CudaProcessSet : public micm::ProcessSet#
- #include <micm/cuda/process/cuda_process_set.hpp>
A GPU-based implementation of ProcessSet.
Public Functions
-
inline CudaProcessSet(const std::vector<Process> &processes, const std::map<std::string, std::size_t> &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
-
template<typename OrderingPolicy>
inline void SetJacobianFlatIds(const SparseMatrix<double, OrderingPolicy> &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:
OrderingPolicy –
matrix –
Public Members
-
ProcessSetParam devstruct_#
This is an instance of struct “ProcessSetParam” that holds the constant data of “ProcessSet” class on the device
-
inline CudaProcessSet(const std::vector<Process> &processes, const std::map<std::string, std::size_t> &variable_map)#
-
template<class RatesPolicy, class LinearSolverPolicy>
class CudaRosenbrockSolver : public micm::AbstractRosenbrockSolver<RatesPolicy, LinearSolverPolicy, CudaRosenbrockSolver<RatesPolicy, LinearSolverPolicy>># Public Types
-
using ParametersType = CudaRosenbrockSolverParameters#
Solver parameters typename.
Public Functions
-
inline CudaRosenbrockSolver()#
Default constructor.
-
inline CudaRosenbrockSolver(RosenbrockSolverParameters parameters, LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, auto &jacobian)#
Builds a CUDA Rosenbrock solver for the given system and solver parameters.
- Parameters:
parameters – Solver parameters
linear_solver – Linear solver
rates – Rates calculator
jacobian – Jacobian matrix
-
inline ~CudaRosenbrockSolver()#
This is the destructor that will free the device memory of the constant data from the class “CudaRosenbrockSolver”
-
template<class SparseMatrixPolicy>
inline void AlphaMinusJacobian(SparseMatrixPolicy &jacobian, const double &alpha) const# Computes [alpha * I - jacobian] on the GPU.
- Template Parameters:
SparseMatrixPolicy –
- Parameters:
jacobian – Jacobian matrix
alpha –
-
template<class DenseMatrixPolicy>
inline double NormalizedError(const DenseMatrixPolicy &y_old, const DenseMatrixPolicy &y_new, const DenseMatrixPolicy &errors) 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
Public Members
-
CudaRosenbrockSolverParam devstruct_#
Default constructor.
This is an instance of struct “CudaRosenbrockSolverParam” that allocates device memory of temporary variables and copy constant data member to device
-
using ParametersType = CudaRosenbrockSolverParameters#
-
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 –
-
inline CudaRosenbrockSolverParameters(const RosenbrockSolverParameters &base)#
-
template<class T, class OrderingPolicy>
class CudaSparseMatrix : public micm::SparseMatrix<T, OrderingPolicy>#
-
template<class DenseMatrixPolicy, class SparseMatrixPolicy>
struct CudaState : public micm::State<DenseMatrixPolicy, SparseMatrixPolicy># - #include <micm/cuda/solver/cuda_state.hpp>
Construct a state variable for CUDA tests.
Public Functions
-
inline CudaState(const StateParameters ¶meters)#
Constructor which takes the state dimension information as input.
- Parameters:
parameters – State dimension information
-
inline void SyncInputsToDevice()#
Copy input variables to the device.
-
inline void SyncOutputsToHost()#
Copy output variables to the host.
-
inline CudaState(const StateParameters ¶meters)#
-
class DoolittleLuDecomposition#
- #include <micm/solver/doolittle_lu_decomposition.hpp>
LU decomposer for SparseMatrix.
This 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
Subclassed by micm::JitDoolittleLuDecomposition< L >, micm::CudaDoolittleLuDecomposition, micm::JitDoolittleLuDecomposition< L >
Public Functions
-
inline DoolittleLuDecomposition()#
default constructor
-
template<class SparseMatrixPolicy>
inline DoolittleLuDecomposition(const SparseMatrixPolicy &matrix)# Construct an LU decomposition algorithm for a given sparse matrix.
- Parameters:
matrix – Sparse matrix
-
template<class SparseMatrixPolicy>
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
-
template<class SparseMatrixPolicy>
static inline DoolittleLuDecomposition Create(const SparseMatrixPolicy &matrix)# Create an LU decomposition algorithm for a given sparse matrix policy.
- Parameters:
matrix – Sparse matrix
-
template<class SparseMatrixPolicy>
static inline std::pair<SparseMatrixPolicy, SparseMatrixPolicy> GetLUMatrices(const SparseMatrixPolicy &A, typename SparseMatrixPolicy::value_type initial_value)# 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
-
inline DoolittleLuDecomposition()#
-
struct InstrumentationSession#
-
class InstrumentationTimer#
-
class Instrumentor#
-
struct JitArgument#
- #include <micm/jit/jit_function.hpp>
JIT function argument.
-
class JitCompiler#
-
template<std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class JitDoolittleLuDecomposition : public micm::DoolittleLuDecomposition# - #include <micm/jit/solver/jit_doolittle_lu_decomposition.hpp>
LU decomposer for SparseMatrix with vector-ordering optimized with JIT-compilation.
See DoolittleLuDecomposition class description for algorithm details The template parameter is the number of blocks (i.e. grid cells) in the block-diagonal matrix
Public Functions
-
inline JitDoolittleLuDecomposition(const SparseMatrix<double, SparseMatrixVectorOrdering<L>> &matrix)#
Create a JITed LU decomposer for a given sparse matrix structure.
- Parameters:
matrix – Sparse matrix to create LU decomposer for
-
template<class SparseMatrixPolicy>
void Decompose(const SparseMatrixPolicy &A, SparseMatrixPolicy &lower, SparseMatrixPolicy &upper) const# Create sparse L and U matrices for a given A matrix.
- Parameters:
A – Sparse matrix that will be decomposed
lower – The lower triangular matrix created by decomposition
upper – The upper triangular matrix created by decomposition
-
inline JitDoolittleLuDecomposition(const SparseMatrix<double, SparseMatrixVectorOrdering<L>> &matrix)#
-
class JitFunction#
- #include <micm/jit/jit_function.hpp>
A JIT-compiled function generator.
An instance of this class can be used to build a single JIT function and includes some convenience functions for creating loops and operating on array elements
Public Functions
-
std::pair<llvm::orc::ResourceTrackerSP, llvm::JITTargetAddress> Generate()#
Generates the function.
This can only be called once.
- Returns:
Resource tracker and function pointer
-
inline llvm::Type *GetType(JitType type)#
Get an LLVM type variable.
- Parameters:
type – Type to get
- Returns:
LLVM type
-
llvm::Value *GetArrayElement(JitArgument array_ptr, llvm::ArrayRef<llvm::Value*> index, JitType type)#
Get a value from an array.
- Parameters:
array_ptr – Array pointer
index – Index in array to return value for
type – Data type of element
- Returns:
Value of array element
-
void SetArrayElement(JitArgument array_ptr, llvm::ArrayRef<llvm::Value*> index, JitType type, llvm::Value *value)#
Set the value in an array.
- Parameters:
array_ptr – Array pointer
index – Index in array to return value for
type – Data type of element
value – Value to set array element to
-
std::pair<llvm::orc::ResourceTrackerSP, llvm::JITTargetAddress> Generate()#
-
class JitFunctionBuilder#
-
template<std::size_t L, class SparseMatrixPolicy, class LuDecompositionPolicy = JitDoolittleLuDecomposition<L>>
class JitLinearSolver : public micm::LinearSolver<SparseMatrixPolicy, JitDoolittleLuDecomposition<L>># - #include <micm/jit/solver/jit_linear_solver.hpp>
A general-use block-diagonal sparse-matrix linear solver with JIT-compiled optimizations.
See LinearSolver class description for algorithm details The template parameter is the number of blocks (i.e. grid cells) in the block-diagonal matrix
Public Functions
-
inline JitLinearSolver(const SparseMatrixPolicy &matrix, double initial_value)#
Create a JITed linear solver for a given sparse matrix structure.
- Parameters:
compiler – JIT compiler
matrix – Block-diagonal sparse matrix to create solver for
initial_value – Initial value for decomposed triangular matrix elements
-
inline void Factor(SparseMatrixPolicy &matrix, SparseMatrixPolicy &lower_matrix, SparseMatrixPolicy &upper_matrix) const#
Decompose the matrix into upper and lower triangular matrices and general JIT functions.
- Parameters:
matrix – Matrix that will be factored into lower and upper triangular matrices
-
template<class MatrixPolicy>
inline void Solve(MatrixPolicy &x, SparseMatrixPolicy &lower_matrix, SparseMatrixPolicy &upper_matrix) const# Solve for x in Ax = b.
-
inline JitLinearSolver(const SparseMatrixPolicy &matrix, double initial_value)#
-
struct JitLoop#
- #include <micm/jit/jit_function.hpp>
JIT function loop.
-
template<std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class JitProcessSet : public micm::ProcessSet# - #include <micm/jit/process/jit_process_set.hpp>
JIT-compiled solver function calculators for a collection of processes The template parameter is the number of grid cells to solve simultaneously.
Public Functions
-
inline JitProcessSet(const std::vector<Process> &processes, const std::map<std::string, std::size_t> &variable_map)#
Create a JITed 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
-
template<typename OrderingPolicy>
inline void SetJacobianFlatIds(const SparseMatrix<double, OrderingPolicy> &matrix)# Sets the indices for each non-zero Jacobian element in the underlying vector.
- Parameters:
matrix – The sparse matrix used for the Jacobian
-
template<class MatrixPolicy>
void AddForcingTerms(const MatrixPolicy &rate_constants, const MatrixPolicy &state_variables, MatrixPolicy &forcing) const# Adds forcing terms for the set of processes for the current conditions.
- Parameters:
rate_constants – Current values for the process rate constants (grid cell, process)
state_variables – Current state variable values (grid cell, state variable)
forcing – Forcing terms for each state variable (grid cell, state variable)
-
template<class MatrixPolicy, class SparseMatrixPolicy>
void SubtractJacobianTerms(const MatrixPolicy &rate_constants, const MatrixPolicy &state_variables, SparseMatrixPolicy &jacobian) const# Subtracts Jacobian terms for the set of processes for the current conditions.
- Parameters:
rate_constants – Current values for the process rate constants (grid cell, process)
state_variables – Current state variable values (grid cell, state variable)
jacobian – Jacobian matrix for the system (grid cell, dependent variable, independent variable)
-
inline JitProcessSet(const std::vector<Process> &processes, const std::map<std::string, std::size_t> &variable_map)#
-
template<class RatesPolicy, class LinearSolverPolicy>
class JitRosenbrockSolver : public micm::AbstractRosenbrockSolver<RatesPolicy, LinearSolverPolicy, JitRosenbrockSolver<RatesPolicy, LinearSolverPolicy>># - #include <micm/jit/solver/jit_rosenbrock.hpp>
A Rosenbrock solver with JIT-compiled optimizations.
Public Types
-
using ParametersType = JitRosenbrockSolverParameters#
Solver parameters typename.
Public Functions
-
inline JitRosenbrockSolver(RosenbrockSolverParameters parameters, LinearSolverPolicy linear_solver, RatesPolicy rates, auto &jacobian)#
Builds a Rosenbrock solver for the given system and solver parameters.
- Parameters:
parameters – Solver parameters
linear_solver – Linear solver
rates – Rates calculator
jacobian – Jacobian matrix
-
template<class SparseMatrixPolicy>
inline void AlphaMinusJacobian(SparseMatrixPolicy &jacobian, const double &alpha) const# compute [alpha * I - dforce_dy]
- Parameters:
jacobian – Jacobian matrix (dforce_dy)
alpha –
-
using ParametersType = JitRosenbrockSolverParameters#
-
struct JitRosenbrockSolverParameters : public micm::RosenbrockSolverParameters#
- #include <micm/jit/solver/jit_solver_parameters.hpp>
Parameters for the JIT Rosenbrock solver.
Public Functions
-
inline JitRosenbrockSolverParameters(const RosenbrockSolverParameters &base)#
Constructor from base class.
- Parameters:
base –
-
inline JitRosenbrockSolverParameters(const RosenbrockSolverParameters &base)#
-
template<class SparseMatrixPolicy, class LuDecompositionPolicy = DoolittleLuDecomposition>
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.
Subclassed by micm::CudaLinearSolver< SparseMatrixPolicy, LuDecompositionPolicy >, micm::JitLinearSolver< L, SparseMatrixPolicy, LuDecompositionPolicy >
Public Functions
-
inline LinearSolver()#
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
-
template<class MatrixPolicy>
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.
-
inline LinearSolver()#
-
template<class T = double>
class Matrix# - #include <micm/util/matrix.hpp>
A 2D array class with contiguous memory.
-
class Phase#
- #include <micm/system/phase.hpp>
A class which represnts a certain chemical phase (gaseous, aquous)
Each phase represents a set of species that participate in chemical reactions in that phase.
Public Functions
-
inline Phase()#
Default constructor.
-
inline Phase(const std::vector<Species> &species)#
Create a phase with a set of species.
- Parameters:
species – A unique list of species
-
inline std::size_t 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 Phase()#
-
struct Process#
Public Static Functions
-
template<class DenseMatrixPolicy, class SparseMatrixPolicy>
static void CalculateRateConstants(const std::vector<Process> &processes, State<DenseMatrixPolicy, SparseMatrixPolicy> &state)# Recalculate the rate constants for each process for the current state.
- Parameters:
processes – The set of processes being solved
state – The solver state to update
-
template<class DenseMatrixPolicy, class SparseMatrixPolicy>
-
class ProcessBuilder#
-
class ProcessSet#
- #include <micm/process/process_set.hpp>
Solver function calculators for a collection of processes.
Subclassed by micm::CudaProcessSet, micm::JitProcessSet< L >
Public Functions
-
ProcessSet() = default#
Default constructor.
-
inline ProcessSet(const std::vector<Process> &processes, const std::map<std::string, std::size_t> &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 std::set<std::pair<std::size_t, std::size_t>> NonZeroJacobianElements() const#
Return the full set of non-zero Jacobian elements for the set of processes.
- Returns:
Jacobian elements as a set of index pairs
-
template<typename OrderingPolicy>
inline void SetJacobianFlatIds(const SparseMatrix<double, OrderingPolicy> &matrix)# Sets the indicies for each non-zero Jacobian element in the underlying vector.
- Parameters:
matrix – The sparse matrix used for the Jacobian
-
template<typename DenseMatrixPolicy>
inline void AddForcingTerms(const DenseMatrixPolicy &rate_constants, const DenseMatrixPolicy &state_variables, DenseMatrixPolicy &forcing) const# Add forcing terms for the set of processes for the current conditions.
- Parameters:
rate_constants – Current values for the process rate constants (grid cell, process)
state_variables – Current state variable values (grid cell, state variable)
forcing – Forcing terms for each state variable (grid cell, state variable)
-
template<class DenseMatrixPolicy, class SparseMatrixPolicy>
inline void SubtractJacobianTerms(const DenseMatrixPolicy &rate_constants, const DenseMatrixPolicy &state_variables, SparseMatrixPolicy &jacobian) const# Subtract Jacobian terms for the set of processes for the current conditions.
- Parameters:
rate_constants – Current values for the process rate constants (grid cell, process)
state_variables – Current state variable values (grid cell, state variable)
jacobian – Jacobian matrix for the system (grid cell, dependent variable, independent variable)
-
ProcessSet() = default#
-
struct ProfileResult#
-
class RateConstant#
- #include <micm/process/rate_constant.hpp>
A base class for any type of rate constant.
Subclassed by micm::ArrheniusRateConstant, micm::BranchedRateConstant, micm::SurfaceRateConstant, micm::TernaryChemicalActivationRateConstant, micm::TroeRateConstant, micm::TunnelingRateConstant, micm::UserDefinedRateConstant
Public Functions
-
inline virtual ~RateConstant()#
Virtual destructor.
-
virtual std::unique_ptr<RateConstant> Clone() const = 0#
Deep copy.
-
inline virtual std::vector<std::string> CustomParameters() const#
Returns a set of labels for user-defined rate constant parameters.
- Returns:
Vector of custom parameter labels
-
inline virtual std::size_t SizeCustomParameters() const#
Returns the number of custom parameters.
- Returns:
Number of custom parameters
-
inline virtual double Calculate(const Conditions &conditions) const#
Calculate the rate constant for a set of conditions.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
The reaction rate constant
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const#
Calculate the rate constant for a set of conditions.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User defined rate constant parameters
- Returns:
The reaction rate constant
-
inline virtual ~RateConstant()#
-
template<class RatesPolicy, class LinearSolverPolicy>
class RosenbrockSolver : public micm::AbstractRosenbrockSolver<RatesPolicy, LinearSolverPolicy, RosenbrockSolver<RatesPolicy, LinearSolverPolicy>># Public Functions
-
inline RosenbrockSolver(const RosenbrockSolverParameters ¶meters, LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, auto &jacobian)#
Default constructor.
Note: This constructor is not intended to be used directly. Instead, use the SolverBuilder to create a solver
- Parameters:
parameters – Solver parameters
linear_solver – Linear solver
rates – Rates calculator
jacobian – Jacobian matrix
-
inline RosenbrockSolver(const RosenbrockSolverParameters ¶meters, LinearSolverPolicy &&linear_solver, RatesPolicy &&rates, auto &jacobian)#
-
struct RosenbrockSolverParameters#
- #include <micm/solver/rosenbrock_solver_parameters.hpp>
Rosenbrock solver parameters.
Subclassed by micm::CudaRosenbrockSolverParameters, micm::JitRosenbrockSolverParameters
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:
-
static inline RosenbrockSolverParameters TwoStageRosenbrockParameters()#
-
template<class DenseMatrixPolicy>
class RosenbrockTemporaryVariables : public micm::TemporaryVariables#
-
template<class SolverPolicy, class StatePolicy>
class Solver#
-
template<class SolverParametersPolicy, class DenseMatrixPolicy, class SparseMatrixPolicy, class RatesPolicy, class LinearSolverPolicy, class StatePolicy>
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
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 &SetNumberOfGridCells(int number_of_grid_cells)#
Set the number of grid cells.
- Parameters:
number_of_grid_cells – The number of grid cells
- 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 ConfigTypePolicy = ConfigReaderPolicy>
class SolverConfig : public micm::ConfigReaderPolicy# - #include <micm/configure/solver_config.hpp>
Public interface to read and parse config.
Public Functions
-
inline void ReadAndParse(const std::filesystem::path &config_dir)#
Reads and parses configures.
- Parameters:
config_dir – Path to a the configuration directory
-
inline SolverParameters GetSolverParams()#
Creates and returns SolverParameters.
- Returns:
SolverParameters that contains ‘System’ and a collection of ‘Process’
-
inline void ReadAndParse(const std::filesystem::path &config_dir)#
-
struct SolverParameters#
-
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.
-
double final_time_ = {}#
The final time the solver iterated to.
-
SolverState state_ = SolverState::NotYetCalled#
-
struct SolverStats#
Public Functions
-
inline void Reset()#
Set all member variables to zero.
Public Members
-
uint64_t function_calls_ = {}#
The number of forcing function calls.
-
uint64_t jacobian_updates_ = {}#
The number of jacobian function calls.
-
uint64_t number_of_steps_ = {}#
The total number of internal time steps taken.
-
uint64_t accepted_ = {}#
The number of accepted integrations.
-
uint64_t rejected_ = {}#
The number of rejected integrations.
-
uint64_t decompositions_ = {}#
The number of LU decompositions.
-
uint64_t solves_ = {}#
The number of linear solves.
-
inline void Reset()#
-
template<class T = double, 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
Sparse matrix data structure follows the Compressed Sparse Row (CSR) pattern
The template parameters are the type of the matrix elements and a class that defines the sizing and ordering of the data elements
Public Functions
-
inline std::vector<std::size_t> DiagonalIndices(std::size_t block_id) const#
Returns the indices of non-zero diagonal elements in a particular block.
- Parameters:
block_id – Block index
- Returns:
Vector of indices of non-zero diagonal elements
-
inline std::vector<std::size_t> DiagonalIndices(std::size_t block_id) const#
-
template<class T, class OrderingPolicy = SparseMatrixStandardOrdering>
class SparseMatrixBuilder#
-
class SparseMatrixStandardOrdering#
- #include <micm/util/sparse_matrix_standard_ordering.hpp>
Defines the ordering of SparseMatrix object data.
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.
-
template<std::size_t L = MICM_DEFAULT_VECTOR_SIZE>
class SparseMatrixVectorOrdering# - #include <micm/util/sparse_matrix_vector_ordering.hpp>
Defines the ordering of SparseMatrix object data 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.
-
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 std::string &name)#
Construct a species by name only.
- Parameters:
name – The name of the species
-
inline Species(const std::string &name, const std::map<std::string, double> &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.
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.
-
std::function<double(const Conditions)> parameterize_ = {nullptr}#
A function that if provided will be used to parameterize the concentration of this species during solving. Species with this function defined will be excluded from the solver state.
-
Species() = default#
-
template<class DenseMatrixPolicy = StandardDenseMatrix, class SparseMatrixPolicy = StandardSparseMatrix>
struct State# 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 ¶meters)#
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 void SetConcentrations(const std::unordered_map<std::string, std::vector<double>> &species_to_concentration)#
Set species’ concentrations.
- Parameters:
species_to_concentration –
-
inline void SetConcentration(const Species &species, double concentration)#
Set a single species concentration.
- Parameters:
species – the species to set the concentration for
concentration – concentration(s) [mol m-3]
-
inline void UnsafelySetCustomRateParameters(const std::vector<std::vector<double>> ¶meters)#
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<double>> ¶meters)#
Set custom parameters for rate constant calculations by label.
- Parameters:
parameters – map of custom rate parameters
-
inline void SetCustomRateParameter(const std::string &label, double value)#
Set a single custom rate constant parameter.
- Parameters:
label – parameter label
value – new parameter value
-
inline void PrintHeader()#
Print a header of species to display concentrations with respect to time.
-
inline void PrintState(double time)#
Print state (concentrations) at the given time.
- Parameters:
time – solving time
Public Members
-
DenseMatrixPolicy variables_#
The concentration of chemicals, varies through time.
-
DenseMatrixPolicy custom_rate_parameters_#
Rate paramters particular to user-defined rate constants, may vary in time.
-
DenseMatrixPolicy rate_constants_#
The reaction rates, may vary in time.
-
std::vector<Conditions> conditions_#
Atmospheric conditions, varies in time.
-
SparseMatrixPolicy jacobian_#
The jacobian structure, varies for each solve.
-
std::map<std::string, std::size_t> variable_map_#
Immutable data required for the state.
-
using DenseMatrixPolicyType = DenseMatrixPolicy#
-
struct StateParameters#
- #include <micm/solver/state.hpp>
Invariants that can be used to construct a state.
-
class SurfaceRateConstant : public micm::RateConstant#
- #include <micm/process/surface_rate_constant.hpp>
A rate constant for surface reactions.
Public Functions
-
inline SurfaceRateConstant(const SurfaceRateConstantParameters ¶meters)#
- Parameters:
parameters – The data required to build this class
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual std::vector<std::string> CustomParameters() const override#
Returns labels for the surface rate constant parameters: aerosol effective radius [m] aerosol number concentration [# m-3].
- Returns:
Rate constant labels
-
inline virtual std::size_t SizeCustomParameters() const override#
Returns the number of custom parameters.
- Returns:
Number of custom parameters
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline SurfaceRateConstant(const SurfaceRateConstantParameters ¶meters)#
-
struct SurfaceRateConstantParameters#
-
class System#
- #include <micm/system/system.hpp>
A
System
holds all physical information that represents a grid cell.Public Functions
-
inline System()#
Default constructor.
-
inline size_t StateSize() const#
Returns the number of doubles required to store the system state.
-
inline std::vector<std::string> UniqueNames() const#
Returns a set of unique 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 std::size_t i)> f) const#
Returns a set of unique species names.
- Parameters:
f – Function used to apply specific order to unique names
- Returns:
vector of unique state variable names
Public Members
-
Phase gas_phase_#
The gas phase is a micm::Phase and determines what species are present.
-
inline System()#
-
struct SystemParameters#
-
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 >
-
class TernaryChemicalActivationRateConstant : public micm::RateConstant#
- #include <micm/process/ternary_chemical_activation_rate_constant.hpp>
A TernaryChemicalActivation rate constant.
Public Functions
-
inline TernaryChemicalActivationRateConstant()#
Default constructor.
-
inline TernaryChemicalActivationRateConstant(const TernaryChemicalActivationRateConstantParameters ¶meters)#
An explicit constructor.
- Parameters:
parameters – A set of troe rate constants
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline double Calculate(const double &temperature, const double &air_number_density) const#
Calculate the rate constant.
- Parameters:
temperature – Temperature in [K]
air_number_density – Number density in [mol m-3]
- Returns:
-
inline TernaryChemicalActivationRateConstant()#
-
struct TernaryChemicalActivationRateConstantParameters#
Public Members
-
double k0_A_ = 1.0#
low-pressure pre-exponential factor
-
double k0_B_ = 0.0#
low-pressure temperature-scaling parameter
-
double k0_C_ = 0.0#
low-pressure exponential factor
-
double kinf_A_ = 1.0#
high-pressure pre-exponential factor
-
double kinf_B_ = 0.0#
high-pressure temperature-scaling parameter
-
double kinf_C_ = 0.0#
high-pressure exponential factor
-
double Fc_ = 0.6#
TernaryChemicalActivation F_c parameter.
-
double N_ = 1.0#
TernaryChemicalActivation N parameter.
-
double k0_A_ = 1.0#
-
class TroeRateConstant : public micm::RateConstant#
- #include <micm/process/troe_rate_constant.hpp>
A Troe rate constant.
Public Functions
-
inline TroeRateConstant()#
Default constructor.
-
inline TroeRateConstant(const TroeRateConstantParameters ¶meters)#
An explicit constructor.
- Parameters:
parameters – A set of troe rate constants
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline double Calculate(const double &temperature, const double &air_number_density) const#
Calculate the rate constant.
- Parameters:
temperature – Temperature in [K]
air_number_density – Number density in [mol m-3]
- Returns:
-
inline TroeRateConstant()#
-
struct TroeRateConstantParameters#
Public Members
-
double k0_A_ = 1.0#
low-pressure pre-exponential factor
-
double k0_B_ = 0.0#
low-pressure temperature-scaling parameter
-
double k0_C_ = 0.0#
low-pressure exponential factor
-
double kinf_A_ = 1.0#
high-pressure pre-exponential factor
-
double kinf_B_ = 0.0#
high-pressure temperature-scaling parameter
-
double kinf_C_ = 0.0#
high-pressure exponential factor
-
double Fc_ = 0.6#
Troe F_c parameter.
-
double N_ = 1.0#
Troe N parameter.
-
double k0_A_ = 1.0#
-
class TunnelingRateConstant : public micm::RateConstant#
- #include <micm/process/tunneling_rate_constant.hpp>
Rate constant for tunneling reactions.
Public Functions
-
inline TunnelingRateConstant()#
Default constructor.
-
inline TunnelingRateConstant(const TunnelingRateConstantParameters ¶meters)#
An explicit constructor.
- Parameters:
parameters – A set of troe rate constants
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline double Calculate(const double &temperature) const#
Calculate the rate constant.
- Parameters:
temperature – Temperature in [K]
- Returns:
the calculated rate constant
-
inline TunnelingRateConstant()#
-
struct TunnelingRateConstantParameters#
-
class UserDefinedRateConstant : public micm::RateConstant#
- #include <micm/process/user_defined_rate_constant.hpp>
A photolysis rate constant.
Public Functions
-
inline UserDefinedRateConstant()#
Default constructor.
-
inline UserDefinedRateConstant(const UserDefinedRateConstantParameters ¶meters)#
- Parameters:
parameters – The data needed to build this class
-
inline virtual std::unique_ptr<RateConstant> Clone() const override#
Deep copy.
-
inline virtual std::vector<std::string> CustomParameters() const override#
Returns a label for the user-defined rate constant parameter.
- Returns:
Rate constant label
-
inline virtual std::size_t SizeCustomParameters() const override#
Returns the number of custom parameters.
- Returns:
Number of custom parameters
-
inline virtual double Calculate(const Conditions &conditions, std::vector<double>::const_iterator custom_parameters) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
custom_parameters – User-defined rate constant parameters
- Returns:
A rate constant based off of the conditions in the system
-
inline virtual double Calculate(const Conditions &conditions) const override#
Calculate the rate constant.
- Parameters:
conditions – The current environmental conditions of the chemical system
- Returns:
A rate constant based off of the conditions in the system
-
inline UserDefinedRateConstant()#
-
struct UserDefinedRateConstantParameters#
-
template<class T, std::size_t 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< T, L >
Public Functions
-
inline void Fill(T val)#
Set every matrix element to a given value.
- Parameters:
val – Value to set each element to
-
inline void Axpy(const double &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:
alpha – The scaling scalar to apply to the VectorMatrix x
x – The input VectorMatrix
-
inline void Fill(T val)#
-
namespace constants#
Variables
-
static constexpr double BOLTZMANN_CONSTANT = 1.380649e-23#
-
static constexpr double AVOGADRO_CONSTANT = 6.02214076e23#
-
static constexpr double GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_CONSTANT#
-
static constexpr double BOLTZMANN_CONSTANT = 1.380649e-23#
-
namespace property_keys#
-
template<class SolverParametersPolicy, std::size_t L = MICM_DEFAULT_VECTOR_SIZE>