Hi Greg,
I didn't perfectly understand what you are trying to do but it seems that a class that I wrote with Cantera is suitable for your needs.
You can find it under my github
https://github.com/waltermateriais/xphysics (you will need the whole package because I reuse some formats across files).
An example of PFR is presented on
https://github.com/waltermateriais/xphysics/blob/master/tests/test_xcantera.py line 158.
The class allows for lambda function temperature profile, which can be set through the dictionary element rsetup['operation']['temperature'].
This lambda function (or any arbitrary function) shall be a function of the position only.
Please find below a snippet that could further illustrate how to use the class:
| # ---------------------------------------------------------------------------- |
| # class plug_flow_reactor |
# ----------------------------------------------------------------------------
from xphysics.xcantera
import plug_flow_reactor
# Wall temperature parameters (see function definition below)
pars = {
'773' : (0.04132785, 0.36586941, 1.92089872, 12.41516606),
'873' : (0.03457862, 0.39032227, 1.41582889, 9.79102679),
'973' : (0.02537489, 0.39703098, 0.99659743, 9.77523826),
'1023' : (0.02528152, 0.40339555, 0.88494798, 10.55513796),
'1073' : (0.02507178, 0.40847247, 0.81631547, 11.98899245),
'1123' : (0.02497517, 0.40832661, 0.80065655, 11.97005813),
'1173' : (0.02492942, 0.40810172, 0.78913918, 11.91548263),
'1223' : (0.02596356, 0.40572591, 0.85168097, 11.01722351),
'1273' : (0.02682903, 0.40342913, 0.91051192, 10.36909121)
}
# Conversion mbar->Pa
mbar = 100
# Reactor setup
rsetup = {
'geometry' : {
'radius' : 0.014,
'length' : 0.450,
'slice' : 0.001,
},
'operation' : {
'pressure' : None,
'temperature' : None,
'flowrate' : None
},
'inletgas' :{
'N2' : 1.0-0.36/0.98,
'C2H2' : 0.36,
'CH3COCH3': 0.36/0.98*1.8e-02,
'CH4' : 0.36/0.98*2.0e-03
},
'hommech' : 'norinaga2009.cti',
'follow' : ('C2H2', 'CH4', 'H2'),
'overwrite' : False,
'preheat' : False,
'energy' : 'on',
'transmod' : 'Mix',
'relerr' : 1.0e-09,
'abserr' : 1.0e-20,
'tstep' : 5.0e-03,
'epsx' : 1.0e-09,
'dxm' : 0.005,
'maxiter' : 500
}
# Define the reactor temperature profile.
def Twall(x, Treg):
a1, a2, m1, m2, k = *pars[str(int(Treg))], 1.0
st_trm, nd_trm = np.exp(-(x/a1)**m1), np.exp(-(x/a2)**m2)
return 300+(k*Treg-300)*(1.0-st_trm)-(k*Treg-400)*(1.0-nd_trm)
## P = 30 mbar
rsetup['operation']['flowrate'] = 222.0
rsetup['operation']['pressure'] = 30*mbar
for T in [1123, 1173, 1223]:
try:
rsetup['operation']['temperature'] = T
rsetup['walltmp'] = lambda x : Twall(x, T)
| pfr = plug_flow_reactor(rsetup) |
pfr.plot([
'C2H2'])
except Exception as err:
print(err)
pass
Sorry for the missing documentation, I just passed my thesis defense and I am working right now fixing some bugs and generalizing this class for my current needs.
Walter