From d671ca745c81436bad62f04ddc6215224bd4bcbf Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Mon, 15 Nov 2004 03:17:15 +0000 Subject: [PATCH] initial import --- Cantera/cxx/demos/flamespeed.cpp | 214 +++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 Cantera/cxx/demos/flamespeed.cpp diff --git a/Cantera/cxx/demos/flamespeed.cpp b/Cantera/cxx/demos/flamespeed.cpp new file mode 100644 index 000000000..d99682a90 --- /dev/null +++ b/Cantera/cxx/demos/flamespeed.cpp @@ -0,0 +1,214 @@ +#ifdef WIN32 +#pragma warning(disable:4786) +/*Warning messages that are identified as Warning C4786: are created +when MSVC generates extremely long names that it uses for debugging +purposes. The long names are generated by the template expansion +process and the warning messages normally can be ignored. Since these +warnings tend to hide more interesting warning/error messages, you may +wish to suppress the warning*/ +#endif + +#include +#include +#include +#include +#include + +// include additional header files here if needed +#ifdef WIN32 +#include +#endif + +int main(int argc, char** argv) { + try { + int i; + // your code goes here + IdealGasMix gas("gri30.cti","gri30_mix"); + //IdealGasMix gas("temp_phi_1.0_sp.cti","gas"); + + doublereal temp = 300.0; // K + doublereal pressure = 1.0*OneAtm; //atm + doublereal uin=0.3; //m/sec + + gas.setState_TPX(temp, pressure, "CH4:1.0, O2:2.0, N2:7.52"); + int nsp = gas.nSpecies(); + + vector_fp x; + x.resize(nsp); + + doublereal phi=1.1; + cout << "Enter phi: "; + cin >> phi; + cout << endl; + + doublereal C_atoms=1.0; + doublereal H_atoms=4.0; + doublereal ax=C_atoms+H_atoms/4.0; + doublereal fa_stoic=1.0/(4.76*ax); + for(int k=0;k yin; + double *yin=new double[nsp]; + gas.getMassFractions(yin); + + try { + equilibrate(gas,HP); + } + catch (CanteraError) { + showErrors(cout); + } + double *yout=new double[nsp]; + gas.getMassFractions(yout); + doublereal rho_out = gas.density(); + doublereal Tad=gas.temperature(); + cout << phi<<' '< domains; + domains.push_back(&inlet); + domains.push_back(&flow); + domains.push_back(&outlet); + + OneDim flamesim(domains); + + Sim1D flame(domains); + + //----------- Supply initial guess---------------------- + + vector_fp locs; + vector_fp value; + + locs.resize(3); + value.resize(3); + + //ramp values from inlet to adiabatic flame conditions + // over 70% of domain and then level off at equilibrium + double z1=0.7; + + double uout; + uout=inlet.mdot()/rho_out; + uin=inlet.mdot()/rho_in; + locs[0]=0.0; locs[1]=z1; locs[2]=1.0; + value[0]=uin; value[1]=uout; value[2]=uout; + flame.setInitialGuess("u",locs,value); + + value[0]=temp; value[1]=Tad; value[2]=Tad; + flame.setInitialGuess("T",locs,value); + + for(i=0;i zvec,Tvec,COvec,CO2vec,Uvec; + + printf("\n%9s\t%8s\t%5s\t%7s\n","z (m)", "T (K)", "U (m/s)", "Y(CO)"); + for(int n=0;n