gas1 = ct.Solution(mech) gas1.TPX = T1,P1,q nsp = gas1.n_species # FIND POST SHOCK STATE FOR GIVEN SPEED gas = PostShock_fr(U1, P1, T1, q, mech) # SOLVE REACTION ZONE STRUCTURE ODES out = zndsolve(gas,gas1,U1,t_end=0.2,max_step=0.01,relTol=1e-12,absTol=1e-12) if graphing: # Demonstrate using the figure outputs from znd_plot to make further formatting # adjustments, then saving maxx = max(out['distance']) figT,figP,figM,figTherm,figSpec = znd_plot(out,maxx=maxx,major_species='All', xscale='log',show=False) figSpec.axes[0].set_xlim((1e-5,None)) figSpec.axes[0].set_ylim((1e-10,1)) plt.show() figP.savefig('shk-P.eps',bbox_inches='tight') figT.savefig('shk-T.eps',bbox_inches='tight') figM.savefig('shk-M.eps',bbox_inches='tight') figTherm.savefig('shk-therm.eps',bbox_inches='tight') figSpec.savefig('shk-Y.eps',bbox_inches='tight') # Can't pickle Cantera Solution objects due to underlying C++ structure, # so remove it from dictionary first out.pop('gas1')
import cantera as ct P1 = 100000 T1 = 300 q = 'H2:2 O2:1 N2:3.76' 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 ZND ODEs, make ZND plots znd_out = zndsolve(gas, gas1, cj_speed, t_end=1e-5, advanced_output=True) znd_plot(znd_out) znd_fileout(file_name, znd_out) print('Reaction zone pulse width (exothermic length) = %.4g m' % znd_out['exo_len_ZND']) print('Reaction zone induction length = %.4g m' % znd_out['ind_len_ZND']) print('Reaction zone pulse time (exothermic time) = %.4g s' % znd_out['exo_time_ZND']) print('Reaction zone induction time = %.4g s' % znd_out['ind_time_ZND'])
print('Reaction zone thermicity half-width = {:8.3e} m'.format( out['exo_len_ZND'])) print('Reaction zone maximum thermicity distance = {:8.3e} m'.format( out['ind_len_ZND'])) print('Reaction zone thermicity half-time = {:8.3e} s'.format( out['exo_time_ZND'])) print('Reaction zone maximum thermicity time = {:8.3e} s'.format( out['ind_time_ZND'])) print('Reaction zone width (u_cj/sigmadot_max) = {:8.3e} m'.format( max_thermicity_width_ZND)) print(' ') print('CV computation results; ') print('Time to dT/dt_max = {:8.3e} s'.format(CVout1['ind_time'])) print('Distance to dT/dt_max = {:8.3e} m'.format(CVout1['ind_time'] * out['U'][0])) print('Reduced activation energy) = {:8.3e}'.format(theta_effective_CV)) print('Time to 50% consumption = {:8.3e} s'.format(t_gav)) print('Distance to 50% consumption = {:8.3e} m'.format(x_gav)) print('Time to 50% temperature rise = {:8.3e} s'.format(t_west)) print('Distance to 50% temperature = {:8.3e} m'.format(x_west)) print(' ') print('Cell size predictions ') print('Gavrikov correlation = {:8.3e} m'.format(cell_gav)) print('Ng et al Chi Parameter = {:8.3e} m'.format(chi_ng)) print('Ng et al correlation = {:8.3e} m'.format(cell_ng)) print('Westbrook correlation = {:8.3e} m'.format(29 * x_west)) znd_plot(out, maxx=0.001, major_species=['H2', 'O2', 'H2O'], minor_species=['H', 'O', 'OH', 'H2O2', 'HO2'])