Cantera  2.3.0
IdealGasMix.h
Go to the documentation of this file.
1 //! @file IdealGasMix.h
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CXX_IDEALGASMIX
7 #define CXX_IDEALGASMIX
8 
9 #include "thermo/IdealGasPhase.h"
10 #include "kinetics/GasKinetics.h"
12 #include "base/stringUtils.h"
13 
14 namespace Cantera
15 {
16 
17 //! Convenience class which inherits from both IdealGasPhase and GasKinetics
18 class IdealGasMix :
19  public IdealGasPhase,
20  public GasKinetics
21 {
22 public:
23  IdealGasMix() : m_ok(false), m_r(0) {}
24 
25  IdealGasMix(const std::string& infile, std::string id_="") :
26  m_ok(false), m_r(0)
27  {
28  m_r = get_XML_File(infile);
29  m_id = id_;
30  if (id_ == "-") {
31  id_ = "";
32  }
33  m_ok = buildSolutionFromXML(*m_r,
34  m_id, "phase", this, this);
35  if (!m_ok) throw CanteraError("IdealGasMix",
36  "Cantera::buildSolutionFromXML returned false");
37  }
38 
39  IdealGasMix(XML_Node& root,
40  std::string id_) : m_ok(false), m_r(&root), m_id(id_) {
41  m_ok = buildSolutionFromXML(root, id_, "phase", this, this);
42  }
43 
44  IdealGasMix(const IdealGasMix& other) : m_ok(false),
45  m_r(other.m_r),
46  m_id(other.m_id) {
47  m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
48  }
49 
50  bool operator!() {
51  return !m_ok;
52  }
53  bool ready() const {
54  return m_ok;
55  }
56  friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
57  std::string r = mix.report(true);
58  s << r;
59  return s;
60  }
61 
62 protected:
63  bool m_ok;
64  XML_Node* m_r;
65  std::string m_id;
66 };
67 }
68 
69 #endif
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
Definition: global.cpp:96
bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
Definition: IdealGasMix.h:53
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
Convenience class which inherits from both IdealGasPhase and GasKinetics.
Definition: IdealGasMix.h:18
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:26
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
bool buildSolutionFromXML(XML_Node &root, const std::string &id, const std::string &nm, ThermoPhase *th, Kinetics *kin)
Build a single-phase ThermoPhase object with associated kinetics mechanism.
Definitions of global routines for the importing of data from XML files (see Input File Handling)...
virtual std::string report(bool show_thermo=true, doublereal threshold=-1e-14) const
returns a summary of the state of the phase as a string
Contains declarations for string manipulation functions within Cantera.
Namespace for the Cantera kernel.
Definition: application.cpp:29