diff --git a/Cantera/python/Cantera/DustyGasTransport.py b/Cantera/python/Cantera/DustyGasTransport.py index 38c1b276a..a87d79efc 100644 --- a/Cantera/python/Cantera/DustyGasTransport.py +++ b/Cantera/python/Cantera/DustyGasTransport.py @@ -10,21 +10,45 @@ class DustyGasTransport(Transport): Transport.__init__(self, model = "DustyGas", phase = phase) def setPorosity(self, porosity): + """Set the porosity.""" self.setParameters(0, 0, [porosity, 0.0]) def setTortuosity(self, tortuosity): + """Set the tortuosity.""" self.setParameters(1, 0, [tortuosity, 0.0]) def setMeanPoreRadius(self, pore_radius): + """Set the mean pore radius.""" self.setParameters(2, 0, [pore_radius, 0.0]) def setMeanParticleDiameter(self, diameter): + """Set the mean particle diameter.""" self.setParameters(3, 0, [diameter, 0.0]) def setPermeability(self, permeability): + """Set the permeability. If not called, the value for close-packed + spheres is used.""" self.setParameters(4, 0, [permeability, 0.0]) - + + def molarFluxes(self, + conc = None, + gradConc = None, + gradPressure = 0.0): + self.setConcentrations(concentrations) + self. + def set(self, **p): + """Set model parameters. This is a convenience method that simply + calls other methods depending on the keyword. + + Keywords: + + - porosity + - tortuosity + - pore_radius + - diameter + - permeability + """ for o in p.keys(): if o == "porosity": self.setPorosity(p[o]) @@ -40,4 +64,5 @@ class DustyGasTransport(Transport): raise 'unknown parameter' + diff --git a/Cantera/python/Cantera/Kinetics.py b/Cantera/python/Cantera/Kinetics.py index 87832d132..4262b8a3f 100755 --- a/Cantera/python/Cantera/Kinetics.py +++ b/Cantera/python/Cantera/Kinetics.py @@ -1,3 +1,6 @@ +""" +Kinetics managers. +""" from Cantera.exceptions import CanteraError, getCanteraError from Cantera.ThermoPhase import ThermoPhase @@ -6,29 +9,29 @@ import Numeric import _cantera -def buildKineticsPhases(root=None, id=None): - """Return a list of ThermoPhase objects representing the phases - involved in a reaction mechanism. +## def buildKineticsPhases(root=None, id=None): +## """Return a list of ThermoPhase objects representing the phases +## involved in a reaction mechanism. - root -- XML node contaning a 'kinetics' child - id -- id attribute of the desired 'kinetics' node - """ - kin = root.child(id = id) - phase_refs = kin.children("phaseRef") - th = None - phases = [] - for p in phase_refs: - phase_id = p["id"] - try: - th = ThermoPhase(root=root, id=phase_id) - except: - if p["src"]: - pnode = XML_Node(name="root",src=src) - th = ThermoPhase(pnode, phase_id) - else: - raise CanteraError("phase "+phase_id+" not found.") - phases.append(th) - return phases +## root -- XML node contaning a 'kinetics' child +## id -- id attribute of the desired 'kinetics' node +## """ +## kin = root.child(id = id) +## phase_refs = kin.children("phaseRef") +## th = None +## phases = [] +## for p in phase_refs: +## phase_id = p["id"] +## try: +## th = ThermoPhase(root=root, id=phase_id) +## except: +## if p["src"]: +## pnode = XML_Node(name="root",src=src) +## th = ThermoPhase(pnode, phase_id) +## else: +## raise CanteraError("phase "+phase_id+" not found.") +## phases.append(th) +## return phases class Kinetics: @@ -36,6 +39,10 @@ class Kinetics: Kinetics managers. Instances of class Kinetics are responsible for evaluating reaction rates of progress, species production rates, and other quantities pertaining to a reaction mechanism. + + parameters - + kintype - integer specifying the type of kinetics manager to create. + """ def __init__(self, kintype=-1, thrm=0, xml_phase=None, id=None, phases=[]): @@ -50,6 +57,9 @@ class Kinetics: self._np = np self._sp = [] self._phnum = {} + + # p0 through p4 are the integer indices of the phase objects + # corresponding to the input sequence of phases self._end = [0] p0 = phases[0].thermophase() @@ -66,7 +76,7 @@ class Kinetics: if np >= 5: p4 = phases[4].thermophase() if np >= 6: - raise CanteraError("only 4 neighbor phases allowed") + raise CanteraError("a maximum of 4 neighbor phases allowed") self.ckin = _cantera.KineticsFromXML(xml_phase, p0, p1, p2, p3, p4) @@ -88,6 +98,7 @@ class Kinetics: _cantera.kin_delete(self.ckin) def kin_index(self): + print "kin_index is deprecated. Use kinetics_hndl." return self.ckin def kinetics_hndl(self): @@ -98,6 +109,19 @@ class Kinetics: return _cantera.kin_type(self.ckin) def kineticsSpeciesIndex(self, name, phase): + """The index of a species. + name -- species name + phase -- phase name + + Kinetics managers for heterogeneous reaction mechanisms + maintain a list of all species in all phases. The order of the + species in this list determines the ordering of the arrays of + production rates. This method returns the index for the + specified species of the specified phase, and is used to + locate the entry for a particular species in the production + rate arrays. + + """ return _cantera.kin_speciesIndex(self.ckin, name, phase) def kineticsStart(self, n): diff --git a/Cantera/python/Cantera/Transport.py b/Cantera/python/Cantera/Transport.py index 9e46b1943..010896579 100755 --- a/Cantera/python/Cantera/Transport.py +++ b/Cantera/python/Cantera/Transport.py @@ -19,7 +19,6 @@ class Transport: model will be taken from the input file. loglevel --- controls amount of diagnostic output """ - if model == "" or model == "Default": try: self.model = xml_phase.child('transport')['model'] diff --git a/Cantera/python/Cantera/elements.py b/Cantera/python/Cantera/elements.py index 1da566aa7..c4e79dc1b 100755 --- a/Cantera/python/Cantera/elements.py +++ b/Cantera/python/Cantera/elements.py @@ -1,21 +1,30 @@ +""" +Atomic elements. -def elementMoles(mix, element): - """Number of moles of an element in one mole of a mixture. +""" - mix -- a mixture object. - element -- the symbol for an element in 'mix'. +def elementMoles(s, element): + """Number of moles of an element in one mole of a solution. + + s -- an object representing a solution. + element -- the symbol for an element in 's'. """ nsp = mix.nSpecies() + + # see if 'element' corresponds to a symbol for one of the elements + # in s. If it does not, return zero moles. try: - m = mix.elementIndex(element) + m = s.elementIndex(element) if m < 0.0: return 0.0 except: return 0.0 - x = mix.moleFractions() + + x = s.moleFractions() moles = 0.0 for k in range(nsp): - moles += x[k]*mix.nAtoms(k,m) + moles += x[k]*s.nAtoms(k,m) return moles + diff --git a/Cantera/python/Cantera/exceptions.py b/Cantera/python/Cantera/exceptions.py index 81db707f6..770192237 100755 --- a/Cantera/python/Cantera/exceptions.py +++ b/Cantera/python/Cantera/exceptions.py @@ -1,6 +1,13 @@ +""" +Cantera exceptions +""" + import _cantera def getCanteraError(): + """ + Get an error message generated when Cantera throws an exception. + """ return _cantera.get_Cantera_Error() class CanteraError(Exception): diff --git a/Cantera/python/Cantera/gases.py b/Cantera/python/Cantera/gases.py index 80a7c4186..e062f0249 100755 --- a/Cantera/python/Cantera/gases.py +++ b/Cantera/python/Cantera/gases.py @@ -23,18 +23,9 @@ def IdealGasMix(src="", id = ""): transport --- transport model trandb --- transport database """ -## p = os.path.normpath(os.path.dirname(src)) -## fname = os.path.basename(src) -## ff = os.path.splitext(fname) -## nm = "" -## if len(ff) > 1: -## nm = ff[0] -## ext = ff[1] -## else: -## nm = ff -## ext = '' return Solution(src=src,id=id) + def GRI30(transport = ""): """Return a Solution instance implementing reaction mechanism GRI-Mech 3.0.""" @@ -52,6 +43,7 @@ def Air(): that of air""" return Solution(src="air.cti", id="air") + def Argon(): """Return a Solution instance representing pure argon.""" return Solution(src="argon.cti", id="argon") diff --git a/Cantera/src/KineticsFactory.cpp b/Cantera/src/KineticsFactory.cpp index 5b984a2c5..feb18fcb0 100644 --- a/Cantera/src/KineticsFactory.cpp +++ b/Cantera/src/KineticsFactory.cpp @@ -31,7 +31,7 @@ namespace Cantera { static int _itypes[] = {0, cGasKinetics, cGRI30, cInterfaceKinetics}; /** - * Return a new kinetics manager that "implements" a reaction + * Return a new kinetics manager that implements a reaction * mechanism specified in a CTML file. In other words, the * kinetics manager, given the rate constants and formulation of the * reactions that make up a kinetics mechanism, is responsible for @@ -73,8 +73,8 @@ namespace Cantera { } /* * Assign the kinetics manager based on the value of ikin. - * Kinetics managers are classed derived from the base - * Kinetics class. Unknown kinetics managers will throw an + * Kinetics managers are classes derived from the base + * Kinetics class. Unknown kinetics managers will throw a * CanteraError here. */ Kinetics* k=0; @@ -101,12 +101,11 @@ namespace Cantera { kintype); } - // Now, that we have the kinetics manager, we can - // import the reaction mechanism into the kinetics manager. + // Now that we have the kinetics manager, we can + // import the reaction mechanism into it. importKinetics(phaseData, th, k); - /* - * Return the pointer to the kinetics manager - */ + + // Return the pointer to the kinetics manager return k; } diff --git a/Cantera/src/Phase.h b/Cantera/src/Phase.h index ba0ae2b0d..56656fbff 100755 --- a/Cantera/src/Phase.h +++ b/Cantera/src/Phase.h @@ -13,11 +13,9 @@ #ifndef CT_PHASE_H #define CT_PHASE_H -//#include "ct_defs.h" #include "State.h" #include "Constituents.h" #include "vec_functions.h" -//#include "ctexceptions.h" #include "ctml.h" using namespace ctml; @@ -160,10 +158,6 @@ namespace Cantera { */ doublereal chargeDensity() const; - //void update_T(int n) const; - - //void update_C(int n) const; - /// Number of spatial dimensions (1, 2, or 3) int nDim() {return m_ndim;} void setNDim(int ndim) {m_ndim = ndim;} @@ -176,9 +170,6 @@ namespace Cantera { virtual bool ready() const; -// int installUpdater_T(Updater* u); - -// int installUpdater_C(Updater* u); protected: