mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Kinetics] Remove RateCoeffMg, FalloffFactory and FalloffMgr
This commit is contained in:
committed by
Bryan Weber
parent
ba207ad3b5
commit
28d9c95c7f
@@ -10,7 +10,7 @@
|
||||
#define CT_BULKKINETICS_H
|
||||
|
||||
#include "Kinetics.h"
|
||||
#include "RateCoeffMgr.h"
|
||||
#include "RxnRates.h"
|
||||
#include "ThirdBodyCalc.h"
|
||||
#include "cantera/kinetics/MultiRate.h"
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* @file FalloffFactory.h
|
||||
* Parameterizations for reaction falloff functions. Used by classes
|
||||
* that implement gas-phase kinetics (GasKinetics, GRI_30_Kinetics)
|
||||
* (see \ref falloffGroup and class \link Cantera::FalloffRate FalloffRate\endlink).
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* FalloffRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
|
||||
// This file is part of Cantera. See License.txt in the top-level directory or
|
||||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#ifndef CT_NEWFALLOFF_H
|
||||
#define CT_NEWFALLOFF_H
|
||||
|
||||
#include "cantera/base/FactoryBase.h"
|
||||
#include "cantera/kinetics/Falloff.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/**
|
||||
* Factory class to construct falloff function calculators.
|
||||
* The falloff factory is accessed through static method factory:
|
||||
*
|
||||
* @code
|
||||
* Falloff* f = FalloffFactory::factory()->newFalloff(type, c)
|
||||
* @endcode
|
||||
*
|
||||
* @ingroup falloffGroup
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* FalloffRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
class FalloffFactory : public Factory<Falloff>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Return a pointer to the factory. On the first call, a new instance is
|
||||
* created. Since there is no need to instantiate more than one factory,
|
||||
* on all subsequent calls, a pointer to the existing factory is returned.
|
||||
*/
|
||||
static FalloffFactory* factory() {
|
||||
std::unique_lock<std::mutex> lock(falloff_mutex);
|
||||
if (!s_factory) {
|
||||
s_factory = new FalloffFactory;
|
||||
}
|
||||
return s_factory;
|
||||
}
|
||||
|
||||
virtual void deleteFactory() {
|
||||
std::unique_lock<std::mutex> lock(falloff_mutex);
|
||||
delete s_factory;
|
||||
s_factory = 0;
|
||||
}
|
||||
|
||||
//! Return a pointer to a new falloff function calculator.
|
||||
/*!
|
||||
* @param type String identifier specifying the type of falloff function.
|
||||
* The standard types match class names defined in Falloff.h.
|
||||
* A factory class derived from FalloffFactory may define
|
||||
* other types as well.
|
||||
* @param c input vector of doubles which populates the falloff
|
||||
* parameterization.
|
||||
* @returns a pointer to a new Falloff class.
|
||||
*/
|
||||
virtual Falloff* newFalloff(const std::string& type, const vector_fp& c);
|
||||
|
||||
private:
|
||||
//! Pointer to the single instance of the factory
|
||||
static FalloffFactory* s_factory;
|
||||
|
||||
//! default constructor, which is defined as private
|
||||
FalloffFactory();
|
||||
|
||||
//! Mutex for use when calling the factory
|
||||
static std::mutex falloff_mutex;
|
||||
};
|
||||
|
||||
//! @copydoc FalloffFactory::newFalloff
|
||||
shared_ptr<Falloff> newFalloff(const std::string& type, const vector_fp& c);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,135 +0,0 @@
|
||||
/**
|
||||
* @file FalloffMgr.h
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* FalloffRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
|
||||
// This file is part of Cantera. See License.txt in the top-level directory or
|
||||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#ifndef CT_FALLOFFMGR_H
|
||||
#define CT_FALLOFFMGR_H
|
||||
|
||||
#include "Falloff.h"
|
||||
#include "cantera/base/global.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* A falloff manager that implements any set of falloff functions.
|
||||
* @ingroup falloffGroup
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* FalloffRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
class FalloffMgr
|
||||
{
|
||||
public:
|
||||
//! Constructor.
|
||||
FalloffMgr() :
|
||||
m_worksize(0) {
|
||||
}
|
||||
|
||||
//! Install a new falloff function calculator.
|
||||
/*
|
||||
* @param rxn Index of the falloff reaction. This will be used to
|
||||
* determine which array entry is modified in method pr_to_falloff.
|
||||
* @param reactionType Either `FALLOFF_RXN` or `CHEMACT_RXN`
|
||||
* @param f The falloff function.
|
||||
*
|
||||
* @deprecated To be removed after Cantera 2.6.
|
||||
*/
|
||||
void install(size_t rxn, int reactionType, shared_ptr<Falloff> f) {
|
||||
warn_deprecated("FalloffMgr::install()",
|
||||
"To be removed after Cantera 2.6. Specify reaction type using "
|
||||
"string instead.");
|
||||
|
||||
m_rxn.push_back(rxn);
|
||||
m_offset.push_back(m_worksize);
|
||||
m_worksize += f->workSize();
|
||||
m_falloff.push_back(f);
|
||||
m_isfalloff.push_back(reactionType == FALLOFF_RXN);
|
||||
m_indices[rxn] = m_falloff.size()-1;
|
||||
}
|
||||
|
||||
//! Install a new falloff function calculator.
|
||||
/*
|
||||
* @param rxn Index of the falloff reaction. This will be used to
|
||||
* determine which array entry is modified in method pr_to_falloff.
|
||||
* @param type Reaction type identifier.
|
||||
* @param f The falloff function.
|
||||
*/
|
||||
void install(size_t rxn, std::string type, shared_ptr<Falloff> f) {
|
||||
m_rxn.push_back(rxn);
|
||||
m_offset.push_back(m_worksize);
|
||||
m_worksize += f->workSize();
|
||||
m_falloff.push_back(f);
|
||||
m_isfalloff.push_back(type == "falloff-legacy");
|
||||
m_indices[rxn] = m_falloff.size()-1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Replace an existing falloff function calculator
|
||||
*
|
||||
* @param rxn External reaction index
|
||||
* @param f New falloff function, of the same kind as the existing one
|
||||
*/
|
||||
void replace(size_t rxn, shared_ptr<Falloff> f) {
|
||||
m_falloff[m_indices[rxn]] = f;
|
||||
}
|
||||
|
||||
//! Size of the work array required to store intermediate results.
|
||||
size_t workSize() {
|
||||
return m_worksize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cached temperature-dependent intermediate
|
||||
* results for all installed falloff functions.
|
||||
* @param t Temperature [K].
|
||||
* @param work Work array. Must be dimensioned at least workSize().
|
||||
*/
|
||||
void updateTemp(doublereal t, doublereal* work) {
|
||||
for (size_t i = 0; i < m_rxn.size(); i++) {
|
||||
m_falloff[i]->updateTemp(t, work + m_offset[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a vector of reduced pressures for each falloff reaction,
|
||||
* replace each entry by the value of the falloff function.
|
||||
*/
|
||||
void pr_to_falloff(doublereal* values, const doublereal* work) {
|
||||
for (size_t i = 0; i < m_rxn.size(); i++) {
|
||||
double pr = values[m_rxn[i]];
|
||||
if (m_isfalloff[i]) {
|
||||
// Pr / (1 + Pr) * F
|
||||
values[m_rxn[i]] *=
|
||||
m_falloff[i]->F(pr, work + m_offset[i]) / (1.0 + pr);
|
||||
} else {
|
||||
// 1 / (1 + Pr) * F
|
||||
values[m_rxn[i]] =
|
||||
m_falloff[i]->F(pr, work + m_offset[i]) / (1.0 + pr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<size_t> m_rxn;
|
||||
std::vector<shared_ptr<Falloff> > m_falloff;
|
||||
vector_int m_loc;
|
||||
std::vector<vector_fp::difference_type> m_offset;
|
||||
size_t m_worksize;
|
||||
|
||||
//! Distinguish between falloff and chemically activated reactions
|
||||
std::vector<bool> m_isfalloff;
|
||||
|
||||
//! map of external reaction index to local index
|
||||
std::map<size_t, size_t> m_indices;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,6 @@
|
||||
#define CT_GASKINETICS_H
|
||||
|
||||
#include "BulkKinetics.h"
|
||||
#include "FalloffMgr.h"
|
||||
#include "Reaction.h"
|
||||
|
||||
namespace Cantera
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define CT_IFACEKINETICS_H
|
||||
|
||||
#include "Kinetics.h"
|
||||
#include "RateCoeffMgr.h"
|
||||
#include "RxnRates.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/**
|
||||
* @file RateCoeffMgr.h
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* ReactionRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
|
||||
// This file is part of Cantera. See License.txt in the top-level directory or
|
||||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#ifndef CT_RATECOEFF_MGR_H
|
||||
#define CT_RATECOEFF_MGR_H
|
||||
|
||||
#include "RxnRates.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/**
|
||||
* This rate coefficient manager supports one parameterization of
|
||||
* the rate constant of any type.
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* ReactionRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
template<class R>
|
||||
class Rate1
|
||||
{
|
||||
public:
|
||||
Rate1() {}
|
||||
virtual ~Rate1() {}
|
||||
|
||||
/**
|
||||
* Install a rate coefficient calculator.
|
||||
* @param rxnNumber the reaction number
|
||||
* @param rate rate coefficient specification for the reaction
|
||||
*/
|
||||
void install(size_t rxnNumber, const R& rate) {
|
||||
m_rxn.push_back(rxnNumber);
|
||||
m_rates.push_back(rate);
|
||||
m_indices[rxnNumber] = m_rxn.size() - 1;
|
||||
}
|
||||
|
||||
//! Replace an existing rate coefficient calculator
|
||||
void replace(size_t rxnNumber, const R& rate) {
|
||||
size_t i = m_indices[rxnNumber];
|
||||
m_rates[i] = rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the concentration-dependent parts of the rate coefficient, if any.
|
||||
* Used by class SurfaceArrhenius to compute coverage-dependent
|
||||
* modifications to the Arrhenius parameters. The array c should contain
|
||||
* whatever data the particular rate coefficient class needs to update its
|
||||
* rates. Note that this method does not return anything. To get the
|
||||
* updated rates, method update must be called after the call to update_C.
|
||||
*/
|
||||
void update_C(const doublereal* c) {
|
||||
for (size_t i = 0; i != m_rates.size(); i++) {
|
||||
m_rates[i].update_C(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the rate coefficients into array values. Each calculator writes one
|
||||
* entry in values, at the location specified by the reaction number when it
|
||||
* was installed. Note that nothing will be done for reactions that have
|
||||
* constant rates. The array values should be preloaded with the constant
|
||||
* rate coefficients.
|
||||
*/
|
||||
void update(doublereal T, doublereal logT, doublereal* values) {
|
||||
doublereal recipT = 1.0/T;
|
||||
for (size_t i = 0; i != m_rates.size(); i++) {
|
||||
values[m_rxn[i]] = m_rates[i].updateRC(logT, recipT);
|
||||
}
|
||||
}
|
||||
|
||||
size_t nReactions() const {
|
||||
return m_rates.size();
|
||||
}
|
||||
|
||||
//! Return effective preexponent for the specified reaction.
|
||||
/*!
|
||||
* Returns effective preexponent, accounting for surface coverage
|
||||
* dependencies. Used in InterfaceKinetics.
|
||||
*
|
||||
* @param irxn Reaction number in the kinetics mechanism
|
||||
* @return Effective preexponent
|
||||
*/
|
||||
double effectivePreExponentialFactor(size_t irxn) {
|
||||
return m_rates[irxn].preExponentialFactor();
|
||||
}
|
||||
|
||||
//! Return effective activation energy for the specified reaction.
|
||||
/*!
|
||||
* Returns effective activation energy, accounting for surface coverage
|
||||
* dependencies. Used in InterfaceKinetics.
|
||||
*
|
||||
* @param irxn Reaction number in the kinetics mechanism
|
||||
* @return Effective activation energy divided by the gas constant
|
||||
*/
|
||||
double effectiveActivationEnergy_R(size_t irxn) {
|
||||
return m_rates[irxn].activationEnergy_R();
|
||||
}
|
||||
|
||||
//! Return effective temperature exponent for the specified reaction.
|
||||
/*!
|
||||
* Returns effective temperature exponent, accounting for surface coverage
|
||||
* dependencies. Used in InterfaceKinetics. Current parameterization in
|
||||
* SurfaceArrhenius does not change this parameter with the change in
|
||||
* surface coverages.
|
||||
*
|
||||
* @param irxn Reaction number in the kinetics mechanism
|
||||
* @return Effective temperature exponent
|
||||
*/
|
||||
double effectiveTemperatureExponent(size_t irxn) {
|
||||
return m_rates[irxn].temperatureExponent();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<R> m_rates;
|
||||
std::vector<size_t> m_rxn;
|
||||
|
||||
//! map reaction number to index in m_rxn / m_rates
|
||||
std::map<size_t, size_t> m_indices;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "cantera/kinetics/ReactionRate.h"
|
||||
#include "cantera/kinetics/RxnRates.h"
|
||||
#include "cantera/base/Units.h"
|
||||
#include "Falloff.h"
|
||||
#include "ChebyshevRate.h"
|
||||
#include "InterfaceRate.h"
|
||||
#include "Custom.h"
|
||||
@@ -20,7 +21,6 @@ namespace Cantera
|
||||
{
|
||||
|
||||
class Kinetics;
|
||||
class FalloffRate;
|
||||
class ThirdBody;
|
||||
|
||||
//! @defgroup reactionGroup Reactions and reaction rates
|
||||
|
||||
@@ -648,9 +648,6 @@ cdef extern from "cantera/kinetics/Reaction.h" namespace "Cantera":
|
||||
cdef cppclass CxxCustomFunc1Reaction "Cantera::CustomFunc1Reaction" (CxxReaction):
|
||||
CxxCustomFunc1Reaction()
|
||||
|
||||
cdef extern from "cantera/kinetics/FalloffFactory.h" namespace "Cantera":
|
||||
cdef shared_ptr[CxxFalloff] CxxNewFalloff "Cantera::newFalloff" (string, vector[double]) except +translate_exception
|
||||
|
||||
cdef extern from "cantera/kinetics/Kinetics.h" namespace "Cantera":
|
||||
cdef cppclass CxxKinetics "Cantera::Kinetics":
|
||||
CxxKinetics()
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* @file FalloffFactory.cpp
|
||||
*
|
||||
* @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
|
||||
* FalloffRate objects managed by MultiRate evaluators.
|
||||
*/
|
||||
|
||||
// This file is part of Cantera. See License.txt in the top-level directory or
|
||||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#include "cantera/kinetics/FalloffFactory.h"
|
||||
#include "cantera/kinetics/reaction_defs.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
FalloffFactory* FalloffFactory::s_factory = 0;
|
||||
std::mutex FalloffFactory::falloff_mutex;
|
||||
|
||||
FalloffFactory::FalloffFactory()
|
||||
{
|
||||
reg("Lindemann", []() { return new Lindemann(); });
|
||||
addAlias("Lindemann", "Simple");
|
||||
reg("Troe", []() { return new Troe(); });
|
||||
reg("SRI", []() { return new SRI(); });
|
||||
reg("Tsang", []() { return new Tsang(); });
|
||||
}
|
||||
|
||||
Falloff* FalloffFactory::newFalloff(const std::string& type, const vector_fp& c)
|
||||
{
|
||||
Falloff* f = create(type);
|
||||
f->init(c);
|
||||
return f;
|
||||
}
|
||||
|
||||
shared_ptr<Falloff> newFalloff(const std::string& type, const vector_fp& c)
|
||||
{
|
||||
shared_ptr<Falloff> f(FalloffFactory::factory()->newFalloff(type, c));
|
||||
return f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
// at https://cantera.org/license.txt for license and copyright information.
|
||||
|
||||
#include "cantera/kinetics/InterfaceKinetics.h"
|
||||
#include "cantera/kinetics/RateCoeffMgr.h"
|
||||
#include "cantera/kinetics/ImplicitSurfChem.h"
|
||||
#include "cantera/kinetics/Reaction.h"
|
||||
#include "cantera/thermo/SurfPhase.h"
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "cantera/kinetics/Reaction.h"
|
||||
#include "ReactionFactory.h"
|
||||
#include "cantera/kinetics/ReactionRateFactory.h"
|
||||
#include "cantera/kinetics/FalloffFactory.h"
|
||||
#include "cantera/kinetics/Kinetics.h"
|
||||
#include "cantera/thermo/ThermoPhase.h"
|
||||
#include "cantera/thermo/SurfPhase.h"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "cantera/thermo/Species.h"
|
||||
#include "cantera/kinetics/GasKinetics.h"
|
||||
#include "cantera/kinetics/InterfaceKinetics.h"
|
||||
#include "cantera/kinetics/FalloffFactory.h"
|
||||
#include "cantera/base/Array.h"
|
||||
#include "cantera/base/stringUtils.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user