Replaced coeffThermExp() with an analytical derivative.
This commit is contained in:
parent
0f57869240
commit
71393768bf
5 changed files with 40 additions and 54 deletions
|
|
@ -435,16 +435,22 @@ namespace Cantera {
|
|||
* \f]
|
||||
*/
|
||||
doublereal PDSS_Water::thermalExpansionCoeff() const {
|
||||
doublereal pres = pressure();
|
||||
doublereal val = m_sub->coeffThermExp(m_temp, pres);
|
||||
doublereal val = m_sub->coeffThermExp();
|
||||
return val;
|
||||
}
|
||||
|
||||
doublereal PDSS_Water::dthermalExpansionCoeffdT() const {
|
||||
doublereal pres = pressure();
|
||||
doublereal dens_save = m_dens;
|
||||
double tt = m_temp - 0.04;
|
||||
doublereal vald = m_sub->coeffThermExp(tt, pres);
|
||||
doublereal val2 = m_sub->coeffThermExp(m_temp, pres);
|
||||
doublereal dd = m_sub->density(tt, pres, m_iState, m_dens);
|
||||
if (dd < 0.0) {
|
||||
throw CanteraError("PDSS_Water::dthermalExpansionCoeffdT",
|
||||
"unable to solve for the density at T = " + fp2str(tt) + ", P = " + fp2str(pres));
|
||||
}
|
||||
doublereal vald = m_sub->coeffThermExp();
|
||||
m_sub->setState_TR(m_temp, dens_save);
|
||||
doublereal val2 = m_sub->coeffThermExp();
|
||||
doublereal val = (val2 - vald) / 0.04;
|
||||
return val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,14 +442,21 @@ namespace Cantera {
|
|||
}
|
||||
|
||||
double WaterProps::coeffThermalExp_IAPWS(double temp, double press) {
|
||||
|
||||
double cte;
|
||||
cte = m_waterIAPWS->coeffThermExp(temp, press);
|
||||
double dens = m_waterIAPWS->density(temp, press, WATER_LIQUID);
|
||||
if (dens < 0.0) {
|
||||
throw CanteraError("WaterProps::coeffThermalExp_IAPWS",
|
||||
"Unable to solve for density at T = " + fp2str(temp) + " and P = " + fp2str(press));
|
||||
}
|
||||
double cte = m_waterIAPWS->coeffThermExp();
|
||||
return cte;
|
||||
}
|
||||
|
||||
double WaterProps::isothermalCompressibility_IAPWS(double temp, double press) {
|
||||
m_waterIAPWS->density(temp, press, WATER_LIQUID);
|
||||
double dens = m_waterIAPWS->density(temp, press, WATER_LIQUID);
|
||||
if (dens < 0.0) {
|
||||
throw CanteraError("WaterProps::isothermalCompressibility_IAPWS",
|
||||
"Unable to solve for density at T = " + fp2str(temp) + " and P = " + fp2str(press));
|
||||
}
|
||||
double kappa = m_waterIAPWS->isothermalCompressibility();
|
||||
return kappa;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,45 +257,6 @@ double WaterPropsIAPWS::psat_est(double temperature) {
|
|||
return ps;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the coefficient of thermal expansion as a function
|
||||
* of temperature and pressure.
|
||||
* alpha = d (ln V) / dT at constant P.
|
||||
*
|
||||
* Currently this function is calculated using a differencing scheme.
|
||||
*/
|
||||
double WaterPropsIAPWS::coeffThermExp(double temperature, double pressure) {
|
||||
|
||||
double deltaT = 0.01;
|
||||
double psat_at=0.0;
|
||||
double rhoguess = -1;
|
||||
int phase = -1;
|
||||
if (temperature > T_c) {
|
||||
rhoguess = pressure * M_water / (Rgas * temperature);
|
||||
} else {
|
||||
psat_at = psat(temperature);
|
||||
if (pressure >= psat_at) {
|
||||
phase = WATER_LIQUID;
|
||||
deltaT = -0.01;
|
||||
} else
|
||||
phase = WATER_GAS;
|
||||
}
|
||||
|
||||
double dens_base = density(temperature, pressure, phase, rhoguess);
|
||||
|
||||
if (dens_base == -1.0) {
|
||||
printf("problems\n");
|
||||
exit(-1);
|
||||
}
|
||||
double temp_del = temperature + deltaT;
|
||||
|
||||
double dens_del = density(temp_del, pressure, phase, dens_base);
|
||||
|
||||
double Vavg = 0.5 * (1./dens_del + 1./dens_base);
|
||||
double retn = 1.0 / Vavg * (1./dens_del - 1.0/dens_base)/deltaT;
|
||||
return retn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the coefficient of isothermal compressibility
|
||||
* of temperature and pressure.
|
||||
|
|
@ -315,6 +276,13 @@ double WaterPropsIAPWS:: coeffPresExp() const {
|
|||
return (retn);
|
||||
}
|
||||
|
||||
double WaterPropsIAPWS:: coeffThermExp() const {
|
||||
double kappa = isothermalCompressibility();
|
||||
double beta = coeffPresExp();
|
||||
double dens = delta * Rho_c;
|
||||
return (kappa * dens * Rgas * beta / M_water);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the Gibbs free energy in mks units of
|
||||
* J kmol-1 K-1.
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public:
|
|||
*/
|
||||
double density() const;
|
||||
|
||||
//! Returns the coefficient of thermal expansion as a function of temperature and pressure.
|
||||
//! Returns the coefficient of thermal expansion.
|
||||
/*!
|
||||
* alpha = d (ln V) / dT at constant P.
|
||||
*
|
||||
|
|
@ -316,7 +316,7 @@ public:
|
|||
* @return
|
||||
* Returns the coefficient of thermal expansion
|
||||
*/
|
||||
double coeffThermExp(double temperature, double pressure);
|
||||
double coeffThermExp() const;
|
||||
|
||||
//! Returns the isochoric pressure-temperature coefficient
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -508,18 +508,23 @@ namespace Cantera {
|
|||
* \f]
|
||||
*/
|
||||
doublereal WaterSSTP::thermalExpansionCoeff() const {
|
||||
doublereal pres = pressure();
|
||||
double T = temperature();
|
||||
doublereal val = m_sub->coeffThermExp(T, pres);
|
||||
doublereal val = m_sub->coeffThermExp();
|
||||
return val;
|
||||
}
|
||||
|
||||
doublereal WaterSSTP::dthermalExpansionCoeffdT() const {
|
||||
doublereal pres = pressure();
|
||||
doublereal dens_save = density();
|
||||
double T = temperature();
|
||||
double tt = T - 0.04;
|
||||
doublereal vald = m_sub->coeffThermExp(tt, pres);
|
||||
doublereal val2 = m_sub->coeffThermExp(T, pres);
|
||||
doublereal dd = m_sub->density(tt, pres, WATER_LIQUID, dens_save);
|
||||
if (dd < 0.0) {
|
||||
throw CanteraError("WaterSSTP::dthermalExpansionCoeffdT",
|
||||
"Unable to solve for the density at T = " + fp2str(tt) + ", P = " + fp2str(pres));
|
||||
}
|
||||
doublereal vald = m_sub->coeffThermExp();
|
||||
m_sub->setState_TR(T, dens_save);
|
||||
doublereal val2 = m_sub->coeffThermExp();
|
||||
doublereal val = (val2 - vald) / 0.04;
|
||||
return val;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue