Cantera  2.4.0
PureFluid.h
Go to the documentation of this file.
1 //! @file PureFluid.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_PUREFLUID
7 #define CXX_PUREFLUID
8 
10 #include "kinetics.h"
11 
12 namespace Cantera
13 {
14 
15 //! Wrapper for PureFluidPhase with constructor from file
16 class PureFluid : public PureFluidPhase
17 {
18 public:
19  PureFluid() : m_ok(false), m_r(0) {}
20 
21  PureFluid(const std::string& infile, std::string id="") : m_ok(false), m_r(0) {
22  m_r = get_XML_File(infile);
23  if (id == "-") {
24  id = "";
25  }
26  m_ok = buildSolutionFromXML(*m_r, id, "phase", this, 0);
27  if (!m_ok) throw CanteraError("PureFluid",
28  "buildSolutionFromXML returned false");
29  }
30 
31  PureFluid(XML_Node& root, const std::string& id) : m_ok(false), m_r(0) {
32  m_ok = buildSolutionFromXML(root, id, "phase", this, 0);
33  }
34 
35  bool operator!() {
36  return !m_ok;
37  }
38 
39  bool ready() const {
40  return m_ok;
41  }
42 
43  friend std::ostream& operator<<(std::ostream& s, PureFluid& mix) {
44  std::string r = mix.report(true);
45  s << r;
46  return s;
47  }
48 
49 protected:
50  bool m_ok;
51  XML_Node* m_r;
52 };
53 
54 class Water : public PureFluid
55 {
56 public:
57  Water() : PureFluid(std::string("liquidvapor.cti"),std::string("water")) {}
58  virtual ~Water() {}
59 };
60 
61 }
62 
63 #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...
bool ready() const
Returns a bool indicating whether the object is ready for use.
Definition: PureFluid.h:39
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
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
STL namespace.
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
Support for chemical kinetics calculation from C++ application programs.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
Wrapper for PureFluidPhase with constructor from file.
Definition: PureFluid.h:16
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.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8