# Tune dt for quicker solving of ODEs. For these parameters, Case 1 has a much longer timescale # than the other cases. if i == 0: t_end = 1e-3 dt = 1e-5 else: t_end = 5e-5 dt = 1e-7 # Approximate the effective activation energy using finite differences gas = PostShock_fr(Ucj[-1], P1, T1, x, mech) Ts = gas.T; Ps = gas.P Ta = Ts*(1.02) gas.TPX = Ta,Ps,x CVout1 = cvsolve(gas,t_end=t_end,max_step=dt) Tb = Ts*(0.98) gas.TPX = Tb,Ps,x CVout2 = cvsolve(gas,t_end=t_end,max_step=dt) # Approximate effective activation energy for CV explosion taua = CVout1['ind_time'] taub = CVout2['ind_time'] if taua==0 and taub==0: theta_effective_CV.append(0) else: theta_effective_CV.append(1/Ts*((np.log(taua)-np.log(taub))/((1/Ta)-(1/Tb)))) print('--------------------------------------'); ###############################
step = 5; start = 10; stop = 60 nsteps = int((stop-start)/step) for compression_ratio in np.linspace(start,stop,num=nsteps): gas.SVX = s1,1/(compression_ratio*rho1),q T2.append(gas.T) P2.append(gas.P) rho2.append(gas.density) print('Compressed State') print(' Pressure '+str(P2[-1])+' (Pa)') print(' Temperature '+str(T2[-1])+' (K)') print(' Density '+str(rho2[-1])+' (kg/m3)') # Compute constant-volume explosion # need to set final time sufficiently long for low temperature cases CVout = cvsolve(gas,t_end=50.,max_step=1) t_ind.append(CVout['ind_time']) t_pulse.append(CVout['exo_time']) print(' Induction time = '+str(t_ind[-1])+' (s)') print(' Pulse time = '+str(t_pulse[-1])+' (s)') if file: y = (T2[-1], P2[-1]/1e6, t_ind[-1], t_pulse[-1]) fid.write('%1.4g \t %6.2f \t %3.2e \t %3.2e\n' % y) if file: fid.close() P2 = np.asarray(P2); T2 = np.asarray(T2) # plot induction time vs reciprocal temperature
u_cj = cj_speed * gas1.density / gas.density # Find frozen post shock state for given speed gas = PostShock_fr(cj_speed, P1, T1, q, mech) # Solve ZND ODEs, make ZND plots out = zndsolve(gas, gas1, cj_speed, t_end=1e-3, advanced_output=True) # Find CV parameters including effective activation energy gas.TPX = T1, P1, q gas = PostShock_fr(cj_speed, P1, T1, q, mech) Ts = gas.T Ps = gas.P Ta = Ts * 1.02 gas.TPX = Ta, Ps, q CVout1 = cvsolve(gas) Tb = Ts * 0.98 gas.TPX = Tb, Ps, q CVout2 = cvsolve(gas) # Approximate effective activation energy for CV explosion taua = CVout1['ind_time'] taub = CVout2['ind_time'] if taua == 0 and taub == 0: theta_effective_CV = 0 else: theta_effective_CV = 1 / Ts * ((np.log(taua) - np.log(taub)) / ((1 / Ta) - (1 / Tb))) # Find Gavrikov induction length based on 50% limiting species consumption, # fuel for lean mixtures, oxygen for rich mixtures # Westbrook time based on 50% temperature rise
for i in range(npoints): P1[i] = Po*(0.1 +1.1/npoints*(i)) P = P1[i] print('%i : P1 = %.2f atm' % (i+1,P/ct.one_atm)) gas.TPX = T1,P1[i],x ### Constant Volume Explosion Data ### # FIND POST SHOCK STATE FOR GIVEN SPEED cj_speed[i] = CJspeed(P1[i], T1, x, mech) gas = PostShock_fr(cj_speed[i], P1[i], T1, x, mech) Ts[i] = gas.T #frozen shock temperature Ps[i] = gas.P #frozen shock pressure # SOLVE CONSTANT VOLUME EXPLOSION ODES CVout = cvsolve(gas,t_end=1e-4) exo_time_CV[i] = CVout['exo_time'] ind_time_CV[i] = CVout['ind_time'] ### ZND Detonation Data ### # FIND POST SHOCK STATE FOR GIVEN SPEED gas1.TPX = T1,P1[i],x gas = PostShock_fr(cj_speed[i], P1[i], T1, x, mech) Ts[i] = gas.T #frozen shock temperature Ps[i] = gas.P #frozen shock pressure # SOLVE ZND DETONATION ODES ZNDout = zndsolve(gas,gas1,cj_speed[i],advanced_output=True) ind_time_ZND[i] = ZNDout['ind_time_ZND'] ind_len_ZND[i] = ZNDout['ind_len_ZND'] exo_time_ZND[i] = ZNDout['exo_time_ZND']
P1 = 100000 T1 = 300 U1 = 2000 q = 'H2:2 O2:1 N2:3.76' mech = 'Mevel2017.cti' file_name = 'h2air' # Set up gas object gas1 = ct.Solution(mech) gas1.TPX = T1, P1, q # Find post shock state for given speed gas = PostShock_fr(U1, P1, T1, q, mech) # Solve constant volume explosion ODEs, make CV plots CVout = cvsolve(gas) cv_plot(CVout) print('Reaction zone pulse time (exothermic time) = ' + str(CVout['exo_time'])) print('Reaction zone induction time = ' + str(CVout['ind_time'])) ############################################################ # CREATE OUTPUT TEXT FILE ############################################################ fid = open(file_name + '_' + str(U1) + '.txt', 'w') d = datetime.date.today().strftime("%B %d, %Y") P = P1 / ct.one_atm fid.write('# CV: EXPLOSION STRUCTURE CALCULATION\n')
mech = 'Mevel2017.cti' file_name = 'h2air' # Find CJ speed and related data, make CJ diagnostic plots cj_speed,R2,plot_data = CJspeed(P1,T1,q,mech,fullOutput=True) CJspeed_plot(plot_data,cj_speed) # Set up gas object gas1 = ct.Solution(mech) gas1.TPX = T1,P1,q # Find post shock state for given speed gas = PostShock_fr(cj_speed, P1, T1, q, mech) # Solve constant volume explosion ODEs, make cv plots CVout = cvsolve(gas,t_end=1e-6,max_step=1e-8) cv_plot(CVout) print('Reaction zone pulse time (exothermic time) = '+str(CVout['exo_time'])) print('Reaction zone induction time = '+str(CVout['ind_time'])) ############################################################ # CREATE OUTPUT TEXT FILE ############################################################ fid = open(file_name+'_'+str(cj_speed)+'.txt','w') d = datetime.date.today().strftime("%B %d, %Y") P = P1/ct.one_atm
R.append(gas1.density) V.append(1 / R[-1]) a.append(soundspeed_eq(gas1)) u.append(u[-1] + 0.5 * (P[-1] - P[-2]) * (1 / (R[-1] * a[-1]) + 1 / (R[-2] * a[-2]))) # estimate plateau conditions (state 3) by interpolating to find the u = 0 state. P3.append(P[-1] + u[-1] * (P[-2] - P[-1]) / (u[-2] - u[-1])) # Approximate the effective activation energy using finite differences gas = PostShock_fr(Ucj[-1], P1, T1, x, mech) Ts = gas.T Ps = gas.P Ta = Ts * (1.02) gas.TPX = Ta, Ps, x CVout1 = cvsolve(gas, t_end=5e-5) Tb = Ts * (0.98) gas.TPX = Tb, Ps, x CVout2 = cvsolve(gas, t_end=5e-5) # Approximate effective activation energy for CV explosion taua = CVout1['ind_time'] taub = CVout2['ind_time'] if taua == 0 and taub == 0: theta_effective_CV.append(0) else: theta_effective_CV.append(1 / Ts * ((np.log(taua) - np.log(taub)) / ((1 / Ta) - (1 / Tb)))) print('--------------------------------------') ###############################