ALL MODULES CAN BE FOUND IN "CANTERA/lib/python2.4/site-packages/Cantera/" (INDEX MODIFIED 11/10/05 - STB) """ Cantera provides capabilities for simulating problems involving chemical kinetics and transport processes. """ ROUTINES IN FILE: __INIT__.PY def writeCSV(f, list): """ Write list items to file 'f' in comma-separated-value format. Strings will be written as-is, and other types of objects will be converted to strings and then written. Each call to writeCSV writes one line of the file.""" def table(keys, values): """Create a map with the keys and values specified.""" def getCanteraError(): """Return the Cantera error message, if any.""" def refCount(a): """Return the reference count for an object.""" def addDirectory(dir): """Add a directory to search for Cantera data files.""" def writeLogFile(file): ------------------------------------------------------------------------- ROUTINES IN FILE: CK2CTI.PY def ck2cti(infile = "chem.inp", thermodb = "", trandb = "", idtag = "", debug = 0, validate = 1): """ Convert a Chemkin-format input file to CTI format. Parameters: infile - name of the Chemkin-format input file. thermodb - Thermodynamic database. This may be a standard Chemkin-format thermo database, or may be any Chemkin-format input file containing a THERMO section. trandb - Transport database. File containing species transport parameters in Chemkin format. If this argument is omitted, the CTI file will not contain transport property information. idtag - ID tag. Used to identify the ideal_gas entry in the CTI file. Optional. debug - If set to 1, extra debugging output will be written. This should only be used if ck2cti fails, in order to view intermediate output of the parser. Default: off (0). validate - If set to 1, the mechanism will be checked for errors. This is recommended, but for very large mechanisms may slow down the conversion process. Default: on (1). The translated file is written to the standard output. """ ------------------------------------------------------------------------- ROUTINES IN FILE: CONSTANTS.PY """ Physical Constants """ # One atmosphere in Pascals OneAtm = 101325.0 # The ideal gas constant in J/kmo-K GasConstant = 8314.47215 # Avogadro's Number, /kmol Avogadro = 6.022136736e26 # The ideal gas constant in cal/mol-K GasConst_cal_mol_K = 1.987 # Boltzmann-s constant Boltzmann = GasConstant / Avogadro # The Stefan-Boltzmann constant, W/m^2K^4 StefanBoltz = 5.67e-8 # The charge on an electron ElectronCharge = 1.602e-19 Pi = 3.1415926 # Faraday's constant, C/kmol Faraday = ElectronCharge * Avogadro # Planck's constant Planck = 6.6262e-34 ------------------------------------------------------------------------- ROUTINES IN FILE: DUSTYGASTRANSPORT.PY """ Dusty Gas model for transport in porous media. The Dusty Gas transport model. This class implements a transport manager for the Dusty Gas model for the effective transport properties of a gas in a stationary, solid, porous medium. The only properties computed are the multicomponent diffusion coefficients. The model does not compute viscosity or thermal conductivity. This class is a Python shadow class for Cantera C++ class DustyGasTransport. """ def setPorosity(self, porosity): """Set the porosity. Internal. See: set""" def setTortuosity(self, tortuosity): """Set the tortuosity. Internal. See: set""" def setMeanPoreRadius(self, pore_radius): """Set the mean pore radius [m]. Internal. See: set""" def setMeanParticleDiameter(self, diameter): """Set the mean particle diameter [m]. Internal. See: set""" def setPermeability(self, permeability): """Set the permeability. If not called, the value for close-packed spheres is used. Internal.""" def set(self, **p): """Set model parameters. This is a convenience method that simply calls other methods depending on the keyword. porosity - Porosity. Volume fraction of pores. tortuosity - Tortuosity. A measure of the extent to which the pores are straight cylinders (tortuosity = 1), or are more tortuous. pore_radius - The pore radius [m]. All keywords are optional. """ ------------------------------------------------------------------------- ROUTINES IN FILE: ELEMENTS.PY """ Atomic elements. """ 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'. """ ------------------------------------------------------------------------- ROUTINES IN FILE: EXCEL.PY """EXCEL CSV file utilities.""" def write_CSV_data(fname, names, npts, nvar, append, data): """ Write CSV data that can be imported into Excel fname -- file name names -- sequence of variable names npts -- number of data points nvar -- number of variables append -- if > 0, append to plot file, otherwise overwrite data -- object to generate plot data. This object must have a method 'value', defined so that data.value(j,n) returns the value of variable n at point j. """ ------------------------------------------------------------------------- EXCEPTIONS.PY """ Cantera exceptions """ def getCanteraError(): """ Get an error message generated when Cantera throws an exception. """ ------------------------------------------------------------------------ ROUTINES IN FILE: GASES.PY """Gas mixtures. These functions all return instances of class Solution that represent gas mixtures. """ def IdealGasMix(src="", id = "", loglevel = 0): """Return a Solution object representing an ideal gas mixture. src --- input file id --- XML id tag for phase """ def GRI30(transport = ""): """Return a Solution instance implementing reaction mechanism GRI-Mech 3.0.""" def Air(): """Return a Solution instance implementing the O/N/Ar portion of reaction mechanism GRI-Mech 3.0. The initial composition is set to that of air""" def Argon(): """Return a Solution instance representing pure argon.""" ------------------------------------------------------------------------ ROUTINES IN FILE: IMPORTFROMFILE.PY """Functions to import phase and interface definitions from CTI or CTML files. This module is imported when the Cantera package is imported, and therfore does not need to be explicitly imported in application programs.""" def importPhase(file, name = '', loglevel = 0): """Import one phase from an input file. If 'name' is specified, the phase definition with this name will be imported, otherwise the first phase definition in the file will be imported. If 'loglevel' is set to a positive integer, additional information will be printed or written to log files about the details of the object constructed. """ def importPhases(file, names = [], loglevel = 0): """Import multiple phases from one file. The phase names should be entered as a list of strings. See: importPhase """ def importInterface(file, name = '', phases = []): """Import an interface definition from input file 'file', and return an instance of class Interface implementing this definition. If 'name' is specified, the definition by this name will be imported; otherwise, the first interface definition in the file will be imported. The 'phases' argument is a list of objects representing the other phases that participate in the interfacial reactions, for example an object representing a gas phase or a solid. >>> gas1, cryst1 = importPhases('diamond.cti', ['gas', 'solid']) >>> diamond_surf = importInterface('diamond.cti', [gas1, cryst1]) Note the difference between the lists in the argument lists of these two functions. In importPhases, a list of name strings is entered, which are used to identify the appropriate definitions in the input file to build the objects. In importInterface, the list is of the objects that were built by importPhases. The reason these objects must be given as inputs is that these objects will be queried when phase properties (temperature, pressure, composition, electric potential) are needed to compute the reaction rates of progress. """ ------------------------------------------------------------------------ ROUTINES IN FILE: INTERP.PY def interp(z0, z, f): """ Linear interpolation. Sequences z and f must be of the same length, and the entries in z must be monotonically increasing. Example: >>> z = [0.0, 0.2, 0.5, 1.2, 2.1] >>> f = [3.0, 2.0, 1.0, 0.0, -1.0] >>>print interp(-2, z, f), interp(0.5, z, f), interp(6, z, f) 3.0 7.0 -9.0 """ def quadInterp(z0, z, f): ------------------------------------------------------------------------ ROUTINES IN FILE: KINETICS.PY """ Kinetics managers. """ def kin_index(self): def kinetics_hndl(self): def kineticsType(self): """Kinetics manager type.""" 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. """ def kineticsStart(self, n): """The starting location of phase n in production rate arrays.""" def phase(self, n): """Return an object representing the nth phase.""" def nReactions(self): """Number of reactions.""" return _cantera.kin_nreactions(self.ckin) def isReversible(self,i): """ True (1) if reaction number 'i' is reversible, and false (0) otherwise. """ def reactionType(self,i): """Type of reaction 'i'""" def reactionEqn(self,i): """The equation for the specified reaction. If a list of equation numbers is given, then a list of equation strings is returned.""" def reactionString(self, i): """Reaction string for reaction number 'i'""" s = '' def reactantStoichCoeff(self,k,i): """The stoichiometric coefficient of species k as a reactant in reaction i.""" def reactantStoichCoeffs(self): """The array of reactant stoichiometric coefficients. Element [k,i] of this array is the reactant stoichiometric coefficient of species k in reaction i.""" def productStoichCoeff(self,k,i): """The stoichiometric coefficient of species k as a product in reaction i.""" def productStoichCoeffs(self): """The array of product stoichiometric coefficients. Element [k,i] of this array is the product stoichiometric coefficient of species k in reaction i.""" def fwdRatesOfProgress(self): """Forward rates of progress of the reactions.""" def revRatesOfProgress(self): """Reverse rates of progress of the reactions.""" def netRatesOfProgress(self): """Net rates of progress of the reactions.""" def equilibriumConstants(self): """Equilibrium constants in concentration units for all reactions.""" def activationEnergies(self): """Activation energies in Kelvin for all reactions.""" def fwdRateConstants(self): """Forward rate constants for all reactions.""" def revRateConstants(self, doIrreversible = 0): """Reverse rate constants for all reactions.""" def creationRates(self, phase = None): def destructionRates(self, phase = None): def netProductionRates(self, phase = None): def sourceTerms(self): def multiplier(self,i): def setMultiplier(self, value = 0.0, reaction = -1): def advanceCoverages(self,dt): ------------------------------------------------------------------------ ROUTINES IN FILE: LIQUIDVAPOR.PY """Fluids with complete liquid/vapor equations of state.. These functions are defined for convenience only. They simply call function 'importPhase' to import the phase definition from file 'liquidvapor.cti' """ def Water(): def Nitrogen(): def Methane(): def Hydrogen(): def Oxygen(): def HFC134a(): ------------------------------------------------------------------------ ROUTINES IN FILE: MIXTURE.PY """ Multiphase mixtures. Multiphase mixtures. Class Mixture represents mixtures of one or more phases of matter. To construct a mixture, supply a list of phases to the constructor, each paired with the number of moles for that phase: >>> gas = importPhase('gas.cti') >>> gas.speciesNames() ['H2', 'H', 'O2', 'O', 'OH'] >>> graphite = importPhase('graphite.cti') >>> graphite.speciesNames() ['C(g)'] >>> mix = Mixture([(gas, 1.0), (graphite, 0.1)]) >>> mix.speciesNames() ['H2', 'H', 'O2', 'O', 'OH', 'C(g)'] Note that the objects representing each phase compute only the intensive state of the phase -- they do not store any information on the amount of this phase. Mixture objects, on the other hand, represent the full extensive state. Mixture objects are 'lightweight' in the sense that they do not store parameters needed to compute thermodynamic or kinetic properties of the phases. These are contained in the ('heavyweight') phase objects. Multiple mixture objects may be constructed using the same set of phase objects. Each one stores its own state information locally, and synchronizes the phases objects whenever it requires phase properties. """ def nPhases(self): """Total number of phases defined for the mixture.""" def phaseName(self, n): """Name of phase n.""" def phaseNames(self): """Names of all phases in the order added.""" def phaseIndex(self, phase): """Index of phase with name 'phase'""" def nElements(self): """Total number of elements present in the mixture.""" def elementIndex(self, element): """Index of element with name 'element'. >>> mix.elementIndex('H') 2 >>> """ def nSpecies(self): """Total number of species present in the mixture. This is the sum of the numbers of species in each phase.""" def speciesName(self, k): """Name of the species with index k. Note that index numbers are assigned in order as phases are added.""" def speciesNames(self): def speciesIndex(self, species): """Index of species with name 'species'. If 'species' is not a string, then it is simply returned.""" def nAtoms(self, k, m): """Number of atoms of element m in species k. Both the species and the element may be referenced either by name or by index number. >>> n = mix.nAtoms('CH4','H') 4.0 """ def setTemperature(self, t): """Set the temperature [K]. The temperatures of all phases are set to this value, holding the pressure fixed.""" def temperature(self): """The temperature [K].""" return _cantera.mix_temperature(self.__mixid) def setPressure(self, p): """Set the pressure [Pa]. The pressures of all phases are set to the specified value, holding the temperature fixed.""" def pressure(self): """The pressure [Pa].""" def phaseMoles(self, n = -1): """Moles of phase n.""" def setPhaseMoles(self, n, moles): """Set the number of moles of phase n.""" def setSpeciesMoles(self, moles): """Set the moles of the species [kmol]. The moles may be specified either as a string, or as an array. If an array is used, it must be dimensioned at least as large as the total number of species in the mixture. Note that the species may belong to any phase, and unspecified species are set to zero. >>> mix.setSpeciesMoles('C(s):1.0, CH4:2.0, O2:0.2') """ def elementMoles(self, m): """Total number of moles of element m, summed over all species. The element may be referenced either by index number or by name. """ def chemPotentials(self, species=[]): """The chemical potentials of all species [J/kmol].""" def set(self, **p): def equilibrate(self, XY = "TP", err = 1.0e-9, maxsteps = 1000, maxiter = 200, loglevel = 0): """Set the mixture to a state of chemical equilibrium. This method uses a version of the VCS algorithm to find the composition that minimizes the total Gibbs free energy of the mixture, subject to element conservation constraints. For a description of the theory, see Smith and Missen, 'Chemical Reaction Equilibrium.' The VCS algorithm is implemented in Cantera kernel class MultiPhaseEquil. The VCS algorithm solves for the equilibrium composition for specified temperature and pressure. If any other property pair other than 'TP' is specified, then an outer iteration loop is used to adjust T and/or P so that the specified property values are obtained. XY - Two-letter string specifying the two properties to hold fixed. Currently, 'TP', 'HP', and 'SP' are implemented. Default: 'TP'. err - Error tolerance. Iteration will continue until (Delta mu)/RT is less than this value for each reaction. Default: 1.0e-9. Note that this default is very conservative, and good equilibrium solutions may be obtained with larger error tolerances. maxsteps - Maximum number of steps to take while solving the equilibrium problem for specified T and P. Default: 1000. maxiter - Maximum number of temperature and/or pressure iterations. This is only relevant if a property pair other than (T,P) is specified. Default: 200. loglevel - Controls the amount of diagnostic output. If loglevel = 0, no diagnostic output is written. For values > 0, more detailed information is written to the log file as loglevel increases. The default is loglevel = 0. The logfile is written in HTML format, and may be viewed with any web browser. The default log file name is 'equilibrium_log.html,' but if this file exists, the log information will be written to 'equilibrium_log{n}.html,' where {n} is an integer chosen so that the log file does not already exist. Therefore, if 'equilibrate' is called multiple times, multiple log files will be written, with names 'equilibrate_log.html,' 'equilibrate_log1.html,' 'equilibrate_log2.html,' and so on. Existing log files will not be overwritten. >>> mix.equilibrate('TP') >>> mix.equilibrate('TP', err = 1.0e-6, maxiter = 500) """ def selectSpecies(self, f, species): """Given an array 'f' of floating-point species properties, return an array of those values corresponding to species listed in 'species'. This method is used internally to implement species selection in methods like moleFractions, massFractions, etc. >>> f = mix.chemPotentials() >>> muo2, muh2 = mix.selectSpecies(f, ['O2', 'H2']) """ ------------------------------------------------------------------------ ROUTINES IN FILE: PHASE.PY """Cantera.Phase This module provides class Phase. Phases of matter. Class Phase manages basic state and constituent property information for a homogeneous phase of matter. It handles only those properties that do not require the equation of state, namely the temperature, density, chemical composition, and attributes of the elements and species. It does not know about the pressure, or any other thermodynamic property requiring the equation of state -- class ThermoPhase derives from Phase and adds those properties. Class Phase is not usually instantiated directly. It is used as a base class for class ThermoPhase. """ def phase_id(self): """The integer index used to access the kernel-level object. Internal.""" def nElements(self): """Number of elements.""" def atomicWeights(self, elements = []): """Array of element molar masses [kg/kmol]. If a sequence of element symbols is supplied, only the values for those elements are returned, ordered as in the list. Otherwise, the values are for all elements in the phase, ordered as in the input file. """ def nSpecies(self): """Number of species.""" def nAtoms(self, species = None, element = None): """Number of atoms of element 'element' in species 'species'. The element and species may be specified by name or by number. >>> ph.nAtoms('CH4','H') ___ 4 """ def temperature(self): """Temperature [K].""" def density(self): """Mass density [kg/m^3].""" def volume_mass(self): """Specific volume [m^3/kg].""" def molarDensity(self): """Molar density [kmol/m^3].""" def meanMolecularWeight(self): """Mean molar mass [kg/kmol].""" def meanMolarMass(self): """Mean molar mass [kg/kmol].""" def molarMasses(self, species = None): """Array of species molar masses [kg/kmol].""" def molecularWeights(self, species = None): """Array of species molar masses [kg/kmol].""" def moleFractions(self, species = None): """Species mole fraction array. If optional argument 'species' is supplied, then only the values for the selected species are returned. >>> x1 = ph.moleFractions() # all species >>> x2 = ph.moleFractions(['OH', 'CH3'. 'O2']) """ def moleFraction(self, species): """Mole fraction of a species, referenced by name or index number. >>> ph.moleFraction(4) >>> ph.moleFraction('CH4') """ def massFractions(self, species = None): """Species mass fraction array. If optional argument 'species' is supplied, then only the values for the selected species are returned. >>> y1 = ph.massFractions() # all species >>> y2 = ph.massFractions(['OH', 'CH3'. 'O2']) """ def massFraction(self, species): """Mass fraction of one species, referenced by name or index number. >>> ph.massFraction(4) >>> ph.massFraction('CH4') """ def elementName(self,m): """Name of the element with index number m.""" def elementNames(self): """Return a tuple of all element names.""" def elementIndex(self, element): """The index of element 'element', which may be specified as a string or an integer index. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown.""" def speciesName(self,k): """Name of the species with index k.""" def speciesNames(self): """Return a tuple of all species names.""" def speciesIndex(self, species): """The index of species 'species', which may be specified as a string or an integer index. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown.""" def setTemperature(self, t): """Set the temperature [K].""" def setDensity(self, rho): """Set the density [kg/m3].""" def setMolarDensity(self, n): """Set the density [kmol/m3].""" def setMoleFractions(self, x, norm = 1): """Set the mole fractions. x - string or array of mole fraction values norm - If non-zero (default), array values will be scaled to sum to 1.0. >>> ph.setMoleFractions('CO:1, H2:7, H2O:7.8') >>> x = [1.0]*ph.nSpecies() >>> ph.setMoleFractions(x) >>> ph.setMoleFractions(x, norm = 0) # don't normalize values """ def setMassFractions(self, x, norm = 1): """Set the mass fractions. See: setMoleFractions """ def setState_TRX(self, t, rho, x): """Set the temperature, density, and mole fractions. The mole fractions may be entered as a string or array, >>> ph.setState_TRX(600.0, 2.0e-3, 'CH4:0.4, O2:0.6') """ def setState_TNX(self, t, n, x): """Set the temperature, molardensity, and mole fractions. The mole fractions may be entered as a string or array, >>> ph.setState_TNX(600.0, 2.0e-3, 'CH4:0.4, O2:0.6') """ def setState_TRY(self, t, rho, y): """Set the temperature, density, and mass fractions.""" def setState_TR(self, t, rho): """Set the temperature and density, leaving the composition unchanged.""" def selectSpecies(self, f, species): """Given an array 'f' of floating-point species properties, return an array of those values corresponding to species listed in 'species'. This method is used internally to implement species selection in methods like moleFractions, massFractions, etc. >>> f = ph.chemPotentials() >>> muo2, muh2 = ph.selectSpecies(f, ['O2', 'H2']) """ def selectElements(self, f, elements): """Given an array 'f' of floating-point element properties, return a nummodule array of those values corresponding to elements listed in 'elements'. >>> f = ph.elementPotentials() >>> lam_o, lam_h = ph.selectElements(f, ['O', 'H']) """ ------------------------------------------------------------------------ ROUTINES IN FILE: REACTORNET.PY """ Reactor networks. Networks of reactors. ReactorNet objects are used to simultaneously advance the state of a set of coupled reactors. Example: r1 = Reactor(gas1) r2 = Reactor(gas2) <... install walls, inlets, outlets, etc...> reactor_network = ReactorNet([r1, r2]) reactor_network.advance(time) """ def add(self, reactor): """ Add a reactor to the network. """ def setInitialTime(self, t0): """Set the initial time. Restarts integration from this time using the current state as the initial condition. Default: 0.0 s""" def advance(self, time): """Advance the state of the reactor network in time from the current time to time 'time'.""" def step(self, time): """Take a single internal time step toward time 'time'. The time after taking the step is returned.""" def reactors(self): ------------------------------------------------------------------------ ROUTINES IN FILE: REACTOR.PY """ Zero-dimensional reactors. Base class for reactors and reservoirs. Classes Reactor and Reservoir derive from a common base class ReactorBase. They have the same set of methods, which are all inherited from ReactorBase. (This is not quite true in the corresponding classes in the Cantera C++ kernel. There class Reactor defines some methods that class Reservoir doesn't. These are used internally by the ReactorNet instance that integrates the system of ODEs describing the network to evaluate the portion of the ODE system associated with that reactor.) """ def name(self): """The name of the reactor.""" def reactor_id(self): """The integer index used to access the kernel reactor object. For internal use.""" def insert(self, contents): """ Insert 'contents' into the reactor. Sets the objects used to compute thermodynamic properties and kinetic rates. """ def setInitialTime(self, T0): """Deprecated. Set the initial time. Restarts integration from this time using the current state as the initial condition. Default: 0.0 s""" def _setInitialVolume(self, V0): """Set the initial reactor volume. """ _cantera.reactor_setInitialVolume(self.__reactor_id, V0) def _setEnergy(self, eflag): """Turn the energy equation on or off. If the argument is the string 'off' or the number 0, the energy equation is disabled, and the reactor temperature is held constant at its initial value.""" def temperature(self): """The temperature in the reactor [K].""" def density(self): """The density of the fluid in the reactor [kg/m^3].""" def volume(self): """The total reactor volume [m^3]. The volume may change with time if non-rigid walls are installed on the reactor.""" def time(self): """Deprecated. The current time [s].""" def mass(self): """The total mass of fluid in the reactor [kg].""" def enthalpy_mass(self): """The specific enthalpy of the fluid in the reactor [J/kg].""" def intEnergy_mass(self): """The specific internal energy of the fluid in the reactor [J/kg].""" def pressure(self): """The pressure in the reactor [Pa].""" def advance(self, time): """Deprecated. Advance the state of the reactor in time from the current time to time 'time'. Note: this method is deprecated. See class ReactorNet.""" def step(self, time): """Deprecated. Take one internal time step from the current time toward time 'time'. Note: this method is deprecated. See class ReactorNet.""" def massFraction(self, s): """The mass fraction of species s, specified either by name or index number. >>> y1 = r.massFraction(7) ___0.02 >>> y2 = r.massFraction('CH3O') ___0.02 """ def massFractions(self): """Return an array of the species mass fractions.""" def moleFractions(self): """Return an array of the species mole fractions.""" def moleFraction(self, s): """The mole fraction of species s, specified either by name or index number. >>> x1 = r.moleFraction(9) ___0.00012 >>> x2 = r.moleFraction('CH3') ___0.00012 """ def inlets(self): """Return the list of flow devices installed on inlets to this reactor. This method can be used to access information about the flows entering the reactor: >>> for n in r.inlets(): ... print n.name(), n.massFlowRate() See: MassFlowController, Valve, PressureController. """ def outlets(self): """Return the list of flow devices installed on outlets on this reactor. >>> for o in r.outlets(): ... print o.name(), o.massFlowRate() See: MassFlowController, Valve, PressureController. """ def walls(self): """Return the list of walls installed on this reactor. >>> for w in r.walls(): ... print w.name() See: Wall. """ def syncContents(self): """Set the state of the object representing the reactor contents to the current reactor state. >>> r = Reactor(gas) >>> (statements that change the state of object 'gas') >>> r.syncContents() After this statement, the state of object 'gas' is synchronized with the reactor state. See 'contents'. """ def contents(self): """Return an object representing the reactor contents, after first synchronizing its state with the current reactor state. This method is useful when some property of the fluid in the reactor is needed that is not provided by a method of class Reactor. >>> r = Reactor(gas) >>> (statements that change the state of object 'gas') >>> c = r.contents() >>> print c.gibbs_mole(), c.chemPotentials() Note that after calling method 'contents', object 'c' references the same underlying kernel object as object 'gas' does. Therefore, all properties of 'c' and 'gas' are identical. (Remember that Python objects are really C pointers; at the C level, both point to the same data structure.) It is also allowed to write >>> gas = r.contents() """ """ Zero-dimensional reactors. Instances of class Reactor represent zero-dimensional reactors. By default, they are closed (no inlets or outlets), have fixed volume, and have adiabatic, chemically-intert walls. These properties may all be changed by adding appropriate components. See classes 'Wall', 'MassFlowController', and 'Valve'. A reservoir is a reactor with a constant state. The temperature, pressure, and chemical composition in a reservoir never change from their initial values. """ def advance(self, time): """Deprecated. Do nothing.""" #------------------ FlowDevice --------------------------------- """ Base class for devices that regulate the flow rate in a fluid line. """ def name(self): """The name specified when initially constructed.""" def ready(self): """ Deprecated. Returns true if the device is ready to use. """ def massFlowRate(self, time = -999.0): """Mass flow rate (kg/s). """ def install(self, upstream, downstream): """ Install the device between the upstream and downstream reactors or reservoirs. >>> f.install(upstream = reactor1, downstream = reservoir2) """ def _setParameters(self, c): def setFunction(self, f): def flowdev_id(self): """Mass flow controllers. A mass flow controller maintains a specified mass flow rate independent of upstream and downstream conditions. The equation used to compute the mass flow rate is \f[ \dot m = \max(\dot m_0, 0.0), \f] where \f$ \dot m_0 \f$ is either a constant value or a function of time. Note that if \f$\dot m_0 < 0\f$, the mass flow rate will be set to zero, since reversal of the flow direction is not allowed. Unlike a real mass flow controller, a MassFlowController object will maintain the flow even if the downstream pressure is greater than the upstream pressure. This allows simple implementation of loops, in which exhaust gas from a reactor is fed back into it through an inlet. But note that this capability should be used with caution, since no account is taken of the work required to do this. A mass flow controller is assumed to be adiabatic, non-reactive, and have negligible volume, so that it is internally always in steady-state even if the upstream and downstream reactors are not. The fluid enthalpy, chemical composition, and mass flow rate are constant across a mass flow controller, and the pressure difference equals the difference in pressure between the upstream and downstream reactors. Examples: >>> mfc1 = MassFlowController(upstream = res1, downstream = reactr, ... name = 'fuel_mfc', mdot = 0.1) >>> air_mdot = Gaussian(A = 0.1, t0 = 2.0, FWHM = 0.1) >>> mfc2 = MassFlowController(upstream = res2, downstream = reactr, ... name = 'air_mfc', mdot = air_mdot) """ def set(self, mdot = 0.0): """Set the mass flow rate [kg/s]. May be called at any time to change the mass flow rate to a new value, or to a new function of time. >>> mfc.set(mdot = 0.2) """ """Valves. In Cantera, a Valve object is a flow devices with mass flow rate that is a function of the pressure drop across it. The default behavior is linear: \f[ \dot m = K_v (P_1 - P_2) \f] if \f$ P_1 > P_2. \f$ Otherwise, \f$ \dot m = 0 \f$. However, an arbitrary function \f$ F\f$ can also be specified, such that \f[ \dot m = F(P_1 - P_2). \f] if \f$ P_1 > P_2, \f$ or \f$ \dot m = 0 \f$ otherwise. It is never possible for the flow to reverse and go from the downstream to the upstream reactor/reservoir through a line containing a Valve object. 'Valve' objects are often used between an upstream reactor and a downstream reactor or reservoir to maintain them both at nearly the same pressure. By setting the constant \f$ K_v \f$ to a sufficiently large value, very small pressure differences will result in flow between the reactors that counteracts the pressure difference. A Valve is assumed to be adiabatic, non-reactive, and have negligible internal volume, so that it is internally always in steady-state even if the upstream and downstream reactors are not. The fluid enthalpy, chemical composition, and mass flow rate are constant across a Valve, and the pressure difference equals the difference in pressure between the upstream and downstream reactors. """ def setValveCoeff(self, Kv = -1.0): """Set or reset the valve coefficient \f$ K_v \f$.""" def _setValveCharacteristic(self, f): """Set or reset the valve characteristics.""" def set(self, Kv = -1.0, F = None): """Set or reset valve properties. All keywords are optional. Kv - constant in linear mass flow rate equation. F - function of \f$\Delta P\f$. """ """ A PressureController is designed to be used in conjunction with another 'master' flow controller, typically a MassFlowController. The master flow controller is installed on the inlet of the reactor, and the corresponding PressureController is installed on on outlet of the reactor. The PressureController mass flow rate is equal to the master mass flow rate, plus a small correction dependent on the pressure difference: \f[ \dot m = \dot m_{\rm master} + K_v(P_1 - P_2). \f] """ def setPressureCoeff(self, Kv): """Set or reset the pressure coefficient \f$ K_v \f$.""" def setMaster(self, master): """Set the master flow controller.""" def set(self, Kv = -1.0, master = None): #------------- Wall --------------------------- """ Reactor walls. A Wall separates two reactors, or a reactor and a reservoir. A wall has a finite area, may conduct or radiate heat between the two reactors on either side, and may move like a piston. Walls are stateless objects in Cantera, meaning that no differential equation is integrated to determine any wall property. Since it is the wall (piston) velocity that enters the energy equation, this means that it is the velocity, not the acceleration or displacement, that is specified. The wall velocity is computed from \f[ v = K(P_{\\rm left} - P_{\\rm right}) + v_0(t), f] where $K$ is a non-negative constant, and \f$v_0(t)$ is a specified function of time. The velocity is positive if the wall is moving to the right. The heat flux through the wall is computed from \f[ q = U(T_{\\rm left} - T_{\\rm right}) + \epsilon\sigma (T_{\\rm left}^4 - T_{\\rm right}^4) + q_0(t), \f] where \f$ U \f$ is the overall heat transfer coefficient for conduction/convection, and \f$ \\epsilon \f$ is the emissivity. The function \f$ q_0(t)$ is a specified function of time. The heat flux is positive when heat flows from the reactor on the left to the reactor on the right. A heterogeneous reaction mechanism may be specified for one or both of the wall surfaces. The mechanism object (typically an instance of class Interface) must be constructed so that it is properly linked to the object representing the fluid in the reactor the surface in question faces. The surface temperature on each side is taken to be equal to the temperature of the reactor it faces. """ def ready(self): """ Return 1 if the wall instance is ready for use, 0 otherwise. Deprecated. """ def area(self): """ The wall area (m^2). """ def setArea(self, a): """ Set the area (m^2). The wall area may be changed manually at any time during a simulation. """ def setThermalResistance(self, rth): """Deprecated.""" def setHeatTransferCoeff(self, u): """ Set the overall heat transfer coefficient [W/m^2/K] """ def setEmissivity(self, epsilon): """ Set the emissivity. """ def setHeatFlux(self, qfunc): """ Specify the time-dependent heat flux function [W/m2]. 'qfunc' must be a functor (an instance of a subclass of Cantera.Func1). See: Func1. """ def setExpansionRateCoeff(self, k): """Set the coefficient K that determines the expansion rate resulting from a unit pressure drop.""" def setVelocity(self, vfunc): """ Specify the velocity function [m/s]. 'vfunc' must be a functor (an instance of a subclass of Cantera.Func1) See: Func1. """ def vdot(self): """Rate of volume change [m^3]. A positive value corresponds to the left-hand reactor volume increasing, and the right-hand reactor volume decreasing.""" def velocity(self): def heatFlowRate(self): """Rate of heat flow through the wall. A positive value corresponds to heat flowing from the left-hand reactor to the right-hand one.""" def heatFlux(self): def install(self, left, right): def setKinetics(self, left, right): """Specify surface reaction mechanisms for the left and right sides of the wall.""" def set(self, **p): """Set various wall parameters: 'A', 'U', 'K', 'Q'. 'velocity'. These have the same meanings as in the constructor. """ """Networks of reactors. ReactorNet objects are used to simultaneously advance the state of a set of coupled reactors. Example: >>> r1 = Reactor(gas1) >>> r2 = Reactor(gas2) >>> <... install walls, inlets, outlets, etc...> >>> reactor_network = ReactorNet([r1, r2]) >>> reactor_network.advance(time) """ def add(self, reactor): """ Add a reactor to the network. """ def setInitialTime(self, t0): """Set the initial time. Restarts integration from this time using the current state as the initial condition. Default: 0.0 s""" def time(self): """The current time [s].""" def setTolerances(self, rtol = 1.0e-9, atol = 1.0e-20): """Set the relative and absolute error tolerances used in integrating the reactor equations.""" def advance(self, time): """Advance the state of the reactor network in time from the current time to time 'time'.""" def step(self, time): """Take a single internal time step toward time 'time'. The time after taking the step is returned.""" def reactors(self): ------------------------------------------------------------------------ ROUTINES IN FILE: RXNPATH.PY """ Reaction path diagrams. To create a simple reaction path diagram: >>> import rxnpath >>> element = 'C' >>> rxnpath.write(gas, element, file) Object 'gas' must an instance of a class derived from class 'Kinetics' (for example class IdealGasMix). The diagram layout is written to 'file'. The output must be postprocessed with program 'dot', which is part of the GraphViz package. To create a Postscript plot: dot -Tps rp.dot > rp.ps Other output formats are also supported by dot, including gif, pcl, jpg, png, and svg For more control over the graph properties, create a PathDiagam object and pass it to the 'write' procedure. PathDiagram keyword options: diagram type: -- detailed 'true' or 'false' -- type 'both' or 'net' (forward and reverse arrows, or net arrow) -- dot_options options passed through to 'dot' colors: -- normal_color color for normal-weight lines -- bold_color color for bold-weight lines -- dashed_color color for dashed lines thresholds: -- threshold min relative strength for a path to be shown -- normal_threshold min relative strength for normal-weight path Below this value, paths are dashed. -- bold_threshold min relative strength for bold-weight path """ def write(self, fmt, file): def add(self, other): def findMajorPaths(self, a, threshold = 0.0): def displayOnly(self, node=-1): def setOptions(self, options): def write(g, el, file, d=None, format="dot"): def view(url, ext = 'png'): ------------------------------------------------------------------------ ROUTINES IN FILE: SCHEM.PY """ Surface chemistry. Classes: BulkSpecies -- bulk species SurfSpecies -- surface species SurfReaction -- surface reactions Interface -- interfaces Surface species. A SurfSpecies object is required for every surface species. """ def nAtoms(self, el): """ Number of atoms of element with symbol 'el'. """ """ Instances of class BulkSpecies represent the bulk-phase species in surface reactions. A 'bulk-phase' species is any species in a 3D phase, whether a gas, solid, or liquid. The species parameters are taken from the bulk-phase object. """ def nAtoms(self, el): """ Reaction rate parameterizations appear in many different forms. Instances of this class are used to collect together a set of parameters for a particular parameterization type. The rate is computed using a generalized law of mass action, where the bulk (3D) species may be specified either by concentration or partial pressure, and empirical reaction orders may be assigned for each species. The surface species may be specified using either surface concentration, or coverage. Finally, the computed rate may be specified to be either a rate per unit area, or per site. Arguments: bulk -- one of ['conc', 'bar']. Specifies how bulk-phase reactant abundances appear in the rate expression. Default: 'conc'. If 'bar' is specified, the ideal gas law is used to convert from partial pressure to concentration units when the reaction is added to the surface mechanism. surf -- one of ['conc', 'cov']. Specifies how surface reactant abundances appear in the rate expression. Default: 'conc'. rate -- one of ['per_area', 'per_site']. Specifies whether the rate expression computes the rate per unit area (default), or per site. These differ only by a factor of the total site density. Note that these values are used to convert the reaction parameterization into concentration form at the time the reaction is added to the surface mechanism. """ """ rate_type --- a triplet of strings specifying how the reaction rate is expressed. """ def addDoc(self, key, value): def save(self, filename, idtag, comment): def setUnits(self, length = '', moles = '', time = '', E = ''): """ Set the unit system for surface reactions. On each call, only the specified unit conversion factors are set; the rest are left unchanged. length -- units for lengths ('m', 'cm', 'mm') moles -- units for amount ('mol', 'kmol', 'molecule') time -- units for time ('s') E -- units for activation energy ('kcal_per_mol', 'cal_per_mol', 'eV', 'K') """ def addSpecies(self, s): """Add a species.""" def nSpecies(self): def speciesIndex(self, sym): def speciesNames(self): def setSiteDensity(self, s0): def show(self): def coverage(self, sp): def coverages(self): def setCoverages(self, cov): def ratesOfProgress(self): """Rates of progress for all surface reactions [kmol/m^2-s].""" def netProductionRates(self): """Net production rates for all bulk and surface species. The results are returned as a tuple of 3 arrays for the species in bulk phase 1, bulk phase 2, and the surface phase, respectively. """ def integrate(self, dt): """Integrate the surface site-balance equations for time dt with fixed bulk compositions.""" def _index(self, sp): """Location of species object 'sp' in the solution array.""" def _uconc(self, n): """Return the concentration conversion factor to SI for the species with index n.""" def isBulkSpecies(self, n): """Return 1 if species n is a bulk species, and 0 if it is a surface species.""" def _bulkReactants(self, reactants): """Given a list of reactant objects, return a list of those that are bulk species.""" def _surfReactants(self, reactants): """Given a list of reactant objects, return a list of those that are surface species.""" def write_C(self, mech): def addReaction(self, r): """Add a reaction to the surface mechanism.""" ------------------------------------------------------------------------ ROUTINES IN FILE: SET.PY def setByName(a, options): """Set properties of phase 'a' by specifying keywords. Either the full property name or the short form may be given. The capitalization must be exactly as shown here. Note: all extensive property values are specified for a unit mass - i.e., the *specific* (not molar) property value should be specified. keyword short form property -------------------------------------------- Pressure P pressure Density Rho density Temperature T temperature Volume V specific volume MoleFractions X mole fractions MassFracttions Y mass fractions Enthalpy H specific enthalpy IntEnergy U specific internal energy Entropy S specific entropy Vapor Vap vapor fraction in a two-phase mixture Liquid Liq liquid fraction in a two-phase mixture """ def set(a, **options): ------------------------------------------------------------------------ ROUTINES IN FILE: SOLIDS.PY """This module defines classes and functions used to model gas mixtures.""" def Solid(src="", kmodel=1, transport=None): ------------------------------------------------------------------------ ROUTINES IN FILE: SOLIDTRANSPORT.PY """ Transport properties for solids. This class implements a simple model for the diffusion coefficients and the thermal conductivity of a solid. The diffusion coefficients have modified Arrhenius form, and the thermal conductivity is constant. All parameters are user-specified, not computed from a physical model. Examples: >>> tr = SolidTransport(solid_phase) >>> tr.setThermalConductivity(0.5) # W/m/K >>> tr.setDiffCoeff(species = "OxygenIon", A = 2.0, n = 0.0, E = 700.0) Note that the diffusion coefficient is computed from D = A * T^n * exp(-E/t) in m^2/s. Diffusion coefficients for unspecified species are set to zero. """ def setThermalConductivity(self, lamb): def setDiffCoeff(self, species = "", A = 0.0, n = 0.0, E = 0.0): ------------------------------------------------------------------------ ROUTINES IN FILE: SOLUTION.PY """ A class for chemically-reacting solutions. Instances can be created to represent any type of solution -- a mixture of gases, a liquid solution, or a solid solution, for example. Class Solution derives from classes ThermoPhase, Kinetics, and Transport. It defines very few methods of its own, and is provided largely for convenience, so that a single object can be used to compute thermodynamic, kinetic, and transport properties of a solution. Functions like IdealGasMix and others defined in module gases return objects of class Solution. """ def name(self): def set(self, **options): """Set various properties. T --- temperature [K] P --- pressure [Pa] Rho --- density [kg/m3] V --- specific volume [m3/kg] H --- specific enthalpy [J/kg] U --- specific internal energy [J/kg] S --- specific entropy [J/kg/K] X --- mole fractions (string or array) Y --- mass fractions (string or array) Vapor --- saturated vapor fraction Liquid --- saturated liquid fraction """ ------------------------------------------------------------------------ ROUTINES IN FILE: SOLVE.PY """ Solve a steady-state problem by combined damped Newton iteration and time integration. Function solve is no longer used, now that the functional equivalent has been added to the Cantera C++ kernel. """ def solve(sim, loglevel = 0, refine_grid = 1, plotfile = '', savefile = ''): """ Solve a steady-state problem by combined damped Newton iteration and time integration. """ ------------------------------------------------------------------------ ROUTINES IN FILE: STOICH.PY def det3(A): """Determinant of a 3x3 matrix.""" def stoich_fuel_to_oxidizer(mix, fuel, oxidizer): """Fuel to oxidizer ratio for stoichiometric combustion. This function only works for fuels composed of carbon, hydrogen, and/or oxygen. The fuel to oxidizer ratio is returned that results in """ ------------------------------------------------------------------------ ROUTINES IN FILE: SURFACEPHASE.PY """A class for surface phases.""" def setSiteDensity(self, n0): """Set the site density.""" _cantera.surf_setsitedensity(self._phase_id, n0) def siteDensity(self): """Site density [kmol/m2]""" def setCoverages(self, theta): """Set the surface coverages to the values in array 'theta'.""" def coverages(self): """Return the array of surface coverages.""" def setConcentrations(self, conc): """Set the surface concentrations to the values in array 'conc'.""" def concentrations(self): """Return the array of surface concentrations [kmol/m2].""" ------------------------------------------------------------------------ ROUTINES IN FILE: SURFWRITER.PY """ Write C functions implementing a surface reaction mechanism. NOT CURRENTLY FUNCTIONAL """ def write(self): def write_top(self): def write_update_rate(self, rate): def write_ROP(self, rindex, rstoich, rorder, pindex, pstoich, rate): def write_sdot(self, rindex, rstoich, pindex, pstoich): ------------------------------------------------------------------------ ROUTINES IN FILE: TECPLOT.PY """TECPLOT utilities.""" def write_TECPLOT_zone(fname, title, zone, names, npts, nvar, append, data): """ Write a TECPLOT zone specification to generate line plots of multiple variables. fname -- file name title -- plot title zone -- zone name names -- sequence of variable names npts -- number of data points nvar -- number of variables append -- if > 0, append to plot file, otherwise overwrite data -- object to generate plot data. This object must have a method 'value', defined so that data.value(j,n) returns the value of variable n at point j. """ ------------------------------------------------------------------------ ROUTINES IN FILE: THERMOPHASE.PY """ This module implements class ThermoPhase, a class representing thermodynamic phases. """ def thermoIndex(id): """ A phase with an equation of state. Class ThermoPhase may be used to represent the intensive thermodynamic state of a phase of matter, which might be a gas, liquid, or solid. Class ThermoPhase extends class Phase by providing methods that require knowledge of the equation of state. Class ThermoPhase is not usually instantiated directly. It is used as base class for classes Solution and Interface. See: Solution, Interface """ def name(self): def refPressure(self): """Reference pressure [Pa]. All standard-state thermodynamic properties are for this pressure. """ def minTemp(self, sp=None): """ Minimum temperature for which thermodynamic property fits are valid. If a species is specified (by name or number), then the minimum temperature is for only this species. Otherwise it is the lowest temperature for which the properties are valid for all species. """ def maxTemp(self, sp=None): """ Maximum temperature for which thermodynamic property fits are valid. If a species is specified (by name or number), then the maximum temperature is for only this species. Otherwise it is the highest temperature for which the properties are valid for all species. """ def enthalpy_mole(self): """ The molar enthalpy [J/kmol].""" def intEnergy_mole(self): """ The molar internal energy [J/kmol].""" def entropy_mole(self): """ The molar entropy [J/kmol/K].""" def gibbs_mole(self): """ The molar Gibbs function [J/kmol].""" def cp_mole(self): """ The molar heat capacity at constant pressure [J/kmol/K].""" def cv_mole(self): """ The molar heat capacity at constant volume [J/kmol/K].""" def pressure(self): """ The pressure [Pa].""" def chemPotentials(self, species = []): """Species chemical potentials. This method returns an array containing the species chemical potentials [J/kmol]. The expressions used to compute these depend on the model implemented by the underlying kernel thermo manager.""" def elementPotentials(self, elements = []): """Element potentials of the elements. This method returns an array containing the element potentials [J/kmol]. The element potentials are only defined for equilibrium states. This method first sets the composition to a state of equilibrium holding T and P constant, then computes the element potentials for this equilibrium state. """ def enthalpies_RT(self, species = []): """Pure species non-dimensional enthalpies. This method returns an array containing the pure-species standard-state enthalpies divided by RT. For gaseous species, these values are ideal gas enthalpies.""" def entropies_R(self, species = []): """Pure species non-dimensional entropies. This method returns an array containing the pure-species standard-state entropies divided by R. For gaseous species, these values are ideal gas entropies.""" def gibbs_RT(self, species = []): """Pure species non-dimensional Gibbs free energies. This method returns an array containing the pure-species standard-state Gibbs free energies divided by R. For gaseous species, these are ideal gas values.""" def cp_R(self, species = []): """Pure species non-dimensional heat capacities at constant pressure. This method returns an array containing the pure-species standard-state heat capacities divided by R. For gaseous species, these values are ideal gas heat capacities.""" def setPressure(self, p): """Set the pressure [Pa].""" def enthalpy_mass(self): """Specific enthalpy [J/kg].""" def intEnergy_mass(self): """Specific internal energy [J/kg].""" def entropy_mass(self): """Specific entropy [J/kg/K].""" def gibbs_mass(self): """Specific Gibbs free energy [J/kg].""" def cp_mass(self): """Specific heat at constant pressure [J/kg/K].""" def cv_mass(self): """Specific heat at constant volume [J/kg/K].""" def setState_TPX(self, t, p, x): """Set the temperature [K], pressure [Pa], and mole fractions.""" def setState_TPY(self, t, p, y): """Set the temperature [K], pressure [Pa], and mass fractions.""" def setState_TP(self, t, p): """Set the temperature [K] and pressure [Pa].""" def setState_PX(self, p, x): """Set the pressure [Pa], and mole fractions.""" def setState_PY(self, p, y): """Set the pressure [Pa], and mass fractions.""" def setState_HP(self, h, p): """Set the state by specifying the specific enthalpy and the pressure.""" def setState_UV(self, u, v): """Set the state by specifying the specific internal energy and the specific volume.""" def setState_SV(self, s, v): """Set the state by specifying the specific entropy and the specific volume.""" def setState_SP(self, s, p): """Set the state by specifying the specific entropy energy and the pressure.""" def setElectricPotential(self, v): """Set the electric potential.""" def equilibrate(self, XY, solver = 0, rtol = 1.0e-9, maxsteps = 1000, loglevel = 0): """Set to a state of chemical equilibrium holding property pair 'XY' constant. The pair is specified by a two-letter string, which must be one of the set ['TP','TV','HP','SP','SV','UV','PT','VT','PH','PS','VS','VU']. If H, U, S, or V is specified, the value must be the specific value (per unit mass). """ def critTemperature(self): """Critical temperature [K].""" def critPressure(self): """Critical pressure [Pa].""" def critDensity(self): """Critical density [kg/m3].""" def vaporFraction(self): """Vapor fraction.""" def setState_Psat(self, p, vaporFraction): """Set the state of a saturated liquid/vapor mixture by specifying the pressure and vapor fraction.""" def setState_Tsat(self, t, vaporFraction): """Set the state of a saturated liquid/vapor mixture by specifying the temperature and vapor fraction.""" def saveState(self): """Return an array with state information that can later be used to restore the state.""" def restoreState(self, s): """Restore the state to that stored in array s.""" def thermophase(self): """Return the integer index that is used to reference the kernel object. For internal use.""" def thermo_hndl(self): """Return the integer index that is used to reference the kernel object. For internal use.""" ------------------------------------------------------------------------ ROUTINES IN FILE: TRANSPORT.PY """ Cantera provides a set of 'transport manager' classes that manage the computation of transport properties. Every object representing a phase of matter for which transport properties are needed has a transport manager assigned to it. The transport manager has only one job: to compute the values of the transport properties of its assigned phase. A transport manager may do things not apparent to the user in order to improve the speed of transport property evaluation. For example, it may cache intermediate results that depend only on temperature, so that if it happens to be called again at the same temperature (a common occurrence) it can skip over computing the stored temperature-dependent intermediate properties. This is why we use the term 'manager' rather than 'calculator.' In the Cantera kernel, each different transport model is implemented by a different class derived from the base class Transport. A highly simplified class structure is used in the Python interface -- there is only one class. """ """Transport properties. This class provides the Python interface to the family of transport manager classes in the Cantera C++ kernel. A transport manager has one job: to compute transport properties of a phase of matter assigned to it. The phase is represented by an object belonging to a class derived from ThermoPhase. In the C++ kernel, a transport manager implements a single transport model, and is an instance of a subclass of the base class 'Transport'. The structure in Python is a little different. A single class 'Transport' represents any kernel-level transport manager. In addition, multiple kernel-kevel transport managers may be installed in one Python transport manager, although only one is active at any one time. This feature allows switching between transport models.""" def addTransportModel(self, model, loglevel=1): """Add a new transport model. Note that if 'model' is the name of an already-installed transport model, the new transport manager will take the place of the old one, which will no longer be accessible. This method does not change the active model.""" def switchTransportModel(self, model): """Switch to a different transport model.""" def desc(self): """A short description of the active model.""" def viscosity(self): "Viscosity [Pa-s].""" def thermalConductivity(self): """Thermal conductivity. [W/m/K].""" def thermalDiffCoeffs(self): """Return a one-dimensional array of the species thermal diffusion coefficients. Not implemented in all transport models.""" def binaryDiffCoeffs(self): """Two-dimensional array of species binary diffusion coefficients.""" def mixDiffCoeffs(self): """Mixture-averaged diffusion coefficients.""" def multiDiffCoeffs(self): """Two-dimensional array of species multicomponent diffusion coefficients. Not implemented in all transport managers.""" def setParameters(self, type, k, params): """Set model-specific parameters.""" def molarFluxes(self, state1, state2, delta): ------------------------------------------------------------------------ ROUTINES IN FILE: UNITS.PY """Conversion factors to SI (m, kg, kmol, s)""" kmol = 1.0 mol = 1.e-3 molecule = kmol/Avogadro m = 1.0 cm = 0.01 mm = 0.001 m2 = 1.0 cm2 = 1.e-4 mm2 = 1.e-6 A2 = 1.e-20 m3 = 1.0 cm3 = 1.e-6 mm3 = 1.e-9 J = 1.0 kJ = 1000.0 cal = 4.184 kcal = 4184.0 K = 1.0 kJ_per_mol = kJ/mol cal_per_mol = cal/mol kcal_per_mol = kcal/mol mol_per_cm2 = mol/cm/cm molecule_per_cm2 = molecule/cm/cm # pressure Pa = 1.0 kPa = 1000.0 atm = 1.01325e5 bar = 1.0e5 torr = atm/760.0 # mass kg = 1.0 gm = 1000.0 # mass flux kg_per_m2_per_s = 1.0 g_per_cm2_per_s = gm/(cm*cm) lengthdict = {'m':m, 'cm':cm, 'mm':mm} def length(u): def mole(u): def actEnergy(u): ------------------------------------------------------------------------