Cantera
3.0.0
|
Methods for calculating analytical and/or numerical derivatives.
Classes | |
class | MultiJac |
Class MultiJac evaluates the Jacobian of a system of equations defined by a residual function supplied by an instance of class OneDim. More... | |
Functions | |
Eigen::SparseMatrix< double > | jacobian () |
Return semi-analytical Jacobian of an AdaptivePreconditioner object. | |
MultiJac & | jacobian () |
Return a reference to the Jacobian evaluator of an OneDim object. | |
virtual Eigen::SparseMatrix< double > | jacobian () |
Calculate the Jacobian of a specific Reactor specialization. | |
Kinetics derivatives are calculated with respect to temperature, pressure, molar concentrations and species mole fractions for forward/reverse/net rates of progress as well as creation/destruction and net production of species. The following suffixes are used to indicate derivatives:
Source term derivatives are based on a generic rate-of-progress expression for the \( i \)-th reaction \( R_i \), which is a function of temperature \( T \), pressure \( P \) and molar concentrations \( C_j \): \[ R_i = k_{f,i} C_M^{\nu_{M,i}} \prod_j C_j^{\nu_{ji}^\prime} - k_{r,i} C_M^{\nu_{M,i}} \prod_j C_j^{\nu_{ji}^{\prime\prime}} \] Forward/reverse rate expressions \( k_{f,i} \) and \( k_{r,i} \) are implemented by ReactionRate specializations; forward/reverse stoichiometric coefficients are \( \nu_{ji}^\prime \) and \( \nu_{ji}^{\prime\prime} \). Unless the reaction involves third-body colliders, \( \nu_{M,i} = 0 \). For three-body reactions, effective ThirdBody collider concentrations \( C_M \) are considered with \( \nu_{M,i} = 1 \). For more detailed information on relevant theory, see, for example, Perini, et al. [31] or Niemeyer, et al. [29], although specifics of Cantera's implementation may differ. Partial derivatives are obtained from the product rule, where resulting terms consider reaction rate derivatives, derivatives of the concentration product term, and, if applicable, third-body term derivatives. ReactionRate specializations may implement exact derivatives (example: ArrheniusRate::ddTScaledFromStruct) or approximate them numerically (examples: ReactionData::perturbTemperature, PlogData::perturbPressure, FalloffData::perturbThirdBodies). Derivatives of concentration and third-body terms are based on analytic expressions. Species creation and destruction rates are obtained by multiplying rate-of-progress vectors by stoichiometric coefficient matrices. As this is a linear operation, it is possible to calculate derivatives the same way. All derivatives are calculated for source terms while holding other properties constant, independent of whether equation of state or \( \sum X_k = 1 \) constraints are satisfied. Thus, derivatives deviate from Jacobians and numerical derivatives that implicitly enforce these constraints. Depending on application and equation of state, derivatives can nevertheless be used to obtain Jacobians, for example:
While some applications require exact derivatives, others can tolerate approximate derivatives that neglect terms to increase computational speed and/or improve Jacobian sparsity (example: AdaptivePreconditioner). Derivative evaluations settings are accessible by keyword/value pairs using the methods getDerivativeSettings() and setDerivativeSettings(). For BulkKinetics, the following keyword/value pairs are supported:
For InterfaceKinetics, the following keyword/value pairs are supported:
| |
virtual void | getDerivativeSettings (AnyMap &settings) const |
Retrieve derivative settings. | |
virtual void | setDerivativeSettings (const AnyMap &settings) |
Set/modify derivative settings. | |
virtual void | getFwdRateConstants_ddT (double *dkfwd) |
Calculate derivatives for forward rate constants with respect to temperature at constant pressure, molar concentration and mole fractions. | |
virtual void | getFwdRateConstants_ddP (double *dkfwd) |
Calculate derivatives for forward rate constants with respect to pressure at constant temperature, molar concentration and mole fractions. | |
virtual void | getFwdRateConstants_ddC (double *dkfwd) |
Calculate derivatives for forward rate constants with respect to molar concentration at constant temperature, pressure and mole fractions. | |
virtual void | getFwdRatesOfProgress_ddT (double *drop) |
Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions. | |
virtual void | getFwdRatesOfProgress_ddP (double *drop) |
Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions. | |
virtual void | getFwdRatesOfProgress_ddC (double *drop) |
Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions. | |
virtual Eigen::SparseMatrix< double > | fwdRatesOfProgress_ddX () |
Calculate derivatives for forward rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
virtual Eigen::SparseMatrix< double > | fwdRatesOfProgress_ddCi () |
Calculate derivatives for forward rates-of-progress with respect to species concentration at constant temperature, pressure and remaining species concentrations. | |
virtual void | getRevRatesOfProgress_ddT (double *drop) |
Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions. | |
virtual void | getRevRatesOfProgress_ddP (double *drop) |
Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions. | |
virtual void | getRevRatesOfProgress_ddC (double *drop) |
Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions. | |
virtual Eigen::SparseMatrix< double > | revRatesOfProgress_ddX () |
Calculate derivatives for reverse rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
virtual Eigen::SparseMatrix< double > | revRatesOfProgress_ddCi () |
Calculate derivatives for forward rates-of-progress with respect to species concentration at constant temperature, pressure and remaining species concentrations. | |
virtual void | getNetRatesOfProgress_ddT (double *drop) |
Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions. | |
virtual void | getNetRatesOfProgress_ddP (double *drop) |
Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions. | |
virtual void | getNetRatesOfProgress_ddC (double *drop) |
Calculate derivatives for net rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions. | |
virtual Eigen::SparseMatrix< double > | netRatesOfProgress_ddX () |
Calculate derivatives for net rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
virtual Eigen::SparseMatrix< double > | netRatesOfProgress_ddCi () |
Calculate derivatives for net rates-of-progress with respect to species concentration at constant temperature, pressure, and remaining species concentrations. | |
void | getCreationRates_ddT (double *dwdot) |
Calculate derivatives for species creation rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
void | getCreationRates_ddP (double *dwdot) |
Calculate derivatives for species creation rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
void | getCreationRates_ddC (double *dwdot) |
Calculate derivatives for species creation rates with respect to molar concentration at constant temperature, pressure and mole fractions. | |
Eigen::SparseMatrix< double > | creationRates_ddX () |
Calculate derivatives for species creation rates with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
Eigen::SparseMatrix< double > | creationRates_ddCi () |
Calculate derivatives for species creation rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. | |
void | getDestructionRates_ddT (double *dwdot) |
Calculate derivatives for species destruction rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
void | getDestructionRates_ddP (double *dwdot) |
Calculate derivatives for species destruction rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
void | getDestructionRates_ddC (double *dwdot) |
Calculate derivatives for species destruction rates with respect to molar concentration at constant temperature, pressure and mole fractions. | |
Eigen::SparseMatrix< double > | destructionRates_ddX () |
Calculate derivatives for species destruction rates with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
Eigen::SparseMatrix< double > | destructionRates_ddCi () |
Calculate derivatives for species destruction rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. | |
void | getNetProductionRates_ddT (double *dwdot) |
Calculate derivatives for species net production rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
void | getNetProductionRates_ddP (double *dwdot) |
Calculate derivatives for species net production rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
void | getNetProductionRates_ddC (double *dwdot) |
Calculate derivatives for species net production rates with respect to molar concentration at constant temperature, pressure and mole fractions. | |
Eigen::SparseMatrix< double > | netProductionRates_ddX () |
Calculate derivatives for species net production rates with respect to species mole fractions at constant temperature, pressure and molar concentration. | |
Eigen::SparseMatrix< double > | netProductionRates_ddCi () |
Calculate derivatives for species net production rates with respect to species concentration at constant temperature, pressure, and concentration of all other species. | |
|
inlinevirtual |
Retrieve derivative settings.
settings | AnyMap containing settings determining derivative evaluation. |
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 721 of file Kinetics.h.
|
inlinevirtual |
Set/modify derivative settings.
settings | AnyMap containing settings determining derivative evaluation. |
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 732 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rate constants with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | dkfwd | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 743 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rate constants with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | dkfwd | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 754 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rate constants with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | dkfwd | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 768 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 779 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 790 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 804 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Reimplemented in BulkKinetics.
Definition at line 821 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to species concentration at constant temperature, pressure and remaining species concentrations.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 841 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for reverse rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 852 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for reverse rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 863 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for reverse rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 877 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for reverse rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Reimplemented in BulkKinetics.
Definition at line 894 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for forward rates-of-progress with respect to species concentration at constant temperature, pressure and remaining species concentrations.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 914 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for net rates-of-progress with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 925 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for net rates-of-progress with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 936 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for net rates-of-progress with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | drop | Output vector of derivatives. Length: nReactions(). |
Reimplemented in BulkKinetics.
Definition at line 950 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for net rates-of-progress with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Reimplemented in BulkKinetics.
Definition at line 967 of file Kinetics.h.
|
inlinevirtual |
Calculate derivatives for net rates-of-progress with respect to species concentration at constant temperature, pressure, and remaining species concentrations.
The method returns a matrix with nReactions() rows and nTotalSpecies() columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 987 of file Kinetics.h.
void getCreationRates_ddT | ( | double * | dwdot | ) |
Calculate derivatives for species creation rates with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 446 of file Kinetics.cpp.
void getCreationRates_ddP | ( | double * | dwdot | ) |
Calculate derivatives for species creation rates with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 458 of file Kinetics.cpp.
void getCreationRates_ddC | ( | double * | dwdot | ) |
Calculate derivatives for species creation rates with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 470 of file Kinetics.cpp.
Eigen::SparseMatrix< double > creationRates_ddX | ( | ) |
Calculate derivatives for species creation rates with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Definition at line 482 of file Kinetics.cpp.
Eigen::SparseMatrix< double > creationRates_ddCi | ( | ) |
Calculate derivatives for species creation rates with respect to species concentration at constant temperature, pressure, and concentration of all other species.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Definition at line 492 of file Kinetics.cpp.
void getDestructionRates_ddT | ( | double * | dwdot | ) |
Calculate derivatives for species destruction rates with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 502 of file Kinetics.cpp.
void getDestructionRates_ddP | ( | double * | dwdot | ) |
Calculate derivatives for species destruction rates with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 514 of file Kinetics.cpp.
void getDestructionRates_ddC | ( | double * | dwdot | ) |
Calculate derivatives for species destruction rates with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 526 of file Kinetics.cpp.
Eigen::SparseMatrix< double > destructionRates_ddX | ( | ) |
Calculate derivatives for species destruction rates with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Definition at line 538 of file Kinetics.cpp.
Eigen::SparseMatrix< double > destructionRates_ddCi | ( | ) |
Calculate derivatives for species destruction rates with respect to species concentration at constant temperature, pressure, and concentration of all other species.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Definition at line 548 of file Kinetics.cpp.
void getNetProductionRates_ddT | ( | double * | dwdot | ) |
Calculate derivatives for species net production rates with respect to temperature at constant pressure, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 558 of file Kinetics.cpp.
void getNetProductionRates_ddP | ( | double * | dwdot | ) |
Calculate derivatives for species net production rates with respect to pressure at constant temperature, molar concentration and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 566 of file Kinetics.cpp.
void getNetProductionRates_ddC | ( | double * | dwdot | ) |
Calculate derivatives for species net production rates with respect to molar concentration at constant temperature, pressure and mole fractions.
[out] | dwdot | Output vector of derivatives. Length: m_kk. |
Definition at line 574 of file Kinetics.cpp.
Eigen::SparseMatrix< double > netProductionRates_ddX | ( | ) |
Calculate derivatives for species net production rates with respect to species mole fractions at constant temperature, pressure and molar concentration.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( X_i \), all other \( X_j \) are held constant, rather than enforcing \( \sum X_j = 1 \).
Definition at line 582 of file Kinetics.cpp.
Eigen::SparseMatrix< double > netProductionRates_ddCi | ( | ) |
Calculate derivatives for species net production rates with respect to species concentration at constant temperature, pressure, and concentration of all other species.
The method returns a square matrix with nTotalSpecies() rows and columns. For a derivative with respect to \( c_i \), all other \( c_j \) are held constant.
Definition at line 587 of file Kinetics.cpp.
|
inline |
Return semi-analytical Jacobian of an AdaptivePreconditioner object.
Definition at line 53 of file AdaptivePreconditioner.h.
MultiJac & jacobian | ( | ) |
Return a reference to the Jacobian evaluator of an OneDim object.
Definition at line 133 of file OneDim.cpp.
|
inlinevirtual |
Calculate the Jacobian of a specific Reactor specialization.
Reimplemented in IdealGasConstPressureMoleReactor, and IdealGasMoleReactor.