*** empty log message ***
This commit is contained in:
parent
27c66a8674
commit
2745d841dc
4 changed files with 100 additions and 22 deletions
|
|
@ -300,20 +300,38 @@ class Valve(FlowDevice):
|
||||||
|
|
||||||
#------------- Wall ---------------------------
|
#------------- Wall ---------------------------
|
||||||
|
|
||||||
|
_wallcount = 0
|
||||||
|
|
||||||
class Wall:
|
class Wall:
|
||||||
"""
|
"""
|
||||||
A Wall separates two reactors. Any number of walls may be created
|
A Wall separates two reactors. Any number of walls may be created
|
||||||
between any pair of reactors.
|
between any pair of reactors.
|
||||||
"""
|
"""
|
||||||
def __init__(self, left=None, right=None, area=1.0):
|
def __init__(self, left=None, right=None, name = '',
|
||||||
|
A = 1.0, K = 0.0, U = 0.0,
|
||||||
|
Q = None, Vdot = None,
|
||||||
|
kinetics = [None, None]):
|
||||||
typ = 0
|
typ = 0
|
||||||
self.__wall_id = _cantera.wall_new(typ)
|
self.__wall_id = _cantera.wall_new(typ)
|
||||||
|
|
||||||
|
global _wallcount
|
||||||
|
if name == '':
|
||||||
|
_nm = 'Wall_'+`_wallcount`
|
||||||
|
else:
|
||||||
|
_nm = name
|
||||||
|
_wallcount += 1
|
||||||
|
|
||||||
if left and right:
|
if left and right:
|
||||||
self.install(left, right)
|
self.install(left, right)
|
||||||
self.setArea(area)
|
elif left or right:
|
||||||
self.setExpansionRateCoeff(0.0)
|
raise CanteraError('both left and right reactors must be specified.')
|
||||||
self.setExpansionRate()
|
self.setArea(A)
|
||||||
self.setHeatFlux()
|
self.setExpansionRateCoeff(K)
|
||||||
|
self.setExpansionRate(Vdot)
|
||||||
|
self.setHeatTransferCoeff(U)
|
||||||
|
self.setHeatFlux(Q)
|
||||||
|
|
||||||
|
self.setKinetics(kinetics[0],kinetics[1])
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -370,10 +388,8 @@ class Wall:
|
||||||
_cantera.wall_setExpansionRate(self.__wall_id, n)
|
_cantera.wall_setExpansionRate(self.__wall_id, n)
|
||||||
|
|
||||||
def install(self, left, right):
|
def install(self, left, right):
|
||||||
#self.left = left
|
left._addWall(self)
|
||||||
#self.right = right
|
right._addWall(self)
|
||||||
left._addWall(this)
|
|
||||||
right._addWall(this)
|
|
||||||
_cantera.wall_install(self.__wall_id, left.reactor_id(),
|
_cantera.wall_install(self.__wall_id, left.reactor_id(),
|
||||||
right.reactor_id())
|
right.reactor_id())
|
||||||
|
|
||||||
|
|
@ -405,17 +421,70 @@ class Wall:
|
||||||
raise 'unknown parameter: ',item
|
raise 'unknown parameter: ',item
|
||||||
|
|
||||||
|
|
||||||
|
class ReactorNet:
|
||||||
|
|
||||||
|
"""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 __init__(self, reactorlist = None):
|
||||||
|
"""
|
||||||
|
Create a new ReactorNet instance. If a list of reactors is supplied,
|
||||||
|
these will be added to the network.
|
||||||
|
"""
|
||||||
|
self._reactors = []
|
||||||
|
self.__reactornet_id = _cantera.reactornet_new()
|
||||||
|
if reactorlist:
|
||||||
|
for r in reactorlist:
|
||||||
|
self.add(r)
|
||||||
|
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
"""Delete the reactor network instance. The reactors in the
|
||||||
|
network are not deleted."""
|
||||||
|
_cantera.reactornet_del(self.__reactornet_id)
|
||||||
|
|
||||||
|
|
||||||
|
def reactornet_id(self):
|
||||||
|
""" The integer index used to access the
|
||||||
|
kernel reactornet object. For internal use. """
|
||||||
|
return self.__reactornet_id
|
||||||
|
|
||||||
|
|
||||||
|
def add(self, reactor):
|
||||||
|
"""
|
||||||
|
Add a reactor to the network.
|
||||||
|
"""
|
||||||
|
self._reactors.append(reactor)
|
||||||
|
_cantera.reactornet_addreactor(self.__reactornet_id, reactor.reactor_id())
|
||||||
|
|
||||||
|
|
||||||
|
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"""
|
||||||
|
_cantera.reactornet_setInitialTime(self.__reactornet_id, t0)
|
||||||
|
|
||||||
|
def advance(self, time):
|
||||||
|
"""Advance the state of the reactor network in time from the current
|
||||||
|
time to time 'time'."""
|
||||||
|
return _cantera.reactornet_advance(self.__reactornet_id, time)
|
||||||
|
|
||||||
|
def step(self, time):
|
||||||
|
"""Take a single internal time step toward time 'time'.
|
||||||
|
The time after taking the step is returned."""
|
||||||
|
return _cantera.reactornet_step(self.__reactornet_id, time)
|
||||||
|
|
||||||
|
def reactors(self):
|
||||||
|
return self._reactors
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ class ReactorNet:
|
||||||
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
"""Delete the reactor network instance."""
|
"""Delete the reactor network instance. The reactors in the
|
||||||
|
network are not deleted."""
|
||||||
_cantera.reactornet_del(self.__reactornet_id)
|
_cantera.reactornet_del(self.__reactornet_id)
|
||||||
|
|
||||||
|
|
||||||
def reactornet_id(self):
|
def reactornet_id(self):
|
||||||
"""
|
""" The integer index used to access the
|
||||||
The integer index used to access the kernel reactornet object. For internal use.
|
kernel reactornet object. For internal use. """
|
||||||
"""
|
|
||||||
return self.__reactornet_id
|
return self.__reactornet_id
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -68,3 +68,7 @@ class ReactorNet:
|
||||||
"""Take a single internal time step toward time 'time'.
|
"""Take a single internal time step toward time 'time'.
|
||||||
The time after taking the step is returned."""
|
The time after taking the step is returned."""
|
||||||
return _cantera.reactornet_step(self.__reactornet_id, time)
|
return _cantera.reactornet_step(self.__reactornet_id, time)
|
||||||
|
|
||||||
|
def reactors(self):
|
||||||
|
return self._reactors
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -244,8 +244,12 @@ namespace Cantera {
|
||||||
const doublereal* mw = m_mix->molecularWeights().begin();
|
const doublereal* mw = m_mix->molecularWeights().begin();
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
|
if (m_chem) {
|
||||||
m_kin->getNetProductionRates(ydot+2); // "omega dot"
|
m_kin->getNetProductionRates(ydot+2); // "omega dot"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fill(ydot + 2, ydot + 2 + m_nsp, 0.0);
|
||||||
|
}
|
||||||
for (n = 0; n < m_nsp; n++) {
|
for (n = 0; n < m_nsp; n++) {
|
||||||
ydot[n+2] *= m_vol; // moles/s/m^3 -> moles/s
|
ydot[n+2] *= m_vol; // moles/s/m^3 -> moles/s
|
||||||
ydot[n+2] += m_sdot[n];
|
ydot[n+2] += m_sdot[n];
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ namespace Cantera {
|
||||||
|
|
||||||
void setKineticsMgr(Kinetics& kin) {
|
void setKineticsMgr(Kinetics& kin) {
|
||||||
m_kin = &kin;
|
m_kin = &kin;
|
||||||
|
if (m_kin->nReactions() == 0) disableChemistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue