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]); }
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); }