diff --git a/include/cantera/transport/TransportData.h b/include/cantera/transport/TransportData.h index ea117543f..2ce7d244a 100644 --- a/include/cantera/transport/TransportData.h +++ b/include/cantera/transport/TransportData.h @@ -13,6 +13,7 @@ namespace Cantera class Species; class XML_Node; +class AnyMap; //! Base class for transport data for a single species class TransportData @@ -87,6 +88,9 @@ public: //! Create a new TransportData object from a 'transport' XML_Node. shared_ptr newTransportData(const XML_Node& transport_node); +//! Create a new TransportData object from an AnyMap specification +unique_ptr newTransportData(const AnyMap& node); + } #endif diff --git a/src/thermo/Species.cpp b/src/thermo/Species.cpp index cb7487ca0..45479ca63 100644 --- a/src/thermo/Species.cpp +++ b/src/thermo/Species.cpp @@ -98,7 +98,23 @@ unique_ptr newSpecies(const AnyMap& node) s->charge = -s->composition["E"]; } - s->input = node; + if (node.hasKey("transport")) { + s->transport = newTransportData(node["transport"].as()); + s->transport->validate(*s); + } + + // Store input parameters in the "input" map, unless they are stored in a + // child object + const static std::set known_keys{ + "transport" + }; + s->input.applyUnits(node.units()); + for (const auto& item : node) { + if (known_keys.count(item.first) == 0) { + s->input[item.first] = item.second; + } + } + return s; } diff --git a/src/transport/TransportData.cpp b/src/transport/TransportData.cpp index bb7a12abb..d3a9a8c7b 100644 --- a/src/transport/TransportData.cpp +++ b/src/transport/TransportData.cpp @@ -154,6 +154,22 @@ void setupGasTransportData(GasTransportData& tr, const XML_Node& tr_node) rot, acentric, dispersion, quad); } +void setupGasTransportData(GasTransportData& tr, const AnyMap& node) +{ + std::string geometry = node["geometry"].asString(); + double welldepth = node["well-depth"].asDouble(); + double diameter = node["diameter"].asDouble(); + double dipole = node.getDouble("dipole", 0.0); + double polar = node.getDouble("polarizability", 0.0); + double rot = node.getDouble("rotational-relaxation", 0.0); + double acentric = node.getDouble("acentric-factor", 0.0); + double dispersion = node.getDouble("dispersion-coefficient", 0.0); + double quad = node.getDouble("quadrupole-polarizability", 0.0); + + tr.setCustomaryUnits(geometry, diameter, welldepth, dipole, polar, + rot, acentric, dispersion, quad); +} + shared_ptr newTransportData(const XML_Node& transport_node) { std::string model = transport_node["model"]; @@ -167,4 +183,16 @@ shared_ptr newTransportData(const XML_Node& transport_node) } } +unique_ptr newTransportData(const AnyMap& node) +{ + if (node.getString("model", "") == "gas") { + unique_ptr tr(new GasTransportData()); + setupGasTransportData(*tr, node); + return unique_ptr(move(tr)); + } else { + // Transport model not handled here + return unique_ptr(new TransportData()); + } +} + }