Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap up GasKinetics #1101

Merged
merged 79 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
db6114e
[Kinetics] Implement Kinetics::getThirdBodyConcentrations
ischoegl Sep 17, 2021
4f6d97b
[Python] Improve error message for invalid CustomRate input
ischoegl Sep 7, 2021
0c66b05
[Kinetics] Mark getReactionDelta as const
ischoegl Sep 6, 2021
a4b33d0
[Kinetics] Make shared ReactionData more flexible
ischoegl Sep 17, 2021
df53ece
[Unittest] Expand kineticsfromscratch.yaml
ischoegl Sep 8, 2021
673c180
[Kinetics] Remove prefix 'm_' in ReactionData
ischoegl Sep 13, 2021
4f3a6a6
[Kinetics] Small adjustments and fixes
ischoegl Sep 17, 2021
a293748
[Unittest] Simplify test_reaction.py suite
ischoegl Sep 17, 2021
7a78e43
[Kinetics] Introduce Arrhenius.h with ArrheniusBase object
ischoegl Sep 17, 2021
a19a875
[Kinetics] Introduce new Arrhenius3 class
ischoegl Sep 17, 2021
3e0aeb3
[Kinetics] Introduce RateTemplate in ReactionRate.h
ischoegl Sep 17, 2021
14d566a
[Kinetics] Switch ArrheniusRate to Arrhenius3
ischoegl Sep 17, 2021
d71713f
[Kinetics] Add type information to MultiRateBase
ischoegl Sep 18, 2021
830c2ad
[Kinetics] Implement BlowersMaselRate3
ischoegl Sep 18, 2021
1fbd4db
[Unittest] Add BlowersMaselRate tests
ischoegl Sep 18, 2021
60f7306
[Kinetics] Implement objects derived from FalloffRate
ischoegl Sep 18, 2021
922a709
Fix warnings/compilation errors
ischoegl Sep 19, 2021
1423c2f
[Python] Use callback in ReactionRate.wrap to set cdef'd references
ischoegl Sep 22, 2021
75b7d94
[Python] Use member variable to access C++ falloff
ischoegl Sep 22, 2021
9e93f34
[Kinetics] Buffer rate index for MultiRate objects
ischoegl Sep 22, 2021
d753730
[Kinetics] make Kinetics::getThirdBodyConcentrations const
ischoegl Sep 23, 2021
d269daa
[Unittest] Add Falloff reaction rate tests
ischoegl Sep 18, 2021
0d165b0
[Kinetics] Ensure rate_index is set correctly
ischoegl Sep 23, 2021
293bc1c
[Kinetics] Refactor BlowersMaselReaction
ischoegl Oct 3, 2021
3efcebb
[Kinetics] Remove transitional BlowersMasel classes
ischoegl Oct 3, 2021
7761001
[Kinetics] Differentiate Arrhenius/BlowersMasel versions 2 and 3
ischoegl Oct 3, 2021
e4f9f71
[Kinetics] Switch Falloff hi/low rates to ArrheniusBase
ischoegl Oct 3, 2021
2a3dadc
[Python] Expose ArrheniusBase to API
ischoegl Oct 3, 2021
8515592
[UnitTest] Add/update unit tests for BlowersMaselReaction
ischoegl Oct 3, 2021
2e1d2e8
[Kinetics] Relabel legacy falloff reactions as FalloffReactions2
ischoegl Oct 4, 2021
3b9cf24
[Kinetics] Prepare FalloffReaction API for legacy support
ischoegl Oct 5, 2021
b883ba5
[Unittest] Add falloff reaction tests
ischoegl Oct 4, 2021
c1ece46
[Kinetics] Remove optional (+M) terms in specialized methods
ischoegl Oct 6, 2021
c8039b2
[Kinetics] Implement initial FalloffReaction3 class
ischoegl Oct 6, 2021
352469b
[Kinetics] Improve handling of explicitly specified collision partners
ischoegl Oct 7, 2021
c61d0d0
[Units] Implement static Units::product method
ischoegl Oct 8, 2021
029797f
[Kinetics] Make ReactionRateFactory more flexible
ischoegl Oct 8, 2021
05713eb
[Kinetics] Add alternative calculateRateCoeffUnits method
ischoegl Oct 8, 2021
021c44f
[Kinetics] Switch ReactionRateFactory to UnitsVector
ischoegl Oct 8, 2021
7f1285f
[Kinetics] Simplify reaction rate unit handling
ischoegl Oct 8, 2021
742d295
[Samples] Fix BlowersMasel example
ischoegl Oct 8, 2021
37e5662
[Kinetics] Switch falloff reactions to new framework
ischoegl Oct 7, 2021
065640b
[Kinetics] Ensure Falloff reactions can be created from scratch
ischoegl Oct 9, 2021
73561bd
[Kinetics] Simplify handling of third-bodies in new framework
ischoegl Oct 11, 2021
e91ba3e
[Python] Add new FalloffReaction implementation to API
ischoegl Oct 9, 2021
52319b8
[Kinetics] Ensure ReactionPath.h works with legacy reactions
ischoegl Oct 11, 2021
99e4d4a
[Unittest] Update Falloff google tests
ischoegl Oct 7, 2021
1e591d3
[Kinetics] Differentiate between check and validate methods
ischoegl Oct 11, 2021
b513865
[Unittest] Add Falloff tests to test_reaction.py
ischoegl Oct 9, 2021
e15be57
[Kinetics] Add todo note for logic update in GasKinetics::update_rates_T
ischoegl Oct 12, 2021
a8728d7
Update/fix docstrings
ischoegl Oct 12, 2021
0e25371
Fix docs build
ischoegl Oct 12, 2021
45192d4
Fix typos in docstrings and comments
ischoegl Oct 17, 2021
c9d8ebc
[Python] Remove Reaction3 fragments
ischoegl Oct 18, 2021
56bce7b
[Unittest] Fix reaction tests with standalone rate objects
ischoegl Oct 18, 2021
3470bec
[Kinetics] Introduce RateEvaluator<> template
ischoegl Oct 19, 2021
c23b22d
[Kinetics] Transition PlogRate to RateEvaluator
ischoegl Oct 21, 2021
bda034c
[Kinetics] Transition ChebyshevRate3 to RateEvaluator
ischoegl Oct 21, 2021
e093f94
[Kinetics] Transition CustomFunc1Rate to RateEvaluator
ischoegl Oct 21, 2021
e4c4722
[Kinetics] Remove ReactionRate template
ischoegl Oct 21, 2021
f15b31f
[Kinetics] Rename ReactionRateBase to ReactionRate
ischoegl Oct 21, 2021
d12b99a
[Test] Fix running reaction tests with optimize=n
speth Nov 12, 2021
983bb2b
[Kinetics] Eliminate need to template ReactionRate types
speth Nov 11, 2021
47c6200
[Kinetics] Automatically determine if reactions use update method
speth Nov 17, 2021
3d0d53d
[Kinetics] Remove unnecessary ReactionRate::update methods
speth Nov 17, 2021
8e70687
[Kinetics] Improve documentation for ReactionRate and MultiRate
speth Nov 17, 2021
0271301
Simple review comments
ischoegl Nov 29, 2021
d838425
[Kinetics] Add suffix *Rate to falloff class names
ischoegl Nov 29, 2021
c10d63a
[Kinetics] Create separate ThirdBodyCalc3 class for new framework
ischoegl Nov 29, 2021
61b785c
[Kinetics] Add suffix *Rate to Arrhenius, BlowersMasel, Plog and Cheb…
ischoegl Nov 29, 2021
48725ce
[Kinetics] Implement setters/getters for allowNegativePreExponentialF…
ischoegl Nov 29, 2021
7cb00cc
[Kinetics] Ensure that chemically-activated reactions are recognized
ischoegl Nov 30, 2021
4c46c0b
[Units] Replace UnitsVector by struct UnitStack
ischoegl Nov 30, 2021
d3664f9
[Kinetics] Clarify ChebyshevRate3::getParameters
ischoegl Nov 30, 2021
6d98196
Address review comments
ischoegl Dec 1, 2021
815cfab
[Sphinx] Add new ReactionRate objects to Sphinx documentation
ischoegl Dec 1, 2021
ab8fd9f
[1D] Do not impose bounds on inactive solution components
speth Dec 2, 2021
1b46a24
[Units] Replace roundf by round
ischoegl Nov 27, 2021
3a662b3
[YAML] Fix glitch in formatDouble serialization
ischoegl Dec 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 66 additions & 7 deletions doc/sphinx/cython/kinetics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ InterfaceKinetics
Reactions
---------

These classes contain the definition of a single reaction and its associated
rate expression, independent of a specific `Kinetics` object.
These classes contain the definition of a single reaction, independent of a specific
`Kinetics` object. For legacy objects (CTI/XML input), each class integrates associated
rate expressions, whereas for the new, YAML-based implementation, reaction rate
evaluation is handled by dedicated `ReactionRate` objects.

Reaction
^^^^^^^^
Expand Down Expand Up @@ -73,26 +75,83 @@ BlowersMaselInterfaceReaction
.. autoclass:: BlowersMaselInterfaceReaction(reactants='', products='')
:no-undoc-members:

Auxilliary Reaction Data
------------------------
Reaction Rates
---------------------------------------

ReactionRate
^^^^^^^^^^^^
.. autoclass:: ReactionRate()

ArrheniusRate
^^^^^^^^^^^^^
.. autoclass:: ArrheniusRate(A, b, Ea)
:no-undoc-members:

BlowersMaselRate
^^^^^^^^^^^^^^^^
.. autoclass:: BlowersMaselRate(A, b, Ea, w)
:no-undoc-members:

FalloffRate
^^^^^^^^^^^
.. autoclass:: FalloffRate()
:no-undoc-members:

LindemannRate
^^^^^^^^^^^^^
.. autoclass:: LindemannRate(low, high, falloff_coeffs)
:no-undoc-members:

TroeRate
^^^^^^^^
.. autoclass:: TroeRate(low, high, falloff_coeffs)
:no-undoc-members:

SriRate
^^^^^^^
.. autoclass:: SriRate(low, high, falloff_coeffs)
:no-undoc-members:

TsangRate
^^^^^^^^^
.. autoclass:: TsangRate(low, high, falloff_coeffs)
:no-undoc-members:

PlogRate
^^^^^^^^
.. autoclass:: PlogRate(rates)
:no-undoc-members:

ChebyshevRate
^^^^^^^^^^^^^
.. autoclass:: ChebyshevRate(temperature_range, pressure_range, data)
:no-undoc-members:

CustomRate
^^^^^^^^^^
.. autoclass:: CustomRate(k)
:no-undoc-members:

Auxilliary Reaction Data (legacy only)
--------------------------------------

Arrhenius
^^^^^^^^^
.. autoclass:: Arrhenius(A, b, E)

Falloff
^^^^^^^
.. autoclass:: Falloff(coeffs=(), init=True)
.. autoclass:: Falloff(params=(), init=True)
:no-undoc-members:

TroeFalloff
^^^^^^^^^^^
.. autoclass:: TroeFalloff(coeffs=(), init=True)
.. autoclass:: TroeFalloff(params=(), init=True)
:no-undoc-members:

SriFalloff
^^^^^^^^^^
.. autoclass:: SriFalloff(coeffs=(), init=True)
.. autoclass:: SriFalloff(params=(), init=True)
:no-undoc-members:

BlowersMasel
Expand Down
54 changes: 54 additions & 0 deletions include/cantera/base/Units.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class Units

bool operator==(const Units& other) const;

//! Return dimension of primary unit component
//! ("mass", "length", "time", "temperature", "current" or "quantity")
double dimension(const std::string& primary) const;

private:
//! Scale the unit by the factor `k`
void scale(double k) { m_factor *= k; }
Expand All @@ -77,6 +81,56 @@ class Units
};


//! Unit aggregation utility
/*!
* Provides functions for updating and calculating effective units from a stack
* of unit-exponent pairs. Matching units are aggregated, where a standard unit
* simplifies access when joining exponents. The utility is used in the context
* of effective reaction rate units.
ischoegl marked this conversation as resolved.
Show resolved Hide resolved
*
* @internal Helper utility class.
*
* @warning This class is an experimental part of the %Cantera API and
* may be changed or removed without notice.
*/
struct UnitStack
{
UnitStack(const Units& standardUnits) {
stack.reserve(2); // covers memory requirements for most applications
stack.emplace_back(standardUnits, 0.);
}

//! Alternative constructor allows for direct assignment of vector
UnitStack(std::initializer_list<std::pair<Units, double>> units)
: stack(units) {}

//! Size of UnitStack
int size() const { return stack.size(); }

//! Get standard unit used by UnitStack
Units standardUnits() const;

//! Set standard units
void setStandardUnits(Units& standardUnits);

//! Effective exponent of standard unit
double standardExponent() const;

//! Join (update) exponent of standard units, where the updated exponent is
//! the sum of the pre-existing exponent and the exponent passed as the argument.
void join(double exponent);
ischoegl marked this conversation as resolved.
Show resolved Hide resolved

//! Update exponent of item with matching units; if it does not exist,
//! add unit-exponent pair at end of stack
void update(const Units& units, double exponent);

//! Calculate product of units-exponent stack
Units product() const;

std::vector<std::pair<Units, double>> stack; //!< Stack uses vector of pairs
};
ischoegl marked this conversation as resolved.
Show resolved Hide resolved


//! Unit conversion utility
/*!
* Provides functions for converting dimensional values from a given unit system.
Expand Down
5 changes: 5 additions & 0 deletions include/cantera/base/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ std::string gitCommit();
*/
std::string canteraRoot();

//! Returns true if Cantera was compiled in debug mode. Used for handling some cases
//! where behavior tested in the test suite changes depending on whether the `NDEBUG`
//! preprocessor macro is defined.
bool debugModeEnabled();

/*!
* @defgroup logs Diagnostic Output
*
Expand Down
13 changes: 13 additions & 0 deletions include/cantera/base/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ const U& getValue(const std::map<T, U>& m, const T& key, const U& default_val) {
return (iter == m.end()) ? default_val : iter->second;
}

//! A macro for generating member function detectors, which can then be used in
//! combination with `std::enable_if` to allow selection of a particular template
//! specialization based on the presence of that member function. See MultiBulkRate for
//! examples of use.
#define CT_DEFINE_HAS_MEMBER(detector_name, func_name) \
template <typename T> \
struct detector_name { \
typedef char (& yes)[1], (& no)[2]; \
template <typename C> static yes check(decltype(&C::func_name)); \
template <typename> static no check(...); \
static bool const value = sizeof(check<T>(0)) == sizeof(yes); \
};

}

#endif
2 changes: 2 additions & 0 deletions include/cantera/cython/wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ KIN_1D(getDeltaSSEnthalpy)
KIN_1D(getDeltaSSGibbs)
KIN_1D(getDeltaSSEntropy)

KIN_1D(getThirdBodyConcentrations)

KIN_1D(getCreationRates)
KIN_1D(getDestructionRates)
KIN_1D(getNetProductionRates)
Expand Down
Loading