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. | |
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. [36] or Niemeyer, et al. [33], 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 (span< double > dkfwd) |
| Calculate derivatives for forward rate constants with respect to temperature at constant pressure, molar concentration and mole fractions. | |
| virtual void | getFwdRateConstants_ddP (span< double > dkfwd) |
| Calculate derivatives for forward rate constants with respect to pressure at constant temperature, molar concentration and mole fractions. | |
| virtual void | getFwdRateConstants_ddC (span< double > dkfwd) |
| Calculate derivatives for forward rate constants with respect to molar concentration at constant temperature, pressure and mole fractions. | |
| virtual void | getFwdRatesOfProgress_ddT (span< 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 (span< 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 (span< 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 (span< 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 (span< 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 (span< 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 (span< 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 (span< 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 (span< 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 (span< double > dwdot) |
| Calculate derivatives for species creation rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
| void | getCreationRates_ddP (span< double > dwdot) |
| Calculate derivatives for species creation rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
| void | getCreationRates_ddC (span< 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 (span< double > dwdot) |
| Calculate derivatives for species destruction rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
| void | getDestructionRates_ddP (span< double > dwdot) |
| Calculate derivatives for species destruction rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
| void | getDestructionRates_ddC (span< 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 (span< double > dwdot) |
| Calculate derivatives for species net production rates with respect to temperature at constant pressure, molar concentration and mole fractions. | |
| void | getNetProductionRates_ddP (span< double > dwdot) |
| Calculate derivatives for species net production rates with respect to pressure at constant temperature, molar concentration and mole fractions. | |
| void | getNetProductionRates_ddC (span< 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. | |
Methods to set up a simulation | |
| virtual Eigen::SparseMatrix< double > | jacobian () |
| Calculate the Jacobian of a specific reactor specialization. | |
|
inlinevirtual |
Retrieve derivative settings.
| settings | AnyMap containing settings determining derivative evaluation. |
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 697 of file Kinetics.h.
|
inlinevirtual |
Set/modify derivative settings.
| settings | AnyMap containing settings determining derivative evaluation. |
Reimplemented in BulkKinetics, and InterfaceKinetics.
Definition at line 708 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 719 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 730 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 744 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 755 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 766 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 780 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 797 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 817 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 828 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 839 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 853 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 870 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 890 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 901 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 912 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 926 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 943 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 963 of file Kinetics.h.
| void getCreationRates_ddT | ( | span< 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 459 of file Kinetics.cpp.
| void getCreationRates_ddP | ( | span< 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 472 of file Kinetics.cpp.
| void getCreationRates_ddC | ( | span< 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 485 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 498 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 508 of file Kinetics.cpp.
| void getDestructionRates_ddT | ( | span< 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 518 of file Kinetics.cpp.
| void getDestructionRates_ddP | ( | span< 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 531 of file Kinetics.cpp.
| void getDestructionRates_ddC | ( | span< 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 544 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 557 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 567 of file Kinetics.cpp.
| void getNetProductionRates_ddT | ( | span< 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 577 of file Kinetics.cpp.
| void getNetProductionRates_ddP | ( | span< 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 586 of file Kinetics.cpp.
| void getNetProductionRates_ddC | ( | span< 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 595 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 604 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 609 of file Kinetics.cpp.
| Eigen::SparseMatrix< double > jacobian | ( | ) |
Return underlying Jacobian matrix.
Definition at line 61 of file EigenSparseJacobian.cpp.
|
virtual |
Calculate the Jacobian of a specific reactor specialization.
Definition at line 124 of file ReactorBase.cpp.