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 underlying Jacobian matrix. | |
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. [33] or Niemeyer, et al. [30], 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 689 of file Kinetics.h.
|
inlinevirtual |
Set/modify derivative settings.
settings | AnyMap containing settings determining derivative evaluation. |
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 700 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 711 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 722 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 736 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 747 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 758 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 772 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 789 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 809 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 820 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 831 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 845 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 862 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 882 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 893 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 904 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 918 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 935 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 955 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 416 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 428 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 440 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 452 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 462 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 472 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 484 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 496 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 508 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 518 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 528 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 536 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 544 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 552 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 557 of file Kinetics.cpp.
Eigen::SparseMatrix< double > jacobian | ( | ) |
Return underlying Jacobian matrix.
Definition at line 61 of file EigenSparseJacobian.cpp.
MultiJac & jacobian | ( | ) |
Return a reference to the Jacobian evaluator of an OneDim object.
Definition at line 88 of file OneDim.cpp.
|
inlinevirtual |
Calculate the Jacobian of a specific Reactor specialization.
Reimplemented in IdealGasConstPressureMoleReactor, and IdealGasMoleReactor.