[Input] Read species Transport data from YAML / AnyMap
This commit is contained in:
parent
96124f8455
commit
6d6f34bee3
3 changed files with 49 additions and 1 deletions
|
|
@ -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<TransportData> newTransportData(const XML_Node& transport_node);
|
||||
|
||||
//! Create a new TransportData object from an AnyMap specification
|
||||
unique_ptr<TransportData> newTransportData(const AnyMap& node);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -98,7 +98,23 @@ unique_ptr<Species> newSpecies(const AnyMap& node)
|
|||
s->charge = -s->composition["E"];
|
||||
}
|
||||
|
||||
s->input = node;
|
||||
if (node.hasKey("transport")) {
|
||||
s->transport = newTransportData(node["transport"].as<AnyMap>());
|
||||
s->transport->validate(*s);
|
||||
}
|
||||
|
||||
// Store input parameters in the "input" map, unless they are stored in a
|
||||
// child object
|
||||
const static std::set<std::string> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TransportData> newTransportData(const XML_Node& transport_node)
|
||||
{
|
||||
std::string model = transport_node["model"];
|
||||
|
|
@ -167,4 +183,16 @@ shared_ptr<TransportData> newTransportData(const XML_Node& transport_node)
|
|||
}
|
||||
}
|
||||
|
||||
unique_ptr<TransportData> newTransportData(const AnyMap& node)
|
||||
{
|
||||
if (node.getString("model", "") == "gas") {
|
||||
unique_ptr<GasTransportData> tr(new GasTransportData());
|
||||
setupGasTransportData(*tr, node);
|
||||
return unique_ptr<TransportData>(move(tr));
|
||||
} else {
|
||||
// Transport model not handled here
|
||||
return unique_ptr<TransportData>(new TransportData());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue