Skip to content

Commit

Permalink
[Kinetics] Remove unnecessary service functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Dec 12, 2021
1 parent 7b9dc72 commit dfabbc6
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 98 deletions.
20 changes: 0 additions & 20 deletions include/cantera/kinetics/MultiRate.h
Expand Up @@ -93,27 +93,7 @@ class MultiBulkRate final : public MultiRateBase
return R.evalFromStruct(m_shared);
}

virtual double ddTSingle(ReactionRate& rate) override
{
RateType& R = static_cast<RateType&>(rate);
return R.evalFromStruct(m_shared) * _get_ddTScaled(R);
}

protected:
//! Helper function to evaluate temperature derivative for rate types that
//! implement the `ddTScaledFromStruct` method.
template <typename T=RateType, typename std::enable_if<has_ddT<T>::value, bool>::type = true>
double _get_ddTScaled(RateType& rate) {
return rate.ddTScaledFromStruct(m_shared);
}

//! Helper function for rate types that do not implement `ddTScaledFromStruct`
template <typename T=RateType, typename std::enable_if<!has_ddT<T>::value, bool>::type = true>
double _get_ddTScaled(RateType& rate) {
throw NotImplementedError("ReactionRate::ddTScaledFromStruct",
"For rate of type {}", rate.type());
}

//! Vector of pairs of reaction rates indices and reaction rates
std::vector<std::pair<size_t, RateType>> m_rxn_rates;
std::map<size_t, size_t> m_indices; //! Mapping of indices
Expand Down
4 changes: 0 additions & 4 deletions include/cantera/kinetics/MultiRateBase.h
Expand Up @@ -78,10 +78,6 @@ class MultiRateBase

//! Get the rate for a single reaction. Used to implement ReactionRate::eval.
virtual double evalSingle(ReactionRate& rate) = 0;

//! Get the derivative of the rate with respect to temperature for a single
//! reaction. Used to implement ReactionRate::ddT.
virtual double ddTSingle(ReactionRate& rate) = 0;
};

} // end namespace Cantera
Expand Down
62 changes: 2 additions & 60 deletions include/cantera/kinetics/ReactionRate.h
@@ -1,8 +1,5 @@
/**
* @file ReactionRate.h
*
* @warning This file is an experimental part of the %Cantera API and
* may be changed or removed without notice.
*/

// This file is part of Cantera. See License.txt in the top-level directory or
Expand Down Expand Up @@ -104,10 +101,6 @@ class ReactionRate

//! Evaluate reaction rate based on temperature
//! @param T temperature [K]
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
double eval(double T) {
_evaluator().update(T);
return _evaluator().evalSingle(*this);
Expand All @@ -116,71 +109,20 @@ class ReactionRate
//! Evaluate reaction rate based on temperature and pressure
//! @param T temperature [K]
//! @param P pressure [Pa]
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
double eval(double T, double P) {
_evaluator().update(T, P);
return _evaluator().evalSingle(*this);
}

//! Evaluate reaction rate based on temperature and pressure
//! Evaluate reaction rate based on temperature, pressure and extra parameter
//! @param T temperature [K]
//! @param P pressure [Pa]
//! @param extra extra parameter
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
//! @param extra extra parameter (used by some parameterizations)
double eval(double T, double P, double extra) {
_evaluator().update(T, P, extra);
return _evaluator().evalSingle(*this);
}

//! Evaluate reaction rate based on bulk phase
//! @param bulk object representing bulk phase
//! @param kin object representing kinetics (not required for all rate types)
double eval(const ThermoPhase& bulk, const Kinetics& kin) {
_evaluator().update(bulk, kin);
return _evaluator().evalSingle(*this);
}

//! Evaluate reaction rate derivative based on temperature
//! @param T temperature [K]
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
double ddT(double T) {
_evaluator().update(T);
return _evaluator().ddTSingle(*this);
}

//! Evaluate reaction rate derivative based on temperature and pressure
//! @param T temperature [K]
//! @param P pressure [Pa]
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
double ddT(double T, double P) {
_evaluator().update(T, P);
return _evaluator().ddTSingle(*this);
}

//! Evaluate reaction rate derivative based on bulk phase
//! @param bulk object representing bulk phase
//! @param kin object representing kinetics (not required for all rate types)
/**
* @warning This method is an experimental part of the %Cantera API and
* may be changed or removed without notice.
* */
double ddT(const ThermoPhase& bulk, const Kinetics& kin) {
_evaluator().update(bulk, kin);
return _evaluator().ddTSingle(*this);
}

protected:
//! Get parameters
//! @param node AnyMap containing rate information
Expand Down
2 changes: 0 additions & 2 deletions interfaces/cython/cantera/_cantera.pxd
Expand Up @@ -405,8 +405,6 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera":
double eval(double) except +translate_exception
double eval(double, double) except +translate_exception
double eval(double, double, double) except +translate_exception
double ddT(double) except +translate_exception
double ddT(double, double) except +translate_exception
CxxAnyMap parameters() except +translate_exception

cdef cppclass CxxArrheniusRate "Cantera::ArrheniusRate" (CxxReactionRate, CxxArrheniusBase):
Expand Down
12 changes: 0 additions & 12 deletions interfaces/cython/cantera/reaction.pyx
Expand Up @@ -31,9 +31,6 @@ cdef class ReactionRate:
For rate expressions that are dependent of pressure, an omission of pressure
will raise an exception. Rate expressions that require an extra parameter
require specification of all three parameters.
Warning: this method is an experimental part of the Cantera API and
may be changed or removed without notice.
"""
if pressure and extra:
return self.rate.eval(temperature, pressure, extra)
Expand Down Expand Up @@ -128,15 +125,6 @@ cdef class ReactionRate:
cxx_rate = CxxNewReactionRate(any_map)
return ReactionRate.wrap(cxx_rate)

def ddT(self, double temperature, pressure=None):
"""
Evaluate derivative of rate expression with respect to temperature.
"""
if pressure:
return self.rate.ddT(temperature, pressure)
else:
return self.rate.ddT(temperature)

property input_data:
"""
Get input data for this reaction rate with its current parameter values.
Expand Down

0 comments on commit dfabbc6

Please sign in to comment.