


#------------------------------------------------------------------------------- # Phases data #------------------------------------------------------------------------------- stoichiometric_solid( name = "wood", species = "wood", density = (700, "kg/m3") ) ideal_gas( name = "gas", species = "gas" ) ideal_gas( name = "tar", species = "tar" ) stoichiometric_solid( name = "char", species = "char", density = (110, "kg/m3") ) #------------------------------------------------------------------------------- # Species data #------------------------------------------------------------------------------- species( name="wood" ) species( name = "gas" ) species( name = "tar" ) species( name = "char" ) #------------------------------------------------------------------------------- # Reaction data #------------------------------------------------------------------------------- # Reaction 1 reaction("wood => gas", [1.4345e4, 0, 88.6]) # Reaction 2 reaction("wood => tar", [4.125e6, 0, 112.7]) # Reaction 3 reaction("wood => char", [7.3766e5, 0, 106.5]) # Reaction 4 reaction("tar => gas", [4.28e6, 0, 108]) # Reaction 5 reaction("tar => char", [1.0e6, 0, 108])and the Python file blasi_reactor.py that uses the above cti file is:
import cantera as ct import matplotlib.pyplot as plt tk = 773.15 # temperature [K] p = 101325.0 # pressure [Pa] gas = ct.Solution('blasi.cti') gas.TP = tk, p r = ct.IdealGasConstPressureReactor(gas) sim = ct.ReactorNet([r]) time = 0.0 states = ct.SolutionArray(gas, extra=['t']) for n in range(50): time += 1.0 sim.advance(time) states.append(r.thermo.state, t=time) plt.figure() plt.plot(states.t, states.X[:, gas.species_index('wood')]) plt.plot(states.t, states.X[:, gas.species_index('gas')]) plt.plot(states.t, states.X[:, gas.species_index('tar')]) plt.plot(states.t, states.X[:, gas.species_index('char')]) plt.xlabel('Time [s]') plt.ylabel('Concentration [kg/m^3]') plt.show() Traceback (most recent call last): File "blasi_cantera.py", line 9, in <module> r = ct.IdealGasConstPressureReactor(gas) File "interfaces/cython/cantera/reactor.pyx", line 191, in cantera._cantera.Reactor.__init__ File "interfaces/cython/cantera/reactor.pyx", line 28, in cantera._cantera.ReactorBase.__init__ File "interfaces/cython/cantera/reactor.pyx", line 199, in cantera._cantera.Reactor.insert File "interfaces/cython/cantera/reactor.pyx", line 50, in cantera._cantera.ReactorBase.insert cantera._cantera.CanteraError: *********************************************************************** CanteraError thrown by IdealGasReactor::setThermoMgr: Incompatible phase type provided ***********************************************************************--
You received this message because you are subscribed to the Google Groups "Cantera Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-user...@googlegroups.com.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at https://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/d/optout.
On Dec 11, 2018, at 5:04 AM, 'Rodolfo Rodrigues' via Cantera Users' Group <canter...@googlegroups.com> wrote:
Hi Gavin,
You have to improve your CTI file in order to get results. Cantera verifies the element balance for chemical reactions so you have to set the atoms composition of all species as well as h, s, and cp values.
I attached a CTI file sample that uses wood gasification kinetics based on Di Blasi (2004) and Tinaut et al. (2008).
Regards,Rodolfo
Em seg, 10 de dez de 2018 às 01:03, Gavin <wig...@gmail.com> escreveu:
I'm trying to use Cantera with a kinetic scheme for biomass pyrolysis to look at concentration changes over time in a batch reactor. An overview of the kinetics is shown below along with a reference to the paper. Notice that species concentrations are on a mass basis such as kg/m^3.
<kinetics-1.png>
<kinetics-2.png>
- wood = biomass which is typically pine
- gas = lumped species which contains light non-condensable gases
- tar = lumped species of condensable pyrolysis vapors
- char = fully pyrolyzed wood, basically carbon
Reference: Colomba Di Blasi. Analysis of Convection and Secondary Reaction Effects Within Porous Solid Fuels Undergoing Pyrolysis. Combustion Science and Technology, vol. 90, pp. 315-340, 1993.
Assuming an initial wood concentration of 1.0, I can solve the system of reaction rate equations with Python and plot the conversion with time as shown below.
<wood.cti>
cantera (master *) $ python blasi_reactor.py
Traceback (most recent call last):
File "blasi_reactor.py", line 9, in <module>
r = ct.IdealGasConstPressureReactor(gas)
File "interfaces/cython/cantera/reactor.pyx", line 191, in cantera._cantera.Reactor.__init__
File "interfaces/cython/cantera/reactor.pyx", line 28, in cantera._cantera.ReactorBase.__init__
File "interfaces/cython/cantera/reactor.pyx", line 199, in cantera._cantera.Reactor.insert
File "interfaces/cython/cantera/reactor.pyx", line 50, in cantera._cantera.ReactorBase.insert
cantera._cantera.CanteraError:
***********************************************************************
CanteraError thrown by IdealGasReactor::setThermoMgr:
Incompatible phase type provided
***********************************************************************r = ct.ConstPressureReactor(gas)
***********************************************************************
CanteraError thrown by CVodesIntegrator::integrate:
CVodes error encountered. Error code: -9
The right-hand side routine failed at the first call.
Exceptions caught during RHS evaluation:
no convergence. dt = 100
Components with largest weighted error estimates:
1: 6.74155e-295
0: 9.63079e-304
2: 1.58101e-313
***********************************************************************
gas = ct.Solution('blasi.cti')
stoichiometric_solid( name = "wood", elements = "C", species = "wood", density = (700, "kg/m3"))gas = ct.Solution('blasi.cti')
gas.TP = tk, p
gas.X = 'wood:1, gas:1'***********************************************************************
(home) (xenial)nick@localhost:~/Documents/paper_repos/defense$ python test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
gas.X = 'wood:1, gas:1'
File "interfaces/cython/cantera/thermo.pyx", line 553, in cantera._cantera.ThermoPhase.X.__set__ (interfaces/cython/cantera/_cantera.cpp:18455)
cantera._cantera.CanteraError:
***********************************************************************
CanteraError thrown by Phase::setMoleFractionsByName:
Unknown species 'gas'
***********************************************************************
ideal_gas( name = "gas", elements = "C", species = "tar gas wood char")gas = ct.Solution('blasi.cti')gas.TP = tk, pgas.X = 'wood:1'r = ct.IdealGasConstPressureReactor(gas)***********************************************************************
CanteraError thrown by CVodesIntegrator::integrate:
CVodes error encountered. Error code: -9
The right-hand side routine failed at the first call.
Exceptions caught during RHS evaluation:
ydot contains non-finite elements:
ydot[1] = nan
Components with largest weighted error estimates:
0: 0
1: 0
2: 0
3: 0
4: 0
5: 0
***********************************************************************
#-------------------------------------------------------------------------------# Phases data#-------------------------------------------------------------------------------
ideal_gas( elements="C", species="wood gas tar char", reactions="all")
#-------------------------------------------------------------------------------# Species data#-------------------------------------------------------------------------------
species( name = "wood", atoms = "C:1")
species( name = "gas", atoms = "C:1")
species( name = "tar", atoms = "C:1")
species( name = "char", atoms = "C:1")
#-------------------------------------------------------------------------------# Reaction data#-------------------------------------------------------------------------------
# Reaction 1reaction("wood => gas", [1.4345e4, 0, 88.6])
# Reaction 2reaction("wood => tar", [4.125e6, 0, 112.7])
# Reaction 3reaction("wood => char", [7.3766e5, 0, 106.5])
# Reaction 4reaction("tar => gas", [4.28e6, 0, 108])
# Reaction 5reaction("tar => char", [1.0e6, 0, 108])
import cantera as ctimport matplotlib.pyplot as plt
tk = 773.15 # temperature [K]p = 101325.0 # pressure [Pa]
gas = ct.Solution('blasi.cti')gas.TP = tk, pr = ct.IdealGasConstPressureReactor(gas, energy='off')
sim = ct.ReactorNet([r])time = 0.0states = ct.SolutionArray(gas, extra=['t'])
for n in range(30): time += 1.0 sim.advance(time) states.append(r.thermo.state, t=time)
plt.figure()plt.plot(states.t, states.X[:, gas.species_index('wood')], label='wood')plt.plot(states.t, states.X[:, gas.species_index('gas')], label='gas')plt.plot(states.t, states.X[:, gas.species_index('tar')], label='tar')plt.plot(states.t, states.X[:, gas.species_index('char')], label='char')plt.xlabel('Time [s]')plt.ylabel('Concentration [kg/m^3]')plt.legend(loc='best')plt.show()

import cantera as ctimport matplotlib.pyplot as plt
tk = 773.15 # temperature [K]p = 101325.0 # pressure [Pa]c0 = 'wood:1 gas:0 char:0 tar:0' # initial concentrations
gas = ct.Solution('blasi.cti')gas.TPX = tk, p, c0r = ct.IdealGasConstPressureReactor(gas, energy='off')
sim = ct.ReactorNet([r])time = 0.0states = ct.SolutionArray(gas, extra=['t'])
for n in range(25): time += 1.0 sim.advance(time) states.append(r.thermo.state, t=time)
plt.figure()plt.plot(states.t, states.X[:, gas.species_index('wood')], label='wood')plt.plot(states.t, states.X[:, gas.species_index('gas')], label='gas')plt.plot(states.t, states.X[:, gas.species_index('tar')], label='tar')plt.plot(states.t, states.X[:, gas.species_index('char')], label='char')plt.xlabel('Time [s]')plt.ylabel('Concentration [kg/m$^3$]')plt.legend(loc='best')plt.show()
import cantera as ctimport matplotlib.pyplot as plt
tk = 773.15 # temperature [K]p = 101325.0 # pressure [Pa]c0 = 'wood:1 gas:0 char:0 tar:0' # initial concentrations
gas = ct.Solution('blasi.cti')gas.TPX = tk, p, c0r = ct.IdealGasConstPressureReactor(gas, energy='off')
sim = ct.ReactorNet([r])time = 0.0states = ct.SolutionArray(gas, extra=['t'])
while sim.time <= 1e-5: sim.step() states.append(r.thermo.state, t=sim.time)
plt.figure()plt.plot(states.t, states.X[:, gas.species_index('wood')], label='wood')plt.plot(states.t, states.X[:, gas.species_index('gas')], label='gas')plt.plot(states.t, states.X[:, gas.species_index('tar')], label='tar')plt.plot(states.t, states.X[:, gas.species_index('char')], label='char')plt.xlabel('Time [s]')plt.ylabel('Concentration [kg/m$^3$]')plt.legend(loc='best')plt.show()
#-------------------------------------------------------------------------------# Phases data#-------------------------------------------------------------------------------
units( length="m", mass="kg", quantity="mol", time="s", energy="J", act_energy="kJ/mol", pressure="Pa")import cantera as ctimport matplotlib.pyplot as pltimport numpy as npimport timeit
# Cantera reactor example with Blasi biomass pyrolysis kinetics# ----------------------------------------------------------------------------
ti = timeit.default_timer()
tk = 773.15 # temperature [K]p = 101325.0 # pressure [Pa]c0 = 'wood:1, gas:0, char:0, tar:0' # initial concentrations [kg/m^3]
gas = ct.Solution('blasi_kinetics.cti')gas.TPX = tk, p, c0r = ct.IdealGasConstPressureReactor(gas, energy='off')
sim = ct.ReactorNet([r])states = ct.SolutionArray(gas, extra=['t'])
# time vector to evaluate reaction rates [s]time = np.linspace(0, 25, num=1000)
for tm in time: sim.advance(tm) states.append(r.thermo.state, t=tm)
print(f'time cantera: {timeit.default_timer() - ti:.4g} s')
# Plot# ----------------------------------------------------------------------------
def style(): plt.box(on=False) plt.grid(color='0.9') plt.tick_params(color='0.9') plt.tight_layout()
plt.figure()plt.plot(states.t, states.X[:, gas.species_index('wood')], label='wood')plt.plot(states.t, states.X[:, gas.species_index('gas')], label='gas')plt.plot(states.t, states.X[:, gas.species_index('tar')], label='tar')plt.plot(states.t, states.X[:, gas.species_index('char')], label='char')plt.legend(loc='best')plt.xlabel('Time [s]')plt.ylabel('Concentration [kg/m$^3$]')plt.title('Cantera example')style()
plt.show()c0 = 'wood:1, gas:0, char:0, tar:0'
c0 = 'wood:2, gas:0, char:0, tar:0'
y0 = 'wood:1, gas:0, char:0, tar:0' # initial mass fractions [-]
gas = ct.Solution('blasi_kinetics.cti')gas.TPY = tk, p, y0r = ct.IdealGasConstPressureReactor(gas, energy='off')plt.ylabel('Mass fractions [-]')