Cantera  2.5.1
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 https://cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CXX_IDEALGASMIX
7 #define CXX_IDEALGASMIX
8 
9 #pragma message("warning: IdealGasMix.h is deprecated and will be removed after Cantera 2.5.")
10 
11 #include "thermo/IdealGasPhase.h"
12 #include "kinetics/GasKinetics.h"
14 #include "base/stringUtils.h"
15 
16 namespace Cantera
17 {
18 
19 //! Convenience class which inherits from both IdealGasPhase and GasKinetics
20 /*!
21  * @deprecated To be removed after Cantera 2.5.
22  * Replaceable with Solution and/or IdealGasPhase/GasKinetics.
23  */
24 class IdealGasMix :
25  public IdealGasPhase,
26  public GasKinetics
27 {
28 public:
29  IdealGasMix() : m_ok(false), m_r(0) {}
30 
31  IdealGasMix(const std::string& infile, std::string id_="") :
32  m_ok(false), m_r(0)
33  {
34  warn_deprecated("class IdealGasMix",
35  "To be removed after Cantera 2.5. "
36  "Replaceable with Solution and/or IdealGasPhase/GasKinetics.");
37  m_r = get_XML_File(infile);
38  m_id = id_;
39  if (id_ == "-") {
40  id_ = "";
41  }
42  m_ok = buildSolutionFromXML(*m_r,
43  m_id, "phase", this, this);
44  if (!m_ok) throw CanteraError("IdealGasMix",
45  "Cantera::buildSolutionFromXML returned false");
46  }
47 
48  IdealGasMix(XML_Node& root,
49  std::string id_) : m_ok(false), m_r(&root), m_id(id_) {
50  warn_deprecated("class IdealGasMix",
51  "To be removed after Cantera 2.5. "
52  "Replaceable with Solution and/or IdealGasPhase/GasKinetics.");
53  m_ok = buildSolutionFromXML(root, id_, "phase", this, this);
54  }
55 
56  IdealGasMix(const IdealGasMix& other) : m_ok(false),
57  m_r(other.m_r),
58  m_id(other.m_id) {
59  warn_deprecated("class IdealGasMix",
60  "To be removed after Cantera 2.5. "
61  "Replaceable with Solution and/or IdealGasPhase/GasKinetics.");
62  m_ok = buildSolutionFromXML(*m_r, m_id, "phase", this, this);
63  }
64 
65  bool operator!() {
66  return !m_ok;
67  }
68  bool ready() const {
69  return m_ok;
70  }
71  friend std::ostream& operator<<(std::ostream& s, IdealGasMix& mix) {
72  std::string r = mix.report(true);
73  s << r;
74  return s;
75  }
76 
77 protected:
78  bool m_ok;
79  XML_Node* m_r;
80  std::string m_id;
81 };
82 }
83 
84 #endif
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:61
Kinetics manager for elementary gas-phase chemistry.
Definition: GasKinetics.h:27
Convenience class which inherits from both IdealGasPhase and GasKinetics.
Definition: IdealGasMix.h:27
bool ready() const
Returns a bool indicating whether the object is ready for use.
Definition: IdealGasMix.h:68
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state.
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:104
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:110
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.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
Definitions of global routines for the importing of data from XML files (see Input File Handling).
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
Contains declarations for string manipulation functions within Cantera.