Ejemplo n.º 1
0
 bool Gas_Impl::setMolecularWeight(const OSOptionalQuantity& molecularWeight) {
   bool result(false);
   OptionalDouble value;
   if (molecularWeight.isSet()) {
     value = getDoubleFromQuantity(OS_WindowMaterial_GasFields::MolecularWeight,molecularWeight.get());
     if (value) {
       result = setMolecularWeight(value);
     }
   }
   else {
     result = setMolecularWeight(value);
   }
   return result;
 }
Ejemplo n.º 2
0
void WaterSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id)
{
    /*
     * Do initializations that don't depend on knowing the XML file
     */
    initThermo();
    /*
     * Calculate the molecular weight. Note while there may
     * be a very good calculated weight in the steam table
     * class, using this weight may lead to codes exhibiting
     * mass loss issues. We need to grab the elemental
     * atomic weights used in the Element class and calculate
     * a consistent H2O molecular weight based on that.
     */
    size_t nH = elementIndex("H");
    if (nH == npos) {
        throw CanteraError("WaterSSTP::initThermo",
                           "H not an element");
    }
    double mw_H = atomicWeight(nH);
    size_t nO = elementIndex("O");
    if (nO == npos) {
        throw CanteraError("WaterSSTP::initThermo",
                           "O not an element");
    }
    double mw_O = atomicWeight(nO);
    m_mw = 2.0 * mw_H + mw_O;
    setMolecularWeight(0,m_mw);
    double one = 1.0;
    setMoleFractions(&one);

    /*
     * Set the baseline
     */
    doublereal T = 298.15;
    Phase::setDensity(7.0E-8);
    Phase::setTemperature(T);

    doublereal presLow = 1.0E-2;
    doublereal oneBar = 1.0E5;
    doublereal dd = m_sub.density(T, presLow, WATER_GAS, 7.0E-8);
    setDensity(dd);
    setTemperature(T);
    SW_Offset = 0.0;
    doublereal s = entropy_mole();
    s -= GasConstant * log(oneBar/presLow);
    if (s != 188.835E3) {
        SW_Offset = 188.835E3 - s;
    }
    s = entropy_mole();
    s -= GasConstant * log(oneBar/presLow);

    doublereal h = enthalpy_mole();
    if (h != -241.826E6) {
        EW_Offset = -241.826E6 - h;
    }
    h = enthalpy_mole();

    /*
     * Set the initial state of the system to 298.15 K and
     * 1 bar.
     */
    setTemperature(298.15);
    double rho0 = m_sub.density(298.15, OneAtm, WATER_LIQUID);
    setDensity(rho0);

    m_waterProps.reset(new WaterProps(&m_sub));

    /*
     * We have to do something with the thermo function here.
     */
    delete m_spthermo;
    m_spthermo = 0;

    /*
     * Set the flag to say we are ready to calculate stuff
     */
    m_ready = true;
}