Implement some things for bicubic backend

This commit is contained in:
Ian Bell
2015-06-28 17:39:34 -06:00
parent fa1720e512
commit 514ecef023
2 changed files with 18 additions and 5 deletions

View File

@@ -268,14 +268,21 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v
std::size_t iL = 0, iV = 0;
CoolPropDbl hL = 0, hV = 0;
_p = val1; _Q = val2;
if (_p < pure_saturation.pL[0]){throw ValueError(format("p (%g) Pa below minimum pressure", static_cast<double>(_p)));}
pure_saturation.is_inside(iP, _p, iQ, _Q, iL, iV, hL, hV);
using_single_phase_table = false;
if(!is_in_closed_range(0.0,1.0,static_cast<double>(_Q))){
if(!is_in_closed_range(0.0, 1.0, static_cast<double>(_Q))){
throw ValueError("vapor quality is not in (0,1)");
}
else{
cached_saturation_iL = iL; cached_saturation_iV = iV;
if (is_mixture){
std::vector<std::pair<std::size_t, std::size_t> > intersect = PhaseEnvelopeRoutines::find_intersections(phase_envelope, iP, _p);
if (intersect.empty()){ throw ValueError(format("p [%g Pa] is not within phase envelope", _p)); }
iV = intersect[0].first; iL = intersect[1].first;
cached_saturation_iL = iL; cached_saturation_iV = iV;
}
else{
cached_saturation_iL = iL; cached_saturation_iV = iV;
}
}
break;
}
@@ -291,6 +298,7 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v
else{
if (is_mixture){
std::vector<std::pair<std::size_t,std::size_t> > intersect = PhaseEnvelopeRoutines::find_intersections(phase_envelope, iT, _T);
if (intersect.empty()){ throw ValueError(format("T [%g K] is not within phase envelope", _T)); }
iV = intersect[0].first; iL = intersect[1].first;
double pL = PhaseEnvelopeRoutines::evaluate(phase_envelope, iP, iT, _T, iL);
double pV = PhaseEnvelopeRoutines::evaluate(phase_envelope, iP, iT, _T, iV);

View File

@@ -353,7 +353,12 @@ CoolPropDbl CoolProp::TabularBackend::calc_T(void){
return _HUGE; // not needed, will never be hit, just to make compiler happy
}
else{
return pure_saturation.evaluate(iT, _p, _Q, cached_saturation_iL, cached_saturation_iV);
if (is_mixture){
return phase_envelope_sat(phase_envelope, iT, iP, _p);
}
else{
return pure_saturation.evaluate(iT, _p, _Q, cached_saturation_iL, cached_saturation_iV);
}
}
}
CoolPropDbl CoolProp::TabularBackend::calc_rhomolar(void){