from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *
gas = GRI30()
gas.set(T=600.0, P=0.2*OneAtm, X='CH4:1.1, O2:2, N2:7.52')
dia = 0.1
stroke = 0.18
cl = 0.02
A = math.pi/4 *(dia**2)
vcom = 0.001
vmax = 3
vol_start = (math.pi/4 *(dia**2)*(stroke+cl)) +
vcom
taccel = 5e-4
t_end = 1e-3
r1 = Reactor(gas, volume=vol_start)
env = Reservoir(Air())
w = Wall(left = env, right = r1)
sim = ReactorNet([r1])
f_accel = Polynomial([0.0, vmax / taccel]) # f(t) = vmax * t / taccel
w.setVelocity(f_accel)
t = 0.0
while t <= taccel:
t += 1.0e-6
sim.advance(t)
print sim.time(), r1.temperature(), r1.volume()
sim.setInitialTime(taccel)
f_const = Polynomial([vmax])
w.setVelocity(f_const)
while t < t_end:
t += 1.0e-6
sim.advance(t)
print sim.time(), r1.temperature(), r1.volume()
Hello Daveking,Thank you for responding to my mail, i really appreciate,i'm also simulating combustion in an RCM. Please i have two questions to ask(1). How do you account for the compression period for the constant volume reaction using python-cantera software.(2)How do generate the heat loss text file that is used to run in the senkin simulation.I would really appreciate if you could give more details on that.Thank you.Oku NyongDoctoral ResearcherDepartment of Mechanical EngineeringSir Frederick Mappin Building
University of SheffieldSheffieldS1 3JDEnglandTelephone: 0114 222 7815 (office)Mobile: +447448145651
--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/Wb8eIsh8a2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
To post to this group, send email to canter...@googlegroups.com.
Visit this group at http://groups.google.com/group/cantera-users.
For more options, visit https://groups.google.com/d/optout.
Hello Daveking,Thank you for responding to my mail, i really appreciate,i'm also simulating combustion in an RCM. Please i have two questions to ask(1). How do you account for the compression period for the constant volume reaction using python-cantera software.(2)How do generate the heat loss text file that is used to run in the senkin simulation.I would really appreciate if you could give more details on that.Thank you.
Oku NyongDoctoral ResearcherDepartment of Mechanical EngineeringSir Frederick Mappin Building
University of SheffieldSheffieldS1 3JDEnglandTelephone: 0114 222 7815 (office)Mobile: +447448145651
On 16 June 2014 18:44, daveKing Agbro <eadav...@gmail.com> wrote:
--
Hello,That error is because in the new versions of Cantera, they are imported with import cantera (lowercase "c").Hope it helps,
Bryan
On Friday, February 6, 2015 at 1:34:32 PM UTC-5, Oku wrote:
Hello Ray,ell
--
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.
piston_rate_B = ct.Func1(lambda t: uBfit[0] + uBfit[1]*t + uBfig[2]*t**2)
w = ct.Wall(r, env, A = np.pi/4, velocity=piston_rate_B)
with open('file.txt','w') as output_file:
code goes here
To unsubscribe from this group and stop receiving emails from it, send an email to cantera-users+unsubscribe@googlegroups.com.
...
--
...
--
import cantera as ct
gas = ct.Solution('gri30.cti')
gas.TPX = 1000, 101325, "CH4:1,O2:2,N2:7.52"
reac = ct.IdealGasReactor(gas)
net = ct.ReactorNet([reac])
t_end = 10
t = 0
while t < t_end:
print t, gas.T, gas.P, gas.mole_fraction['CH4']
t = net.step(t_end)
...
--
...
--
...
--
--
...
r = ct.IdealGasReactor(contents = air)
r.volume = 0.0001959
Bryan
...
--
...
Dear Oku,
It depends on how you're modeling the RCM. You can model it as an adiabatic volume expansion; then you need to specify a certain velocity of the wall, just like for the compression stroke. You cannot directly specify the volume of the reactor as a polynomial, you have to specify the velocity as before.
Bryan
On Tuesday, March 10, 2015 at 9:00:47 AM UTC-4, Oku wrote:
Dear Bryan,
I really appreciate your comments and guidance, i seems to get the pressure trace close to the experimental data shown below.Is it possible to represent the volume change with time from a derived polynomial coefficient?please how do i go about the heat loss from the fluid to the walls.
Thank you.
--
...
--
...
--
...
--
tim.append(t)
don't do what I think you want them to do. step takes one internal time step, it does not necessarily get all the way to t. Please read the documentation and understand the difference between step and advance. That said, you never actually use the tim list, so maybe its not a problem.
Bryan
...
--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/Wb8eIsh8a2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
net.max_error_test_fails = 5
failcount = 0
while t < t_end:
try:
net.advance(t + dt)
t += dt
failcount = 0
except:
failcount += 1
#step failed, try again
if failcount > 5:
print "Error in integration, exiting..."
t = t_end + dt
...
" it didn't work,please could you
impliment the second option in the attached code since i find it
confusing.The compression time for experiment is 32.8ms and the
simulation would be running for a total time of 120ms.--
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.
...
--
def run_sim(steps, velocity_fit, outname):
gas = ct.Solution('air.cti')
air = ct.Solution('air.xml')
gas.TPX = 298.0, 1.003306*ct.one_atm, 'O2:0.21,N2:0.78,AR:0.01'
r = ct.IdealGasReactor(contents = air)
r.volume = 0.0002103
env = ct.Reservoir(contents=air, name='environment')
# add a flexible wall (a piston) between r and env
wall = ct.Wall(env, r, A=np.pi*0.0198**2, velocity=velocity_fit, name='rcm')
net = ct.ReactorNet([env, r])
t = 0.0
outfile = open(outname, 'w')
csvfile = csv.writer(outfile)
csvfile.writerow(['time(s)','temperature (K)','pressure(Bar)','volume (m3)','piston velocity,(m/s)'])
tim = []
temp = []
pres = []
vol = []
vel = []
error_count = 0
dt = 1e-4
for n in range(steps):
try:
net.advance(t + dt)
t +=
dt
tim.append(t)
temp.append(r.T)
pres.append(1.e-5*r.thermo.P)
vol.append(r.volume)
vel.append(wall.vdot(t))
csvfile = csv.writer(outfile)
csvfile.writerow([net.time, r.T, r.thermo.P, r.volume, wall.vdot(t)])
#print('%10.3e %10.3f %10.3f %10.3f %14.6e' % (net.time, r.T, r.thermo.P, r.volume, wall.vdot(t)))
error_count = 0
except:
error_count += 1
if error_count >= 5:
print('Maximum error test convergence failures exceded')
sys.exit(-1)
# Read in polynomial coefficients for calculating piston velocity
uBfit_input = np.loadtxt('velcoeff_BTDC_rev.dat')
uBfit = uBfit_input.tolist() # Convert from Numpy array to Python list
uAfit_input = np.loadtxt('velcoeff_ATDC_rev.dat')
uAfit = uAfit_input.tolist()
v_B = ct.Func1(lambda t: (uBfit[0] + uBfit[1]*t + uBfit[2]*t**2 + uBfit[3]*t**3 + uBfit[4]*t**4 + uBfit[5]*t**5 + uBfit[6]*t**6 + uBfit[7]*t**7 - uBfit[8]*t**8))
v_A = ct.Func1(lambda t: (uAfit[0] - uAfit[1]*t + uAfit[2]*t**2 - uAfit[3]*t**3 + uAfit[4]*t**4 - uAfit[5]*t**5 + uAfit[6]*t**6 - uAfit[7]*t**7 + uAfit[8]*t**8 - uAfit[9]*t**9 + uAfit[10]*t**10 - uAfit[11]*t**11 + uAfit[12]*t**12 + uAfit[13]*t**13))
v_stop = ct.Func1(lambda t: [0])
run_sim(350, v_B, "b_out.csv")
run_sim(350, v_A, "a_out.csv")
def forward_euler_int(velocity_profile):
vol_init = 0.0002103
dt = 1e-6
A = np.pi*0.0198**2
t= 0
vol= vol_init
while t < 350e-4: #or 600 for v_A
vol -= A * velocity_profile(t) * dt
t += dt
print(t, vol)
...
--
#Assuming a reactor r, and a wall w
def heat_loss(t):
return 1000 * (w.left.T - w.right.T) #or a polynomial fit, or ...
w.set_heat_flux(heat_loss)
...
--
Hi Oku,1) If you have a compression period, you no longer have a constant volume reactor, so I do not understand this question. In general, you account for the compression period by the same method as the heat loss - by specifying the volume as a function of time.2) The heat loss file is generated from experiments, you can have a look at the website http://combdiaglab.engr.uconn.edu/database/rcm-database for information about the heat loss files from RCM experiments.Bryan
On Tuesday, June 17, 2014 2:54:24 AM UTC-4, OKU E NYONG wrote:Hello Daveking,Thank you for responding to my mail, i really appreciate,i'm also simulating combustion in an RCM. Please i have two questions to ask(1). How do you account for the compression period for the constant volume reaction using python-cantera software.(2)How do generate the heat loss text file that is used to run in the senkin simulation.I would really appreciate if you could give more details on that.Thank you.Oku NyongDoctoral ResearcherDepartment of Mechanical EngineeringSir Frederick Mappin Building
University of SheffieldSheffieldS1 3JDEnglandTelephone: 0114 222 7815 (office)Mobile: +447448145651On 16 June 2014 18:44, daveKing Agbro <eadav...@gmail.com> wrote:Hi Oku,Those parameters are for a rapid compression machine (RCM). Their values are obtained experimentally and you only need them if you are simulating autoignition of fuel combustion in an RCM setup. you wont need to use those parameters if the configuration you are simulating can be represented by a constant volume reactor or constant pressure reactor. You can start with the examples here http://cantera.github.io/dev-docs/sphinx/html/cython/examples/reactors_reactor1.html (Cantera documentation website)RegardsDave
On Saturday, 14 June 2014 09:36:09 UTC+1, mep1...@sheffield.ac.uk wrote:Hello Dave Chavwuko,Please can you explain to me in more details how you went on to simulating the autoignition of fuel using cantera/python as i,m a novice in python. i want to know where you got vcom,vmax,taccel and t_end from your code. i will be glad if you could give me a clue.Thank you.Oku.
On Friday, 13 September 2013 08:00:11 UTC+1, davè chavwuko wrote:Hi every one. I use cantra from python and I am trying to simulate autoignition of DME using a constant volume reactor. Please how do I go about this? Any information could be helpful.--
You received this message because you are subscribed to a topic in the Google Groups "Cantera Users' Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cantera-users/Wb8eIsh8a2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cantera-user...@googlegroups.com.
...
CanteraError thrown by Phase::setDensity():
density must be positive
I read some posts on this group suggesting adjusting r.tol and a.tol to get rid of it but it did not worked.
Pl help me fixing this error.
Also I need to add two more non reactive zones with effective mass transfer from adiabatic core i.e Boundary Layer and Crevice.
Could someone pl also show me how to go about it.