The Matlab code
Important
Some run-time options for Matlab-language integrators (specified in the ICNTRL and RCNTRL arrays) do not exactly correspond to the Fortran90 run-time options. We will standardize run-time integrator options across all target languages in a future KPP release.
Matlab provides a high-level programming environment that allows algorithm development, numerical computations, and data analysis and visualization. The KPP-generated Matlab code allows for a rapid prototyping of chemical kinetic schemes, and for a convenient analysis and visualization of the results. Differences between different kinetic mechanisms can be easily understood. The Matlab code can be used to derive reference numerical solutions, which are then compared against the results obtained with user-supplied numerical techniques. KPP/Matlab can also be used to teach students fundamentals of chemical kinetics and chemical numerical simulations.
Each Matlab function has to reside in a separate m-file. Function calls
use the m-function-file names to reference the function. Consequently,
KPP generates one m-function-file for each of the functions discussed in
the sections entitled ROOT_Function ,
ROOT_Jacobian and ROOT_JacobianSP, ROOT_Hessian and ROOT_HessianSP,
ROOT_Stoichiom and ROOT_StoichiomSP, ROOT_Util. The names of the
m-function-files are the same as the names of the functions (prefixed
by the model name ROOT.
The variables of Parameters Declared in ROOT_Parameters are defined as Matlab global
variables and initialized in the file
ROOT_parameter_defs.m. The variables of Global Variables Declared in ROOT_Global are
declared as Matlab global variables in the file
ROOT_global_defs.m. They can be accessed from within each
Matlab function by using declarations of the variables of interest.
The sparse data structures for the Jacobian (cf. Sparse Jacobian Data Structures), the Hessian
(cf. Sparse Hessian Data), the stoichiometric matrix (cf. Sparse Stoichiometric Matrix),
and the Jacobian of reaction (see Sparse Data for Jacobian of Reactant Products) are declared as
Matlab global variables in the file
ROOT_Sparse_defs.m. They are initialized in separate m-files,
namely ROOT_JacobianSP.m, ROOT_HessianSP.m, and
ROOT_StoichiomSP.m respectively.
Two wrappers (ROOT_Fun_Chem.m and ROOT_Jac_SP_Chem.m) are
provided for interfacing the ODE function and the sparse ODE Jacobian
with Matlab’s suite of ODE integrators. Specifically, the syntax of
the wrapper calls matches the syntax required by Matlab’s integrators
like ode15s. Moreover, the Jacobian wrapper converts the sparse KPP
format into a Matlab sparse matrix.
Function |
Description |
|---|---|
|
Driver |
|
Global parameters |
|
Global variables |
|
Global sparsity data |
|
Template for ODE function |
|
ODE function |
|
Template for ODE Jacobian |
|
Jacobian in sparse format |
|
Sparsity data structures |
|
ODE Hessian in sparse format |
|
Sparsity data structures |
|
Hessian action on vectors |
|
Transposed Hessian action on vectors |
|
Derivatives of Fun and Jac w/r/t rate coefficients |
|
Sparse data |
|
Reactant products |
|
Jacobian of reactant products |
|
User-defined rate reaction laws |
|
Update photolysis rate coefficients |
|
Update all rate coefficients |
|
Update sola intensity |
|
Check mass balance for selected atoms |
|
Set initial values |
|
Shuffle concentration vector |
|
Shuffle concentration vector |