Skip to content

Commit

Permalink
Use max of Tmin and Ttriple to build tables; closes #738
Browse files Browse the repository at this point in the history
  • Loading branch information
ibell committed Aug 2, 2015
1 parent 55143c0 commit 0afd230
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Backends/Tabular/TabularBackends.cpp
Expand Up @@ -120,7 +120,8 @@ void CoolProp::PureFluidSaturationTableData::build(shared_ptr<CoolProp::Abstract
// ------------------------
// Actually build the table
// ------------------------
AS->update(QT_INPUTS, 0, AS->Ttriple());
CoolPropDbl Tmin = std::max(AS->Ttriple(), AS->Tmin());
AS->update(QT_INPUTS, 0, Tmin);
CoolPropDbl p_triple = AS->p();
CoolPropDbl p, pmin = p_triple, pmax = 0.9999*AS->p_critical();
for (std::size_t i = 0; i < N-1; ++i)
Expand Down
11 changes: 6 additions & 5 deletions src/Backends/Tabular/TabularBackends.h
Expand Up @@ -292,7 +292,7 @@ class PureFluidSaturationTableData{
*/
double first_saturation_deriv(parameters Of1, parameters Wrt1, int Q, double val, std::size_t i)
{
if (i < 2 || i > TL.size() - 2){throw ValueError("Invalid index to calc_first_saturation_deriv in TabularBackends");}
if (i < 2 || i > TL.size() - 2){throw ValueError(format("Invalid index (%d) to calc_first_saturation_deriv in TabularBackends",i));}
std::vector<double> *x, *y;
// Connect pointers for each vector
switch(Wrt1){
Expand Down Expand Up @@ -517,8 +517,9 @@ class LogPHTable : public SinglePhaseGriddedTableData
if (this->AS.get() == NULL){
throw ValueError("AS is not yet set");
}
CoolPropDbl Tmin = std::max(AS->Ttriple(), AS->Tmin());
// Minimum enthalpy is the saturated liquid enthalpy
AS->update(QT_INPUTS, 0, AS->Ttriple());
AS->update(QT_INPUTS, 0, Tmin);
xmin = AS->hmolar(); ymin = AS->p();

// Check both the enthalpies at the Tmax isotherm to see whether to use low or high pressure
Expand Down Expand Up @@ -562,9 +563,9 @@ class LogPTTable : public SinglePhaseGriddedTableData
void set_limits(){
if (this->AS.get() == NULL){
throw ValueError("AS is not yet set");
}
xmin = AS->Ttriple();
AS->update(QT_INPUTS, 0, AS->Ttriple());
}
CoolPropDbl Tmin = std::max(AS->Ttriple(), AS->Tmin());
AS->update(QT_INPUTS, 0, Tmin);
ymin = AS->p();

xmax = AS->Tmax()*1.499; ymax = AS->pmax();
Expand Down

0 comments on commit 0afd230

Please sign in to comment.