void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata)
{
    eosdata._require("model","LatticeSolid");
    XML_Node& la = eosdata.child("LatticeArray");
    std::vector<XML_Node*> lattices = la.getChildren("phase");
    size_t nl = lattices.size();
    m_nlattice = nl;
    for (size_t n = 0; n < nl; n++) {
        XML_Node& i = *lattices[n];
        m_lattice.push_back((LatticePhase*)newPhase(i));
    }
    std::vector<string> pnam;
    std::vector<string> pval;
    XML_Node& ls = eosdata.child("LatticeStoichiometry");
    int np = ctml::getPairs(ls, pnam, pval);
    theta_.resize(nl);
    for (int i = 0; i < np; i++) {
        double val = fpValueCheck(pval[i]);
        bool found = false;
        for (size_t j = 0; j < nl; j++) {
            ThermoPhase& tp = *(m_lattice[j]);
            string idj = tp.id();
            if (idj == pnam[i]) {
                theta_[j] = val;
                found = true;
                break;
            }
        }
        if (!found) {
            throw CanteraError("", "not found");
        }
    }

}
Beispiel #2
0
TEST_F(FixedChemPotSstpConstructorTest, fromXML)
{
    std::unique_ptr<ThermoPhase> p(newPhase("../data/LiFixed.xml"));
    ASSERT_EQ((int) p->nSpecies(), 1);
    double mu;
    p->getChemPotentials(&mu);
    ASSERT_DOUBLE_EQ(-2.3e7, mu);
}
Beispiel #3
0
ThermoPhase* newPhase(const std::string& infile, std::string id)
{
    XML_Node* root = get_XML_File(infile);
    if (id == "-") {
        id = "";
    }
    XML_Node* xphase = get_XML_NameID("phase", "#"+id, root);
    if (!xphase) {
        throw CanteraError("newPhase",
                           "Couldn't find phase named \"" + id + "\" in file, " + infile);
    }
    return newPhase(*xphase);
}
 void LatticeSolidPhase::setParametersFromXML(const XML_Node& eosdata) {
     eosdata._require("model","LatticeSolid");
     XML_Node& la = eosdata.child("LatticeArray");
     vector<XML_Node*> lattices;
     la.getChildren("phase",lattices);
     int n;
     int nl = lattices.size();
     m_nlattice = nl;
     for (n = 0; n < nl; n++) {
         XML_Node& i = *lattices[n];
         m_lattice.push_back((LatticePhase*)newPhase(i));
     }
 }
Beispiel #5
0
  ThermoPhase* newPhase(std::string infile, std::string id) {
    XML_Node* root = get_XML_File(infile); 
    if (id == "-") id = "";
    XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
    if (!xphase) {
      throw CanteraError("newPhase",
			  "Couldn't find phase named \"" + id + "\" in file, " + infile);
    }
    if (xphase) 
      return newPhase(*xphase);
    else
      return (ThermoPhase *) 0;
  }
Beispiel #6
0
TEST(IonsFromNeutralConstructor, fromXML)
{
    std::unique_ptr<ThermoPhase> p(newPhase("../data/mock_ion.xml",
                                            "mock_ion_phase"));
    ASSERT_EQ((int) p->nSpecies(), 2);
    p->setState_TPX(500, 2e5, "K+:0.1, Cl-:0.1");
    vector_fp mu(p->nSpecies());
    p->getChemPotentials(mu.data());

    // Values for regression testing only -- no reference values known for comparison
    EXPECT_NEAR(p->density(), 1984.3225978174073, 1e-6);
    EXPECT_NEAR(p->enthalpy_mass(), -8035317241137.971, 1e-1);
    EXPECT_NEAR(mu[0], -4.66404010e+08, 1e1);
    EXPECT_NEAR(mu[1], -2.88157298e+06, 1e-1);
}
Beispiel #7
0
// The actual code is put into a function that
// can be called from the main program.
void simple_demo() {

    // Create a new phase 
    ThermoPhase* gas = newPhase("h2o2.cti","ohmech");

    // Set its state by specifying T (500 K) P (2 atm) and the mole
    // fractions. Note that the mole fractions do not need to sum to
    // 1.0 - they will be normalized internally. Also, the values for
    // any unspecified species will be set to zero.
    gas->setState_TPX(500.0, 2.0*OneAtm, "H2O:1.0, H2:8.0, AR:1.0");

    // Print a summary report of the state of the gas
    cout << report(*gas) << endl;

    //  Clean up
    delete gas;
}
 TestThermoMethods() {
     thermo.reset(newPhase("h2o2.xml"));
 }
 void initializeTestPhaseWithXML(const std::string & filename)
 {
     test_phase.reset(newPhase(filename));
 }
Beispiel #10
0
TEST_F(ChemkinConversionTest, ValidConversion) {
    copyInputFile("pdep-test.inp");
    ck2cti("pdep-test.inp");
    std::unique_ptr<ThermoPhase> p(newPhase("pdep-test.cti"));
    ASSERT_GT(p->temperature(), 0.0);
}
Beispiel #11
0
TEST_F(CtiConversionTest, ImplicitConversion) {
    p1.reset(newPhase("../data/air-no-reactions.xml"));
    p2.reset(newPhase("../data/air-no-reactions.cti"));
    compare();
}