43#include <boost/algorithm/string.hpp>
75 reg(
"HMW-electrolyte", []() {
return new HMWSoln(); });
93 addAlias(
"ions-from-neutral-molecule",
"IonsFromNeutralMolecule");
94 addAlias(
"ions-from-neutral-molecule",
"IonsFromNeutral");
101 addAlias(
"Maskell-solid-solution",
"MaskellSolidSolnPhase");
102 addAlias(
"Maskell-solid-solution",
"MaskellSolidsoln");
103 reg(
"liquid-water-IAPWS95", []() {
return new WaterSSTP(); });
130 "To be removed after Cantera 3.0; superseded by newThermoModel.");
137 "To be removed after Cantera 3.0; superseded by newThermo.");
149 if (!phaseNode.
hasKey(
"kinetics") && phaseNode.
hasKey(
"reactions")) {
151 "Phase entry includes a 'reactions' field but does not "
152 "specify a kinetics model.");
154 string model = phaseNode[
"thermo"].asString();
160shared_ptr<ThermoPhase>
newThermo(
const string& infile,
const string&
id)
162 size_t dot = infile.find_last_of(
".");
166 "Changed in Cantera 3.0. Replaced by newThermoModel.\n");
175 if (extension ==
"cti" || extension ==
"xml") {
177 "The CTI and XML formats are no longer supported.");
181 AnyMap& phase = root[
"phases"].getMapWhere(
"name", id_);
188 "To be removed after Cantera 3.0; superseded by\n"
189 "newThermo(const AnyMap&, const AnyMap&).");
190 if (!phaseNode.
hasKey(
"kinetics") && phaseNode.
hasKey(
"reactions")) {
192 "Phase entry includes a 'reactions' field but does not "
193 "specify a kinetics model.");
195 unique_ptr<ThermoPhase> t(
newThermoPhase(phaseNode[
"thermo"].asString()));
203 "To be removed after Cantera 3.0; superseded by\n"
204 "newThermo(const string&, const string&).");
205 size_t dot = infile.find_last_of(
".");
215 if (extension ==
"cti" || extension ==
"xml") {
217 "The CTI and XML formats are no longer supported.");
221 AnyMap& phase = root[
"phases"].getMapWhere(
"name", id_);
222 string model = phase[
"thermo"].asString();
228void addDefaultElements(ThermoPhase& thermo,
const vector<string>& element_names) {
229 for (
const auto& symbol : element_names) {
230 thermo.addElement(symbol);
234void addElements(ThermoPhase& thermo,
const vector<string>& element_names,
235 const AnyValue& elements,
bool allow_default)
237 const auto& local_elements = elements.asMap(
"symbol");
238 for (
const auto& symbol : element_names) {
239 if (local_elements.count(symbol)) {
240 auto& element = *local_elements.at(symbol);
241 double weight = element[
"atomic-weight"].asDouble();
242 long int number = element.getInt(
"atomic-number", 0);
244 thermo.addElement(symbol, weight, number, e298);
245 }
else if (allow_default) {
246 thermo.addElement(symbol);
248 throw InputFileError(
"addElements", elements,
249 "Element '{}' not found", symbol);
254void addSpecies(ThermoPhase& thermo,
const AnyValue& names,
const AnyValue& species)
256 if (names.is<vector<string>>()) {
258 const auto& species_nodes = species.asMap(
"name");
259 for (
const auto& name : names.asVector<string>()) {
260 if (species_nodes.count(name)) {
261 thermo.addSpecies(
newSpecies(*species_nodes.at(name)));
263 throw InputFileError(
"addSpecies", names, species,
264 "Could not find a species named '{}'.", name);
267 }
else if (names ==
"all") {
269 for (
const auto& item : species.asVector<AnyMap>()) {
273 throw InputFileError(
"addSpecies", names,
274 "Could not parse species declaration of type '{}'", names.type_str());
280 thermo.
setName(phaseNode[
"name"].asString());
282 if (phaseNode.
hasKey(
"deprecated")) {
283 string msg = phaseNode[
"deprecated"].asString();
284 string filename = phaseNode.
getString(
"__file__",
285 rootNode.
getString(
"__file__",
"unknown file"));
286 string method = fmt::format(
"{}/{}", filename, phaseNode[
"name"].asString());
291 if (phaseNode.
hasKey(
"elements")) {
292 if (phaseNode.
getBool(
"skip-undeclared-elements",
false)) {
298 if (phaseNode[
"elements"].is<vector<string>>()) {
300 if (rootNode.
hasKey(
"elements")) {
301 addElements(thermo, phaseNode[
"elements"].asVector<string>(),
302 rootNode[
"elements"],
true);
304 addDefaultElements(thermo, phaseNode[
"elements"].asVector<string>());
306 }
else if (phaseNode[
"elements"].is<vector<AnyMap>>()) {
310 for (
const auto& elemNode : phaseNode[
"elements"].asVector<
AnyMap>()) {
311 const string& source = elemNode.begin()->first;
312 const auto& names = elemNode.begin()->second.asVector<
string>();
313 const auto& slash = boost::ifind_last(source,
"/");
315 string fileName(source.begin(), slash.begin());
316 string node(slash.end(), source.end());
319 addElements(thermo, names, elements.
at(node),
false);
320 }
else if (rootNode.
hasKey(source)) {
321 addElements(thermo, names, rootNode.
at(source),
false);
322 }
else if (source ==
"default") {
323 addDefaultElements(thermo, names);
326 "Could not find elements section named '{}'", source);
331 "Could not parse elements declaration of type '{}'",
332 phaseNode[
"elements"].type_str());
341 if (phaseNode.
hasKey(
"species")) {
342 if (phaseNode[
"species"].is<vector<string>>()) {
345 addSpecies(thermo, phaseNode[
"species"], rootNode[
"species"]);
346 }
else if (phaseNode[
"species"].is<string>()) {
349 addSpecies(thermo, phaseNode[
"species"], rootNode[
"species"]);
350 }
else if (phaseNode[
"species"].is<vector<AnyMap>>()) {
354 for (
const auto& speciesNode : phaseNode[
"species"].asVector<
AnyMap>()) {
355 const string& source = speciesNode.begin()->first;
356 const auto& names = speciesNode.begin()->second;
357 const auto& slash = boost::ifind_last(source,
"/");
360 string fileName(source.begin(), slash.begin());
361 string node(slash.end(), source.end());
364 addSpecies(thermo, names, species[node]);
365 }
else if (rootNode.
hasKey(source)) {
367 addSpecies(thermo, names, rootNode[source]);
370 "Could not find species section named '{}'", source);
375 "Could not parse species declaration of type '{}'",
376 phaseNode[
"species"].type_str());
378 }
else if (rootNode.
hasKey(
"species")) {
380 addSpecies(thermo,
AnyValue(
"all"), rootNode[
"species"]);
385 for (
size_t k = 0; k < thermo.
nSpecies(); k++) {
386 unique_ptr<PDSS> pdss;
387 if (thermo.
species(k)->input.hasKey(
"equation-of-state")) {
389 auto& eos = thermo.
species(k)->input[
"equation-of-state"];
391 for (
auto& node : eos.asVector<
AnyMap>()) {
392 string model = node[
"model"].asString();
393 if (PDSSFactory::factory()->exists(model)) {
394 pdss.reset(newPDSS(model));
395 pdss->setParameters(node);
402 "Could not find an equation-of-state specification "
403 "which defines a known PDSS model.");
406 pdss.reset(newPDSS(
"ideal-gas"));
408 vpssThermo->installPDSS(k, std::move(pdss));
415 if (phaseNode.
hasKey(
"state")) {
416 auto node = phaseNode[
"state"].as<
AnyMap>();
Header file for an binary solution model with tabulated standard state thermodynamic data (see Thermo...
Header for a thermodynamics model of a coverage-dependent surface phase derived from SurfPhase,...
Headers for the DebyeHuckel ThermoPhase object, which models dilute electrolyte solutions (see Thermo...
Declarations for the EdgePhase ThermoPhase object, which models the interface between two surfaces (s...
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298....
Headers for the HMWSoln ThermoPhase object, which models concentrated electrolyte solutions (see Ther...
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
Definition file for a derived class of ThermoPhase that assumes an ideal solution approximation and h...
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
Header for a simple thermodynamics model of a bulk phase derived from ThermoPhase,...
Header for a simple thermodynamics model of a bulk solid phase derived from ThermoPhase,...
(see Thermodynamic Properties and class MargulesVPSSTP).
Header file for a solid solution model following Maskell, Shaw, and Tye.
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
Header file for class PlasmaPhase.
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
(see Thermodynamic Properties and class RedlichKisterVPSSTP).
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
Declaration for class Cantera::Species.
Header file for the StoichSubstance class, which represents a fixed-composition incompressible substa...
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
A map of string keys to values whose type can vary at runtime.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
bool getBool(const string &key, bool default_) const
If key exists, return it as a bool, otherwise return default_.
const string & getString(const string &key, const string &default_) const
If key exists, return it as a string, otherwise return default_.
static AnyMap fromYamlFile(const string &name, const string &parent_name="")
Create an AnyMap from a YAML file.
const AnyValue & at(const string &key) const
Get the value of the item stored in key.
A wrapper for a variable whose type is determined at runtime.
Overloads the virtual methods of class IdealSolidSolnPhase to implement tabulated standard state ther...
Base class for exceptions thrown by Cantera classes.
A thermodynamic model for a coverage-dependent surface phase, applying surface species lateral intera...
Class DebyeHuckel represents a dilute liquid electrolyte phase which obeys the Debye Huckel formulati...
A thermodynamic phase representing a one dimensional edge between two surfaces.
ThermoPhase * create(const string &name, Args... args)
Create an object using the object construction function corresponding to "name" and the provided cons...
void reg(const string &name, function< ThermoPhase *(Args...)> f)
Register a new object construction function.
void addAlias(const string &original, const string &alias)
Add an alias for an existing registered type.
void addDeprecatedAlias(const string &original, const string &alias)
Add a deprecated alias for an existing registered type.
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
Class IdealSolidSolnPhase represents a condensed phase ideal solution compound.
An ideal solution approximation of a phase.
The IonsFromNeutralVPSSTP is a derived class of ThermoPhase that handles the specification of the che...
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms.
A phase that is comprised of a fixed additive combination of other lattice phases.
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
Class MaskellSolidSolnPhase represents a condensed phase non-ideal solution with 2 species following ...
Implementation of a multi-species Peng-Robinson equation of state.
size_t nSpecies() const
Returns the number of species in the phase.
void ignoreUndefinedElements()
Set behavior when adding a species containing undefined elements to just skip the species.
void addUndefinedElements()
Set behavior when adding a species containing undefined elements to add those elements to the phase.
shared_ptr< Species > species(const string &name) const
Return the Species object for the named species.
void throwUndefinedElements()
Set the behavior when adding a species containing undefined elements to throw an exception.
void setName(const string &nm)
Sets the string name for the phase.
Base class for a phase with plasma properties.
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
Implementation of a multi-species Redlich-Kwong equation of state.
Class StoichSubstance represents a stoichiometric (fixed composition) incompressible substance.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Factory class for thermodynamic property managers.
void deleteFactory() override
delete the static instance of this factory
ThermoFactory()
Private constructors prevents usage.
static ThermoFactory * factory()
Static function that creates a static instance of the factory.
static std::mutex thermo_mutex
Decl for locking mutex for thermo factory singleton.
ThermoPhase * newThermoPhase(const string &model)
Create a new thermodynamic property manager.
static ThermoFactory * s_factory
static member of a single instance
Base class for a phase with thermodynamic properties.
virtual void setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
virtual void setState(const AnyMap &state)
Set the state using an AnyMap containing any combination of properties supported by the thermodynamic...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
string toLowerCopy(const string &input)
Convert to lower case.
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
const double OneAtm
One atmosphere [Pa].
shared_ptr< ThermoPhase > newThermo(const AnyMap &phaseNode, const AnyMap &rootNode)
Create a new ThermoPhase object and initialize it.
void setupPhase(ThermoPhase &thermo, const AnyMap &phaseNode, const AnyMap &rootNode)
Initialize a ThermoPhase object.
unique_ptr< ThermoPhase > newPhase(const AnyMap &phaseNode, const AnyMap &rootNode)
Create a new ThermoPhase object and initialize it.
shared_ptr< ThermoPhase > newThermoModel(const string &model)
Create a new ThermoPhase instance.
ThermoPhase * newThermoPhase(const string &model)
Create a new ThermoPhase instance.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
unique_ptr< Species > newSpecies(const AnyMap &node)
Create a new Species object from an AnyMap specification.
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
Contains declarations for string manipulation functions within Cantera.