Ejemplo n.º 1
0
XML_Node* MetalSHEelectrons::makeDefaultXMLTree()
{
    XML_Node* xtop = new XML_Node("ctml", 0);
    XML_Node& xv = xtop->addChild("validate");
    xv.addAttribute("reactions", "yes");
    xv.addAttribute("species", "yes");

    XML_Node& xp = xtop->addChild("phase");
    xp.addAttribute("dim", "3");
    xp.addAttribute("id", "MetalSHEelectrons");
    XML_Node& xe = xp.addChild("elementArray", "E");
    xe.addAttribute("datasrc", "elements.xml");
    XML_Node& xs = xp.addChild("speciesArray", "she_electron");
    xs.addAttribute("datasrc", "#species_Metal_SHEelectrons");
    XML_Node& xt = xp.addChild("thermo");
    xt.addAttribute("model", "metalSHEelectrons");
    XML_Node& xtr = xp.addChild("transport");
    xtr.addAttribute("model", "none");
    XML_Node& xk = xp.addChild("kinetics");
    xk.addAttribute("model", "none");

    XML_Node& xsd = xtop->addChild("speciesData");
    xsd.addAttribute("id", "species_Metal_SHEelectrons");

    XML_Node& xsp = xsd.addChild("species");
    xsp.addAttribute("name", "she_electron");
    xsp.addChild("atomArray", "E:1");
    xsp.addChild("charge", "-1");
    XML_Node& xspt = xsp.addChild("thermo");

    XML_Node& xN1 = xspt.addChild("NASA");
    xN1.addAttribute("Tmax", "1000.");
    xN1.addAttribute("Tmin", "200.");
    xN1.addAttribute("P0", "100000.0");
    XML_Node& xF1 = xsd.addChild("floatArray",
                                 "1.172165560E+00,   3.990260375E-03,  -9.739075500E-06, "
                                 "1.007860470E-08, -3.688058805E-12, -4.589675865E+02,  3.415051190E-01");
    xF1.addAttribute("name", "coeffs");
    xF1.addAttribute("size", "7");

    XML_Node& xN2 = xspt.addChild("NASA");
    xN2.addAttribute("Tmax", "6000.");
    xN2.addAttribute("Tmin", "1000.");
    xN2.addAttribute("P0", "100000.0");
    XML_Node& xF2 = xsd.addChild("floatArray",
                                 "1.466432895E+00,  4.133039835E-04, -7.320116750E-08, 7.705017950E-12,"
                                 "-3.444022160E-16, -4.065327985E+02, -5.121644350E-01");
    xF2.addAttribute("name", "coeffs");
    xF2.addAttribute("size", "7");

    return xtop;
}
Ejemplo n.º 2
0
//====================================================================================================================
FixedChemPotSSTP::FixedChemPotSSTP(std::string Ename, doublereal val) :
    SingleSpeciesTP(),
    chemPot_(0.0)
{

    std::string pname = Ename + "Fixed";
    setID(pname);
    setName(pname);
    setNDim(3);
    addUniqueElement(Ename, -12345.);
    freezeElements();
    vector_fp ecomp(nElements(), 0.0);
    ecomp[0] = 1.0;
    double chrg = 0.0;
    SpeciesThermo* spth = new SimpleThermo();
    setSpeciesThermo(spth);
    addUniqueSpecies(pname, &ecomp[0], chrg, 0.0);
    double c[4];
    c[0] = 298.15;
    c[1] = val;
    c[2] = 0.0;
    c[3] = 0.0;
    m_spthermo->install(pname, 0, SIMPLE, c, 0.0, 1.0E30, OneAtm);
    freezeSpecies();
    initThermo();
    m_p0 = OneAtm;
    m_tlast = 298.15;
    setChemicalPotential(val);

    // Create an XML_Node entry for this species
    XML_Node* s = new XML_Node("species", 0);
    s->addAttribute("name", pname);
    std::string aaS = Ename + ":1";
    s->addChild("atomArray", aaS);
    XML_Node& tt = s->addChild("thermo");
    XML_Node& ss = tt.addChild("Simple");
    ss.addAttribute("Pref", "1 bar");
    ss.addAttribute("Tmax", "5000.");
    ss.addAttribute("Tmin", "100.");
    ss.addChild("t0", "298.15");
    ss.addChild("cp0", "0.0");
    std::string sval = fp2str(val);
    ss.addChild("h", sval);
    ss.addChild("s", "0.0");
    saveSpeciesData(0, s);
    delete s;
    s = 0;
}
Ejemplo n.º 3
0
void addFloatArray(XML_Node& node, const std::string& title, const size_t n,
                   const doublereal* const vals, const std::string& units,
                   const std::string& type,
                   const doublereal minval, const doublereal maxval)
{
    std::string v = "";
    for (size_t i = 0; i < n; i++) {
        v += fp2str(vals[i],FP_Format);
        if (i == n-1) {
            v += "\n";
        } else if (i > 0 && (i+1) % 3 == 0) {
            v += ",\n";
        } else {
            v += ", ";
        }
    }
    XML_Node& f = node.addChild("floatArray",v);
    f.addAttribute("title",title);
    if (type != "") {
        f.addAttribute("type",type);
    }
    f.addAttribute("size", double(n));
    if (units != "") {
        f.addAttribute("units",units);
    }
    if (minval != Undef) {
        f.addAttribute("min",minval);
    }
    if (maxval != Undef) {
        f.addAttribute("max",maxval);
    }
}
Ejemplo n.º 4
0
 void OutletRes1D::
 save(XML_Node& o, doublereal* soln) {
     XML_Node& outlt = o.addChild("domain");
     outlt.addAttribute("id",id());
     outlt.addAttribute("points",1);
     outlt.addAttribute("type","outletres");
     outlt.addAttribute("components",nComponents());
 }
Ejemplo n.º 5
0
 void Symm1D::
 save(XML_Node& o, doublereal* soln) {
     XML_Node& symm = o.addChild("domain");
     symm.addAttribute("id",id());
     symm.addAttribute("points",1);
     symm.addAttribute("type","symmetry");
     symm.addAttribute("components",nComponents());
 }
Ejemplo n.º 6
0
int main()
{
    XML_Document pars;
    pars.addDecleration();
    XML_Node    files;
    XML_Attrib  files_attrib;

    pars.addNode(files, "Files");
    files.addAttribute(files_attrib, "dummy", "foobar.com");

    XML_Node file, path, name;
    for(int i=0; i<10; ++i)
    {
        files.addChild(file, "File");
        file.addChild(path, "Path", "File_Path");
        file.addChild(name, "Name", "File_Name");

        cout << file.name() << " -> " << file.value() << endl;
        cout << path.name() << " -> " << path.value() << endl;
        cout << name.name() << " -> " << name.value() << endl;
        
    }

    file.removeChild(name);
    pars.save("example2.xml");

    return 0;
    
    // xml_document<> doc;
    // xml_node<>* decl = doc.allocate_node(node_declaration);
    // decl->append_attribute(doc.allocate_attribute("version", "1.0"));
    // decl->append_attribute(doc.allocate_attribute("encoding", "UTF-8"));
    // doc.append_node(decl);  



    // xml_node<> *files = doc.allocate_node(node_element, "Files");
    // doc.append_node(files);
    // xml_attribute<> *attr = doc.allocate_attribute("dummy", "google.com");
    // files->append_attribute(attr);

    // for(int i = 0;i<10;++i)
    // {
    //     xml_node<> *file = doc.allocate_node(node_element, "File");
    //     files->append_node(file);

    //     xml_node<> *path = doc.allocate_node(node_element, "Path","File_path");
    //     file->append_node(path);
    //     xml_node<> *name = doc.allocate_node(node_element, "Name","File_name");
    //     file->append_node(name);
    // }

    // std::ofstream myfile;
    // myfile.open ("example.xml");
    // myfile << doc;
    // //print(std::cout, doc, 0);
    // return 0;
};
Ejemplo n.º 7
0
void addString(XML_Node& node, const std::string& titleString,
               const std::string& valueString,
               const std::string& typeString)
{
    XML_Node& f = node.addChild("string", valueString);
    f.addAttribute("title", titleString);
    if (typeString != "") {
        f.addAttribute("type", typeString);
    }
}
Ejemplo n.º 8
0
 void Inlet1D::
 save(XML_Node& o, doublereal* soln) {
     doublereal* s = soln + loc();
     XML_Node& inlt = o.addChild("domain");
     inlt.addAttribute("id",id());
     inlt.addAttribute("points",1);
     inlt.addAttribute("type","inlet");
     inlt.addAttribute("components",nComponents());
     for (int k = 0; k < nComponents(); k++) {
         ctml::addFloat(inlt, componentName(k), s[k], "", "",lowerBound(k), upperBound(k));
     }
 }
Ejemplo n.º 9
0
void addInteger(XML_Node& node, const std::string& title, const int val,
                const std::string& units, const std::string& type)
{
    XML_Node& f = node.addChild(title, val);
    f.addAttribute("vtype", "integer");
    if (type != "") {
        f.addAttribute("type",type);
    }
    if (units != "") {
        f.addAttribute("units",units);
    }
}
Ejemplo n.º 10
0
 void ReactingSurf1D::
 save(XML_Node& o, doublereal* soln) {
     doublereal* s = soln + loc();
     //XML_Node& inlt = o.addChild("inlet");
     XML_Node& inlt = o.addChild("domain");
     inlt.addAttribute("id",id());
     inlt.addAttribute("points",1);
     inlt.addAttribute("type","surface");
     inlt.addAttribute("components",nComponents());
     for (int k = 0; k < nComponents(); k++) {
         ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0);
     }
 }
Ejemplo n.º 11
0
void addFloat(XML_Node& node, const std::string& title,
              const doublereal val, const std::string& units,
              const std::string& type, const doublereal minval,
              const doublereal maxval)
{
    XML_Node& f = node.addChild(title, val, FP_Format);
    if (type != "") {
        f.addAttribute("type",type);
    }
    if (units != "") {
        f.addAttribute("units",units);
    }
    f.addAttribute("vtype", "float");
    if (minval != Undef) {
        f.addAttribute("min",minval);
    }
    if (maxval != Undef) {
        f.addAttribute("max",maxval);
    }
}
Ejemplo n.º 12
0
void addNamedFloatArray(XML_Node& node, const std::string& name, const size_t n,
                        const doublereal* const vals, const std::string units,
                        const std::string type, const doublereal minval,
                        const doublereal maxval)
{
    std::string v = "";
    for (size_t i = 0; i < n; i++) {
        v += fp2str(vals[i],FP_Format);
        if (i == n-1) {
            v += "\n";
        } else if (i > 0 && (i+1) % 3 == 0) {
            v += ",\n";
        } else {
            v += ", ";
        }
    }
    XML_Node& f = node.addChild(name, v);
    if (type != "") {
        f.addAttribute("type",type);
    }
    /*
     *  Add vtype, which indicates the type of the value. Here we specify it as a list of floats separated
     *  by commas, with a length given by size attribute.
     */
    f.addAttribute("vtype", "floatArray");

    f.addAttribute("size", n);
    if (units != "") {
        f.addAttribute("units", units);
    }
    if (minval != Undef) {
        f.addAttribute("min", minval);
    }
    if (maxval != Undef) {
        f.addAttribute("max", maxval);
    }
}