当前位置: 首页>>代码示例>>C++>>正文


C++ XML_Node::findNameID方法代码示例

本文整理汇总了C++中XML_Node::findNameID方法的典型用法代码示例。如果您正苦于以下问题:C++ XML_Node::findNameID方法的具体用法?C++ XML_Node::findNameID怎么用?C++ XML_Node::findNameID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_Node的用法示例。


在下文中一共展示了XML_Node::findNameID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) {
  int i;
  //double ca[10];

  std::string ctv = CANTERA_VERSION;
  bool canHandle = ctversionCanHandle(ctv);

  try {
    string id;
    Cantera::PrintCtrl pc;

    XML_Node *xc = new XML_Node();
    string path = findInputFile("ReactionSurf.xml");
    ctml::get_CTML_Tree(xc, path);

    XML_Node * const xg = xc->findNameID("phase", "reaction_surface");
    if (!xg) {
      throw CanteraError("couldn't find file", "");
    }
    ThermoPhase *surfTP = newPhase(*xg);

  
    ThermoPhase *gasTP =  newPhase("gas.xml", "");
    //IdealGasPhase *gasTP = new IdealGasPhase("gas.xml", "");

    string s_cao_s = "CaO_Solid.xml";
    id = "CaO(S)";
    Cantera::ThermoPhase *cao_s = Cantera::newPhase(s_cao_s, id);

    string  s_caco3_s = "CaCO3_Solid.xml";
    id = "CaCO3(S)";
    Cantera::ThermoPhase *caco3_s = Cantera::newPhase(s_caco3_s, id);

    string  s_c_s = "C_Solid.xml";
    id = "C(S)";
    Cantera::ThermoPhase *c_s = Cantera::newPhase(s_c_s, id);

    string  s_fe3o4_s = "Fe3O4_Solid.xml";
    id = "Fe3O4(S)";
    Cantera::ThermoPhase *fe3o4_s = Cantera::newPhase(s_fe3o4_s, id);

    string  s_feo_s = "FeO_Solid.xml";
    id = "FeO(S)";
    Cantera::ThermoPhase *feo_s = Cantera::newPhase(s_feo_s, id);


    string  s_fe_s = "Fe_Solid.xml";
    id = "Fe(S)";
    Cantera::ThermoPhase *fe_s = Cantera::newPhase(s_fe_s, id);

    //   string s_reactSurf = "ReactionSurf.xml";
    // id = "reaction_surface";
    //Cantera::ThermoPhase *surfTP = Cantera::newPhase(s_reactSurf, id);


    vector<ThermoPhase *> phaseList;
     
    phaseList.push_back(gasTP);
    phaseList.push_back(cao_s);
    phaseList.push_back(caco3_s);
    phaseList.push_back(c_s);
    phaseList.push_back(fe3o4_s);
    phaseList.push_back(feo_s);
    phaseList.push_back(fe_s);
    phaseList.push_back(surfTP);
    InterfaceKinetics *iKin_ptr = new InterfaceKinetics();
    importKinetics(*xg, phaseList, iKin_ptr);
    //    int nr = iKin_ptr->nReactions();
   

    double x[20];
    for (i = 0; i < 20; i++) x[i] = 0.0;
    double mll[20];
    for (i = 0; i < 20; i++) mll[i] = 0.0;
    //int ikca0 = iKin_ptr->kineticsSpeciesIndex("CaO(S)");
    //int ikcaco3 = iKin_ptr->kineticsSpeciesIndex("CaCO3(S)");
    //int ikco2 = iKin_ptr->kineticsSpeciesIndex("CO2");


    int igco2 = gasTP->speciesIndex("CO2");
    int igo2  = gasTP->speciesIndex("O2");
    int ign2  = gasTP->speciesIndex("N2");

    mll[igco2] = 0.2;
    mll[igo2] = 0.1;
    mll[ign2] = 0.7;
    double Temp = 1000.;
    gasTP->setState_TPX(Temp, OneAtm, mll);
   
    double p = 20.0*OneAtm/760.0;
    
    for (i = 0; i < 20; i++) x[i] = 0.0;
   

    for (i = 0; i < 20; i++) x[i] = 0.0;
    x[0] = 1.0;


    // Set the bath gas of TempK and 1 atm
    cao_s->setState_TP(Temp, OneAtm);
//.........这里部分代码省略.........
开发者ID:hkmoffat,项目名称:cantera,代码行数:101,代码来源:stoichSolidKinetics.cpp

示例2: main

int main(int argc, char** argv) {
    int i, k;
    string infile = "diamond.xml";
 
    try {
      XML_Node *xc = new XML_Node();
      string path = findInputFile(infile);
      ctml::get_CTML_Tree(xc, path);

      XML_Node * const xg = xc->findNameID("phase", "gas");
      ThermoPhase *gasTP = newPhase(*xg);
      int nsp = gasTP->nSpecies();
      cout << "Number of species = " << nsp << endl;

      XML_Node * const xd = xc->findNameID("phase", "diamond");
      ThermoPhase *diamondTP = newPhase(*xd);
      int nsp_diamond = diamondTP->nSpecies();
      cout << "Number of species in diamond = " << nsp_diamond << endl;


      XML_Node * const xs = xc->findNameID("phase", "diamond_100");
      ThermoPhase *diamond100TP = newPhase(*xs);
      //SurfPhase *diamond100TP = new SurfPhase(*xs);
      int nsp_d100 = diamond100TP->nSpecies();
      cout << "Number of species in diamond_100 = " << nsp_d100 << endl;

      vector<ThermoPhase *> phaseList;
      phaseList.push_back(gasTP);     
      phaseList.push_back(diamondTP);
      phaseList.push_back(diamond100TP);
      InterfaceKinetics *iKin_ptr = new InterfaceKinetics();
      importKinetics(*xs, phaseList, iKin_ptr);
      int nr = iKin_ptr->nReactions();
      cout << "Number of reactions = " << nr << endl;

      double x[20];
      for (i = 0; i < 20; i++) x[i] = 0.0;
      x[0] = 0.0010;
      x[1] = 0.9888;
      x[2] = 0.0002;
      x[3] = 0.0100;
      double p = 20.0*OneAtm/760.0;

      gasTP->setState_TPX(1200., p, x);
      
      for (i = 0; i < 20; i++) x[i] = 0.0;
      int i0 = diamond100TP->speciesIndex("c6H*");
      x[i0] = 0.1;
      int i1 = diamond100TP->speciesIndex("c6HH");
      x[i1] = 0.9;
      diamond100TP->setState_TX(1200., x);

      for (i = 0; i < 20; i++) x[i] = 0.0;
      x[0] = 1.0;
      diamondTP->setState_TPX(1200., p, x);

      iKin_ptr->advanceCoverages(100.);

      // Throw some asserts in here to test that they compile
      AssertTrace(p == p); 
      AssertThrow(p == p, "main"); 
      AssertThrowMsg(i == 20, "main", "are you kidding"); 

      double src[20];
      for (i = 0; i < 20; i++) src[i] = 0.0;
      iKin_ptr->getNetProductionRates(src);
      double sum = 0.0;
      double naH = 0.0;
      for (k = 0; k < 13; k++) {
	if (k < 4) {
	  naH = gasTP->nAtoms(k, 0);
	} else if (k == 4) {
	  naH = 0;
	} else if (k > 4) {
	  int itp = k - 5;
	  naH = diamond100TP->nAtoms(itp, 0);
	}
	cout << k << "  " << naH << "  " ;
	printDbl(src[k]);
	cout << endl;
	sum += naH * src[k];
	
      }
  
      cout << "sum = ";
      printDbl(sum);
      cout << endl; 
      double mwd = diamondTP->molecularWeight(0);
      double dens = diamondTP->density();
      double gr = src[4] * mwd / dens;
      gr *= 1.0E6 * 3600.;
      cout << "growth rate = " << gr << " microns per hour" << endl;

      
      diamond100TP->getMoleFractions(x);
      cout << "Coverages:" << endl;
      for (k = 0; k < 8; k++) {
	cout << k << "   " << diamond100TP->speciesName(k) 
	     << "   " 
	     << x[k] << endl;
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:runDiamond.cpp

示例3: main

int main()
{
#ifdef _MSC_VER
    _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
    double pres;
    try {

        XML_Node* xc = get_XML_File("liquidvapor.xml");
        XML_Node* const xs = xc->findNameID("phase", "water");
        thermo_t_double* water_tp = newPhase<doublereal>(*xs);
        PureFluidPhase* w = dynamic_cast <PureFluidPhase*>(water_tp);

        /*
         * Print out the triple point conditions
         */
        double temp = 273.16;
        pres = w->satPressure(temp);
        printf("psat(%g) = %.4g\n", temp, pres);
        double presLow = 1.0E-2;
        temp = 298.15;
        double oneBar = 1.0E5;

        printf("Comparisons to NIST: (see http://webbook.nist.gov):\n\n");

        w->setDensity(1.0E-8);
        w->setState_TP(temp, presLow);
        double h = w->enthalpy_mole();
        printf("H0(298.15) = %g J/kmol\n", h);
        double h298 = h;

        double s = w->entropy_mole();
        s -= GasConstant * log(oneBar/presLow);
        printf("S0(298.15) = %g J/kmolK\n", s);


        double T[20];
        T[0] = 298.15;
        T[1] = 500.;
        T[2] = 600.;
        T[3] = 1000.;

        double Cp0, delh0, delg0, g;

        printf("\nIdeal Gas Standard State:\n");
        printf("        T      Cp0           S0     "
               " -(G0-H298)/T       H0-H298\n");
        printf("       (K)   (J/molK)     (J/molK)  "
               "   (J/molK)        (kJ/mol)\n");
        for (int i = 0; i < 4; i++) {
            temp = T[i];
            w->setState_TP(temp, presLow);
            h = w->enthalpy_mole();
            delh0 = tvalue(h - h298, 1.0E-6);
            g = w->gibbs_mole();
            delg0 = (g - h298)/temp + GasConstant * log(oneBar/presLow);
            Cp0 = w->cp_mole();
            s = w->entropy_mole();
            s -= GasConstant * log(oneBar/presLow);
            printf("%10g %10g %13.4g %13.4g %13.4g\n", temp, Cp0*1.0E-3, s*1.0E-3,
                   -delg0*1.0E-3, delh0*1.0E-6);
        }
        printf("\n\n");

        temp = 298.15;
        w->setDensity(1000.);
        w->setState_TP(temp, oneBar);
        h = w->enthalpy_mole();
        printf("H_liq(298.15, onebar) = %g J/kmol\n", h);
        double h298l = h;
        s = w->entropy_mole();
        printf("S_liq(298.15, onebar) = %g J/kmolK\n", s);


        T[0] = 273.19;
        T[1] = 298.15;
        T[2] = 300.;
        T[3] = 373.15;
        T[4] = 400.;
        T[5] = 500.;
        printf("\nLiquid 1bar or psat Standard State\n");
        printf("       T     press         psat            Cp0            S0   "
               "  -(G0-H298)/T       H0-H298\n");
        printf("      (K)     (bar)        (bar)        (J/molK)       (J/molK)"
               "     (J/molK)        (kJ/mol)\n");

        for (int i = 0; i < 6; i++) {
            temp = T[i];
            double psat = w->satPressure(temp);
            double press = oneBar;
            if (psat > press) {
                press = psat*1.002;
            }
            w->setState_TP(temp, press);
            h = w->enthalpy_mole();
            delh0 = tvalue(h - h298l, 1.0E-6);
            g = w->gibbs_mole();
            delg0 = (g - h298l)/temp;
            Cp0 = w->cp_mole();
            s = w->entropy_mole();
//.........这里部分代码省略.........
开发者ID:anujg1991,项目名称:cantera,代码行数:101,代码来源:testPureWater.cpp

示例4: main

int main(int argc, char** argv)
{
#ifdef _MSC_VER
    _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
    try {
        if (argc != 2) {
            cout << "Error: no input file specified.\n"
                 "Choose either 'noxNeg.cti' or 'noxNeg_blessed.xml" << endl;
            exit(-1);
        }
        std::string infile(argv[1]);

        size_t i;
        double x[20];
        double cdot[20], ddot[20];

        XML_Node* xc = new XML_Node();
        string path = findInputFile(infile);
        ctml::get_CTML_Tree(xc, path);

        XML_Node* const xg = xc->findNameID("phase", "air");
        ThermoPhase* gasTP = newPhase(*xg);
        size_t nsp = gasTP->nSpecies();
        cout << "Number of species = " << nsp << endl;


        vector<ThermoPhase*> phaseList;
        phaseList.push_back(gasTP);
        GasKinetics* iKin_ptr = new GasKinetics();
        importKinetics(*xg, phaseList, iKin_ptr);
        size_t nr = iKin_ptr->nReactions();
        cout << "Number of reactions = " << nr << endl;

        size_t iH = gasTP->speciesIndex("H");
        size_t iO2 = gasTP->speciesIndex("O2");
        size_t iH2O = gasTP->speciesIndex("H2O");
        size_t iNH = gasTP->speciesIndex("NH");
        size_t iNO = gasTP->speciesIndex("NO");
        size_t iN2O = gasTP->speciesIndex("N2O");

        for (i = 0; i < nsp; i++) {
            x[i] = 0.0;
        }
        x[iH2O] = 1.0 /2.0;
        x[iH]   = 0.2 /2.0;
        x[iO2]  = 0.3 /2.0;
        x[iNH]  = 0.05/2.0;
        x[iNO]  = 0.05/2.0;
        x[iN2O]  = 0.05/2.0;

        double p = OneAtm;

        gasTP->setState_TPX(2000., p, x);


        double src[20];
        for (i = 0; i < 20; i++) {
            src[i] = 0.0;
        }
        iKin_ptr->getNetProductionRates(src);

        for (i = 0; i < nsp; i++) {
            string sSt = gasTP->speciesName(i);
            printf("rop [ %.4d:%s ] = %.5g \n", (int) i, sSt.c_str(), src[i]);
        }

        size_t nReactions = iKin_ptr->nReactions();
        cout << "number of reactions = " << nReactions << endl;

        double fwd_rop[20];
        double rev_rop[20];
        iKin_ptr->getFwdRatesOfProgress(fwd_rop);
        iKin_ptr->getRevRatesOfProgress(rev_rop);
        for (i = 0; i < nReactions; i++) {
            printf("fwd_rop[%3d] = %13g    rev_rop[%3d] = %13g\n", (int) i,
                   fwd_rop[i], (int) i, rev_rop[i]);
        }



        iKin_ptr->getCreationRates(cdot);
        iKin_ptr->getDestructionRates(ddot);


        return 0;
    } catch (CanteraError& err) {
        std::cerr << err.what() << std::endl;
        cerr << "program terminating." << endl;
        return -1;
    }
}
开发者ID:anujg1991,项目名称:cantera,代码行数:92,代码来源:negATest.cpp

示例5: main

int main(int argc, char** argv)
{
#if defined(_MSC_VER) && _MSC_VER < 1900
    _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
    if (argc != 2) {
        cout << "Error: no input file specified.\n"
             "Choose either 'diamond.cti' or 'diamond_blessed.xml" << endl;
        exit(-1);
    }
    std::string infile(argv[1]);
    int i, k;

    try {
        XML_Node* xc = get_XML_File(infile);

        XML_Node* const xg = xc->findNameID("phase", "gas");
        ThermoPhase* gasTP = newPhase(*xg);
        size_t nsp = gasTP->nSpecies();
        cout.precision(4);
        cout << "Number of species = " << nsp << endl;

        XML_Node* const xd = xc->findNameID("phase", "diamond");
        ThermoPhase* diamondTP = newPhase(*xd);
        size_t nsp_diamond = diamondTP->nSpecies();
        cout << "Number of species in diamond = " << nsp_diamond << endl;


        XML_Node* const xs = xc->findNameID("phase", "diamond_100");
        ThermoPhase* diamond100TP = newPhase(*xs);
        size_t nsp_d100 = diamond100TP->nSpecies();
        cout << "Number of species in diamond_100 = " << nsp_d100 << endl;

        vector<ThermoPhase*> phaseList { gasTP, diamondTP, diamond100TP };
        InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
        importKinetics(*xs, phaseList, iKin_ptr);
        size_t nr = iKin_ptr->nReactions();
        cout << "Number of reactions = " << nr << endl;

        double x[20];
        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        x[0] = 0.0010;
        x[1] = 0.9888;
        x[2] = 0.0002;
        x[3] = 0.0100;
        double p = 20.0*OneAtm/760.0;

        gasTP->setState_TPX(1200., p, x);

        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        size_t i0 = diamond100TP->speciesIndex("c6H*");
        x[i0] = 0.1;
        size_t i1 = diamond100TP->speciesIndex("c6HH");
        x[i1] = 0.9;
        diamond100TP->setState_TX(1200., x);

        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        x[0] = 1.0;
        diamondTP->setState_TPX(1200., p, x);

        iKin_ptr->advanceCoverages(100.);

        // Throw some asserts in here to test that they compile
        AssertTrace(p == p);
        AssertThrow(p == p, "main");
        AssertThrowMsg(i == 20, "main", "are you kidding");

        double src[20];
        for (i = 0; i < 20; i++) {
            src[i] = 0.0;
        }
        iKin_ptr->getNetProductionRates(src);
        double sum = 0.0;
        double naH = 0.0;
        for (k = 0; k < 13; k++) {
            if (k < 4) {
                naH = gasTP->nAtoms(k, 0);
            } else if (k == 4) {
                naH = 0;
            } else if (k > 4) {
                int itp = k - 5;
                naH = diamond100TP->nAtoms(itp, 0);
            }
            cout << k << "  " << naH << "  " ;
            printDbl(src[k]);
            cout << endl;
            sum += naH * src[k];

        }

        cout << "sum = ";
        printDbl(sum);
        cout << endl;
        double mwd = diamondTP->molecularWeight(0);
//.........这里部分代码省略.........
开发者ID:CSM-Offenburg,项目名称:cantera,代码行数:101,代码来源:runDiamond.cpp

示例6: main

int main(int argc, char** argv)
{
    int i, k;
    string infile = "diamond.xml";

    try {
        XML_Node* xc = get_XML_File(infile);
        cout.precision(3);

        XML_Node* const xg = xc->findNameID("phase", "gas");
        ThermoPhase* gasTP = newPhase(*xg);
        int nsp = gasTP->nSpecies();
        cout << "Number of species = " << nsp << endl;

        XML_Node* const xd = xc->findNameID("phase", "diamond");
        ThermoPhase* diamondTP = newPhase(*xd);
        int nsp_diamond = diamondTP->nSpecies();
        cout << "Number of species in diamond = " << nsp_diamond << endl;


        XML_Node* const xs = xc->findNameID("phase", "diamond_100");
        ThermoPhase* diamond100TP = newPhase(*xs);
        int nsp_d100 = diamond100TP->nSpecies();
        cout << "Number of species in diamond_100 = " << nsp_d100 << endl;

        vector<ThermoPhase*> phaseList { gasTP, diamondTP, diamond100TP };
        InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
        importKinetics(*xs, phaseList, iKin_ptr);
        int nr = iKin_ptr->nReactions();
        cout << "Number of reactions = " << nr << endl;

        double x[20];
        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        x[0] = 0.0010;
        x[1] = 0.9888;
        x[2] = 0.0002;
        x[3] = 0.0100;
        double p = 20.0*OneAtm/760.0;

        gasTP->setState_TPX(1200., p, x);

        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        int i0 = diamond100TP->speciesIndex("c6H*");
        x[i0] = 0.1;
        int i1 = diamond100TP->speciesIndex("c6HH");
        x[i1] = 0.9;
        diamond100TP->setState_TX(1200., x);

        for (i = 0; i < 20; i++) {
            x[i] = 0.0;
        }
        x[0] = 1.0;
        diamondTP->setState_TPX(1200., p, x);

        iKin_ptr->advanceCoverages(100.);

        // Throw some asserts in here to test that they compile
        AssertTrace(p == p);
        AssertThrow(p == p, "main");
        AssertThrowMsg(i == 20, "main", "are you kidding");

        double src[20];
        for (i = 0; i < 20; i++) {
            src[i] = 0.0;
        }
        iKin_ptr->getNetProductionRates(src);
        double sum = 0.0;
        double naH = 0.0;
        for (k = 0; k < 13; k++) {
            if (k < 4) {
                naH = gasTP->nAtoms(k, 0);
            } else if (k == 4) {
                naH = 0;
            } else if (k > 4) {
                int itp = k - 5;
                naH = diamond100TP->nAtoms(itp, 0);
            }
            cout << k << "  " << naH << "  " ;
            printDbl(src[k]);
            cout << endl;
            sum += naH * src[k];

        }

        cout << "sum = ";
        printDbl(sum);
        cout << endl;
        double mwd = diamondTP->molecularWeight(0);
        double dens = diamondTP->density();
        double gr = src[4] * mwd / dens;
        gr *= 1.0E6 * 3600.;
        cout << "growth rate = " << gr << " microns per hour" << endl;


        diamond100TP->getMoleFractions(x);
        cout << "Coverages:" << endl;
//.........这里部分代码省略.........
开发者ID:eburke90,项目名称:Cantera---Turbulent-Flame,代码行数:101,代码来源:runDiamondDupl.cpp

示例7: main

int main(int argc, char** argv) {
#ifdef _MSC_VER
    _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
    int i, k;
    string infile = "frac.xml";
    double x[10], kc[10];
    double cdot[10], ddot[10];
    //double fwd_rop[10]; 
    try {
      XML_Node *xc = new XML_Node();
      string path = findInputFile(infile);
      ctml::get_CTML_Tree(xc, path);

      XML_Node * const xg = xc->findNameID("phase", "gas");
      ThermoPhase *gasTP = newPhase(*xg);
      int nsp = gasTP->nSpecies();
      cout << "Number of species = " << nsp << endl;



      vector<ThermoPhase *> phaseList;
      phaseList.push_back(gasTP);     
      GasKinetics *iKin_ptr = new GasKinetics();
      importKinetics(*xg, phaseList, iKin_ptr);
      int nr = iKin_ptr->nReactions();
      cout << "Number of reactions = " << nr << endl;

      int iH2 = gasTP->speciesIndex("H2");
      int iH = gasTP->speciesIndex("H");
      int iO2 = gasTP->speciesIndex("O2");
      int iOH = gasTP->speciesIndex("OH");
      int iH2O = gasTP->speciesIndex("H2O");


      for (i = 0; i < nsp; i++) {
       x[i] = 0.0;
      }
      x[iH2O] = 1.0/2.0;
      x[iOH] = 0.1/2.0;
      x[iH]  = 0.2/2.0;
      x[iO2] = 0.3/2.0;
      x[iH2] = 0.4/2.0;

      double p = OneAtm;

      gasTP->setState_TPX(2000., p, x);


      double src[20];
      for (i = 0; i < 20; i++) src[i] = 0.0;
      iKin_ptr->getNetProductionRates(src);

      double fwd_rop[10];
      iKin_ptr->getFwdRatesOfProgress(fwd_rop);
      cout << "fwd_rop[0] = " << fwd_rop[0] << endl;
      cout << "fwd_rop[1] = " << fwd_rop[1] << endl;

      iKin_ptr->getCreationRates(cdot);
      iKin_ptr->getDestructionRates(ddot);

      for (k = 0; k < nsp; k++) {
        string sss = gasTP->speciesName(k);
	cout << k << "  " << sss << "  ";
	printDbl(src[k]);
	cout << endl;
      }

      printf("Creation Rates: \n");
      for (k = 0; k < nsp - 1; k++) {
        string sss = gasTP->speciesName(k);
        cout << k << "  " << sss << "  ";
        cout << cdot[k] << "  ";
        cout << cdot[k] / fwd_rop[0] << " "; 
        cout << endl;
      }
     string sss = gasTP->speciesName(iH2O);
     cout << iH2O << "  " << sss << "  ";
        cout << cdot[iH2O] << "  ";
        cout << cdot[iH2O] / fwd_rop[1] << " ";
        cout << endl;


      printf("Destruction Rates: \n");
      for (k = 0; k < nsp-1; k++) {
        string sss = gasTP->speciesName(k);
        cout << k << "  " << sss << "  ";
        cout << ddot[k] << "  ";
        cout << ddot[k] / fwd_rop[1] << " "; 
        cout << endl;
      }
     sss = gasTP->speciesName(iH2O);
     cout << iH2O << "  " << sss << "  ";
     cout << ddot[iH2O] << "  ";
     cout << ddot[iH2O] / fwd_rop[0] << " ";
     cout << endl;


     double c[10];
     gasTP->getConcentrations(c);
//.........这里部分代码省略.........
开发者ID:hkmoffat,项目名称:cantera,代码行数:101,代码来源:fracCoeff.cpp

示例8: main

int main(int argc, char **argv) {
  try {   
    int i;
    std::string infile = "noxNeg.xml";
    double x[20];
    double cdot[20], ddot[20];
    
    XML_Node *xc = new XML_Node();
    string path = findInputFile(infile);
    ctml::get_CTML_Tree(xc, path);

    XML_Node * const xg = xc->findNameID("phase", "air");
    ThermoPhase *gasTP = newPhase(*xg);
    int nsp = gasTP->nSpecies();
    cout << "Number of species = " << nsp << endl;


    vector<ThermoPhase *> phaseList;
    phaseList.push_back(gasTP);
    GasKinetics *iKin_ptr = new GasKinetics();
    importKinetics(*xg, phaseList, iKin_ptr);
    int nr = iKin_ptr->nReactions();
    cout << "Number of reactions = " << nr << endl;

    int iH2 = gasTP->speciesIndex("H2");
    int iH = gasTP->speciesIndex("H");
    int iO2 = gasTP->speciesIndex("O2");
    int iOH = gasTP->speciesIndex("OH");
    int iH2O = gasTP->speciesIndex("H2O");
    int iNH = gasTP->speciesIndex("NH");
    int iNO = gasTP->speciesIndex("NO");
    int iN2O = gasTP->speciesIndex("N2O");

    for (i = 0; i < nsp; i++) {
      x[i] = 0.0;
    }
    x[iH2O] = 1.0 /2.0;
    x[iOH]  = 0.1 /2.0;
    x[iH]   = 0.2 /2.0;
    x[iO2]  = 0.3 /2.0;
    x[iH2]  = 0.25 /2.0;
    x[iNH]  = 0.05/2.0;
    x[iNO]  = 0.05/2.0;
    x[iN2O]  = 0.05/2.0;

    double p = OneAtm;

    gasTP->setState_TPX(2000., p, x);


    double src[20];
    for (i = 0; i < 20; i++) src[i] = 0.0;
    iKin_ptr->getNetProductionRates(src);

    for (i = 0; i < nsp; i++) {
      string sSt = gasTP->speciesName(i);
      printf("rop [ %d:%s ] = %g \n", i, sSt.c_str(), src[i]);
    }

    int nReactions = iKin_ptr->nReactions();
    cout << "number of reactions = " << nReactions << endl;

    double fwd_rop[20];
    double rev_rop[20];
    iKin_ptr->getFwdRatesOfProgress(fwd_rop);
    iKin_ptr->getRevRatesOfProgress(rev_rop);
    for (i = 0; i < nReactions; i++) {
      printf("fwd_rop[%3d] = %13g    rev_rop[%3d] = %13g\n", i, fwd_rop[i],
	     i, rev_rop[i]);
    }



    iKin_ptr->getCreationRates(cdot);
    iKin_ptr->getDestructionRates(ddot);
    

    return 0;
  }
  catch (CanteraError) {
    showErrors(cerr);
    cerr << "program terminating." << endl;
    return -1;
  }
}
开发者ID:hkmoffat,项目名称:cantera,代码行数:85,代码来源:negATest.cpp


注:本文中的XML_Node::findNameID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。