pyjac.core.rate_subs module¶
Module for writing species/reaction rate subroutines.
This is kept separate from Jacobian creation module in order to create only the rate subroutines if desired.
-
pyjac.core.rate_subs.
rxn_rate_const
(A, b, E)[source]¶ Returns line with reaction rate calculation (after = sign).
Parameters: Returns: line – String with expression for reaction rate.
Return type: Notes
Form of the reaction rate constant (from, e.g., Lu and Law [1]):
k_f = \begin{cases} A & \text{if } \beta = 0 \text{ and } T_a = 0 \\ \exp \left( \log A + \beta \log T \right) & \text{if } \beta \neq 0 \text{ and } \text{if } T_a = 0 \\ \exp \left( \log A + \beta \log T - T_a / T \right) & \text{if } \beta \neq 0 \text{ and } T_a \neq 0 \\ \exp \left( \log A - T_a / T \right) & \text{if } \beta = 0 \text{ and } T_a \neq 0 \\ A \prod^b T & \text{if } T_a = 0 \text{ and } b \in \mathbb{Z} \text{ (integers) } \end{cases}References
[1] TF Lu and CK Law, “Toward accommodating realistic fuel chemistry in large-scale computations,” Progress in Energy and Combustion Science, vol. 35, pp. 192-215, 2009. doi:10.1016/j.pecs.2008.10.002
-
pyjac.core.rate_subs.
get_cheb_rate
(lang, rxn, write_defns=True)[source]¶ Given a reaction, and a temperature and pressure, this routine will generate code to evaluate the Chebyshev rate efficiently.
Note
Assumes existence of variables dot_prod* of sized at least rxn.cheb_n_temp Pred and Tred, T and pres, and kf, cheb_temp_0 and cheb_temp_1.
Parameters: Returns: line – Line with evaluation of Chebyshev reaction rate.
Return type: list of
str
-
pyjac.core.rate_subs.
write_rxn_rates
(path, lang, specs, reacs, fwd_rxn_mapping, smm=None, auto_diff=False)[source]¶ Write reaction rate subroutine.
Includes conditionals for reversible reactions.
Parameters: - path (str) – Path to build directory for file.
- lang ({'c', 'cuda', 'fortran', 'matlab'}) – Programming language.
- specs (list of
SpecInfo
) – List of species in the mechanism. - reacs (list of
ReacInfo
) – List of reactions in the mechanism. - fwd_rxn_mapping (List of integers) – The index of the reaction in the original mechanism
- smm (
shared_memory_manager
, optional) – If notNone
(default),shared_memory_manager
for CUDA optimizations - auto_diff (Optional[bool]) – If
True
, generate files for Adept autodifferention library.
Returns: Return type: None
-
pyjac.core.rate_subs.
write_rxn_pressure_mod
(path, lang, specs, reacs, fwd_rxn_mapping, smm=None, auto_diff=False)[source]¶ Write subroutine to for reaction pressure dependence modifications.
Parameters: - path (str) – Path to build directory for file.
- lang ({'c', 'cuda', 'fortran', 'matlab'}) – Language type.
- specs (list of
SpecInfo
) – List of species in mechanism. - reacs (list of
ReacInfo
) – List of reactions in mechanism. - fwd_rxn_mapping (List of int) – The order of the reaction in the original mechanism
- smm (
shared_memory_manager
, optional) – If not`None`
,shared_memory_manager
to use for CUDA optimizations - auto_diff (bool, optional) – If
`True`
, generate files for Adept autodifferention library.
Returns: Return type: None
-
pyjac.core.rate_subs.
write_spec_rates
(path, lang, specs, reacs, fwd_spec_mapping, fwd_rxn_mapping, smm=None, auto_diff=False)[source]¶ Write subroutine to evaluate species rates of production.
Parameters: - path (str) – Path to build directory for file.
- lang ({'c', 'cuda', 'fortran', 'matlab'}) – Programming language.
- specs (list of
SpecInfo
) – List of species in mechanism. - reacs (list of
ReacInfo
) – List of reactions in mechanism. - fwd_spec_mapping (list of int) – the index of the species in the original mechanism
- fwd_rxn_mapping (list of int) – the index of the reactions in the original mechanism
- smm (shared_memory_manager, optional) – If not
`None`
,shared_memory_manager
to use for CUDA optimizations - auto_diff (bool, optional) – If
`True`
, generate files for Adept autodifferention library.
Returns: seen
Return type: list of
bool
,True
if species rate i is not identically zero
-
pyjac.core.rate_subs.
write_chem_utils
(path, lang, specs, auto_diff)[source]¶ Write subroutine to evaluate species thermodynamic properties.
Notes
Thermodynamic properties include: enthalpy, energy, specific heat (constant pressure and volume).
Parameters: Returns: Return type: None
-
pyjac.core.rate_subs.
write_derivs
(path, lang, specs, reacs, specs_nonzero, auto_diff=False)[source]¶ Writes derivative function file and header.
Parameters: - path (str) – Path to build directory for file.
- lang ({'c', 'cuda', 'fortran', 'matlab'}) – Programming language.
- specs (list of
SpecInfo
) – List of species in the mechanism. - reacs (list of
ReacInfo
) – List of reactions in the mechanism. - specs_nonzero (list of bool) – List of
bool
indicating species with zero net production - auto_diff (bool, optional) – If
True
, generate files for Adept autodifferention library.
Returns: Return type: None