Added in duplication routines.
Added in a shallow pointer copy facility.
This commit is contained in:
parent
63aadd5ab0
commit
7d901ed74f
6 changed files with 1134 additions and 945 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -34,385 +34,435 @@ void get_wdot(const doublereal* rop, doublereal* wdot);
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
// forward references
|
||||
// forward references
|
||||
|
||||
class Enhanced3BConc;
|
||||
class ReactionData;
|
||||
class GasKineticsData;
|
||||
class Thermo;
|
||||
class Enhanced3BConc;
|
||||
class ReactionData;
|
||||
class GasKineticsData;
|
||||
class Thermo;
|
||||
|
||||
/**
|
||||
* Holds mechanism-specific data.
|
||||
*/
|
||||
class GasKineticsData {
|
||||
public:
|
||||
GasKineticsData() :
|
||||
m_logp_ref(0.0),
|
||||
m_logc_ref(0.0),
|
||||
m_logStandConc(0.0),
|
||||
m_ROP_ok(false),
|
||||
m_temp(0.0)
|
||||
{}
|
||||
virtual ~GasKineticsData(){}
|
||||
|
||||
doublereal m_logp_ref, m_logc_ref, m_logStandConc;
|
||||
array_fp m_ropf, m_ropr, m_ropnet;
|
||||
array_fp m_rfn_low, m_rfn_high;
|
||||
bool m_ROP_ok;
|
||||
|
||||
doublereal m_temp;
|
||||
array_fp m_rfn;
|
||||
array_fp falloff_work;
|
||||
array_fp concm_3b_values;
|
||||
array_fp concm_falloff_values;
|
||||
array_fp m_rkcn;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Kinetics manager for elementary gas-phase chemistry. This
|
||||
* kinetics manager implements standard mass-action reaction rate
|
||||
* expressions for low-density gases.
|
||||
* @ingroup kinetics
|
||||
*/
|
||||
class GasKinetics : public Kinetics {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Holds mechanism-specific data.
|
||||
* @name Constructors and General Information
|
||||
*/
|
||||
class GasKineticsData {
|
||||
public:
|
||||
GasKineticsData() :
|
||||
m_logp_ref(0.0),
|
||||
m_logc_ref(0.0),
|
||||
m_logStandConc(0.0),
|
||||
m_ROP_ok(false),
|
||||
m_temp(0.0)
|
||||
{}
|
||||
virtual ~GasKineticsData(){}
|
||||
//@{
|
||||
|
||||
doublereal m_logp_ref, m_logc_ref, m_logStandConc;
|
||||
array_fp m_ropf, m_ropr, m_ropnet;
|
||||
array_fp m_rfn_low, m_rfn_high;
|
||||
bool m_ROP_ok;
|
||||
//! Constructor.
|
||||
/*!
|
||||
* @param thermo Pointer to the gas ThermoPhase (optional)
|
||||
*/
|
||||
GasKinetics(thermo_t* thermo = 0);
|
||||
|
||||
doublereal m_temp;
|
||||
array_fp m_rfn;
|
||||
array_fp falloff_work;
|
||||
array_fp concm_3b_values;
|
||||
array_fp concm_falloff_values;
|
||||
array_fp m_rkcn;
|
||||
};
|
||||
|
||||
//!Copy Constructor for the %GasKinetics object.
|
||||
/*!
|
||||
* Currently, this is not fully implemented. If called it will
|
||||
* throw an exception.
|
||||
*
|
||||
* @param right object to be copied
|
||||
*/
|
||||
GasKinetics(const GasKinetics &right);
|
||||
|
||||
//! Destructor.
|
||||
virtual ~GasKinetics();
|
||||
|
||||
//! Assignment operator
|
||||
/*!
|
||||
* This is NOT a virtual function.
|
||||
*
|
||||
* @param right Reference to %GasKinetics object to be copied into the
|
||||
* current one.
|
||||
*/
|
||||
GasKinetics& operator=(const GasKinetics &right);
|
||||
|
||||
//! Duplication routine for objects which inherit from Kinetics
|
||||
/*!
|
||||
* This virtual routine can be used to duplicate %Kinetics objects
|
||||
* inherited from %Kinetics even if the application only has
|
||||
* a pointer to %Kinetics to work with.
|
||||
*
|
||||
* These routines are basically wrappers around the derived copy constructor.
|
||||
*
|
||||
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
|
||||
* m_thermo vector within this object
|
||||
*/
|
||||
virtual Kinetics *duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
|
||||
|
||||
|
||||
//! Identifies the subclass of the Kinetics manager type.
|
||||
/*!
|
||||
* These are listed in mix_defs.h.
|
||||
*/
|
||||
virtual int ID() const { return cGasKinetics; }
|
||||
|
||||
//! Identifies the kinetics manager type.
|
||||
/*!
|
||||
* Each class derived from Kinetics should overload this method to
|
||||
* return a unique integer. Standard values are defined in file
|
||||
* mix_defs.h.
|
||||
*/
|
||||
virtual int type() const { return cGasKinetics; }
|
||||
|
||||
virtual doublereal reactantStoichCoeff(int k, int i) const {
|
||||
return m_rrxn[k][i];
|
||||
}
|
||||
|
||||
virtual doublereal productStoichCoeff(int k, int i) const {
|
||||
return m_prxn[k][i];
|
||||
}
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Rates Of Progress
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* Forward rates of progress.
|
||||
* Return the forward rates of progress in array fwdROP, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
virtual void getFwdRatesOfProgress(doublereal* fwdROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropf.begin(), m_kdata->m_ropf.end(), fwdROP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse rates of progress.
|
||||
* Return the reverse rates of progress in array revROP, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
virtual void getRevRatesOfProgress(doublereal* revROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropr.begin(), m_kdata->m_ropr.end(), revROP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Net rates of progress. Return the net (forward - reverse)
|
||||
* rates of progress in array netROP, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* reactions.
|
||||
*/
|
||||
virtual void getNetRatesOfProgress(doublereal* netROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropnet.begin(), m_kdata->m_ropnet.end(), netROP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Kinetics manager for elementary gas-phase chemistry. This
|
||||
* kinetics manager implements standard mass-action reaction rate
|
||||
* expressions for low-density gases.
|
||||
* @ingroup kinetics
|
||||
* Equilibrium constants. Return the equilibrium constants of
|
||||
* the reactions in concentration units in array kc, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
class GasKinetics : public Kinetics {
|
||||
virtual void getEquilibriumConstants(doublereal* kc);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the array of values for the reaction gibbs free energy
|
||||
* change.
|
||||
* These values depend on the species concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaGibbs( doublereal* deltaG);
|
||||
|
||||
/**
|
||||
* @name Constructors and General Information
|
||||
*/
|
||||
//@{
|
||||
/// Constructor.
|
||||
GasKinetics(thermo_t* thermo = 0);
|
||||
/**
|
||||
* Return the array of values for the reaction enthalpy change.
|
||||
* These values depend upon the species concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaEnthalpy( doublereal* deltaH);
|
||||
|
||||
/// Destructor.
|
||||
virtual ~GasKinetics();
|
||||
/**
|
||||
* Return the array of values for the reactions change in
|
||||
* entropy.
|
||||
* These values depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1 Kelvin-1
|
||||
*/
|
||||
virtual void getDeltaEntropy(doublereal* deltaS);
|
||||
|
||||
virtual int ID() const { return cGasKinetics; }
|
||||
virtual int type() const { return cGasKinetics; }
|
||||
/**
|
||||
* Return the array of values for the reaction
|
||||
* standard state Gibbs free energy change.
|
||||
* These values do not depend on the species
|
||||
* concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaSSGibbs(doublereal* deltaG);
|
||||
|
||||
virtual doublereal reactantStoichCoeff(int k, int i) const {
|
||||
return m_rrxn[k][i];
|
||||
}
|
||||
/**
|
||||
* Return the array of values for the change in the
|
||||
* standard state enthalpies of reaction.
|
||||
* These values do not depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaSSEnthalpy(doublereal* deltaH);
|
||||
|
||||
virtual doublereal productStoichCoeff(int k, int i) const {
|
||||
return m_prxn[k][i];
|
||||
}
|
||||
/**
|
||||
* Return the array of values for the change in the
|
||||
* standard state entropies for each reaction.
|
||||
* These values do not depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1 Kelvin-1
|
||||
*/
|
||||
virtual void getDeltaSSEntropy(doublereal* deltaS);
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Rates Of Progress
|
||||
*/
|
||||
//@{
|
||||
/**
|
||||
* Forward rates of progress.
|
||||
* Return the forward rates of progress in array fwdROP, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
virtual void getFwdRatesOfProgress(doublereal* fwdROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropf.begin(), m_kdata->m_ropf.end(), fwdROP);
|
||||
}
|
||||
//@}
|
||||
/**
|
||||
* @name Species Production Rates
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Reverse rates of progress.
|
||||
* Return the reverse rates of progress in array revROP, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
virtual void getRevRatesOfProgress(doublereal* revROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropr.begin(), m_kdata->m_ropr.end(), revROP);
|
||||
}
|
||||
//! Return the species net production rates
|
||||
/*!
|
||||
* Species net production rates [kmol/m^3/s]. Return the species
|
||||
* net production rates (creation - destruction) in array
|
||||
* wdot, which must be dimensioned at least as large as the
|
||||
* total number of species.
|
||||
*
|
||||
* @param net Array of species production rates.
|
||||
* units kmol m-3 s-1
|
||||
*/
|
||||
virtual void getNetProductionRates(doublereal* net) {
|
||||
updateROP();
|
||||
//#ifdef HWMECH
|
||||
//get_wdot(&m_kdata->m_ropnet[0], net);
|
||||
//#else
|
||||
m_rxnstoich->getNetProductionRates(m_kk,
|
||||
&m_kdata->m_ropnet[0], net);
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Net rates of progress. Return the net (forward - reverse)
|
||||
* rates of progress in array netROP, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* reactions.
|
||||
*/
|
||||
virtual void getNetRatesOfProgress(doublereal* netROP) {
|
||||
updateROP();
|
||||
std::copy(m_kdata->m_ropnet.begin(), m_kdata->m_ropnet.end(), netROP);
|
||||
}
|
||||
/**
|
||||
* Species creation rates [kmol/m^3]. Return the species
|
||||
* creation rates in array cdot, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* species.
|
||||
*
|
||||
*/
|
||||
virtual void getCreationRates(doublereal* cdot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getCreationRates(m_kk, &m_kdata->m_ropf[0],
|
||||
&m_kdata->m_ropr[0], cdot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Species destruction rates [kmol/m^3]. Return the species
|
||||
* destruction rates in array ddot, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* species.
|
||||
*
|
||||
*/
|
||||
virtual void getDestructionRates(doublereal* ddot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getDestructionRates(m_kk, &m_kdata->m_ropf[0],
|
||||
&m_kdata->m_ropr[0], ddot);
|
||||
// fill(ddot, ddot + m_kk, 0.0);
|
||||
//m_revProductStoich.incrementSpecies(
|
||||
// m_kdata->m_ropr.begin(), ddot);
|
||||
//m_reactantStoich.incrementSpecies(
|
||||
// m_kdata->m_ropf.begin(), ddot);
|
||||
}
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Mechanism Informational Query Routines
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Flag specifying the type of reaction. The legal values and
|
||||
* their meaning are specific to the particular kinetics
|
||||
* manager.
|
||||
*/
|
||||
virtual int reactionType(int i) const {
|
||||
return m_index[i].first;
|
||||
}
|
||||
|
||||
virtual std::string reactionString(int i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* True if reaction i has been declared to be reversible. If
|
||||
* isReversible(i) is false, then the reverse rate of progress
|
||||
* for reaction i is always zero.
|
||||
*/
|
||||
virtual bool isReversible(int i) {
|
||||
if (std::find(m_revindex.begin(), m_revindex.end(), i)
|
||||
< m_revindex.end()) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the forward rate constants
|
||||
*
|
||||
* length is the number of reactions. units depends
|
||||
* on many issues.
|
||||
*/
|
||||
virtual void getFwdRateConstants(doublereal *kfwd);
|
||||
|
||||
/**
|
||||
* Return the reverse rate constants.
|
||||
*
|
||||
* length is the number of reactions. units depends
|
||||
* on many issues. Note, this routine will return rate constants
|
||||
* for irreversible reactions if the default for
|
||||
* doIrreversible is overridden.
|
||||
*/
|
||||
virtual void getRevRateConstants(doublereal *krev,
|
||||
bool doIrreversible = false);
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Mechanism Setup Routines
|
||||
*/
|
||||
//@{
|
||||
|
||||
virtual void init();
|
||||
|
||||
/// Add a reaction to the mechanism.
|
||||
virtual void addReaction(const ReactionData& r);
|
||||
|
||||
virtual void finalize();
|
||||
virtual bool ready() const;
|
||||
|
||||
virtual void update_T();
|
||||
virtual void update_C();
|
||||
|
||||
void updateROP();
|
||||
|
||||
|
||||
/**
|
||||
* Equilibrium constants. Return the equilibrium constants of
|
||||
* the reactions in concentration units in array kc, which
|
||||
* must be dimensioned at least as large as the total number
|
||||
* of reactions.
|
||||
*/
|
||||
virtual void getEquilibriumConstants(doublereal* kc);
|
||||
|
||||
/**
|
||||
* Return the array of values for the reaction gibbs free energy
|
||||
* change.
|
||||
* These values depend on the species concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaGibbs( doublereal* deltaG);
|
||||
|
||||
/**
|
||||
* Return the array of values for the reaction enthalpy change.
|
||||
* These values depend upon the species concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaEnthalpy( doublereal* deltaH);
|
||||
|
||||
/**
|
||||
* Return the array of values for the reactions change in
|
||||
* entropy.
|
||||
* These values depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1 Kelvin-1
|
||||
*/
|
||||
virtual void getDeltaEntropy(doublereal* deltaS);
|
||||
|
||||
/**
|
||||
* Return the array of values for the reaction
|
||||
* standard state Gibbs free energy change.
|
||||
* These values do not depend on the species
|
||||
* concentrations.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaSSGibbs(doublereal* deltaG);
|
||||
|
||||
/**
|
||||
* Return the array of values for the change in the
|
||||
* standard state enthalpies of reaction.
|
||||
* These values do not depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1
|
||||
*/
|
||||
virtual void getDeltaSSEnthalpy(doublereal* deltaH);
|
||||
|
||||
/**
|
||||
* Return the array of values for the change in the
|
||||
* standard state entropies for each reaction.
|
||||
* These values do not depend upon the concentration
|
||||
* of the solution.
|
||||
*
|
||||
* units = J kmol-1 Kelvin-1
|
||||
*/
|
||||
virtual void getDeltaSSEntropy(doublereal* deltaS);
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Species Production Rates
|
||||
*/
|
||||
//@{
|
||||
|
||||
//! Return the species net production rates
|
||||
/*!
|
||||
* Species net production rates [kmol/m^3/s]. Return the species
|
||||
* net production rates (creation - destruction) in array
|
||||
* wdot, which must be dimensioned at least as large as the
|
||||
* total number of species.
|
||||
*
|
||||
* @param net Array of species production rates.
|
||||
* units kmol m-3 s-1
|
||||
*/
|
||||
virtual void getNetProductionRates(doublereal* net) {
|
||||
updateROP();
|
||||
//#ifdef HWMECH
|
||||
//get_wdot(&m_kdata->m_ropnet[0], net);
|
||||
//#else
|
||||
m_rxnstoich->getNetProductionRates(m_kk,
|
||||
&m_kdata->m_ropnet[0], net);
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Species creation rates [kmol/m^3]. Return the species
|
||||
* creation rates in array cdot, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* species.
|
||||
*
|
||||
*/
|
||||
virtual void getCreationRates(doublereal* cdot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getCreationRates(m_kk, &m_kdata->m_ropf[0],
|
||||
&m_kdata->m_ropr[0], cdot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Species destruction rates [kmol/m^3]. Return the species
|
||||
* destruction rates in array ddot, which must be
|
||||
* dimensioned at least as large as the total number of
|
||||
* species.
|
||||
*
|
||||
*/
|
||||
virtual void getDestructionRates(doublereal* ddot) {
|
||||
updateROP();
|
||||
m_rxnstoich->getDestructionRates(m_kk, &m_kdata->m_ropf[0],
|
||||
&m_kdata->m_ropr[0], ddot);
|
||||
// fill(ddot, ddot + m_kk, 0.0);
|
||||
//m_revProductStoich.incrementSpecies(
|
||||
// m_kdata->m_ropr.begin(), ddot);
|
||||
//m_reactantStoich.incrementSpecies(
|
||||
// m_kdata->m_ropf.begin(), ddot);
|
||||
}
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Mechanism Informational Query Routines
|
||||
*/
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Flag specifying the type of reaction. The legal values and
|
||||
* their meaning are specific to the particular kinetics
|
||||
* manager.
|
||||
*/
|
||||
virtual int reactionType(int i) const {
|
||||
return m_index[i].first;
|
||||
}
|
||||
|
||||
virtual std::string reactionString(int i) const {
|
||||
return m_rxneqn[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* True if reaction i has been declared to be reversible. If
|
||||
* isReversible(i) is false, then the reverse rate of progress
|
||||
* for reaction i is always zero.
|
||||
*/
|
||||
virtual bool isReversible(int i) {
|
||||
if (std::find(m_revindex.begin(), m_revindex.end(), i)
|
||||
< m_revindex.end()) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the forward rate constants
|
||||
*
|
||||
* length is the number of reactions. units depends
|
||||
* on many issues.
|
||||
*/
|
||||
virtual void getFwdRateConstants(doublereal *kfwd);
|
||||
|
||||
/**
|
||||
* Return the reverse rate constants.
|
||||
*
|
||||
* length is the number of reactions. units depends
|
||||
* on many issues. Note, this routine will return rate constants
|
||||
* for irreversible reactions if the default for
|
||||
* doIrreversible is overridden.
|
||||
*/
|
||||
virtual void getRevRateConstants(doublereal *krev,
|
||||
bool doIrreversible = false);
|
||||
|
||||
//@}
|
||||
/**
|
||||
* @name Reaction Mechanism Setup Routines
|
||||
*/
|
||||
//@{
|
||||
|
||||
virtual void init();
|
||||
|
||||
/// Add a reaction to the mechanism.
|
||||
virtual void addReaction(const ReactionData& r);
|
||||
|
||||
virtual void finalize();
|
||||
virtual bool ready() const;
|
||||
|
||||
virtual void update_T();
|
||||
virtual void update_C();
|
||||
|
||||
void updateROP();
|
||||
const std::vector<grouplist_t>& reactantGroups(int i)
|
||||
{ return m_rgroups[i]; }
|
||||
const std::vector<grouplist_t>& productGroups(int i)
|
||||
{ return m_pgroups[i]; }
|
||||
|
||||
|
||||
const std::vector<grouplist_t>& reactantGroups(int i)
|
||||
{ return m_rgroups[i]; }
|
||||
const std::vector<grouplist_t>& productGroups(int i)
|
||||
{ return m_pgroups[i]; }
|
||||
void _update_rates_T();
|
||||
void _update_rates_C();
|
||||
|
||||
//@}
|
||||
|
||||
protected:
|
||||
|
||||
int m_kk;
|
||||
|
||||
int m_nfall;
|
||||
|
||||
array_int m_fallindx;
|
||||
|
||||
Rate1<Arrhenius> m_falloff_low_rates;
|
||||
Rate1<Arrhenius> m_falloff_high_rates;
|
||||
Rate1<Arrhenius> m_rates;
|
||||
|
||||
mutable std::map<int, std::pair<int, int> > m_index;
|
||||
|
||||
FalloffMgr m_falloffn;
|
||||
|
||||
ThirdBodyMgr<Enhanced3BConc> m_3b_concm;
|
||||
ThirdBodyMgr<Enhanced3BConc> m_falloff_concm;
|
||||
|
||||
std::vector<int> m_irrev;
|
||||
|
||||
ReactionStoichMgr* m_rxnstoich;
|
||||
|
||||
std::vector<int> m_fwdOrder;
|
||||
|
||||
int m_nirrev;
|
||||
int m_nrev;
|
||||
|
||||
std::map<int, std::vector<grouplist_t> > m_rgroups;
|
||||
std::map<int, std::vector<grouplist_t> > m_pgroups;
|
||||
|
||||
std::vector<int> m_rxntype;
|
||||
|
||||
mutable std::vector<std::map<int, doublereal> > m_rrxn;
|
||||
mutable std::vector<std::map<int, doublereal> > m_prxn;
|
||||
|
||||
/**
|
||||
* Difference between the input global reactants order
|
||||
* and the input global products order. Changed to a double
|
||||
* to account for the fact that we can have real-valued
|
||||
* stoichiometries.
|
||||
*/
|
||||
array_fp m_dn;
|
||||
array_int m_revindex;
|
||||
|
||||
std::vector<std::string> m_rxneqn;
|
||||
|
||||
GasKineticsData* m_kdata;
|
||||
|
||||
array_fp m_conc;
|
||||
void processFalloffReactions();
|
||||
array_fp m_grt;
|
||||
|
||||
|
||||
void _update_rates_T();
|
||||
void _update_rates_C();
|
||||
private:
|
||||
|
||||
//@}
|
||||
int reactionNumber(){ return m_ii;}
|
||||
std::vector<std::map<int, doublereal> > m_stoich;
|
||||
|
||||
protected:
|
||||
void addElementaryReaction(const ReactionData& r);
|
||||
void addThreeBodyReaction(const ReactionData& r);
|
||||
void addFalloffReaction(const ReactionData& r);
|
||||
|
||||
int m_kk, m_nfall;
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
array_int m_fallindx;
|
||||
void installGroups(int irxn, const std::vector<grouplist_t>& r,
|
||||
const std::vector<grouplist_t>& p);
|
||||
void updateKc();
|
||||
|
||||
Rate1<Arrhenius> m_falloff_low_rates;
|
||||
Rate1<Arrhenius> m_falloff_high_rates;
|
||||
Rate1<Arrhenius> m_rates;
|
||||
|
||||
mutable std::map<int, std::pair<int, int> > m_index;
|
||||
|
||||
FalloffMgr m_falloffn;
|
||||
|
||||
ThirdBodyMgr<Enhanced3BConc> m_3b_concm;
|
||||
ThirdBodyMgr<Enhanced3BConc> m_falloff_concm;
|
||||
|
||||
std::vector<int> m_irrev;
|
||||
|
||||
ReactionStoichMgr* m_rxnstoich;
|
||||
|
||||
std::vector<int> m_fwdOrder;
|
||||
|
||||
int m_nirrev;
|
||||
int m_nrev;
|
||||
|
||||
std::map<int, std::vector<grouplist_t> > m_rgroups;
|
||||
std::map<int, std::vector<grouplist_t> > m_pgroups;
|
||||
|
||||
std::vector<int> m_rxntype;
|
||||
|
||||
mutable std::vector<std::map<int, doublereal> > m_rrxn;
|
||||
mutable std::vector<std::map<int, doublereal> > m_prxn;
|
||||
|
||||
/**
|
||||
* Difference between the input global reactants order
|
||||
* and the input global products order. Changed to a double
|
||||
* to account for the fact that we can have real-valued
|
||||
* stoichiometries.
|
||||
*/
|
||||
array_fp m_dn;
|
||||
array_int m_revindex;
|
||||
|
||||
std::vector<std::string> m_rxneqn;
|
||||
|
||||
GasKineticsData* m_kdata;
|
||||
|
||||
array_fp m_conc;
|
||||
void processFalloffReactions();
|
||||
array_fp m_grt;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int reactionNumber(){ return m_ii;}
|
||||
std::vector<std::map<int, doublereal> > m_stoich;
|
||||
|
||||
void addElementaryReaction(const ReactionData& r);
|
||||
void addThreeBodyReaction(const ReactionData& r);
|
||||
void addFalloffReaction(const ReactionData& r);
|
||||
|
||||
void installReagents(const ReactionData& r);
|
||||
|
||||
void installGroups(int irxn, const std::vector<grouplist_t>& r,
|
||||
const std::vector<grouplist_t>& p);
|
||||
void updateKc();
|
||||
|
||||
void registerReaction(int rxnNumber, int type, int loc) {
|
||||
m_index[rxnNumber] = std::pair<int, int>(type, loc);
|
||||
}
|
||||
bool m_finalized;
|
||||
};
|
||||
void registerReaction(int rxnNumber, int type, int loc) {
|
||||
m_index[rxnNumber] = std::pair<int, int>(type, loc);
|
||||
}
|
||||
bool m_finalized;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -217,10 +217,14 @@ namespace Cantera {
|
|||
*
|
||||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
*
|
||||
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
|
||||
* m_thermo vector within this object
|
||||
*/
|
||||
Kinetics *InterfaceKinetics::duplMyselfAsKinetics() const {
|
||||
InterfaceKinetics* tp = new InterfaceKinetics(*this);
|
||||
return dynamic_cast<Kinetics *>(tp);
|
||||
Kinetics *InterfaceKinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const {
|
||||
InterfaceKinetics* iK = new InterfaceKinetics(*this);
|
||||
iK->assignShallowPointers(tpVector);
|
||||
return dynamic_cast<Kinetics *>(iK);
|
||||
}
|
||||
//====================================================================================================================
|
||||
// Update properties that depend on temperature
|
||||
|
|
|
|||
|
|
@ -115,17 +115,19 @@ namespace Cantera {
|
|||
InterfaceKinetics& operator=(const InterfaceKinetics &right);
|
||||
|
||||
|
||||
//! Duplication routine for objects which inherit from
|
||||
//! Kinetics
|
||||
|
||||
//! Duplication routine for objects which inherit from Kinetics
|
||||
/*!
|
||||
* This virtual routine can be used to duplicate %InterfaceKinetics objects
|
||||
* This virtual routine can be used to duplicate %Kinetics objects
|
||||
* inherited from %Kinetics even if the application only has
|
||||
* a pointer to %Kinetics to work with.
|
||||
*
|
||||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
* These routines are basically wrappers around the derived copy constructor.
|
||||
*
|
||||
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
|
||||
* m_thermo vector within this object
|
||||
*/
|
||||
virtual Kinetics *duplMyselfAsKinetics() const;
|
||||
virtual Kinetics *duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
|
||||
|
||||
//! Return the ID of the kinetics object
|
||||
virtual int ID() const;
|
||||
|
|
|
|||
|
|
@ -32,11 +32,17 @@ namespace Cantera {
|
|||
Kinetics::Kinetics() :
|
||||
m_ii(0),
|
||||
m_nTotalSpecies(0),
|
||||
m_perturb(0),
|
||||
m_reactants(0),
|
||||
m_products(0),
|
||||
m_thermo(0),
|
||||
m_start(0),
|
||||
m_phaseindex(),
|
||||
m_index(-1),
|
||||
m_surfphase(-1),
|
||||
m_rxnphase(-1),
|
||||
m_mindim(4)
|
||||
m_mindim(4),
|
||||
m_dummygroups(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -51,16 +57,22 @@ namespace Cantera {
|
|||
Kinetics::Kinetics(const Kinetics &right) :
|
||||
m_ii(0),
|
||||
m_nTotalSpecies(0),
|
||||
m_perturb(0),
|
||||
m_reactants(0),
|
||||
m_products(0),
|
||||
m_thermo(0),
|
||||
m_start(0),
|
||||
m_phaseindex(),
|
||||
m_index(-1),
|
||||
m_surfphase(-1),
|
||||
m_rxnphase(-1),
|
||||
m_mindim(4)
|
||||
m_mindim(4),
|
||||
m_dummygroups(0)
|
||||
{
|
||||
/*
|
||||
* Call the assignment operator
|
||||
*/
|
||||
*this = operator=(right);
|
||||
*this = right;
|
||||
}
|
||||
|
||||
// Assignment operator
|
||||
|
|
@ -96,7 +108,7 @@ namespace Cantera {
|
|||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//====================================================================================================================
|
||||
// Duplication routine for objects which inherit from
|
||||
// Kinetics
|
||||
/*
|
||||
|
|
@ -107,22 +119,48 @@ namespace Cantera {
|
|||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
*/
|
||||
Kinetics *Kinetics::duplMyselfAsKinetics() const {
|
||||
Kinetics* tp = new Kinetics(*this);
|
||||
return tp;
|
||||
Kinetics *Kinetics::duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const {
|
||||
Kinetics* ko = new Kinetics(*this);
|
||||
|
||||
ko->assignShallowPointers(tpVector);
|
||||
return ko;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//====================================================================================================================
|
||||
int Kinetics::ID() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
int Kinetics::type() const {
|
||||
return 0;
|
||||
}
|
||||
//====================================================================================================================
|
||||
void Kinetics::assignShallowPointers(const std::vector<thermo_t*> & tpVector) {
|
||||
size_t ns = tpVector.size();
|
||||
if (ns != m_thermo.size()) {
|
||||
throw CanteraError(" Kinetics::assignShallowPointers",
|
||||
" Number of ThermoPhase objects arent't the same");
|
||||
}
|
||||
for (size_t i = 0; i < ns; i++) {
|
||||
ThermoPhase *ntp = tpVector[i];
|
||||
ThermoPhase *otp = m_thermo[i];
|
||||
if (ntp->id() != otp->id()) {
|
||||
throw CanteraError(" Kinetics::assignShallowPointers",
|
||||
" id() of the ThermoPhase objects isn't the same");
|
||||
}
|
||||
if (ntp->eosType() != otp->eosType()) {
|
||||
throw CanteraError(" Kinetics::assignShallowPointers",
|
||||
" eosType() of the ThermoPhase objects isn't the same");
|
||||
}
|
||||
if (ntp->nSpecies() != otp->nSpecies()) {
|
||||
throw CanteraError(" Kinetics::assignShallowPointers",
|
||||
" Number of ThermoPhase objects isn't the same");
|
||||
}
|
||||
m_thermo[i] = tpVector[i];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//====================================================================================================================
|
||||
/**
|
||||
* Takes as input an array of properties for all species in the
|
||||
* mechanism and copies those values beloning to a particular
|
||||
|
|
@ -284,17 +322,13 @@ namespace Cantera {
|
|||
if (type() == cEdgeKinetics) ptype = cEdge;
|
||||
else if (type() == cInterfaceKinetics) ptype = cSurf;
|
||||
if (thermo.eosType() == ptype) {
|
||||
// if (m_surfphase >= 0) {
|
||||
// throw CanteraError("Kinetics::addPhase",
|
||||
// "cannot add more than one surface phase");
|
||||
// }
|
||||
m_surfphase = nPhases();
|
||||
m_rxnphase = nPhases();
|
||||
}
|
||||
m_thermo.push_back(&thermo);
|
||||
m_phaseindex[m_thermo.back()->id()] = nPhases();
|
||||
}
|
||||
|
||||
|
||||
void Kinetics::finalize() {
|
||||
m_nTotalSpecies = 0;
|
||||
int np = nPhases();
|
||||
|
|
@ -305,9 +339,9 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
|
||||
//! Private function of the class Kinetics, indicating that a function
|
||||
//! inherited from the base class hasn't had a definition assigned to it
|
||||
/*!
|
||||
// Private function of the class Kinetics, indicating that a function
|
||||
// inherited from the base class hasn't had a definition assigned to it
|
||||
/*
|
||||
* @param m String message
|
||||
*/
|
||||
void Kinetics::err(std::string m) const {
|
||||
|
|
|
|||
|
|
@ -169,18 +169,35 @@ namespace Cantera {
|
|||
Kinetics& operator=(const Kinetics &right);
|
||||
|
||||
|
||||
//! Duplication routine for objects which inherit from
|
||||
//! Kinetics
|
||||
//! Duplication routine for objects which inherit from Kinetics
|
||||
/*!
|
||||
* This virtual routine can be used to duplicate %Kinetics objects
|
||||
* inherited from %Kinetics even if the application only has
|
||||
* a pointer to %Kinetics to work with.
|
||||
*
|
||||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
* These routines are basically wrappers around the derived copy constructor.
|
||||
*
|
||||
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
|
||||
* m_thermo vector within this object
|
||||
*/
|
||||
virtual Kinetics *duplMyselfAsKinetics() const;
|
||||
virtual Kinetics *duplMyselfAsKinetics(const std::vector<thermo_t*> & tpVector) const;
|
||||
|
||||
//! Reassign the shallow pointers within the %FKinetics object
|
||||
/*!
|
||||
* This type or routine is absolute necessary because the Kinetics object doesn't
|
||||
* own the ThermoPhase objects. After a duplication, we need to point to different
|
||||
* ThermoPhase objects.
|
||||
*
|
||||
* We check that the ThermoPhase objects are alligned in the same order and have
|
||||
* the following identical properties to the ones that they are replacing.
|
||||
* id()
|
||||
* eosType()
|
||||
* nSpecies()
|
||||
*
|
||||
* @param tpVector Vector of shallow pointers to ThermoPhase objects. this is the
|
||||
* m_thermo vector within this object
|
||||
*/
|
||||
virtual void assignShallowPointers(const std::vector<thermo_t*> & tpVector);
|
||||
|
||||
//! Identifies the subclass of the Kinetics manager type.
|
||||
/*!
|
||||
|
|
@ -875,13 +892,13 @@ namespace Cantera {
|
|||
*/
|
||||
//@{
|
||||
|
||||
/// The current value of the multiplier for reaction i.
|
||||
//! The current value of the multiplier for reaction i.
|
||||
/*!
|
||||
* @param i index of the reaction
|
||||
*/
|
||||
doublereal multiplier(int i) const {return m_perturb[i];}
|
||||
|
||||
/// Set the multiplier for reaction i to f.
|
||||
//! Set the multiplier for reaction i to f.
|
||||
/*!
|
||||
* @param i index of the reaction
|
||||
* @param f value of the multiplier.
|
||||
|
|
@ -965,8 +982,7 @@ namespace Cantera {
|
|||
*/
|
||||
std::vector<vector_int> m_products;
|
||||
|
||||
//! m_thermo is a vector of pointers to ThermoPhase
|
||||
//! objects.
|
||||
//! m_thermo is a vector of pointers to ThermoPhase objects that are involved with this kinetics operator
|
||||
/*!
|
||||
* For homogeneous kinetics applications, this vector
|
||||
* will only have one entry. For interfacial reactions, this
|
||||
|
|
@ -999,21 +1015,27 @@ namespace Cantera {
|
|||
* -1.
|
||||
*/
|
||||
std::map<std::string, int> m_phaseindex;
|
||||
|
||||
//! Index of the Kinetics Manager
|
||||
int m_index;
|
||||
|
||||
/**
|
||||
* Index in the list of phases of the one surface phase.
|
||||
*/
|
||||
|
||||
//! Index in the list of phases of the one surface phase.
|
||||
/*!
|
||||
*
|
||||
*/
|
||||
int m_surfphase;
|
||||
|
||||
/**
|
||||
* Index in the list of phases of the one phase where the reactions
|
||||
* occur.
|
||||
|
||||
//! Phase Index where reactions are assumed to be taking place
|
||||
/*!
|
||||
* We calculate this by assuming that the phase with the lowest dimensionality is the phase where reactions
|
||||
* are taking place
|
||||
* @deprecated
|
||||
*/
|
||||
int m_rxnphase;
|
||||
|
||||
/// number of spatial dimensions of lowest-dimensional phase.
|
||||
//! number of spatial dimensions of lowest-dimensional phase.
|
||||
int m_mindim;
|
||||
|
||||
private:
|
||||
|
|
@ -1021,9 +1043,11 @@ namespace Cantera {
|
|||
//! Vector of group lists
|
||||
std::vector<grouplist_t> m_dummygroups;
|
||||
|
||||
//! Function for unhandled situations
|
||||
|
||||
//! Private function of the class Kinetics, indicating that a function
|
||||
//! inherited from the base class hasn't had a definition assigned to it
|
||||
/*!
|
||||
* @param m String error message
|
||||
* @param m String message
|
||||
*/
|
||||
void err(std::string m) const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue