From 7a24dc3817639b79c321a5e1ea4d0c11a9bbaa4b Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 28 Oct 2016 18:20:11 -0400 Subject: [PATCH] Replace lowercase with boost string algorithms --- include/cantera/base/stringUtils.h | 2 + src/base/stringUtils.cpp | 2 + src/kinetics/KineticsFactory.cpp | 2 +- src/kinetics/Reaction.cpp | 28 ++--- src/thermo/DebyeHuckel.cpp | 41 +++---- src/thermo/HMWSoln_input.cpp | 150 ++++++++++-------------- src/thermo/IdealSolidSolnPhase.cpp | 16 ++- src/thermo/IdealSolnGasVPSS.cpp | 11 +- src/thermo/IonsFromNeutralVPSSTP.cpp | 6 +- src/thermo/LatticePhase.cpp | 5 +- src/thermo/MargulesVPSSTP.cpp | 14 +-- src/thermo/MaskellSolidSolnPhase.cpp | 5 +- src/thermo/MixedSolventElectrolyte.cpp | 15 ++- src/thermo/MolarityIonicVPSSTP.cpp | 10 +- src/thermo/PDSS_HKFT.cpp | 4 +- src/thermo/PDSS_IonsFromNeutral.cpp | 2 +- src/thermo/Phase.cpp | 20 ++-- src/thermo/PhaseCombo_Interaction.cpp | 14 +-- src/thermo/RedlichKisterVPSSTP.cpp | 15 ++- src/thermo/RedlichKwongMFTP.cpp | 18 +-- src/thermo/SpeciesThermoFactory.cpp | 8 +- src/thermo/VPSSMgrFactory.cpp | 4 +- src/thermo/VPSSMgr_Water_HKFT.cpp | 3 +- src/tpx/utils.cpp | 2 +- src/transport/LiquidTranInteraction.cpp | 4 +- src/transport/TransportFactory.cpp | 2 +- 26 files changed, 176 insertions(+), 227 deletions(-) diff --git a/include/cantera/base/stringUtils.h b/include/cantera/base/stringUtils.h index cb0e386a7..7daafef25 100644 --- a/include/cantera/base/stringUtils.h +++ b/include/cantera/base/stringUtils.h @@ -73,6 +73,8 @@ std::string stripnonprint(const std::string& s); /*! * @param s Input string * @returns a copy of the string, with all characters lowercase. + * @deprecated Use boost::algorithm::to_lower_copy instead. To be removed after + * Cantera 2.3. */ std::string lowercase(const std::string& s); diff --git a/src/base/stringUtils.cpp b/src/base/stringUtils.cpp index 0b9abaa67..eadb481b3 100644 --- a/src/base/stringUtils.cpp +++ b/src/base/stringUtils.cpp @@ -84,6 +84,8 @@ std::string vec2str(const vector_fp& v, const std::string& fmt, std::string lowercase(const std::string& s) { + warn_deprecated("lowercase", "Use boost::algorithm::to_lower_copy instead. " + "To be removed after Cantera 2.3."); std::string lc(s); for (size_t i = 0; i < s.size(); i++) { lc[i] = (char) tolower(s[i]); diff --git a/src/kinetics/KineticsFactory.cpp b/src/kinetics/KineticsFactory.cpp index 2ac522171..7a4712e0d 100644 --- a/src/kinetics/KineticsFactory.cpp +++ b/src/kinetics/KineticsFactory.cpp @@ -49,7 +49,7 @@ KineticsFactory::KineticsFactory() { Kinetics* KineticsFactory::newKinetics(const string& model) { - return create(lowercase(model)); + return create(ba::to_lower_copy(model)); } } diff --git a/src/kinetics/Reaction.cpp b/src/kinetics/Reaction.cpp index c3afe66a4..8d6c919ef 100644 --- a/src/kinetics/Reaction.cpp +++ b/src/kinetics/Reaction.cpp @@ -296,19 +296,19 @@ void readFalloff(FalloffReaction& R, const XML_Node& rc_node) } int falloff_type = 0; - if (lowercase(falloff["type"]) == "lindemann") { + if (ba::iequals(falloff["type"], "lindemann")) { falloff_type = SIMPLE_FALLOFF; if (np != 0) { throw CanteraError("readFalloff", "Lindemann parameterization " "takes no parameters, but {} were given", np); } - } else if (lowercase(falloff["type"]) == "troe") { + } else if (ba::iequals(falloff["type"], "troe")) { falloff_type = TROE_FALLOFF; if (np != 3 && np != 4) { throw CanteraError("readFalloff", "Troe parameterization takes " "3 or 4 parameters, but {} were given", np); } - } else if (lowercase(falloff["type"]) == "sri") { + } else if (ba::iequals(falloff["type"], "sri")) { falloff_type = SRI_FALLOFF; if (np != 3 && np != 5) { throw CanteraError("readFalloff", "SRI parameterization takes " @@ -479,23 +479,23 @@ void setupChebyshevReaction(ChebyshevReaction& R, const XML_Node& rxn_node) void setupInterfaceReaction(InterfaceReaction& R, const XML_Node& rxn_node) { - if (lowercase(rxn_node["type"]) == "global") { + if (ba::iequals(rxn_node["type"], "global")) { R.reaction_type = GLOBAL_RXN; } XML_Node& arr = rxn_node.child("rateCoeff").child("Arrhenius"); - if (lowercase(arr["type"]) == "stick") { + if (ba::iequals(arr["type"], "stick")) { R.is_sticking_coefficient = true; R.sticking_species = arr["species"]; - if (lowercase(arr["motz_wise"]) == "true") { + if (ba::iequals(arr["motz_wise"], "true")) { R.use_motz_wise_correction = true; - } else if (lowercase(arr["motz_wise"]) == "false") { + } else if (ba::iequals(arr["motz_wise"], "false")) { R.use_motz_wise_correction = false; } else { // Default value for all reactions XML_Node* parent = rxn_node.parent(); if (parent && parent->name() == "reactionData" - && lowercase((*parent)["motz_wise"]) == "true") { + && ba::iequals((*parent)["motz_wise"], "true")) { R.use_motz_wise_correction = true; } } @@ -514,7 +514,7 @@ void setupElectrochemicalReaction(ElectrochemicalReaction& R, const XML_Node& rxn_node) { // Fix reaction_type for some specialized reaction types - std::string type = lowercase(rxn_node["type"]); + std::string type = ba::to_lower_copy(rxn_node["type"]); if (type == "butlervolmer") { R.reaction_type = BUTLERVOLMER_RXN; } else if (type == "butlervolmer_noactivitycoeffs") { @@ -526,7 +526,7 @@ void setupElectrochemicalReaction(ElectrochemicalReaction& R, } XML_Node& rc = rxn_node.child("rateCoeff"); - std::string rc_type = lowercase(rc["type"]); + std::string rc_type = ba::to_lower_copy(rc["type"]); if (rc_type == "exchangecurrentdensity") { R.exchange_current_density_formulation = true; } else if (rc_type != "" && rc_type != "arrhenius") { @@ -569,13 +569,13 @@ void setupElectrochemicalReaction(ElectrochemicalReaction& R, R.orders.clear(); R.allow_nonreactant_orders = true; const XML_Node& rof_node = rxn_node.child("reactionOrderFormulation"); - if (lowercase(rof_node["model"]) == "reactantorders") { + if (ba::iequals(rof_node["model"], "reactantorders")) { R.orders = initial_orders; - } else if (lowercase(rof_node["model"]) == "zeroorders") { + } else if (ba::iequals(rof_node["model"], "zeroorders")) { for (const auto& sp : R.reactants) { R.orders[sp.first] = 0.0; } - } else if (lowercase(rof_node["model"]) == "butlervolmerorders") { + } else if (ba::iequals(rof_node["model"], "butlervolmerorders")) { // Reaction orders based on provided reaction orders for (const auto& sp : R.reactants) { double c = getValue(initial_orders, sp.first, sp.second); @@ -603,7 +603,7 @@ void setupElectrochemicalReaction(ElectrochemicalReaction& R, shared_ptr newReaction(const XML_Node& rxn_node) { - std::string type = lowercase(rxn_node["type"]); + std::string type = ba::to_lower_copy(rxn_node["type"]); // Modify the reaction type for edge reactions which contain electrochemical // reaction data diff --git a/src/thermo/DebyeHuckel.cpp b/src/thermo/DebyeHuckel.cpp index 92325f609..e21893ad7 100644 --- a/src/thermo/DebyeHuckel.cpp +++ b/src/thermo/DebyeHuckel.cpp @@ -397,24 +397,21 @@ void DebyeHuckel::getPartialMolarCp(doublereal* cpbar) const */ static int interp_est(const std::string& estString) { - const char* cc = estString.c_str(); - string lc = lowercase(estString); - const char* ccl = lc.c_str(); - if (!strcmp(ccl, "solvent")) { + if (ba::iequals(estString, "solvent")) { return cEST_solvent; - } else if (!strcmp(ccl, "chargedspecies")) { + } else if (ba::iequals(estString, "chargedspecies")) { return cEST_chargedSpecies; - } else if (!strcmp(ccl, "weakacidassociated")) { + } else if (ba::iequals(estString, "weakacidassociated")) { return cEST_weakAcidAssociated; - } else if (!strcmp(ccl, "strongacidassociated")) { + } else if (ba::iequals(estString, "strongacidassociated")) { return cEST_strongAcidAssociated; - } else if (!strcmp(ccl, "polarneutral")) { + } else if (ba::iequals(estString, "polarneutral")) { return cEST_polarNeutral; - } else if (!strcmp(ccl, "nonpolarneutral")) { + } else if (ba::iequals(estString, "nonpolarneutral")) { return cEST_nonpolarNeutral; } int retn, rval; - if ((retn = sscanf(cc, "%d", &rval)) != 1) { + if ((retn = sscanf(estString.c_str(), "%d", &rval)) != 1) { return -1; } return rval; @@ -543,17 +540,16 @@ void DebyeHuckel::initThermoXML(XML_Node& phaseNode, const std::string& id_) "Species " + sss[k] + " standardState XML block not found"); } - std::string modelStringa = ss->attrib("model"); - if (modelStringa == "") { + std::string modelString = ss->attrib("model"); + if (modelString == "") { throw CanteraError("DebyeHuckel::initThermoXML", "Species " + sss[k] + " standardState XML block model attribute not found"); } - std::string modelString = lowercase(modelStringa); if (k == 0) { - if (modelString == "wateriapws" || modelString == "real_water" || - modelString == "waterpdss") { + if (ba::iequals(modelString, "wateriapws") || ba::iequals(modelString, "real_water") || + ba::iequals(modelString, "waterpdss")) { // Initialize the water standard state model m_waterSS = dynamic_cast(providePDSS(0)); if (!m_waterSS) { @@ -568,17 +564,17 @@ void DebyeHuckel::initThermoXML(XML_Node& phaseNode, const std::string& id_) double dens = m_waterSS->density(); double mw = m_waterSS->molecularWeight(); m_speciesSize[0] = mw / dens; - } else if (modelString == "constant_incompressible") { + } else if (ba::iequals(modelString, "constant_incompressible")) { m_speciesSize[k] = getFloat(*ss, "molarVolume", "toSi"); } else { throw CanteraError("DebyeHuckel::initThermoXML", - "Solvent SS Model \"" + modelStringa + + "Solvent SS Model \"" + modelString + "\" is not known"); } } else { - if (modelString != "constant_incompressible") { + if (!ba::iequals(modelString, "constant_incompressible")) { throw CanteraError("DebyeHuckel::initThermoXML", - "Solute SS Model \"" + modelStringa + + "Solute SS Model \"" + modelString + "\" is not known"); } m_speciesSize[k] = getFloat(*ss, "molarVolume", "toSI"); @@ -595,14 +591,13 @@ void DebyeHuckel::initThermoXML(XML_Node& phaseNode, const std::string& id_) // Look for parameters for A_Debye if (acNode.hasChild("A_Debye")) { XML_Node* ss = acNode.findByName("A_Debye"); - string modelStringa = ss->attrib("model"); - string modelString = lowercase(modelStringa); + string modelString = ss->attrib("model"); if (modelString != "") { - if (modelString == "water") { + if (ba::iequals(modelString, "water")) { m_form_A_Debye = A_DEBYE_WATER; } else { throw CanteraError("DebyeHuckel::initThermoXML", - "A_Debye Model \"" + modelStringa + + "A_Debye Model \"" + modelString + "\" is not known"); } } else { diff --git a/src/thermo/HMWSoln_input.cpp b/src/thermo/HMWSoln_input.cpp index d3e704ae8..012f17c0b 100644 --- a/src/thermo/HMWSoln_input.cpp +++ b/src/thermo/HMWSoln_input.cpp @@ -26,24 +26,21 @@ namespace Cantera { int HMWSoln::interp_est(const std::string& estString) { - const char* cc = estString.c_str(); - string lcs = lowercase(estString); - const char* ccl = lcs.c_str(); - if (!strcmp(ccl, "solvent")) { + if (ba::iequals(estString, "solvent")) { return cEST_solvent; - } else if (!strcmp(ccl, "chargedspecies")) { + } else if (ba::iequals(estString, "chargedspecies")) { return cEST_chargedSpecies; - } else if (!strcmp(ccl, "weakacidassociated")) { + } else if (ba::iequals(estString, "weakacidassociated")) { return cEST_weakAcidAssociated; - } else if (!strcmp(ccl, "strongacidassociated")) { + } else if (ba::iequals(estString, "strongacidassociated")) { return cEST_strongAcidAssociated; - } else if (!strcmp(ccl, "polarneutral")) { + } else if (ba::iequals(estString, "polarneutral")) { return cEST_polarNeutral; - } else if (!strcmp(ccl, "nonpolarneutral")) { + } else if (ba::iequals(estString, "nonpolarneutral")) { return cEST_nonpolarNeutral; } int retn, rval; - if ((retn = sscanf(cc, "%d", &rval)) != 1) { + if ((retn = sscanf(estString.c_str(), "%d", &rval)) != 1) { return -1; } return rval; @@ -90,11 +87,10 @@ void HMWSoln::readXMLBinarySalt(XML_Node& BinSalt) int counter = m_CounterIJ[n]; for (size_t iChild = 0; iChild < BinSalt.nChildren(); iChild++) { XML_Node& xmlChild = BinSalt.child(iChild); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); + string nodeName = xmlChild.name(); // Process the binary salt child elements - if (nodeName == "beta0") { + if (ba::iequals(nodeName, "beta0")) { // Get the string containing all of the values getFloatArray(xmlChild, vParams, false, "", "beta0"); size_t nParamsFound = vParams.size(); @@ -127,7 +123,7 @@ void HMWSoln::readXMLBinarySalt(XML_Node& BinSalt) m_Beta0MX_ij[counter] = vParams[0]; } } - if (nodeName == "beta1") { + if (ba::iequals(nodeName, "beta1")) { // Get the string containing all of the values getFloatArray(xmlChild, vParams, false, "", "beta1"); size_t nParamsFound = vParams.size(); @@ -160,7 +156,7 @@ void HMWSoln::readXMLBinarySalt(XML_Node& BinSalt) m_Beta1MX_ij[counter] = vParams[0]; } } - if (nodeName == "beta2") { + if (ba::iequals(nodeName, "beta2")) { getFloatArray(xmlChild, vParams, false, "", "beta2"); size_t nParamsFound = vParams.size(); if (m_formPitzerTemp == PITZER_TEMP_CONSTANT) { @@ -192,7 +188,7 @@ void HMWSoln::readXMLBinarySalt(XML_Node& BinSalt) m_Beta2MX_ij[counter] = vParams[0]; } } - if (nodeName == "cphi") { + if (ba::iequals(nodeName, "cphi")) { // Get the string containing all of the values getFloatArray(xmlChild, vParams, false, "", "Cphi"); size_t nParamsFound = vParams.size(); @@ -226,14 +222,12 @@ void HMWSoln::readXMLBinarySalt(XML_Node& BinSalt) } } - if (nodeName == "alpha1") { - stemp = xmlChild.value(); - m_Alpha1MX_ij[counter] = fpValueCheck(stemp); + if (ba::iequals(nodeName, "alpha1")) { + m_Alpha1MX_ij[counter] = fpValueCheck(xmlChild.value()); } - if (nodeName == "alpha2") { - stemp = xmlChild.value(); - m_Alpha2MX_ij[counter] = fpValueCheck(stemp); + if (ba::iequals(nodeName, "alpha2")) { + m_Alpha2MX_ij[counter] = fpValueCheck(xmlChild.value()); } } } @@ -246,7 +240,6 @@ void HMWSoln::readXMLThetaAnion(XML_Node& BinSalt) throw CanteraError("HMWSoln::readXMLThetaAnion", "Incorrect name for processing this routine: " + xname); } - string stemp; string ispName = BinSalt.attrib("anion1"); if (ispName == "") { throw CanteraError("HMWSoln::readXMLThetaAnion", "no anion1 attrib"); @@ -277,10 +270,8 @@ void HMWSoln::readXMLThetaAnion(XML_Node& BinSalt) int counter = m_CounterIJ[n]; for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "theta") { - getFloatArray(xmlChild, vParams, false, "", stemp); + if (ba::iequals(xmlChild.name(), "theta")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); if (m_formPitzerTemp == PITZER_TEMP_CONSTANT) { if (nParamsFound != 1) { @@ -355,10 +346,8 @@ void HMWSoln::readXMLThetaCation(XML_Node& BinSalt) int counter = m_CounterIJ[n]; for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "theta") { - getFloatArray(xmlChild, vParams, false, "", stemp); + if (ba::iequals(xmlChild.name(), "theta")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); if (m_formPitzerTemp == PITZER_TEMP_CONSTANT) { if (nParamsFound != 1) { @@ -447,19 +436,16 @@ void HMWSoln::readXMLPsiCommonCation(XML_Node& BinSalt) int counter = m_CounterIJ[n]; for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "theta") { - stemp = xmlChild.value(); + if (ba::iequals(xmlChild.name(), "theta")) { double old = m_Theta_ij[counter]; - m_Theta_ij[counter] = fpValueCheck(stemp); + m_Theta_ij[counter] = fpValueCheck(xmlChild.value()); if (old != 0.0 && old != m_Theta_ij[counter]) { throw CanteraError("HMWSoln::readXMLPsiCommonCation", "conflicting values"); } } - if (nodeName == "psi") { - getFloatArray(xmlChild, vParams, false, "", stemp); + if (ba::iequals(xmlChild.name(), "psi")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); n = iSpecies * m_kk *m_kk + jSpecies * m_kk + kSpecies; @@ -580,19 +566,16 @@ void HMWSoln::readXMLPsiCommonAnion(XML_Node& BinSalt) int counter = m_CounterIJ[n]; for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "theta") { - stemp = xmlChild.value(); + if (ba::iequals(xmlChild.name(), "theta")) { double old = m_Theta_ij[counter]; - m_Theta_ij[counter] = fpValueCheck(stemp); + m_Theta_ij[counter] = fpValueCheck(xmlChild.value()); if (old != 0.0 && old != m_Theta_ij[counter]) { throw CanteraError("HMWSoln::readXMLPsiCommonAnion", "conflicting values"); } } - if (nodeName == "psi") { - getFloatArray(xmlChild, vParams, false, "", stemp); + if (ba::iequals(xmlChild.name(), "psi")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); n = iSpecies * m_kk *m_kk + jSpecies * m_kk + kSpecies; @@ -697,11 +680,9 @@ void HMWSoln::readXMLLambdaNeutral(XML_Node& BinSalt) for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "lambda") { + if (ba::iequals(xmlChild.name(), "lambda")) { size_t nCount = iSpecies*m_kk + jSpecies; - getFloatArray(xmlChild, vParams, false, "", stemp); + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); if (m_formPitzerTemp == PITZER_TEMP_CONSTANT) { if (nParamsFound != 1) { @@ -746,7 +727,6 @@ void HMWSoln::readXMLMunnnNeutral(XML_Node& BinSalt) throw CanteraError("HMWSoln::readXMLMunnnNeutral", "Incorrect name for processing this routine: " + xname); } - string stemp; string iName = BinSalt.attrib("species1"); if (iName == "") { throw CanteraError("HMWSoln::readXMLMunnnNeutral", "no species1 attrib"); @@ -765,10 +745,8 @@ void HMWSoln::readXMLMunnnNeutral(XML_Node& BinSalt) for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "munnn") { - getFloatArray(xmlChild, vParams, false, "", "Munnn"); + if (ba::iequals(xmlChild.name(), "Munnn")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); if (m_formPitzerTemp == PITZER_TEMP_CONSTANT) { if (nParamsFound != 1) { @@ -854,10 +832,8 @@ void HMWSoln::readXMLZetaCation(const XML_Node& BinSalt) for (size_t i = 0; i < BinSalt.nChildren(); i++) { XML_Node& xmlChild = BinSalt.child(i); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "zeta") { - getFloatArray(xmlChild, vParams, false, "", "zeta"); + if (ba::iequals(xmlChild.name(), "zeta")) { + getFloatArray(xmlChild, vParams, false, "", xmlChild.name()); size_t nParamsFound = vParams.size(); size_t n = iSpecies * m_kk *m_kk + jSpecies * m_kk + kSpecies; @@ -968,18 +944,17 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) if (thermoNode.hasChild("standardConc")) { XML_Node& scNode = thermoNode.child("standardConc"); m_formGC = 2; - string stemp = scNode.attrib("model"); - string formString = lowercase(stemp); + string formString = scNode.attrib("model"); if (formString != "") { - if (formString == "unity") { + if (ba::iequals(formString, "unity")) { m_formGC = 0; throw CanteraError("HMWSoln::initThermoXML", "standardConc = unity not done"); - } else if (formString == "molar_volume") { + } else if (ba::iequals(formString, "molar_volume")) { m_formGC = 1; throw CanteraError("HMWSoln::initThermoXML", "standardConc = molar_volume not done"); - } else if (formString == "solvent_volume") { + } else if (ba::iequals(formString, "solvent_volume")) { m_formGC = 2; } else { throw CanteraError("HMWSoln::initThermoXML", @@ -992,12 +967,11 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) // size arrays below. if (thermoNode.hasChild("activityCoefficients")) { XML_Node& scNode = thermoNode.child("activityCoefficients"); - string stemp = scNode.attrib("model"); - string formString = lowercase(stemp); + string formString = scNode.attrib("model"); if (formString != "") { - if (formString == "pitzer" || formString == "default") { + if (ba::iequals(formString, "pitzer") || ba::iequals(formString, "default")) { m_formPitzer = PITZERFORM_BASE; - } else if (formString == "base") { + } else if (ba::iequals(formString, "base")) { m_formPitzer = PITZERFORM_BASE; } else { throw CanteraError("HMWSoln::initThermoXML", @@ -1008,14 +982,13 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) // Determine the form of the temperature dependence of the Pitzer // activity coefficient model. - stemp = scNode.attrib("TempModel"); - formString = lowercase(stemp); + formString = scNode.attrib("TempModel"); if (formString != "") { - if (formString == "constant" || formString == "default") { + if (ba::iequals(formString, "constant") || ba::iequals(formString, "default")) { m_formPitzerTemp = PITZER_TEMP_CONSTANT; - } else if (formString == "linear") { + } else if (ba::iequals(formString, "linear")) { m_formPitzerTemp = PITZER_TEMP_LINEAR; - } else if (formString == "complex" || formString == "complex1") { + } else if (ba::iequals(formString, "complex") || ba::iequals(formString, "complex1")) { m_formPitzerTemp = PITZER_TEMP_COMPLEX1; } else { throw CanteraError("HMWSoln::initThermoXML", @@ -1027,8 +1000,7 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) // Determine the reference temperature of the Pitzer activity // coefficient model's temperature dependence formulation: defaults to // 25C - stemp = scNode.attrib("TempReference"); - formString = lowercase(stemp); + formString = scNode.attrib("TempReference"); if (formString != "") { m_TempPitzerRef = fpValueCheck(formString); } else { @@ -1100,13 +1072,12 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) "Species " + sss[k] + " standardState XML block not found"); } - string modelStringa = ss->attrib("model"); - if (modelStringa == "") { + string modelString = ba::to_lower_copy(ss->attrib("model")); + if (modelString == "") { throw CanteraError("HMWSoln::initThermoXML", "Species " + sss[k] + " standardState XML block model attribute not found"); } - string modelString = lowercase(modelStringa); if (k == 0) { if (modelString == "wateriapws" || modelString == "real_water" || modelString == "waterpdss") { @@ -1136,7 +1107,7 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) } else { if (modelString != "constant_incompressible" && modelString != "hkft") { throw CanteraError("HMWSoln::initThermoXML", - "Solute SS Model \"" + modelStringa + + "Solute SS Model \"" + modelString + "\" is not known"); } if (modelString == "constant_incompressible") { @@ -1169,10 +1140,8 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) XML_Node& ADebye = acNode.child("A_Debye"); m_form_A_Debye = A_DEBYE_CONST; string stemp = "model"; - if (ADebye.hasAttrib(stemp)) { - string atemp = ADebye.attrib(stemp); - stemp = lowercase(atemp); - if (stemp == "water") { + if (ADebye.hasAttrib("model")) { + if (ba::iequals(ADebye.attrib("model"), "water")) { m_form_A_Debye = A_DEBYE_WATER; } } @@ -1242,25 +1211,24 @@ void HMWSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_) if (acNodePtr) { for (size_t i = 0; i < acNodePtr->nChildren(); i++) { XML_Node& xmlACChild = acNodePtr->child(i); - string stemp = xmlACChild.name(); - string nodeName = lowercase(stemp); + string nodeName = xmlACChild.name(); // Process a binary salt field, or any of the other XML fields // that make up the Pitzer Database. Entries will be ignored // if any of the species in the entry isn't in the solution. - if (nodeName == "binarysaltparameters") { + if (ba::iequals(nodeName, "binarysaltparameters")) { readXMLBinarySalt(xmlACChild); - } else if (nodeName == "thetaanion") { + } else if (ba::iequals(nodeName, "thetaanion")) { readXMLThetaAnion(xmlACChild); - } else if (nodeName == "thetacation") { + } else if (ba::iequals(nodeName, "thetacation")) { readXMLThetaCation(xmlACChild); - } else if (nodeName == "psicommonanion") { + } else if (ba::iequals(nodeName, "psicommonanion")) { readXMLPsiCommonAnion(xmlACChild); - } else if (nodeName == "psicommoncation") { + } else if (ba::iequals(nodeName, "psicommoncation")) { readXMLPsiCommonCation(xmlACChild); - } else if (nodeName == "lambdaneutral") { + } else if (ba::iequals(nodeName, "lambdaneutral")) { readXMLLambdaNeutral(xmlACChild); - } else if (nodeName == "zetacation") { + } else if (ba::iequals(nodeName, "zetacation")) { readXMLZetaCation(xmlACChild); } } diff --git a/src/thermo/IdealSolidSolnPhase.cpp b/src/thermo/IdealSolidSolnPhase.cpp index 98224b7f5..fbc3f80f7 100644 --- a/src/thermo/IdealSolidSolnPhase.cpp +++ b/src/thermo/IdealSolidSolnPhase.cpp @@ -443,10 +443,9 @@ void IdealSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string& // if (phaseNode.hasChild("thermo")) { XML_Node& thNode = phaseNode.child("thermo"); - string mString = thNode.attrib("model"); - if (lowercase(mString) != "idealsolidsolution") { + if (!ba::iequals(thNode["model"], "idealsolidsolution")) { throw CanteraError("IdealSolidSolnPhase::initThermoXML", - "Unknown thermo model: " + mString); + "Unknown thermo model: " + thNode["model"]); } } else { throw CanteraError("IdealSolidSolnPhase::initThermoXML", @@ -460,17 +459,16 @@ void IdealSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string& // if (phaseNode.hasChild("standardConc")) { XML_Node& scNode = phaseNode.child("standardConc"); - string formStringa = scNode.attrib("model"); - string formString = lowercase(formStringa); - if (formString == "unity") { + string formString = scNode.attrib("model"); + if (ba::iequals(formString, "unity")) { m_formGC = 0; - } else if (formString == "molar_volume") { + } else if (ba::iequals(formString, "molar_volume")) { m_formGC = 1; - } else if (formString == "solvent_volume") { + } else if (ba::iequals(formString, "solvent_volume")) { m_formGC = 2; } else { throw CanteraError("IdealSolidSolnPhase::initThermoXML", - "Unknown standardConc model: " + formStringa); + "Unknown standardConc model: " + formString); } } else { throw CanteraError("IdealSolidSolnPhase::initThermoXML", diff --git a/src/thermo/IdealSolnGasVPSS.cpp b/src/thermo/IdealSolnGasVPSS.cpp index ceb697485..87448823b 100644 --- a/src/thermo/IdealSolnGasVPSS.cpp +++ b/src/thermo/IdealSolnGasVPSS.cpp @@ -297,17 +297,16 @@ void IdealSolnGasVPSS::initThermoXML(XML_Node& phaseNode, const std::string& id_ "standardConc node for ideal gas"); } XML_Node& scNode = phaseNode.child("standardConc"); - string formStringa = scNode.attrib("model"); - string formString = lowercase(formStringa); - if (formString == "unity") { + string formString = scNode.attrib("model"); + if (ba::iequals(formString, "unity")) { m_formGC = 0; - } else if (formString == "molar_volume") { + } else if (ba::iequals(formString, "molar_volume")) { m_formGC = 1; - } else if (formString == "solvent_volume") { + } else if (ba::iequals(formString, "solvent_volume")) { m_formGC = 2; } else { throw CanteraError("initThermoXML", - "Unknown standardConc model: " + formStringa); + "Unknown standardConc model: " + formString); } } else { if (!m_idealGas) { diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index a593f8fb3..15bba53d1 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -639,10 +639,10 @@ void IonsFromNeutralVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string XML_Node& thermoNode = phaseNode.child("thermo"); // Make sure that the thermo model is IonsFromNeutralMolecule - string formString = lowercase(thermoNode.attrib("model")); - if (formString != "ionsfromneutralmolecule") { + if (!ba::iequals(thermoNode["model"], "ionsfromneutralmolecule")) { throw CanteraError("IonsFromNeutralVPSSTP::initThermoXML", - "model name isn't IonsFromNeutralMolecule: " + formString); + "model name isn't IonsFromNeutralMolecule: " + + thermoNode["model"]); } // Find the Neutral Molecule Phase diff --git a/src/thermo/LatticePhase.cpp b/src/thermo/LatticePhase.cpp index 7c7dc4aa6..7da31bd67 100644 --- a/src/thermo/LatticePhase.cpp +++ b/src/thermo/LatticePhase.cpp @@ -284,10 +284,9 @@ void LatticePhase::initThermoXML(XML_Node& phaseNode, const std::string& id_) // if (phaseNode.hasChild("thermo")) { XML_Node& thNode = phaseNode.child("thermo"); - std::string mString = thNode.attrib("model"); - if (lowercase(mString) != "lattice") { + if (!ba::iequals(thNode["model"], "lattice")) { throw CanteraError("LatticePhase::initThermoXML", - "Unknown thermo model: " + mString); + "Unknown thermo model: " + thNode["model"]); } } else { throw CanteraError("LatticePhase::initThermoXML", diff --git a/src/thermo/MargulesVPSSTP.cpp b/src/thermo/MargulesVPSSTP.cpp index 7a65cf9c1..0e53e502a 100644 --- a/src/thermo/MargulesVPSSTP.cpp +++ b/src/thermo/MargulesVPSSTP.cpp @@ -264,20 +264,18 @@ void MargulesVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_) XML_Node& thermoNode = phaseNode.child("thermo"); // Make sure that the thermo model is Margules - string formString = lowercase(thermoNode.attrib("model")); - if (formString != "margules") { + if (!ba::iequals(thermoNode["model"], "margules")) { throw CanteraError("MargulesVPSSTP::initThermoXML", - "model name isn't Margules: " + formString); + "model name isn't Margules: " + thermoNode["model"]); } // Go get all of the coefficients and factors in the activityCoefficients // XML block if (thermoNode.hasChild("activityCoefficients")) { XML_Node& acNode = thermoNode.child("activityCoefficients"); - string mStringa = acNode.attrib("model"); - if (lowercase(mStringa) != "margules") { + if (!ba::iequals(acNode["model"], "margules")) { throw CanteraError("MargulesVPSSTP::initThermoXML", - "Unknown activity coefficient model: " + mStringa); + "Unknown activity coefficient model: " + acNode["model"]); } for (size_t i = 0; i < acNode.nChildren(); i++) { XML_Node& xmlACChild = acNode.child(i); @@ -285,7 +283,7 @@ void MargulesVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_) // Process a binary salt field, or any of the other XML fields that // make up the Pitzer Database. Entries will be ignored if any of // the species in the entry isn't in the solution. - if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") { + if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) { readXMLBinarySpecies(xmlACChild); } } @@ -578,7 +576,7 @@ void MargulesVPSSTP::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); - string nodeName = lowercase(xmlChild.name()); + string nodeName = ba::to_lower_copy(xmlChild.name()); // Process the binary species interaction parameters. // They are in subblocks labeled: diff --git a/src/thermo/MaskellSolidSolnPhase.cpp b/src/thermo/MaskellSolidSolnPhase.cpp index a287db965..09edd4b1a 100644 --- a/src/thermo/MaskellSolidSolnPhase.cpp +++ b/src/thermo/MaskellSolidSolnPhase.cpp @@ -222,10 +222,9 @@ void MaskellSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string // if (phaseNode.hasChild("thermo")) { XML_Node& thNode = phaseNode.child("thermo"); - std::string mString = thNode.attrib("model"); - if (lowercase(mString) != "maskellsolidsolnphase") { + if (!ba::iequals(thNode["model"], "maskellsolidsolnphase")) { throw CanteraError("MaskellSolidSolnPhase::initThermoXML", - "Unknown thermo model: " + mString); + "Unknown thermo model: " + thNode["model"]); } // Parse the enthalpy of mixing constant diff --git a/src/thermo/MixedSolventElectrolyte.cpp b/src/thermo/MixedSolventElectrolyte.cpp index b99355579..e2b004a38 100644 --- a/src/thermo/MixedSolventElectrolyte.cpp +++ b/src/thermo/MixedSolventElectrolyte.cpp @@ -260,20 +260,19 @@ void MixedSolventElectrolyte::initThermoXML(XML_Node& phaseNode, const std::stri "no thermo XML node"); } XML_Node& thermoNode = phaseNode.child("thermo"); - string mString = thermoNode.attrib("model"); - if (lowercase(mString) != "mixedsolventelectrolyte") { + string mString = thermoNode["model"]; + if (!ba::iequals(thermoNode["model"], "mixedsolventelectrolyte")) { throw CanteraError("MixedSolventElectrolyte::initThermoXML", - "Unknown thermo model: " + mString); + "Unknown thermo model: " + thermoNode["model"]); } // Go get all of the coefficients and factors in the activityCoefficients // XML block if (thermoNode.hasChild("activityCoefficients")) { XML_Node& acNode = thermoNode.child("activityCoefficients"); - mString = acNode.attrib("model"); - if (lowercase(mString) != "margules") { + if (!ba::iequals(acNode["model"], "margules")) { throw CanteraError("MixedSolventElectrolyte::initThermoXML", - "Unknown activity coefficient model: " + mString); + "Unknown activity coefficient model: " + acNode["model"]); } for (size_t i = 0; i < acNode.nChildren(); i++) { XML_Node& xmlACChild = acNode.child(i); @@ -281,7 +280,7 @@ void MixedSolventElectrolyte::initThermoXML(XML_Node& phaseNode, const std::stri // Process a binary salt field, or any of the other XML fields that // make up the Pitzer Database. Entries will be ignored if any of // the species in the entry isn't in the solution. - if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") { + if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) { readXMLBinarySpecies(xmlACChild); } } @@ -566,7 +565,7 @@ void MixedSolventElectrolyte::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); - string nodeName = lowercase(xmlChild.name()); + string nodeName = ba::to_lower_copy(xmlChild.name()); // Process the binary species interaction child elements if (nodeName == "excessenthalpy") { diff --git a/src/thermo/MolarityIonicVPSSTP.cpp b/src/thermo/MolarityIonicVPSSTP.cpp index 7182d22d9..d0a3e711e 100644 --- a/src/thermo/MolarityIonicVPSSTP.cpp +++ b/src/thermo/MolarityIonicVPSSTP.cpp @@ -317,11 +317,11 @@ void MolarityIonicVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& "no thermo XML node"); } XML_Node& thermoNode = phaseNode.child("thermo"); - std::string mStringa = thermoNode.attrib("model"); - std::string mString = lowercase(mStringa); - if (mString != "molarityionicvpss" && mString != "molarityionicvpsstp") { + if (!ba::iequals(thermoNode["model"], "molarityionicvpss") + && !ba::iequals(thermoNode["model"], "molarityionicvpsstp")) { throw CanteraError("MolarityIonicVPSSTP::initThermoXML", - "Unknown thermo model: " + mStringa + " - This object only knows \"MolarityIonicVPSSTP\" "); + "Unknown thermo model: " + thermoNode["model"] + + " - This object only knows \"MolarityIonicVPSSTP\" "); } // Go get all of the coefficients and factors in the activityCoefficients @@ -331,7 +331,7 @@ void MolarityIonicVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& for (size_t i = 0; i < acNode.nChildren(); i++) { XML_Node& xmlACChild = acNode.child(i); // Process a binary interaction - if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") { + if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) { readXMLBinarySpecies(xmlACChild); } } diff --git a/src/thermo/PDSS_HKFT.cpp b/src/thermo/PDSS_HKFT.cpp index 8b6cc4748..b220a35a1 100644 --- a/src/thermo/PDSS_HKFT.cpp +++ b/src/thermo/PDSS_HKFT.cpp @@ -467,7 +467,7 @@ void PDSS_HKFT::constructPDSSXML(VPStandardStateTP* tp, size_t spindex, throw CanteraError("PDSS_HKFT::constructPDSSXML", "no thermo Node for species " + speciesNode.name()); } - if (lowercase(tn->attrib("model")) != "hkft") { + if (!ba::iequals(tn->attrib("model"), "hkft")) { throw CanteraError("PDSS_HKFT::initThermoXML", "thermo model for species isn't hkft: " + speciesNode.name()); @@ -518,7 +518,7 @@ void PDSS_HKFT::constructPDSSXML(VPStandardStateTP* tp, size_t spindex, throw CanteraError("PDSS_HKFT::constructPDSSXML", "no standardState Node for species " + speciesNode.name()); } - if (lowercase(ss->attrib("model")) != "hkft") { + if (!ba::iequals(ss->attrib("model"), "hkft")) { throw CanteraError("PDSS_HKFT::initThermoXML", "standardState model for species isn't hkft: " + speciesNode.name()); diff --git a/src/thermo/PDSS_IonsFromNeutral.cpp b/src/thermo/PDSS_IonsFromNeutral.cpp index 7e95ca0ff..c06a7ed7f 100644 --- a/src/thermo/PDSS_IonsFromNeutral.cpp +++ b/src/thermo/PDSS_IonsFromNeutral.cpp @@ -113,7 +113,7 @@ void PDSS_IonsFromNeutral::constructPDSSXML(VPStandardStateTP* tp, size_t spinde throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML", "no thermo Node for species " + speciesNode.name()); } - if (lowercase(tn->attrib("model")) != "ionfromneutral") { + if (!ba::iequals(tn->attrib("model"), "ionfromneutral")) { throw CanteraError("PDSS_IonsFromNeutral::constructPDSSXML", "thermo model for species isn't IonsFromNeutral: " + speciesNode.name()); diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 44f8a0324..6513bcdcc 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -252,14 +252,14 @@ size_t Phase::speciesIndex(const std::string& nameStr) const { if (nameStr.find(':') != npos) { std::string pn; - std::string sn = lowercase(parseSpeciesName(nameStr, pn)); + std::string sn = ba::to_lower_copy(parseSpeciesName(nameStr, pn)); if (pn == "" || pn == m_name || pn == m_id) { return getValue(m_speciesIndices, sn, npos); } else { return npos; } } else { - return getValue(m_speciesIndices, lowercase(nameStr), npos); + return getValue(m_speciesIndices, ba::to_lower_copy(nameStr), npos); } } @@ -369,7 +369,7 @@ void Phase::setMoleFractionsByName(const compositionMap& xMap) vector_fp mf(m_kk, 0.0); for (const auto& sp : xMap) { try { - mf[m_speciesIndices.at(lowercase(sp.first))] = sp.second; + mf[m_speciesIndices.at(ba::to_lower_copy(sp.first))] = sp.second; } catch (std::out_of_range&) { throw CanteraError("Phase::setMoleFractionsByName", "Unknown species '{}'", sp.first); @@ -413,7 +413,7 @@ void Phase::setMassFractionsByName(const compositionMap& yMap) vector_fp mf(m_kk, 0.0); for (const auto& sp : yMap) { try { - mf[m_speciesIndices.at(lowercase(sp.first))] = sp.second; + mf[m_speciesIndices.at(ba::to_lower_copy(sp.first))] = sp.second; } catch (std::out_of_range&) { throw CanteraError("Phase::setMassFractionsByName", "Unknown species '{}'", sp.first); @@ -758,7 +758,7 @@ size_t Phase::addElement(const std::string& symbol, doublereal weight, } bool Phase::addSpecies(shared_ptr spec) { - if (m_species.find(lowercase(spec->name)) != m_species.end()) { + if (m_species.find(ba::to_lower_copy(spec->name)) != m_species.end()) { throw CanteraError("Phase::addSpecies", "Phase '{}' already contains a species named '{}'.", m_name, spec->name); @@ -788,8 +788,8 @@ bool Phase::addSpecies(shared_ptr spec) { } m_speciesNames.push_back(spec->name); - m_species[lowercase(spec->name)] = spec; - m_speciesIndices[lowercase(spec->name)] = m_kk; + m_species[ba::to_lower_copy(spec->name)] = spec; + m_speciesIndices[ba::to_lower_copy(spec->name)] = m_kk; m_speciesCharge.push_back(spec->charge); m_speciesSize.push_back(spec->size); size_t ne = nElements(); @@ -854,19 +854,19 @@ void Phase::modifySpecies(size_t k, shared_ptr spec) "New species name '{}' does not match existing name '{}'", spec->name, speciesName(k)); } - const shared_ptr& old = m_species[lowercase(spec->name)]; + const shared_ptr& old = m_species[ba::to_lower_copy(spec->name)]; if (spec->composition != old->composition) { throw CanteraError("Phase::modifySpecies", "New composition for '{}' does not match existing composition", spec->name); } - m_species[lowercase(spec->name)] = spec; + m_species[ba::to_lower_copy(spec->name)] = spec; invalidateCache(); } shared_ptr Phase::species(const std::string& name) const { - return m_species.at(lowercase(name)); + return m_species.at(ba::to_lower_copy(name)); } shared_ptr Phase::species(size_t k) const diff --git a/src/thermo/PhaseCombo_Interaction.cpp b/src/thermo/PhaseCombo_Interaction.cpp index 430f7ff83..c342c9633 100644 --- a/src/thermo/PhaseCombo_Interaction.cpp +++ b/src/thermo/PhaseCombo_Interaction.cpp @@ -270,20 +270,18 @@ void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, const std::strin "no thermo XML node"); } XML_Node& thermoNode = phaseNode.child("thermo"); - string formString = lowercase(thermoNode.attrib("model")); - if (formString != "phasecombo_interaction") { + if (!ba::iequals(thermoNode["model"], "phasecombo_interaction")) { throw CanteraError("PhaseCombo_Interaction::initThermoXML", - "model name isn't PhaseCombo_Interaction: " + formString); + "model name isn't PhaseCombo_Interaction: " + thermoNode["model"]); } // Go get all of the coefficients and factors in the activityCoefficients // XML block if (thermoNode.hasChild("activityCoefficients")) { XML_Node& acNode = thermoNode.child("activityCoefficients"); - string mString = acNode.attrib("model"); - if (lowercase(mString) != "margules") { + if (!ba::iequals(acNode["model"], "margules")) { throw CanteraError("PhaseCombo_Interaction::initThermoXML", - "Unknown activity coefficient model: " + mString); + "Unknown activity coefficient model: " + acNode["model"]); } for (size_t i = 0; i < acNode.nChildren(); i++) { XML_Node& xmlACChild = acNode.child(i); @@ -291,7 +289,7 @@ void PhaseCombo_Interaction::initThermoXML(XML_Node& phaseNode, const std::strin // Process a binary salt field, or any of the other XML fields that // make up the Pitzer Database. Entries will be ignored if any of // the species in the entry isn't in the solution. - if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") { + if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) { readXMLBinarySpecies(xmlACChild); } } @@ -611,7 +609,7 @@ void PhaseCombo_Interaction::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); - string nodeName = lowercase(xmlChild.name()); + string nodeName = ba::to_lower_copy(xmlChild.name()); // Process the binary species interaction child elements if (nodeName == "excessenthalpy") { diff --git a/src/thermo/RedlichKisterVPSSTP.cpp b/src/thermo/RedlichKisterVPSSTP.cpp index 2b3fe6b58..7f8f81a97 100644 --- a/src/thermo/RedlichKisterVPSSTP.cpp +++ b/src/thermo/RedlichKisterVPSSTP.cpp @@ -236,20 +236,19 @@ void RedlichKisterVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& "no thermo XML node"); } XML_Node& thermoNode = phaseNode.child("thermo"); - std::string mString = thermoNode.attrib("model"); - if (lowercase(mString) != "redlich-kister") { + if (!ba::iequals(thermoNode["model"], "redlich-kister")) { throw CanteraError("RedlichKisterVPSSTP::initThermoXML", - "Unknown thermo model: " + mString + " - This object only knows \"Redlich-Kister\" "); + "Unknown thermo model: " + thermoNode["model"] + + " - This object only knows \"Redlich-Kister\" "); } // Go get all of the coefficients and factors in the activityCoefficients // XML block if (thermoNode.hasChild("activityCoefficients")) { XML_Node& acNode = thermoNode.child("activityCoefficients"); - mString = acNode.attrib("model"); - if (lowercase(mString) != "redlich-kister") { + if (!ba::iequals(acNode["model"], "redlich-kister")) { throw CanteraError("RedlichKisterVPSSTP::initThermoXML", - "Unknown activity coefficient model: " + mString); + "Unknown activity coefficient model: " + acNode["model"]); } for (size_t i = 0; i < acNode.nChildren(); i++) { XML_Node& xmlACChild = acNode.child(i); @@ -257,7 +256,7 @@ void RedlichKisterVPSSTP::initThermoXML(XML_Node& phaseNode, const std::string& // Process a binary salt field, or any of the other XML fields that // make up the Pitzer Database. Entries will be ignored if any of // the species in the entry isn't in the solution. - if (lowercase(xmlACChild.name()) == "binaryneutralspeciesparameters") { + if (ba::iequals(xmlACChild.name(), "binaryneutralspeciesparameters")) { readXMLBinarySpecies(xmlACChild); } } @@ -587,7 +586,7 @@ void RedlichKisterVPSSTP::readXMLBinarySpecies(XML_Node& xmLBinarySpecies) for (size_t iChild = 0; iChild < xmLBinarySpecies.nChildren(); iChild++) { XML_Node& xmlChild = xmLBinarySpecies.child(iChild); - string nodeName = lowercase(xmlChild.name()); + string nodeName = ba::to_lower_copy(xmlChild.name()); // Process the binary species interaction child elements if (nodeName == "excessenthalpy") { diff --git a/src/thermo/RedlichKwongMFTP.cpp b/src/thermo/RedlichKwongMFTP.cpp index 5a491d704..67d850778 100644 --- a/src/thermo/RedlichKwongMFTP.cpp +++ b/src/thermo/RedlichKwongMFTP.cpp @@ -594,9 +594,7 @@ void RedlichKwongMFTP::initThermoXML(XML_Node& phaseNode, const std::string& id) // parameters for (size_t i = 0; i < nC; i++) { XML_Node& xmlACChild = acNodePtr->child(i); - string stemp = xmlACChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "purefluidparameters") { + if (ba::iequals(xmlACChild.name(), "purefluidparameters")) { readXMLPureFluid(xmlACChild); } } @@ -608,9 +606,7 @@ void RedlichKwongMFTP::initThermoXML(XML_Node& phaseNode, const std::string& id) // parameters for (size_t i = 0; i < nC; i++) { XML_Node& xmlACChild = acNodePtr->child(i); - string stemp = xmlACChild.name(); - string nodeName = lowercase(stemp); - if (nodeName == "crossfluidparameters") { + if (ba::iequals(xmlACChild.name(), "crossfluidparameters")) { readXMLCrossFluid(xmlACChild); } } @@ -652,11 +648,10 @@ void RedlichKwongMFTP::readXMLPureFluid(XML_Node& pureFluidParam) size_t num = pureFluidParam.nChildren(); for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = pureFluidParam.child(iChild); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); + string nodeName = ba::to_lower_copy(xmlChild.name()); if (nodeName == "a_coeff") { - string iModel = lowercase(xmlChild.attrib("model")); + string iModel = ba::to_lower_copy(xmlChild.attrib("model")); if (iModel == "constant") { nParamsExpected = 1; } else if (iModel == "linear_a") { @@ -741,11 +736,10 @@ void RedlichKwongMFTP::readXMLCrossFluid(XML_Node& CrossFluidParam) size_t num = CrossFluidParam.nChildren(); for (size_t iChild = 0; iChild < num; iChild++) { XML_Node& xmlChild = CrossFluidParam.child(iChild); - string stemp = xmlChild.name(); - string nodeName = lowercase(stemp); + string nodeName = ba::to_lower_copy(xmlChild.name()); if (nodeName == "a_coeff") { - string iModel = lowercase(xmlChild.attrib("model")); + string iModel = ba::to_lower_copy(xmlChild.attrib("model")); if (iModel == "constant") { nParamsExpected = 1; } else if (iModel == "linear_a") { diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 1973b16d2..3674a8c98 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -57,7 +57,7 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const std::string& stype, double tlow, double thigh, double pref, const double* coeffs) { int itype = -1; - std::string type = lowercase(stype); + std::string type = ba::to_lower_copy(stype); if (type == "nasa2" || type == "nasa") { itype = NASA2; // two-region 7-coefficient NASA polynomials } else if (type == "const_cp" || type == "simple") { @@ -392,10 +392,10 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo) } } - std::string thermoType = lowercase(tp[0]->name()); + std::string thermoType = ba::to_lower_copy(tp[0]->name()); for (size_t i = 1; i < tp.size(); i++) { - if (lowercase(tp[i]->name()) != thermoType) { + if (!ba::iequals(tp[i]->name(), thermoType)) { throw CanteraError("newSpeciesThermoInterpType", "Encountered unsupported mixed species thermo parameterizations"); } @@ -408,7 +408,7 @@ SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo) "Too many regions in thermo parameterization."); } - std::string model = lowercase(thermo["model"]); + std::string model = ba::to_lower_copy(thermo["model"]); if (model == "mineraleq3") { if (thermoType != "mineq3") { throw CanteraError("newSpeciesThermoInterpType", diff --git a/src/thermo/VPSSMgrFactory.cpp b/src/thermo/VPSSMgrFactory.cpp index d661e3e57..61d958fd9 100644 --- a/src/thermo/VPSSMgrFactory.cpp +++ b/src/thermo/VPSSMgrFactory.cpp @@ -212,7 +212,7 @@ VPSSMgrFactory::VPSSMgr_StringConversion(const std::string& ssModel) const { warn_deprecated("VPSSMgrFactory::VPSSMgr_StringConversion", "To be removed after Cantera 2.3."); - std::string lssModel = lowercase(ssModel); + std::string lssModel = ba::to_lower_copy(ssModel); VPSSMgr_enumType type; if (lssModel == "idealgas") { type = cVPSSMGR_IDEALGAS; @@ -249,7 +249,7 @@ VPSSMgr* VPSSMgrFactory::newVPSSMgr(VPStandardStateTP* vp_ptr, } if (thermoNode.hasChild("variablePressureStandardStateManager")) { const XML_Node& vpssNode = thermoNode.child("variablePressureStandardStateManager"); - vpssManager = lowercase(vpssNode["model"]); + vpssManager = ba::to_lower_copy(vpssNode["model"]); } } diff --git a/src/thermo/VPSSMgr_Water_HKFT.cpp b/src/thermo/VPSSMgr_Water_HKFT.cpp index 5a4019999..57d325e42 100644 --- a/src/thermo/VPSSMgr_Water_HKFT.cpp +++ b/src/thermo/VPSSMgr_Water_HKFT.cpp @@ -204,8 +204,7 @@ void VPSSMgr_Water_HKFT::initThermoXML(XML_Node& phaseNode, throw CanteraError("VPSSMgr_Water_HKFT::initThermoXML", "No standardState Node for species " + name); } - std::string model = lowercase(ss->attrib("model")); - if (model != "hkft") { + if (!ba::iequals(ss->attrib("model"), "hkft")) { throw CanteraError("VPSSMgr_Water_HKFT::initThermoXML", "Standard state model for a solute species isn't " "the HKFT standard state model: " + name); diff --git a/src/tpx/utils.cpp b/src/tpx/utils.cpp index 9853fa0d5..400926ca6 100644 --- a/src/tpx/utils.cpp +++ b/src/tpx/utils.cpp @@ -20,7 +20,7 @@ namespace tpx { Substance* GetSubstanceByName(std::string name) { - std::string lcname = Cantera::lowercase(name); + std::string lcname = boost::algorithm::to_lower_copy(name); if (lcname == "water") { return new water; } else if (lcname == "nitrogen") { diff --git a/src/transport/LiquidTranInteraction.cpp b/src/transport/LiquidTranInteraction.cpp index 7585eafe1..4fa0c9dea 100644 --- a/src/transport/LiquidTranInteraction.cpp +++ b/src/transport/LiquidTranInteraction.cpp @@ -62,8 +62,8 @@ void LiquidTranInteraction::init(const XML_Node& compModelNode, for (size_t iChild = 0; iChild < compModelNode.nChildren(); iChild++) { XML_Node& xmlChild = compModelNode.child(iChild); - std::string nodeName = lowercase(xmlChild.name()); - if (nodeName != "interaction") { + std::string nodeName = xmlChild.name(); + if (!ba::iequals(nodeName, "interaction")) { throw CanteraError("TransportFactory::getLiquidInteractionsTransportData", "expected element and got <" + nodeName + ">"); } diff --git a/src/transport/TransportFactory.cpp b/src/transport/TransportFactory.cpp index 488862561..2634f2ac9 100644 --- a/src/transport/TransportFactory.cpp +++ b/src/transport/TransportFactory.cpp @@ -115,7 +115,7 @@ std::string TransportFactory::modelName(int model) LTPspecies* TransportFactory::newLTP(const XML_Node& trNode, const std::string& name, TransportPropertyType tp_ind, thermo_t* thermo) { - std::string model = lowercase(trNode["model"]); + std::string model = ba::to_lower_copy(trNode["model"]); switch (m_LTRmodelMap[model]) { case LTP_TD_CONSTANT: return new LTPspecies_Const(trNode, name, tp_ind, thermo);