From d5b18300cc0ce85393edd16f0155c5b2841dab3c Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Sun, 23 Apr 2006 07:27:10 +0000 Subject: [PATCH] initial import --- Cantera/python/Cantera/Edge.py | 80 ++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Cantera/python/Cantera/Edge.py diff --git a/Cantera/python/Cantera/Edge.py b/Cantera/python/Cantera/Edge.py new file mode 100644 index 000000000..a6c661186 --- /dev/null +++ b/Cantera/python/Cantera/Edge.py @@ -0,0 +1,80 @@ + +import string +import os + +from constants import * +from SurfacePhase import EdgePhase +from Kinetics import Kinetics +import XML + +__revision__ = "$Id$" + +class Edge(EdgePhase, Kinetics): + """ + One-dimensional edge between two surfaces. + + Instances of class Edge represent reacting 1D edges between + between 2D surfaces. Class Edge defines no methods of its + own. All of its methods derive from either EdgePhase or Kinetics. + + Function importInterface should usually be used to build an + Edge object from a CTI file definition, rather than calling + the Interface constructor directly. + + See: EdgePhase, Kinetics, importInterface + """ + def __init__(self, src="", root=None, surfaces=[]): + """ + src - CTML or CTI input file name. If more than one phase is + defined in the file, src should be specified as 'filename\#id' + If the file is not CTML, it will be run through the CTI -> CTML + preprocessor first. + + root - If a CTML tree has already been read in that contains + the definition of this interface, the root of this tree can be + specified instead of specifying 'src'. + + phases - A list of all objects representing the neighboring + surface phases which participate in the reaction mechanism. + + """ + self.ckin = 0 + self._owner = 0 + self.verbose = 1 + + # src has the form '#' + fn = src.split('#') + id = "" + if len(fn) > 1: + id = fn[1] + fn = fn[0] + + # read in the root element of the tree if not building from + # an already-built XML tree. Enable preprocessing if the film + # is a .cti file instead of XML. + if src and not root: + root = XML.XML_Node(name = 'doc', src = fn, preprocess = 1) + + # If an 'id' tag was specified, find the node in the tree with + # that tag + if id: + s = root.child(id = id) + + # otherwise, find the first element with tag name 'phase' + # (1D, 2D and 3D phases use the CTML tag name 'phase' + else: + s = root.child(name = "phase") + + # build the surface phase + EdgePhase.__init__(self, xml_phase=s) + + # build the reaction mechanism. This object (representing the + # surface phase) is added to the end of the list of phases + Kinetics.__init__(self, xml_phase=s, phases=surfaces+[self]) + + + def __del__(self): + """Delete the Edge instance.""" + Kinetics.__del__(self) + EdgePhase.__del__(self) +