MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / build_saturation_shim

Method build_saturation_shim

src/Backends/REFPROP/REFPROPMixtureBackend.cpp:2386–2407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2384}
2385
2386shared_ptr<REFPROPMixtureBackend> REFPROPMixtureBackend::build_saturation_shim(int Q) {
2387 this->check_loaded_fluid();
2388 if (!(Q == 0 || Q == 1)) {
2389 throw ValueError(format("build_saturation_shim requires Q==0 or Q==1; got %d", Q));
2390 }
2391 const std::vector<double>& x_phase = (Q == 0) ? mole_fractions_liq : mole_fractions_vap;
2392 // is_cached (operator bool) check first: operator double()/CoolPropDbl() throws if uncached.
2393 bool have = (Q == 0) ? static_cast<bool>(_rhoLmolar) : static_cast<bool>(_rhoVmolar);
2394 CoolPropDbl rho_phase = have ? ((Q == 0) ? static_cast<CoolPropDbl>(_rhoLmolar) : static_cast<CoolPropDbl>(_rhoVmolar)) : _HUGE;
2395 if (!have || !ValidNumber(rho_phase)) {
2396 throw ValueError("The saturated state has not been set (no two-phase density available).");
2397 }
2398 shared_ptr<REFPROPMixtureBackend> shim(new REFPROPMixtureBackend());
2399 shim->link_to_loaded_fluids(*this);
2400 // Copy only the first Ncomp entries of the per-phase composition.
2401 std::vector<CoolPropDbl> x(x_phase.begin(), x_phase.begin() + Ncomp);
2402 shim->set_mole_fractions(x);
2403 shim->specify_phase((Q == 0) ? iphase_liquid : iphase_gas);
2404 shim->update_DmolarT_direct(rho_phase, _T);
2405 shim->_Q = static_cast<CoolPropDbl>(Q); // mark the shim as sitting on the envelope
2406 return shim;
2407}
2408
2409double REFPROPMixtureBackend::dpdT_along_saturation_pure(int kph) {
2410 if (Ncomp != 1) { // precondition: DPTSATKdll is a single-component saturation routine

Callers 1

CoolProp-Tests.cppFile · 0.80

Calls 7

check_loaded_fluidMethod · 0.95
ValidNumberFunction · 0.85
link_to_loaded_fluidsMethod · 0.80
specify_phaseMethod · 0.80
formatFunction · 0.50
set_mole_fractionsMethod · 0.45
update_DmolarT_directMethod · 0.45

Tested by

no test coverage detected