Cantera  2.4.0
Interface.h
Go to the documentation of this file.
1 /**
2  * @file Interface.h
3  * Declaration and Definition for the class Interface.
4  */
5 
6 // This file is part of Cantera. See License.txt in the top-level directory or
7 // at http://www.cantera.org/license.txt for license and copyright information.
8 
9 #ifndef CXX_INTERFACE
10 #define CXX_INTERFACE
11 
12 #include "thermo.h"
13 #include "kinetics.h"
16 
17 namespace Cantera
18 {
19 //! An interface between multiple bulk phases.
20 /*!
21  * This class is defined mostly for convenience. It inherits both from SurfPhase
22  * and InterfaceKinetics. It therefore represents a surface phase, and also acts
23  * as the kinetics manager to manage reactions occurring on the surface,
24  * possibly involving species from other phases.
25  */
26 class Interface :
27  public SurfPhase,
28  public InterfaceKinetics
29 {
30 public:
31  //! Constructor.
32  /*!
33  * Construct an Interface instance from a specification in an input file.
34  *
35  * @param infile Cantera input file in CTI or CTML format.
36  * @param id Identification string to distinguish between multiple
37  * definitions within one input file.
38  * @param otherPhases Neighboring phases that may participate in the
39  * reactions on this interface. Don't include the surface phase
40  */
41  Interface(const std::string& infile, std::string id,
42  std::vector<ThermoPhase*> otherPhases) :
43  m_ok(false),
44  m_r(0) {
45  m_r = get_XML_File(infile);
46  if (id == "-") {
47  id = "";
48  }
49 
50  XML_Node* x = get_XML_Node("#"+id, m_r);
51  if (!x) {
52  throw CanteraError("Interface","error in get_XML_Node");
53  }
54  importPhase(*x, this);
55  otherPhases.push_back(this);
56  importKinetics(*x, otherPhases, this);
57  m_ok = true;
58  }
59 
60  //! Not operator
61  bool operator!() {
62  return !m_ok;
63  }
64 
65  //! return whether the object has been instantiated
66  bool ready() const {
67  return m_ok;
68  }
69 
70 protected:
71  //! Flag indicating that the object has been instantiated
72  bool m_ok;
73 
74  //! XML_Node pointer to the XML File object that contains the Surface and
75  //! the Interfacial Reaction object description
77 };
78 
79 //! Import an instance of class Interface from a specification in an input file.
80 /*!
81  * This is the preferred method to create an Interface instance.
82  */
83 inline Interface* importInterface(const std::string& infile,
84  const std::string& id,
85  std::vector<ThermoPhase*> phases)
86 {
87  return new Interface(infile, id, phases);
88 }
89 
90 }
91 
92 #endif
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:189
Support for thermo property calculation from C++ application programs.
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
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
bool operator!()
Not operator.
Definition: Interface.h:61
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
bool ready() const
return whether the object has been instantiated
Definition: Interface.h:66
Interface(const std::string &infile, std::string id, std::vector< ThermoPhase *> otherPhases)
Constructor.
Definition: Interface.h:41
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:142
bool m_ok
Flag indicating that the object has been instantiated.
Definition: Interface.h:72
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase *> th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
Interface * importInterface(const std::string &infile, const std::string &id, std::vector< ThermoPhase *> phases)
Import an instance of class Interface from a specification in an input file.
Definition: Interface.h:83
A kinetics manager for heterogeneous reaction mechanisms.
Support for chemical kinetics calculation from C++ application programs.
XML_Node * m_r
XML_Node pointer to the XML File object that contains the Surface and the Interfacial Reaction object...
Definition: Interface.h:76
An interface between multiple bulk phases.
Definition: Interface.h:26
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8