diff --git a/include/cantera/thermo/EdgePhase.h b/include/cantera/thermo/EdgePhase.h index 94188b7f6..d26b463a5 100644 --- a/include/cantera/thermo/EdgePhase.h +++ b/include/cantera/thermo/EdgePhase.h @@ -33,7 +33,7 @@ public: /*! * @param n0 Surface site density (kmol m-1). */ - EdgePhase(doublereal n0 = 0.0); + EdgePhase(doublereal n0=1.0); //! Copy Constructor /*! diff --git a/include/cantera/thermo/SurfPhase.h b/include/cantera/thermo/SurfPhase.h index 35e7bde30..de6663503 100644 --- a/include/cantera/thermo/SurfPhase.h +++ b/include/cantera/thermo/SurfPhase.h @@ -148,7 +148,7 @@ public: * @param n0 Site Density of the Surface Phase * Units: kmol m-2. */ - SurfPhase(doublereal n0 = 0.0); + SurfPhase(doublereal n0 = 1.0); //! Construct and initialize a SurfPhase ThermoPhase object //! directly from an ASCII input file diff --git a/src/thermo/SurfPhase.cpp b/src/thermo/SurfPhase.cpp index a69b4adfc..26b404c78 100644 --- a/src/thermo/SurfPhase.cpp +++ b/src/thermo/SurfPhase.cpp @@ -20,19 +20,13 @@ using namespace std; namespace Cantera { SurfPhase::SurfPhase(doublereal n0): - m_n0(n0), - m_logn0(0.0), m_press(OneAtm) { - if (n0 > 0.0) { - m_logn0 = log(n0); - } + setSiteDensity(n0); setNDim(2); } SurfPhase::SurfPhase(const std::string& infile, std::string id_) : - m_n0(0.0), - m_logn0(0.0), m_press(OneAtm) { XML_Node* root = get_XML_File(infile); @@ -54,8 +48,6 @@ SurfPhase::SurfPhase(const std::string& infile, std::string id_) : } SurfPhase::SurfPhase(XML_Node& xmlphase) : - m_n0(0.0), - m_logn0(0.0), m_press(OneAtm) { string model = xmlphase.child("thermo")["model"]; @@ -284,7 +276,7 @@ void SurfPhase::setSiteDensity(doublereal n0) { if (n0 <= 0.0) { throw CanteraError("SurfPhase::setSiteDensity", - "Bad value for parameter"); + "Site density must be positive. Got " + fp2str(n0)); } m_n0 = n0; m_logn0 = log(m_n0); @@ -373,11 +365,7 @@ void SurfPhase::setParametersFromXML(const XML_Node& eosdata) { eosdata._require("model","Surface"); doublereal n = getFloat(eosdata, "site_density", "toSI"); - if (n <= 0.0) - throw CanteraError("SurfPhase::setParametersFromXML", - "missing or negative site density"); - m_n0 = n; - m_logn0 = log(m_n0); + setSiteDensity(n); } void SurfPhase::setStateFromXML(const XML_Node& state) @@ -424,11 +412,7 @@ void EdgePhase::setParametersFromXML(const XML_Node& eosdata) { eosdata._require("model","Edge"); doublereal n = getFloat(eosdata, "site_density", "toSI"); - if (n <= 0.0) - throw CanteraError("EdgePhase::setParametersFromXML", - "missing or negative site density"); - m_n0 = n; - m_logn0 = log(m_n0); + setSiteDensity(n); } }