9 namespace SaturationSolvers {
51 std::vector<CoolPropDbl>
x,
y,
K;
67 return log(pci / p) + 5.373 * (1 + omegai) * (1 - Tci / T);
100 #if !defined(NO_FMTLIB) && FMT_VERSION >= 90000
102 return fmt::underlying(option);
144 const std::vector<CoolPropDbl>& z, std::vector<CoolPropDbl>& K, mixture_VLE_IO& options);
152 void x_and_y_from_K(
CoolPropDbl beta,
const std::vector<CoolPropDbl>& K,
const std::vector<CoolPropDbl>& z, std::vector<CoolPropDbl>& x,
153 std::vector<CoolPropDbl>& y);
165 const std::vector<CoolPropDbl>&
z;
166 std::vector<CoolPropDbl>&
K;
170 const std::vector<CoolPropDbl>&
z, std::vector<CoolPropDbl>&
K)
178 double call(
double input_value) {
185 for (
unsigned int i = 0; i <
z.size(); i++) {
186 K[i] = exp(Wilson_lnK_factor(
HEOS,
T,
p, i));
187 summer +=
z[i] * (
K[i] - 1) / (1 -
beta +
beta *
K[i]);
193 const std::vector<CoolPropDbl>& z) {
194 double ptriple = 0, pcrit = 0, Ttriple = 0, Tcrit = 0;
200 for (
unsigned int i = 0; i < z.size(); i++) {
212 return exp(log(pcrit / ptriple) / (Tcrit - Ttriple) * (input_value - Ttriple) + log(ptriple));
214 return 1 / (1 / Tcrit - (1 / Ttriple - 1 / Tcrit) / log(pcrit / ptriple) * log(input_value / pcrit));
247 const std::vector<CoolPropDbl>& z,
double guess) {
252 if (input_type ==
imposed_T && (std::abs(beta) < 1e-12 || std::abs(beta - 1) < 1e-12)) {
254 bool beta0 = std::abs(beta) < 1e-12;
255 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
260 out += z[i] * pci * exp(5.373 * (1 + omegai) * (1 - Tci / input_value));
262 out += z[i] / (pci * exp(5.373 * (1 + omegai) * (1 - Tci / input_value)));
268 std::vector<CoolPropDbl>& K = HEOS.
get_K();
269 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
273 K[i] = pci / out * exp(5.373 * (1 + omegai) * (1 - Tci / input_value));
279 out =
Brent(Resid, 50, 10000, 1e-10, 1e-10, 100);
281 out =
Secant(Resid, guess, 0.001, 1e-10, 100);
283 throw ValueError(
"saturation_p_Wilson failed to get good output value");
303 CoolPropDbl beta,
omega,
rhomolar_liq,
rhomolar_vap,
pL,
pV,
p,
T,
hmolar_liq,
hmolar_vap,
smolar_liq,
smolar_vap;
305 std::vector<CoolPropDbl>
x,
y,
z;
365 std::vector<CoolPropDbl>
K,
x,
y,
z;
427 CoolPropDbl omega,
rhomolar_liq,
rhomolar_vap,
pL,
pV,
p,
T,
hmolar_liq,
hmolar_vap,
smolar_liq,
smolar_vap;
429 std::vector<CoolPropDbl>
x,
y;
488 std::vector<CoolPropDbl>
K,
x,
y;
538 std::vector<CoolPropDbl>
x,
579 namespace StabilityRoutines {
589 const std::vector<double>&
z;
600 z(
HEOS.get_mole_fractions_doubleref()),
647 void get_liq(std::vector<double>&
x,
double& rhomolar) {
652 void get_vap(std::vector<double>&
y,
double& rhomolar) {