def _setValveCharacteristic(self, f): """Set or reset the valve characteristics. """ if type(f) == types.InstanceType: self.setFunction(f) else: raise CanteraError("Wrong type for valve characteristic function.")
def kinetics(self, side='left'): if side == 'left': return self._leftkin elif side == 'right': return self._rightkin else: raise CanteraError("side must be 'left' or 'right'")
def __init__(self, left, right, name = '', A = 1.0, K = 0.0, U = 0.0, Q = None, velocity = None, kinetics = [None, None]): """ Constructor arguments: left - Reactor or reservoir on the left. Required. right - Reactor or reservoir on the right. Required. name - Name string. If omitted, the name is 'Wall_n', where 'n' is an integer assigned in the order walls are created. A - Wall area [m^2]. Defaults to 1.0 m^2. K - Wall expansion rate parameter [m/s/Pa]. Defaults to 0.0. U - Overall heat transfer coefficient [W/m^2]. Defaults to 0.0 (adiabbatic wall). Q - Heat flux function \f$ q_0(t) \f$ [W/m^2]. Optional. Default: \f$ q_0(t) = 0.0 \f$. velocity - Wall velocity function \f$ v_0(t) \f$ [m/s]. Default: \f$ v_0(t) = 0.0 \f$. kinetics - Surface reaction mechanisms for the left-facing and right-facing surface, respectively. These must be instances of class Kinetics, or of a class derived from Kinetics, such as Interface. If chemistry occurs on only one side, enter 'None' for the non-reactive side. """ typ = 0 self.__wall_id = _cantera.wall_new(typ) global _wallcount if name == '': _nm = 'Wall_'+`_wallcount` else: _nm = name _wallcount += 1 if left and right: self.install(left, right) else: raise CanteraError('both left and right reactors must be specified.') self.setArea(A) self.setExpansionRateCoeff(K) self.setVelocity(velocity) self.setHeatTransferCoeff(U) self.setHeatFlux(Q) self.setKinetics(kinetics[0],kinetics[1]) self._paramid = []
def netProductionRates(self, phase=None): w = _cantera.kin_getarray(self.ckin, 70) if phase: kp = phase.thermophase() if self._phnum.has_key(kp): n = self._phnum[kp] return w[self._end[n]:self._end[n + 1]] else: raise CanteraError('unknown phase') else: return w
def __init__(self, kintype=-1, thrm=0, xml_phase=None, id=None, phases=[]): """ Build a kinetics manager from an XML specification. :param kintype: Integer specifying the type of kinetics manager to create. :param root: Root of a CTML tree :param id: id of the 'kinetics' node within the tree that contains the specification of the parameters. """ np = len(phases) 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() p1 = -1 p2 = -1 p3 = -1 p4 = -1 if np >= 2: p1 = phases[1].thermophase() if np >= 3: p2 = phases[2].thermophase() if np >= 4: p3 = phases[3].thermophase() if np >= 5: p4 = phases[4].thermophase() if np >= 6: raise CanteraError("a maximum of 4 neighbor phases allowed") self.ckin = _cantera.KineticsFromXML(xml_phase, p0, p1, p2, p3, p4) self._np = self.nPhases() for nn in range(self._np): p = self.phase(nn) self._phnum[p.thermophase()] = nn self._end.append(self._end[-1] + p.nSpecies()) for k in range(p.nSpecies()): self._sp.append(p.speciesName(k))
def __init__(self, left, right, name='', A=1.0, K=0.0, U=0.0, Q=None, velocity=None, kinetics=[None, None]): """ :param left: Reactor or reservoir on the left. Required. :param right: Reactor or reservoir on the right. Required. :param name: Name string. If omitted, the name is ``'Wall_n'``, where ``'n'`` is an integer assigned in the order walls are created. :param A: Wall area [m^2]. Defaults to 1.0 m^2. :param K: Wall expansion rate parameter [m/s/Pa]. Defaults to 0.0. :param U: Overall heat transfer coefficient [W/m^2]. Defaults to 0.0 (adiabatic wall). :param Q: Heat flux function :math:`q_0(t)` [W/m^2]. Optional. Default: :math:`q_0(t) = 0.0`. :param velocity: Wall velocity function :math:`v_0(t)` [m/s]. Default: :math:`v_0(t) = 0.0`. :param kinetics: Surface reaction mechanisms for the left-facing and right-facing surface, respectively. These must be instances of class Kinetics, or of a class derived from Kinetics, such as Interface. If chemistry occurs on only one side, enter ``None`` for the non-reactive side. """ typ = 0 self.__wall_id = _cantera.wall_new(typ) global _wallcount if name == '': _nm = 'Wall_' + ` _wallcount ` else: _nm = name _wallcount += 1 if left and right: self.install(left, right) else: raise CanteraError( 'both left and right reactors must be specified.') self.setArea(A) self.setExpansionRateCoeff(K) self.setVelocity(velocity) self.setHeatTransferCoeff(U) self.setHeatFlux(Q) self.setKinetics(kinetics[0], kinetics[1]) self._paramid = []