Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IdealGasMix.h
Go to the documentation of this file.
1 //! @file IdealGasMix.h
2 #ifndef CXX_IDEALGASMIX
3 #define CXX_IDEALGASMIX
4 
5 #include "thermo/IdealGasPhase.h"
6 #include "kinetics/GasKinetics.h"
8 #include "base/stringUtils.h"
9 
10 namespace Cantera
11 {
12 
13 //! Convenience class which inherits from both IdealGasPhase and GasKinetics
14 class IdealGasMix :
15  public IdealGasPhase,
16  public GasKinetics
17 {
18 public:
19 
20  IdealGasMix() : m_ok(false), m_r(0) {}
21 
22  IdealGasMix(const std::string& infile, std::string id_="") :
23  m_ok(false), m_r(0) {
24 
25  m_r = get_XML_File(infile);
26  m_id = id_;
27  if (id_ == "-") {
28  id_ = "";
29  }
30  m_ok = buildSolutionFromXML(*m_r,
31  m_id, "phase", this, this);
32  if (!m_ok) throw CanteraError("IdealGasMix",
33  "Cantera::buildSolutionFromXML returned false");
34  }
35 
36 
37  IdealGasMix(XML_Node& root,
38  std::string id_) : m_ok(false), m_r(&root), m_id(id_) {
39  m_ok = buildSolutionFromXML(root, id_, "phase", this, this);
40  }
41 
42  IdealGasMix(const IdealGasMix& other) : m_ok(false),
43  m_r(other.m_r),
44  m_id(other.m_id) {
45  m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
46  }
47 
48  bool operator!() {
49  return !m_ok;
50  }
51  bool ready() const {
52  return m_ok;
53  }
54  friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
55  std::string r = mix.report(true);
56  s << r;
57  return s;
58  }
59 
60 
61 protected:
62  bool m_ok;
63  XML_Node* m_r;
64  std::string m_id;
65 
66 private:
67 };
68 }
69 
70 
71 #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:105
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:100
Convenience class which inherits from both IdealGasPhase and GasKinetics.
Definition: IdealGasMix.h:14
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:26
bool ready() const
Returns true if the kinetics manager has been properly initialized and finalized. ...
Definition: IdealGasMix.h:51
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:99
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.