Bug fixes to the PDSS_SSVol object.

This commit is contained in:
Harry Moffat 2009-10-20 23:46:29 +00:00
parent 48261703d4
commit 60c4b40d32
6 changed files with 1032 additions and 995 deletions

View file

@ -883,17 +883,27 @@ namespace ctml {
* units converter is used.
* @param nodeName XML Name of the XML node to read.
* The default value for the node name is floatArray
*
* @return Returns the number of floats read
*/
void getFloatArray(const Cantera::XML_Node& node, vector_fp& v, const bool convert,
int getFloatArray(const Cantera::XML_Node& node, vector_fp& v, const bool convert,
const std::string unitsString, const std::string nodeName) {
string::size_type icom;
string numstr;
doublereal dtmp;
string nn = node.name();
if (nn != nodeName)
throw CanteraError("getFloatArray",
"wrong xml element type/name: was expecting "
const Cantera::XML_Node *readNode = &node;
if (nn != nodeName) {
vector<Cantera::XML_Node *> ll;
node.getChildren(nodeName, ll);
if (ll.size() == 0) {
throw CanteraError("getFloatArray",
"wrong xml element type/name: was expecting "
+ nodeName + "but accessed " + node.name());
} else {
readNode = ll[0];
}
}
v.clear();
doublereal vmin = Undef, vmax = Undef;
@ -902,7 +912,7 @@ namespace ctml {
/*
* Get the attributes field, units, from the XML node
*/
std::string units = node["units"];
std::string units = (*readNode)["units"];
if (units != "" && convert) {
if (unitsString == "actEnergy" && units != "") {
funit = actEnergyToSI(units);
@ -911,13 +921,13 @@ namespace ctml {
}
}
if (node["min"] != "")
vmin = atofCheck(node["min"].c_str());
if (node["max"] != "")
vmax = atofCheck(node["max"].c_str());
if ((*readNode)["min"] != "")
vmin = atofCheck((*readNode)["min"].c_str());
if ((*readNode)["max"] != "")
vmax = atofCheck((*readNode)["max"].c_str());
doublereal vv;
std::string val = node.value();
std::string val = readNode->value();
while (1 > 0) {
icom = val.find(',');
if (icom != string::npos) {
@ -956,6 +966,7 @@ namespace ctml {
for (int n = 0; n < nv; n++) {
v[n] *= funit;
}
return v.size();
}
// This routine is used to interpret the value portions of XML

View file

@ -363,8 +363,9 @@ namespace ctml {
* units converter is used.
* @param nodeName XML Name of the XML node to read.
* The default value for the node name is floatArray
* @return Returns the number of floats read into v.
*/
void getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
int getFloatArray(const Cantera::XML_Node& node, Cantera::vector_fp& v,
const bool convert=true, const std::string typeString="",
const std::string nodeName = "floatArray");

View file

@ -58,7 +58,7 @@ namespace Cantera {
m_jstart(0),
m_left(0),
m_right(0),
m_id("-"), m_desc("-"),
m_id(""), m_desc(""),
m_refiner(0), m_bw(-1) {
resize(nv, points);
}
@ -412,9 +412,11 @@ namespace Cantera {
*/
void setID(const std::string& s) {m_id = s;}
std::string id() {
if (m_id != "") return m_id;
else return std::string("domain ") + int2str(m_index);
std::string id() const {
if (m_id != "")
return m_id;
else
return std::string("domain ") + int2str(m_index);
}
/**
@ -519,7 +521,10 @@ namespace Cantera {
int m_jstart;
Domain1D *m_left, *m_right;
std::string m_id, m_desc;
//! Identity tag for the domain
std::string m_id;
std::string m_desc;
Refiner* m_refiner;
vector_int m_td;
std::vector<std::string> m_name;

File diff suppressed because it is too large Load diff

View file

@ -133,12 +133,20 @@ namespace Cantera {
m_constMolarVolume = getFloat(*ss, "molarVolume", "toSI");
} else if (model == "temperature_polynomial") {
volumeModel_ = cSSVOLUME_TPOLY;
getFloatArray(*ss, TCoeff_, true, "", "floatArray");
int num = getFloatArray(*ss, TCoeff_, true, "", "volumeTemperaturePolynomial");
if (num != 4) {
throw CanteraError("PDSS_SSVol::constructPDSSXML",
" Didn't get 3 density polynomial numbers for species " + speciesNode.name());
}
} else if (model == "density_temperature_polynomial") {
volumeModel_ = cSSVOLUME_DENSITY_TPOLY;
getFloatArray(*ss, TCoeff_, true, "", "floatArray");
int num = getFloatArray(*ss, TCoeff_, true, "", "densityTemperaturePolynomial");
if (num != 4) {
throw CanteraError("PDSS_SSVol::constructPDSSXML",
" Didn't get 3 density polynomial numbers for species " + speciesNode.name());
}
} else {
throw CanteraError("PDSS_SSVol::initThermoXML",
throw CanteraError("PDSS_SSVol::constructPDSSXML",
"standardState model for species isn't constant_incompressible: " + speciesNode.name());
}
std::string id = "";
@ -327,15 +335,15 @@ namespace Cantera {
if (volumeModel_ == cSSVOLUME_CONSTANT ) {
m_Vss_ptr[m_spindex] = m_constMolarVolume;
} else if (volumeModel_ == cSSVOLUME_TPOLY) {
m_Vss_ptr[m_spindex] = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * TCoeff_[2]);
dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2];
d2VdT2_ = 2.0 * TCoeff_[2];
m_Vss_ptr[m_spindex] = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
d2VdT2_ = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
} else if (volumeModel_ == cSSVOLUME_DENSITY_TPOLY) {
doublereal dens = (TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * TCoeff_[2]));
doublereal dens = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3]));
m_Vss_ptr[m_spindex] = m_mw / dens;
doublereal dens2 = dens * dens;
doublereal ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2];
doublereal d2densdT2 = 2.0 * TCoeff_[2];
doublereal ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3];
doublereal d2densdT2 = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3];
dVdT_ = - m_mw / (dens2) * (ddensdT);
d2VdT2_ = 2.0 * m_mw / (dens2 * dens) * ddensdT * ddensdT - m_mw / dens2 * d2densdT2;
} else {

View file

@ -114,6 +114,10 @@ namespace Cantera {
} else if (ssModel == "constant_incompressible" ||
ssModel == "constantVolume") {
has_nasa_constVol++;
} else if (ssModel == "temperature_polynomial" ||
ssModel == "density_temperature_polynomial" ||
ssModel == "constant") {
has_other++;
} else {
throw UnknownVPSSMgrModel("getVPSSMgrTypes:",
spNode->attrib("name"));
@ -126,6 +130,10 @@ namespace Cantera {
} else if (ssModel == "constant_incompressible" ||
ssModel == "constantVolume") {
has_shomate_constVol++;
} else if (ssModel == "temperature_polynomial" ||
ssModel == "density_temperature_polynomial" ||
ssModel == "constant") {
has_other++;
} else {
throw UnknownVPSSMgrModel("getVPSSMgrTypes:",
spNode->attrib("name"));
@ -138,6 +146,10 @@ namespace Cantera {
} else if (ssModel == "constant_incompressible" ||
ssModel == "constantVolume") {
has_simple_constVol++;
} else if (ssModel == "temperature_polynomial" ||
ssModel == "density_temperature_polynomial" ||
ssModel == "constant") {
has_other++;
} else {
throw UnknownVPSSMgrModel("getVPSSMgrTypes:",
spNode->attrib("name"));