Esempio n. 1
0
  void PDSS_IdealGas::constructPDSSFile(VPStandardStateTP *tp, int spindex,
					std::string inputFile, std::string id) {

    if (inputFile.size() == 0) {
      throw CanteraError("PDSS_IdealGas::constructPDSSFile",
			 "input file is null");
    }
    std::string path = findInputFile(inputFile);
    ifstream fin(path.c_str());
    if (!fin) {
      throw CanteraError("PDSS_IdealGas::constructPDSSFile","could not open "
			 +path+" for reading.");
    }
    /*
     * The phase object automatically constructs an XML object.
     * Use this object to store information.
     */

    XML_Node *fxml = new XML_Node();
    fxml->build(fin);
    XML_Node *fxml_phase = findXMLPhase(fxml, id);
    if (!fxml_phase) {
      throw CanteraError("PDSS_IdealGas::constructPDSSFile",
			 "ERROR: Can not find phase named " +
			 id + " in file named " + inputFile);
    }	
    constructPDSSXML(tp, spindex, *fxml_phase, id);
    delete fxml;
  }
void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
        const std::string& inputFile, const std::string& id)
{
    warn_deprecated("PDSS_IonsFromNeutral::constructPDSSFile",
                    "To be removed after Cantera 2.3.");
    if (inputFile.size() == 0) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile",
                           "input file is null");
    }
    std::string path = findInputFile(inputFile);
    ifstream fin(path);
    if (!fin) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile","could not open "
                           +path+" for reading.");
    }

    // The phase object automatically constructs an XML object. Use this object
    // to store information.
    XML_Node fxml;
    fxml.build(fin);
    XML_Node* fxml_phase = findXMLPhase(&fxml, id);
    if (!fxml_phase) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile",
                           "ERROR: Can not find phase named " +
                           id + " in file named " + inputFile);
    }

    XML_Node& speciesList = fxml_phase->child("speciesArray");
    XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
                                         &fxml_phase->root());
    const XML_Node* s = speciesDB->findByAttr("name", tp->speciesName(spindex));
    constructPDSSXML(tp, spindex, *s, *fxml_phase, id);
}
Esempio n. 3
0
void PDSS_IdealGas::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
                                      const std::string& inputFile,
                                      const std::string& id)
{
    warn_deprecated("PDSS_IdealGas::constructPDSSFile",
                    "To be removed after Cantera 2.3.");
    if (inputFile.size() == 0) {
        throw CanteraError("PDSS_IdealGas::constructPDSSFile",
                           "input file is null");
    }
    std::string path = findInputFile(inputFile);
    ifstream fin(path);
    if (!fin) {
        throw CanteraError("PDSS_IdealGas::constructPDSSFile","could not open "
                           +path+" for reading.");
    }
    /*
     * The phase object automatically constructs an XML object.
     * Use this object to store information.
     */

    XML_Node fxml;
    fxml.build(fin);
    XML_Node* fxml_phase = findXMLPhase(&fxml, id);
    if (!fxml_phase) {
        throw CanteraError("PDSS_IdealGas::constructPDSSFile",
                           "ERROR: Can not find phase named " +
                           id + " in file named " + inputFile);
    }
    constructPDSSXML(tp, spindex, *fxml_phase, id);
}
Esempio n. 4
0
  /*
   *   Import, construct, and initialize a phase
   *   specification from an XML tree into the current object.
   *
   * This routine is a precursor to constructPhaseXML(XML_Node*)
   * routine, which does most of the work.
   *
   * @param infile XML file containing the description of the
   *        phase
   *
   * @param id  Optional parameter identifying the name of the
   *            phase. If none is given, the first XML
   *            phase element will be used.
   */
  void MargulesVPSSTP::constructPhaseFile(std::string inputFile, std::string id) {

    if (inputFile.size() == 0) {
      throw CanteraError("MargulesVPSSTP:constructPhaseFile",
                         "input file is null");
    }
    string path = findInputFile(inputFile);
    std::ifstream fin(path.c_str());
    if (!fin) {
      throw CanteraError("MargulesVPSSTP:constructPhaseFile","could not open "
                         +path+" for reading.");
    }
    /*
     * The phase object automatically constructs an XML object.
     * Use this object to store information.
     */
    XML_Node &phaseNode_XML = xml();
    XML_Node *fxml = new XML_Node();
    fxml->build(fin);
    XML_Node *fxml_phase = findXMLPhase(fxml, id);
    if (!fxml_phase) {
      throw CanteraError("MargulesVPSSTP:constructPhaseFile",
                         "ERROR: Can not find phase named " +
                         id + " in file named " + inputFile);
    }
    fxml_phase->copy(&phaseNode_XML);
    constructPhaseXML(*fxml_phase, id);
    delete fxml;
  }
MixedSolventElectrolyte::MixedSolventElectrolyte(XML_Node& phaseRoot,
        const std::string& id_) :
    numBinaryInteractions_(0),
    formMargules_(0),
    formTempModel_(0)
{
    importPhase(*findXMLPhase(&phaseRoot, id_), this);
}
Esempio n. 6
0
Phase& Phase::operator=(const Phase& right)
{
    // Check for self assignment.
    if (this == &right) {
        return *this;
    }

    // Handle our own data
    m_kk = right.m_kk;
    m_ndim = right.m_ndim;
    m_undefinedElementBehavior = right.m_undefinedElementBehavior;
    m_temp = right.m_temp;
    m_dens = right.m_dens;
    m_mmw = right.m_mmw;
    m_ym = right.m_ym;
    m_y = right.m_y;
    m_molwts = right.m_molwts;
    m_rmolwts = right.m_rmolwts;
    m_stateNum = -1;

    m_speciesNames = right.m_speciesNames;
    m_speciesComp = right.m_speciesComp;
    m_speciesCharge = right.m_speciesCharge;
    m_speciesSize = right.m_speciesSize;
    m_mm = right.m_mm;
    m_atomicWeights = right.m_atomicWeights;
    m_atomicNumbers = right.m_atomicNumbers;
    m_elementNames = right.m_elementNames;
    m_entropy298 = right.m_entropy298;
    m_elem_type = right.m_elem_type;

    // This is a little complicated. -> Because we delete m_xml in the
    // destructor, we own m_xml completely, and we need to have our own
    // individual copies of the XML data tree in each object
    if (m_xml) {
        XML_Node* rroot = &m_xml->root();
        delete rroot;
        m_xml = 0;
    }
    if (right.m_xml) {
        XML_Node *rroot = &right.m_xml->root();
        XML_Node *root_xml = new XML_Node();
        rroot->copy(root_xml);
        m_xml = findXMLPhase(root_xml, right.m_xml->id());
        if (!m_xml) {
          throw CanteraError("Phase::operator=()", "Confused: Couldn't find original phase " + right.m_xml->id());
        }
        if (&m_xml->root() != root_xml) {
          throw CanteraError("Phase::operator=()", "confused: root changed");
        }
    }
    m_id = right.m_id;
    m_name = right.m_name;
    return *this;
}
void ThermoPhase::initThermoFile(const std::string& inputFile,
                                 const std::string& id)
{
    XML_Node* fxml = get_XML_File(inputFile);
    XML_Node* fxml_phase = findXMLPhase(fxml, id);
    if (!fxml_phase) {
        throw CanteraError("ThermoPhase::initThermoFile",
                           "ERROR: Can not find phase named {} in file"
                           " named {}", id, inputFile);
    }
    importPhase(*fxml_phase, this);
}
Esempio n. 8
0
MolarityIonicVPSSTP::MolarityIonicVPSSTP(XML_Node& phaseRoot,
        const std::string& id_) :
    GibbsExcessVPSSTP(),
    PBType_(PBTYPE_PASSTHROUGH),
    numPBSpecies_(m_kk),
    indexSpecialSpecies_(npos),
    numCationSpecies_(0),
    numAnionSpecies_(0),
    numPassThroughSpecies_(0),
    neutralPBindexStart(0)
{
    importPhase(*findXMLPhase(&phaseRoot, id_), this);
}
Esempio n. 9
0
void Phase::setXMLdata(XML_Node& xmlPhase)
{
    XML_Node* xroot = &xmlPhase.root();
    XML_Node *root_xml = new XML_Node();
    xroot->copy(root_xml);
    if (m_xml) {
       XML_Node *rOld = &m_xml->root();
       delete rOld;
       m_xml = 0;
    }
    m_xml = findXMLPhase(root_xml, xmlPhase.id());
    if (!m_xml) {
        throw CanteraError("Phase::setXMLdata()", "XML 'phase' node not found");
    }
    if (&m_xml->root() != root_xml) {
        throw CanteraError("Phase::setXMLdata()", "Root XML node not found");
    }
}
Esempio n. 10
0
/*
 *
 * This routine is a precursor to constructPDSSXML(XML_Node*)
 * routine, which does most of the work.
 *
 * @param vptp_ptr    Pointer to the Variable pressure %ThermoPhase object
 *                    This object must have already been malloced.
 *
 * @param spindex     Species index within the phase
 *
 * @param inputFile   XML file containing the description of the
 *                    phase
 *
 * @param id          Optional parameter identifying the name of the
 *                    phase. If none is given, the first XML
 *                    phase element will be used.
 */
void PDSS_IonsFromNeutral::constructPDSSFile(VPStandardStateTP* tp, size_t spindex,
                                             const std::string& inputFile, const std::string& id)
{

    if (inputFile.size() == 0) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile",
                           "input file is null");
    }
    std::string path = findInputFile(inputFile);
    ifstream fin(path.c_str());
    if (!fin) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile","could not open "
                           +path+" for reading.");
    }
    /*
     * The phase object automatically constructs an XML object.
     * Use this object to store information.
     */

    XML_Node* fxml = new XML_Node();
    fxml->build(fin);
    XML_Node* fxml_phase = findXMLPhase(fxml, id);
    if (!fxml_phase) {
        throw CanteraError("PDSS_IonsFromNeutral::constructPDSSFile",
                           "ERROR: Can not find phase named " +
                           id + " in file named " + inputFile);
    }

    XML_Node& speciesList = fxml_phase->child("speciesArray");
    XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"],
                                         &(fxml_phase->root()));
    const vector<string>&sss = tp->speciesNames();

    const XML_Node* s =  speciesDB->findByAttr("name", sss[spindex]);

    constructPDSSXML(tp, spindex, *s, *fxml_phase, id);
    delete fxml;
}