Esempio n. 1
0
void MMCollisionInt::fit(int degree, doublereal deltastar,
                         doublereal* a, doublereal* b, doublereal* c)
{
    int i, n = m_nmax - m_nmin + 1;
    int ndeg=0;
    vector_fp values(n);
    doublereal rmserr;
    vector_fp w(n);
    doublereal* logT = DATA_PTR(m_logTemp) + m_nmin;
    for (i = 0; i < n; i++) {
        if (deltastar == 0.0) {
            values[i] = astar_table[8*(i + m_nmin + 1)];
        } else {
            values[i] = poly5(deltastar, DATA_PTR(m_apoly[i+m_nmin]));
        }
    }
    w[0]= -1.0;
    rmserr = polyfit(n, logT, DATA_PTR(values),
                     DATA_PTR(w), degree, ndeg, 0.0, a);

    for (i = 0; i < n; i++) {
        if (deltastar == 0.0) {
            values[i] = bstar_table[8*(i + m_nmin + 1)];
        } else {
            values[i] = poly5(deltastar, DATA_PTR(m_bpoly[i+m_nmin]));
        }
    }
    w[0]= -1.0;
    rmserr = polyfit(n, logT, DATA_PTR(values),
                     DATA_PTR(w), degree, ndeg, 0.0, b);

    for (i = 0; i < n; i++) {
        if (deltastar == 0.0) {
            values[i] = cstar_table[8*(i + m_nmin + 1)];
        } else {
            values[i] = poly5(deltastar, DATA_PTR(m_cpoly[i+m_nmin]));
        }
    }
    w[0]= -1.0;
    rmserr = polyfit(n, logT, DATA_PTR(values),
                     DATA_PTR(w), degree, ndeg, 0.0, c);
    if (DEBUG_MODE_ENABLED && m_loglevel > 2) {
        writelogf("\nT* fit at delta* = %.6g\n", deltastar);

        writelog("astar = [" + vec2str(vector_fp(a, a+degree+1))+ "]\n");
        if (rmserr > 0.01) {
            writelogf("Warning: RMS error = %12.6g for A* fit\n", rmserr);
        }

        writelog("bstar = [" + vec2str(vector_fp(b, b+degree+1))+ "]\n");
        if (rmserr > 0.01) {
            writelogf("Warning: RMS error = %12.6g for B* fit\n", rmserr);
        }

        writelog("cstar = [" + vec2str(vector_fp(c, c+degree+1))+ "]\n");
        if (rmserr > 0.01) {
            writelogf("Warning: RMS error = %12.6g for C* fit\n", rmserr);
        }
    }
}
Esempio n. 2
0
Nasa9Poly1<ValAndDerivType>::Nasa9Poly1() :
        m_lowT(0.0),
        m_highT(0.0),
        m_Pref(1.0E5),
        m_index(0),
        m_coeff(vector_fp(9))
{
}
Esempio n. 3
0
Nasa9Poly1<ValAndDerivType>::Nasa9Poly1(const Nasa9Poly1<ValAndDerivType>& b) :
        m_lowT(b.m_lowT),
        m_highT(b.m_highT),
        m_Pref(b.m_Pref),
        m_index(b.m_index),
        m_coeff(vector_fp(9))
{
    std::copy(b.m_coeff.begin(), b.m_coeff.begin() + 9, m_coeff.begin());
}
Esempio n. 4
0
Nasa9Poly1<ValAndDerivType>::Nasa9Poly1(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal* coeffs) :
        m_lowT(tlow),
        m_highT(thigh),
        m_Pref(pref),
        m_index(n),
        m_coeff(vector_fp(9))
{
    std::copy(coeffs, coeffs + 9, m_coeff.begin());
}
void MolalityVPSSTP::getCsvReportData(std::vector<std::string>& names,
                                      std::vector<vector_fp>& data) const
{
    names.clear();
    data.assign(10, vector_fp(nSpecies()));

    names.push_back("X");
    getMoleFractions(&data[0][0]);

    names.push_back("Molal");
    getMolalities(&data[1][0]);

    names.push_back("Chem. Pot. (J/kmol)");
    getChemPotentials(&data[2][0]);

    names.push_back("Chem. Pot. SS (J/kmol)");
    getStandardChemPotentials(&data[3][0]);

    names.push_back("Molal Act. Coeff.");
    getMolalityActivityCoefficients(&data[4][0]);

    names.push_back("Molal Activity");
    getActivities(&data[5][0]);

    names.push_back("Part. Mol Enthalpy (J/kmol)");
    getPartialMolarEnthalpies(&data[5][0]);

    names.push_back("Part. Mol. Entropy (J/K/kmol)");
    getPartialMolarEntropies(&data[6][0]);

    names.push_back("Part. Mol. Energy (J/kmol)");
    getPartialMolarIntEnergies(&data[7][0]);

    names.push_back("Part. Mol. Cp (J/K/kmol");
    getPartialMolarCp(&data[8][0]);

    names.push_back("Part. Mol. Cv (J/K/kmol)");
    getPartialMolarVolumes(&data[9][0]);
}