Copy constructors, assignment operators, and duplicators:
Extended these to the more common ThermoPhase objects.
This commit is contained in:
parent
6a85d86b78
commit
410dd699da
9 changed files with 422 additions and 57 deletions
|
|
@ -639,6 +639,13 @@ namespace Cantera {
|
|||
virtual ~DebyeHuckel();
|
||||
|
||||
//! Duplicator from the ThermoPhase parent class
|
||||
/*!
|
||||
* Given a pointer to a ThermoPhase object, this function will
|
||||
* duplicate the ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a ThermoPhase
|
||||
*/
|
||||
ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,15 +89,37 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
/// Constructors
|
||||
/// Default Constructor
|
||||
HMWSoln();
|
||||
|
||||
HMWSoln(const HMWSoln &);
|
||||
HMWSoln& operator=(const HMWSoln&);
|
||||
|
||||
//! Full constructor for setting up the entire ThermoPhase Object
|
||||
HMWSoln(std::string inputFile, std::string id = "");
|
||||
|
||||
//! Full constructor for setting up the entire ThermoPhase Object
|
||||
HMWSoln(XML_Node& phaseRef, std::string id = "");
|
||||
|
||||
|
||||
//! Copy Constructor
|
||||
/*!
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
HMWSoln(const HMWSoln &right);
|
||||
|
||||
//! Asignment operator
|
||||
/*!
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
HMWSoln& operator=(const HMWSoln& right);
|
||||
|
||||
/**
|
||||
* This is a special constructor, used to replicate test problems
|
||||
* during the initial verification of the object
|
||||
|
|
@ -107,7 +129,14 @@ namespace Cantera {
|
|||
/// Destructor.
|
||||
virtual ~HMWSoln();
|
||||
|
||||
|
||||
//! Duplicator from the ThermoPhase parent class
|
||||
/*!
|
||||
* Given a pointer to a ThermoPhase object, this function will
|
||||
* duplicate the ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a ThermoPhase
|
||||
*/
|
||||
ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
// Empty Constructor
|
||||
// Default empty Constructor
|
||||
IdealGasPhase::IdealGasPhase():
|
||||
m_mm(0),
|
||||
m_tmin(0.0),
|
||||
|
|
@ -34,7 +34,130 @@ namespace Cantera {
|
|||
{
|
||||
}
|
||||
|
||||
// Molar Thermodynamic Properties of the Solution ----------
|
||||
// Copy Constructor
|
||||
IdealGasPhase::IdealGasPhase(const IdealGasPhase& right):
|
||||
m_mm(right.m_mm),
|
||||
m_tmin(right.m_tmin),
|
||||
m_tmax(right.m_tmax),
|
||||
m_p0(right.m_p0),
|
||||
m_tlast(right.m_tlast),
|
||||
m_logc0(right.m_logc0)
|
||||
{
|
||||
/*
|
||||
* Use the assignment operator to do the brunt
|
||||
* of the work for the copy construtor.
|
||||
*/
|
||||
*this = right;
|
||||
}
|
||||
|
||||
// Asignment operator
|
||||
/*
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
IdealGasPhase& IdealGasPhase::
|
||||
operator=(const IdealGasPhase &right) {
|
||||
if (&right != this) {
|
||||
ThermoPhase::operator=(right);
|
||||
m_mm = right.m_mm;
|
||||
m_tmin = right.m_tmin;
|
||||
m_tmax = right.m_tmax;
|
||||
m_p0 = right.m_p0;
|
||||
m_tlast = right.m_tlast;
|
||||
m_logc0 = right.m_logc0;
|
||||
m_h0_RT = right.m_h0_RT;
|
||||
m_cp0_R = right.m_cp0_R;
|
||||
m_g0_RT = right.m_g0_RT;
|
||||
m_s0_R = right.m_s0_R;
|
||||
m_expg0_RT= right.m_expg0_RT;
|
||||
m_pe = right.m_pe;
|
||||
m_pp = right.m_pp;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Duplicator from the %ThermoPhase parent class
|
||||
/*
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase
|
||||
*/
|
||||
ThermoPhase *IdealGasPhase::duplMyselfAsThermoPhase() const {
|
||||
ThermoPhase *igp = new IdealGasPhase(*this);
|
||||
return (ThermoPhase *) igp;
|
||||
}
|
||||
|
||||
// Molar Thermodynamic Properties of the Solution ------------------
|
||||
|
||||
/*
|
||||
* Molar internal energy. J/kmol. For an ideal gas mixture,
|
||||
* \f[
|
||||
* \hat u(T) = \sum_k X_k \hat h^0_k(T) - \hat R T,
|
||||
* \f]
|
||||
* and is a function only of temperature.
|
||||
* The reference-state pure-species enthalpies
|
||||
* \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic
|
||||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
doublereal IdealGasPhase::intEnergy_mole() const {
|
||||
return GasConstant * temperature()
|
||||
* ( mean_X(&enthalpy_RT_ref()[0]) - 1.0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Molar entropy. Units: J/kmol/K.
|
||||
* For an ideal gas mixture,
|
||||
* \f[
|
||||
* \hat s(T, P) = \sum_k X_k \hat s^0_k(T) - \hat R \log (P/P^0).
|
||||
* \f]
|
||||
* The reference-state pure-species entropies
|
||||
* \f$ \hat s^0_k(T) \f$ are computed by the species thermodynamic
|
||||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
doublereal IdealGasPhase::entropy_mole() const {
|
||||
return GasConstant * (mean_X(&entropy_R_ref()[0]) -
|
||||
sum_xlogx() - std::log(pressure()/m_spthermo->refPressure()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Molar Gibbs free Energy for an ideal gas.
|
||||
* Units = J/kmol.
|
||||
*/
|
||||
doublereal IdealGasPhase::gibbs_mole() const {
|
||||
return enthalpy_mole() - temperature() * entropy_mole();
|
||||
}
|
||||
|
||||
/*
|
||||
* Molar heat capacity at constant pressure. Units: J/kmol/K.
|
||||
* For an ideal gas mixture,
|
||||
* \f[
|
||||
* \hat c_p(t) = \sum_k \hat c^0_{p,k}(T).
|
||||
* \f]
|
||||
* The reference-state pure-species heat capacities
|
||||
* \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic
|
||||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
doublereal IdealGasPhase::cp_mole() const {
|
||||
return GasConstant * mean_X(&cp_R_ref()[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Molar heat capacity at constant volume. Units: J/kmol/K.
|
||||
* For an ideal gas mixture,
|
||||
* \f[ \hat c_v = \hat c_p - \hat R. \f]
|
||||
*/
|
||||
doublereal IdealGasPhase::cv_mole() const {
|
||||
return cp_mole() - GasConstant;
|
||||
}
|
||||
|
||||
// Mechanical Equation of State ----------------------------
|
||||
// Chemical Potentials and Activities ----------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -313,12 +313,44 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
//! Empty Constructor
|
||||
//! Default empty Constructor
|
||||
IdealGasPhase();
|
||||
|
||||
//! Copy Constructor
|
||||
/*!
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
IdealGasPhase(const IdealGasPhase &right);
|
||||
|
||||
//! Asignment operator
|
||||
/*!
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
IdealGasPhase& operator=(const IdealGasPhase& right);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IdealGasPhase() {}
|
||||
|
||||
|
||||
//! Duplicator from the %ThermoPhase parent class
|
||||
/*!
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the inherited copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase object, containing
|
||||
* a copy of the current object
|
||||
*/
|
||||
ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
//! Equation of state flag.
|
||||
/*!
|
||||
* Returns the value cIdealGas, defined in mix_defs.h.
|
||||
|
|
@ -360,10 +392,7 @@ namespace Cantera {
|
|||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
virtual doublereal intEnergy_mole() const {
|
||||
return GasConstant * temperature()
|
||||
* ( mean_X(&enthalpy_RT_ref()[0]) - 1.0);
|
||||
}
|
||||
virtual doublereal intEnergy_mole() const;
|
||||
|
||||
/**
|
||||
* Molar entropy. Units: J/kmol/K.
|
||||
|
|
@ -376,19 +405,13 @@ namespace Cantera {
|
|||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
virtual doublereal entropy_mole() const {
|
||||
return GasConstant * (mean_X(&entropy_R_ref()[0]) -
|
||||
sum_xlogx() - std::log(pressure()/m_spthermo->refPressure()));
|
||||
}
|
||||
virtual doublereal entropy_mole() const;
|
||||
|
||||
/**
|
||||
* Molar Gibbs free Energy for an ideal gas.
|
||||
* Units = J/kmol.
|
||||
*/
|
||||
virtual doublereal gibbs_mole() const {
|
||||
return enthalpy_mole() - temperature() * entropy_mole();
|
||||
}
|
||||
|
||||
virtual doublereal gibbs_mole() const;
|
||||
|
||||
/**
|
||||
* Molar heat capacity at constant pressure. Units: J/kmol/K.
|
||||
|
|
@ -401,18 +424,14 @@ namespace Cantera {
|
|||
* property manager.
|
||||
* @see SpeciesThermo
|
||||
*/
|
||||
virtual doublereal cp_mole() const {
|
||||
return GasConstant * mean_X(&cp_R_ref()[0]);
|
||||
}
|
||||
virtual doublereal cp_mole() const;
|
||||
|
||||
/**
|
||||
* Molar heat capacity at constant volume. Units: J/kmol/K.
|
||||
* For an ideal gas mixture,
|
||||
* \f[ \hat c_v = \hat c_p - \hat R. \f]
|
||||
*/
|
||||
virtual doublereal cv_mole() const {
|
||||
return cp_mole() - GasConstant;
|
||||
}
|
||||
virtual doublereal cv_mole() const;
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,78 @@
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
|
||||
// Default empty constructor
|
||||
StoichSubstance::StoichSubstance() :
|
||||
m_kk(0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_p0(OneAtm),
|
||||
m_tlast(-1.0) {
|
||||
}
|
||||
|
||||
// Copy Constructor
|
||||
/*
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
StoichSubstance::StoichSubstance(const StoichSubstance &right) :
|
||||
m_kk(0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_p0(OneAtm),
|
||||
m_tlast(-1.0) {
|
||||
*this = operator=(right);
|
||||
}
|
||||
|
||||
// Asignment operator
|
||||
/*
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
StoichSubstance& StoichSubstance::
|
||||
operator=(const StoichSubstance &right) {
|
||||
if (&right != this) {
|
||||
ThermoPhase::operator=(right);
|
||||
m_kk = right.m_kk;
|
||||
m_tmin = right.m_tmin;
|
||||
m_tmax = right.m_tmax;
|
||||
m_press = right.m_press;
|
||||
m_p0 = right.m_p0;
|
||||
m_tlast = right.m_tlast;
|
||||
m_h0_RT = right.m_h0_RT;
|
||||
m_cp0_R = right.m_cp0_R;
|
||||
m_s0_R = right.m_s0_R;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Duplicator from the %ThermoPhase parent class
|
||||
/*
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase
|
||||
*/
|
||||
ThermoPhase *StoichSubstance::duplMyselfAsThermoPhase() const {
|
||||
ThermoPhase *igp = new StoichSubstance(*this);
|
||||
return (ThermoPhase *) igp;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
StoichSubstance::~StoichSubstance() {
|
||||
}
|
||||
|
||||
void StoichSubstance::initThermo() {
|
||||
m_kk = nSpecies();
|
||||
if (m_kk > 1) {
|
||||
|
|
|
|||
|
|
@ -36,15 +36,42 @@ namespace Cantera {
|
|||
|
||||
public:
|
||||
|
||||
StoichSubstance():
|
||||
m_kk(0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_p0(OneAtm),
|
||||
m_tlast(-1.0) {}
|
||||
//! Default empty constructor
|
||||
StoichSubstance();
|
||||
|
||||
virtual ~StoichSubstance() {}
|
||||
//! Copy Constructor
|
||||
/*!
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
StoichSubstance(const StoichSubstance &right);
|
||||
|
||||
//! Asignment operator
|
||||
/*!
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
StoichSubstance& operator=(const StoichSubstance &right);
|
||||
|
||||
//! Destructor
|
||||
virtual ~StoichSubstance();
|
||||
|
||||
//! Duplicator from the %ThermoPhase parent class
|
||||
/*
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase
|
||||
*/
|
||||
ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -33,19 +33,18 @@ using namespace std;
|
|||
|
||||
namespace Cantera {
|
||||
|
||||
SurfPhase::
|
||||
SurfPhase(doublereal n0):
|
||||
ThermoPhase(),
|
||||
m_n0(n0),
|
||||
m_logn0(0.0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_tlast(0.0)
|
||||
{
|
||||
if (n0 > 0.0) m_logn0 = log(n0);
|
||||
setNDim(2);
|
||||
}
|
||||
SurfPhase::SurfPhase(doublereal n0):
|
||||
ThermoPhase(),
|
||||
m_n0(n0),
|
||||
m_logn0(0.0),
|
||||
m_tmin(0.0),
|
||||
m_tmax(0.0),
|
||||
m_press(OneAtm),
|
||||
m_tlast(0.0)
|
||||
{
|
||||
if (n0 > 0.0) m_logn0 = log(n0);
|
||||
setNDim(2);
|
||||
}
|
||||
|
||||
SurfPhase::SurfPhase(XML_Node& xmlphase) {
|
||||
const XML_Node& th = xmlphase.child("thermo");
|
||||
|
|
@ -57,6 +56,66 @@ namespace Cantera {
|
|||
importPhase(xmlphase, this);
|
||||
}
|
||||
|
||||
// Copy Constructor
|
||||
/*
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
SurfPhase::SurfPhase(const SurfPhase &right) :
|
||||
m_n0(right.m_n0),
|
||||
m_logn0(right.m_logn0),
|
||||
m_tmin(right.m_tmin),
|
||||
m_tmax(right.m_tmax),
|
||||
m_press(right.m_press),
|
||||
m_tlast(right.m_tlast)
|
||||
{
|
||||
*this = operator=(right);
|
||||
}
|
||||
|
||||
// Asignment operator
|
||||
/*
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
SurfPhase& SurfPhase::
|
||||
operator=(const SurfPhase &right) {
|
||||
if (&right != this) {
|
||||
ThermoPhase::operator=(right);
|
||||
m_n0 = right.m_n0;
|
||||
m_logn0 = right.m_logn0;
|
||||
m_tmin = right.m_tmin;
|
||||
m_tmax = right.m_tmax;
|
||||
m_press = right.m_press;
|
||||
m_tlast = right.m_tlast;
|
||||
m_h0 = right.m_h0;
|
||||
m_cp0 = right.m_cp0;
|
||||
m_mu0 = right.m_mu0;
|
||||
m_work = right.m_work;
|
||||
m_pe = right.m_pe;
|
||||
m_logsize = right.m_logsize;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Duplicator from the %ThermoPhase parent class
|
||||
/*
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase
|
||||
*/
|
||||
ThermoPhase *SurfPhase::duplMyselfAsThermoPhase() const {
|
||||
ThermoPhase *igp = new SurfPhase(*this);
|
||||
return (ThermoPhase *) igp;
|
||||
}
|
||||
|
||||
doublereal SurfPhase::
|
||||
enthalpy_mole() const {
|
||||
|
|
|
|||
|
|
@ -167,10 +167,40 @@ namespace Cantera {
|
|||
*/
|
||||
SurfPhase(XML_Node& xmlphase);
|
||||
|
||||
//! Copy Constructor
|
||||
/*!
|
||||
* Copy constructor for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
* This is a wrapper around the assignment operator
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
SurfPhase(const SurfPhase &right);
|
||||
|
||||
//! Asignment operator
|
||||
/*!
|
||||
* Assignment operator for the object. Constructed
|
||||
* object will be a clone of this object, but will
|
||||
* also own all of its data.
|
||||
*
|
||||
* @param right Object to be copied.
|
||||
*/
|
||||
SurfPhase& operator=(const SurfPhase &right);
|
||||
|
||||
//! Destructor.
|
||||
virtual ~SurfPhase();
|
||||
|
||||
//! Duplicator from the %ThermoPhase parent class
|
||||
/*
|
||||
* Given a pointer to a %ThermoPhase object, this function will
|
||||
* duplicate the %ThermoPhase object and all underlying structures.
|
||||
* This is basically a wrapper around the copy constructor.
|
||||
*
|
||||
* @return returns a pointer to a %ThermoPhase
|
||||
*/
|
||||
ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
//----- reimplimented methods of class ThermoPhase ------
|
||||
|
||||
//! Equation of state type flag.
|
||||
|
|
|
|||
|
|
@ -264,16 +264,15 @@ namespace Cantera {
|
|||
*/
|
||||
ThermoPhase& operator=(const ThermoPhase &right);
|
||||
|
||||
/**
|
||||
* Duplication routine for objects which inherit from
|
||||
* ThermoPhase.
|
||||
*
|
||||
* This virtual routine can be used to duplicate thermophase objects
|
||||
* inherited from ThermoPhase even if the application only has
|
||||
* a pointer to ThermoPhase to work with.
|
||||
//! Duplication routine for objects which inherit from
|
||||
//! ThermoPhase.
|
||||
/*!
|
||||
* This virtual routine can be used to duplicate %ThermoPhase objects
|
||||
* inherited from %ThermoPhase even if the application only has
|
||||
* a pointer to %ThermoPhase to work with.
|
||||
*
|
||||
* Currently, this is not fully implemented. If called, an
|
||||
* exception will be called.
|
||||
* These routines are basically wrappers around the derived copy
|
||||
* constructor.
|
||||
*/
|
||||
virtual ThermoPhase *duplMyselfAsThermoPhase() const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue