Mu0Poly* newMu0ThermoFromXML(const XML_Node& Mu0Node) { bool dimensionlessMu0Values = false; doublereal h298 = 0.0; if (Mu0Node.hasChild("H298")) { h298 = getFloat(Mu0Node, "H298", "actEnergy"); } size_t numPoints = 1; if (Mu0Node.hasChild("numPoints")) { numPoints = getInteger(Mu0Node, "numPoints"); } vector_fp cValues(numPoints); const XML_Node* valNode_ptr = getByTitle(Mu0Node, "Mu0Values"); if (!valNode_ptr) { throw CanteraError("installMu0ThermoFromXML", "missing Mu0Values"); } getFloatArray(*valNode_ptr, cValues, true, "actEnergy"); // Check to see whether the Mu0's were input in a dimensionless form. If // they were, then the assumed temperature needs to be adjusted from the // assumed T = 273.15 if (valNode_ptr->attrib("units") == "Dimensionless") { dimensionlessMu0Values = true; } if (cValues.size() != numPoints) { throw CanteraError("installMu0ThermoFromXML", "numPoints inconsistent"); } vector_fp cTemperatures(numPoints); const XML_Node* tempNode_ptr = getByTitle(Mu0Node, "Mu0Temperatures"); if (!tempNode_ptr) { throw CanteraError("installMu0ThermoFromXML", "missing Mu0Temperatures"); } getFloatArray(*tempNode_ptr, cTemperatures, false); if (cTemperatures.size() != numPoints) { throw CanteraError("installMu0ThermoFromXML", "numPoints inconsistent"); } // Fix up dimensionless Mu0 values if input if (dimensionlessMu0Values) { for (size_t i = 0; i < numPoints; i++) { cValues[i] *= cTemperatures[i] / 273.15; } } vector_fp c(2 + 2 * numPoints); c[0] = static_cast<double>(numPoints); c[1] = h298; for (size_t i = 0; i < numPoints; i++) { c[2+i*2] = cTemperatures[i]; c[2+i*2+1] = cValues[i]; } return new Mu0Poly(fpValue(Mu0Node["Tmin"]), fpValue(Mu0Node["Tmax"]), fpValue(Mu0Node["Pref"]), &c[0]); }
/* * This function will read a child node to the current XML node, with the * name "string". It must have a title attribute, named titleString, and the body * of the XML node will be read into the valueString output argument. * * Example: * * Code snipet: * @verbatum const XML_Node &node; getString(XML_Node& node, std::string titleString, std::string valueString, std::string typeString); @endverbatum * * Reads the following the snippet in the XML file: * @verbatum <string title="titleString" type="typeString"> valueString <\string> @endverbatum * * @param node reference to the XML_Node object of the parent XML element * @param titleString String name of the title attribute of the child node * @param valueString Value string that is found in the child node. output variable * @param typeString String type. This is an optional output variable */ void getString(const Cantera::XML_Node& node, const std::string &titleString, std::string& valueString, std::string& typeString) { valueString = ""; typeString = ""; XML_Node* s = getByTitle(node, titleString); if (s) if (s->name() == "string") { valueString = (*s).value(); typeString = (*s)["type"]; return; } }
void getString(const XML_Node& node, const std::string& titleString, std::string& valueString, std::string& typeString) { XML_Node* s = getByTitle(node, titleString); if (s && s->name() == "string") { valueString = s->value(); typeString = s->attrib("type"); } else { valueString = ""; typeString = ""; } }
void installMu0ThermoFromXML(const std::string& speciesName, SpeciesThermo<ValAndDerivType>& sp, size_t k, const XML_Node* Mu0Node_ptr) { doublereal tmin, tmax; bool dimensionlessMu0Values = false; const XML_Node& Mu0Node = *Mu0Node_ptr; tmin = fpValue(Mu0Node["Tmin"]); tmax = fpValue(Mu0Node["Tmax"]); doublereal pref = fpValue(Mu0Node["Pref"]); doublereal h298 = 0.0; if (Mu0Node.hasChild("H298")) { h298 = getFloat(Mu0Node, "H298", "actEnergy"); } size_t numPoints = 1; if (Mu0Node.hasChild("numPoints")) { numPoints = getInteger(Mu0Node, "numPoints"); } vector_fp cValues(numPoints); const XML_Node* valNode_ptr = getByTitle(const_cast<XML_Node&>(Mu0Node), "Mu0Values"); if (!valNode_ptr) { throw CanteraError("installMu0ThermoFromXML", "missing required while processing " + speciesName); } getFloatArray(*valNode_ptr, cValues, true, "actEnergy"); /* * Check to see whether the Mu0's were input in a dimensionless * form. If they were, then the assumed temperature needs to be * adjusted from the assumed T = 273.15 */ string uuu = (*valNode_ptr)["units"]; if (uuu == "Dimensionless") { dimensionlessMu0Values = true; } size_t ns = cValues.size(); if (ns != numPoints) { throw CanteraError("installMu0ThermoFromXML", "numPoints inconsistent while processing " + speciesName); } vector_fp cTemperatures(numPoints); const XML_Node* tempNode_ptr = getByTitle(const_cast<XML_Node&>(Mu0Node), "Mu0Temperatures"); if (!tempNode_ptr) { throw CanteraError("installMu0ThermoFromXML", "missing required while processing + " + speciesName); } getFloatArray(*tempNode_ptr, cTemperatures, false); ns = cTemperatures.size(); if (ns != numPoints) { throw CanteraError("installMu0ThermoFromXML", "numPoints inconsistent while processing " + speciesName); } /* * Fix up dimensionless Mu0 values if input */ if (dimensionlessMu0Values) { for (size_t i = 0; i < numPoints; i++) { cValues[i] *= cTemperatures[i] / 273.15; } } vector_fp c(2 + 2 * numPoints); c[0] = static_cast<double>(numPoints); c[1] = h298; for (size_t i = 0; i < numPoints; i++) { c[2 + i * 2] = cTemperatures[i]; c[2 + i * 2 + 1] = cValues[i]; } sp.install(speciesName, k, MU0_INTERP, &c[0], tmin, tmax, pref); }