mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Implement QT_INPUTS for Tabular backends; closes #674
This commit is contained in:
@@ -280,8 +280,23 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QT_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl dummyL = 0, dummyV = 0;
|
||||
_Q = val1; _T = val2;
|
||||
pure_saturation.is_inside(iT, _T, iQ, _Q, iL, iV, dummyL, dummyV);
|
||||
using_single_phase_table = false;
|
||||
if(!is_in_closed_range(0.0, 1.0, static_cast<double>(_Q))){
|
||||
throw ValueError("vapor quality is not in (0,1)");
|
||||
}
|
||||
else{
|
||||
_p = pure_saturation.evaluate(iP, _T, _Q, iL, iV);
|
||||
cached_saturation_iL = iL; cached_saturation_iV = iV;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw ValueError("input pair is not currently supported");
|
||||
throw ValueError("Sorry, but this set of inputs is not supported for Bicubic backend");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,6 +180,21 @@ void CoolProp::TTSEBackend::update(CoolProp::input_pairs input_pair, double val1
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QT_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl dummyL = 0, dummyV = 0;
|
||||
_Q = val1; _T = val2;
|
||||
pure_saturation.is_inside(iT, _T, iQ, _Q, iL, iV, dummyL, dummyV);
|
||||
using_single_phase_table = false;
|
||||
if(!is_in_closed_range(0.0, 1.0, static_cast<double>(_Q))){
|
||||
throw ValueError("vapor quality is not in (0,1)");
|
||||
}
|
||||
else{
|
||||
_p = pure_saturation.evaluate(iP, _T, _Q, iL, iV);
|
||||
cached_saturation_iL = iL; cached_saturation_iV = iV;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw ValueError("Sorry, but this set of inputs is not supported for TTSE backend");
|
||||
}
|
||||
|
||||
@@ -181,14 +181,20 @@ class PureFluidSaturationTableData{
|
||||
std::swap(*this, temp); // Swap
|
||||
this->AS = temp.AS; // Reconnect the AbstractState pointer
|
||||
};
|
||||
double evaluate(parameters output, double p, double Q, std::size_t iL, std::size_t iV)
|
||||
double evaluate(parameters output, double p_or_T, double Q, std::size_t iL, std::size_t iV)
|
||||
{
|
||||
if (iL <= 2){ iL = 2; }
|
||||
else if (iL+1 == N){ iL = N-2; }
|
||||
if (iV <= 2){ iV = 2; }
|
||||
else if (iV+1 == N){ iV = N-2; }
|
||||
double logp = log(p);
|
||||
double logp = log(p_or_T);
|
||||
switch(output){
|
||||
case iP:
|
||||
{
|
||||
double _logpV = CubicInterp(this->TV, logpV, iV-2, iV-1, iV, iV+1, p_or_T);
|
||||
double _logpL = CubicInterp(this->TL, logpL, iL-2, iL-1, iL, iL+1, p_or_T);
|
||||
return Q*exp(_logpV) + (1-Q)*exp(_logpL);
|
||||
}
|
||||
case iT:
|
||||
{
|
||||
double TV = CubicInterp(logpV, this->TV, iV-2, iV-1, iV, iV+1, logp);
|
||||
@@ -237,9 +243,8 @@ class PureFluidSaturationTableData{
|
||||
if (!ValidNumber(muL)){throw ValueError("muL is invalid");}
|
||||
return 1/(Q/muV + (1-Q)/muL);
|
||||
}
|
||||
|
||||
default:
|
||||
throw ValueError("can't be something other than T or rho");
|
||||
throw ValueError("Output variable for evaluatre is invalid");
|
||||
}
|
||||
};
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user