From 0440e3fcf13476e287bbdb97064425350fe52340 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 30 Jul 2014 16:59:27 +0000 Subject: [PATCH] [Python/Examples] Update adiabatic.py to use features of the Cython module --- .../cantera/examples/multiphase/adiabatic.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/interfaces/cython/cantera/examples/multiphase/adiabatic.py b/interfaces/cython/cantera/examples/multiphase/adiabatic.py index 5e8d21456..0aa41cf67 100644 --- a/interfaces/cython/cantera/examples/multiphase/adiabatic.py +++ b/interfaces/cython/cantera/examples/multiphase/adiabatic.py @@ -25,40 +25,25 @@ mix_phases = [(gas, 1.0), (carbon, 0.0)] # gaseous fuel species fuel_species = 'CH4' -# air composition -air_N2_O2_ratio = 3.76 - # equivalence ratio range -phi_min = 0.3 -phi_max = 3.5 npoints = 50 +phi = np.linspace(0.3, 3.5, npoints) ############################################################################## mix = ct.Mixture(mix_phases) # create some arrays to hold the data -phi = np.zeros(npoints) tad = np.zeros(npoints) xeq = np.zeros((mix.n_species,npoints)) -# find fuel, nitrogen, and oxygen indices -ifuel = gas.species_index(fuel_species) -io2 = gas.species_index('O2') -in2 = gas.species_index('N2') - if gas.n_atoms(fuel_species,'O') > 0 or gas.n_atoms(fuel_species,'N') > 0: raise "Error: only hydrocarbon fuels are supported." stoich_O2 = gas.n_atoms(fuel_species,'C') + 0.25*gas.n_atoms(fuel_species,'H') for i in range(npoints): - phi[i] = phi_min + (phi_max - phi_min)*i/(npoints - 1) - X = np.zeros(gas.n_species) - X[ifuel] = phi[i] - X[io2] = stoich_O2 - X[in2] = stoich_O2*air_N2_O2_ratio - + X = {fuel_species: phi[i] / stoich_O2, 'O2': 1.0, 'N2': 3.76} # set the gas state gas.TPX = T, P, X