Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PureFluid.h
Go to the documentation of this file.
1 //! @file PureFluid.h
2 #ifndef CXX_PUREFLUID
3 #define CXX_PUREFLUID
4 
6 #include "kinetics.h"
7 
8 namespace Cantera
9 {
10 
11 //! Wrapper for PureFluidPhase with constructor from file
12 class PureFluid : public PureFluidPhase
13 {
14 public:
15  PureFluid() : m_ok(false), m_r(0) {}
16 
17  PureFluid(const std::string& infile, std::string id="") : m_ok(false), m_r(0) {
18  m_r = get_XML_File(infile);
19  if (id == "-") {
20  id = "";
21  }
22  m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
23  if (!m_ok) throw CanteraError("PureFluid",
24  "buildSolutionFromXML returned false");
25  }
26 
27  PureFluid(XML_Node& root, const std::string& id) : m_ok(false), m_r(0) {
28  m_ok = buildSolutionFromXML(root, id, "phase", this, 0);
29  }
30 
31  bool operator!() {
32  return !m_ok;
33  }
34 
35  bool ready() const {
36  return m_ok;
37  }
38 
39  friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) {
40  std::string r = mix.report(true);
41  s << r;
42  return s;
43  }
44 
45 protected:
46  bool m_ok;
47  XML_Node* m_r;
48 };
49 
50 class Water : public PureFluid
51 {
52 public:
53  Water() : PureFluid(std::string("liquidvapor.cti"),std::string("water")) {}
54  virtual ~Water() {}
55 };
56 
57 }
58 
59 #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
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
bool ready() const
Returns a bool indicating whether the object is ready for use.
Definition: PureFluid.h:35
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
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
Wrapper for PureFluidPhase with constructor from file.
Definition: PureFluid.h:12
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.