mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Replaced all fabs() with std::abs()
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -119,7 +119,7 @@ void FlashRoutines::QT_flash(HelmholtzEOSMixtureBackend &HEOS)
|
||||
rhoLsat = HEOS.solver_rho_Tp(HEOS._T, psatLanc, rhoLanc);
|
||||
rhoVsat = HEOS.solver_rho_Tp(HEOS._T, psatVanc, rhoVanc);
|
||||
if (!ValidNumber(rhoLsat) || !ValidNumber(rhoVsat) ||
|
||||
fabs(rhoLsat/rhoLanc-1) > 0.5 || fabs(rhoVanc/rhoVsat-1) > 0.5)
|
||||
std::abs(rhoLsat/rhoLanc-1) > 0.5 || std::abs(rhoVanc/rhoVsat-1) > 0.5)
|
||||
{
|
||||
throw ValueError("pseudo-pure failed");
|
||||
}
|
||||
@@ -524,10 +524,10 @@ void FlashRoutines::HSU_P_flash_singlephase_Newton(HelmholtzEOSMixtureBackend &H
|
||||
tau -= omega*(B[0][0]*f1+B[0][1]*f2);
|
||||
delta -= omega*(B[1][0]*f1+B[1][1]*f2);
|
||||
|
||||
if (fabs(f1)>fabs(f2))
|
||||
worst_error=fabs(f1);
|
||||
if (std::abs(f1) > std::abs(f2))
|
||||
worst_error = std::abs(f1);
|
||||
else
|
||||
worst_error=fabs(f2);
|
||||
worst_error = std::abs(f2);
|
||||
|
||||
if (!ValidNumber(f1) || !ValidNumber(f2))
|
||||
{
|
||||
|
||||
@@ -222,7 +222,7 @@ protected:
|
||||
long double T0 = cpjson::get_double(contribution, "T0");
|
||||
|
||||
// Take the constant term if nonzero and set it as a polyT term
|
||||
if (fabs(constants[0]) > 1e-14){
|
||||
if (std::abs(constants[0]) > 1e-14){
|
||||
std::vector<long double> c(1,constants[0]), t(1,0);
|
||||
if (EOS.alpha0.CP0PolyT.is_enabled() == true){
|
||||
EOS.alpha0.CP0PolyT.extend(c,t);
|
||||
@@ -233,7 +233,7 @@ protected:
|
||||
}
|
||||
|
||||
std::vector<long double> n, c, d, t;
|
||||
if (fabs(constants[1]) > 1e-14){
|
||||
if (std::abs(constants[1]) > 1e-14){
|
||||
// sinh term can be converted by setting a_k = C, b_k = 2*D, c_k = -1, d_k = 1
|
||||
n.push_back(constants[1]);
|
||||
t.push_back(-2*constants[2]/Tc);
|
||||
@@ -241,7 +241,7 @@ protected:
|
||||
d.push_back(-1);
|
||||
}
|
||||
|
||||
if (fabs(constants[3]) > 1e-14){
|
||||
if (std::abs(constants[3]) > 1e-14){
|
||||
// cosh term can be converted by setting a_k = C, b_k = 2*D, c_k = 1, d_k = 1
|
||||
n.push_back(-constants[3]);
|
||||
t.push_back(-2*constants[4]/Tc);
|
||||
|
||||
@@ -282,14 +282,14 @@ long double TransportRoutines::viscosity_water_hardcoded(HelmholtzEOSMixtureBack
|
||||
else
|
||||
{
|
||||
psi_D=acos(pow(1+powInt(qd*zeta,2),-1.0/2.0));
|
||||
w=sqrt(fabs((qc*zeta-1)/(qc*zeta+1)))*tan(psi_D/2.0);
|
||||
w=sqrt(std::abs((qc*zeta-1)/(qc*zeta+1)))*tan(psi_D/2.0);
|
||||
if (qc*zeta>1){
|
||||
L=log((1+w)/(1-w));
|
||||
}
|
||||
else{
|
||||
L=2*atan(fabs(w));
|
||||
L=2*atan(std::abs(w));
|
||||
}
|
||||
Y=1.0/12.0*sin(3*psi_D)-1/(4*qc*zeta)*sin(2*psi_D)+1.0/powInt(qc*zeta,2)*(1-5.0/4.0*powInt(qc*zeta,2))*sin(psi_D)-1.0/powInt(qc*zeta,3)*((1-3.0/2.0*powInt(qc*zeta,2))*psi_D-pow(fabs(powInt(qc*zeta,2)-1),3.0/2.0)*L);
|
||||
Y=1.0/12.0*sin(3*psi_D)-1/(4*qc*zeta)*sin(2*psi_D)+1.0/powInt(qc*zeta,2)*(1-5.0/4.0*powInt(qc*zeta,2))*sin(psi_D)-1.0/powInt(qc*zeta,3)*((1-3.0/2.0*powInt(qc*zeta,2))*psi_D-pow(std::abs(powInt(qc*zeta,2)-1),3.0/2.0)*L);
|
||||
}
|
||||
mubar_2=exp(x_mu*Y);
|
||||
|
||||
@@ -780,7 +780,7 @@ long double TransportRoutines::conductivity_critical_hardcoded_ammonia(Helmholtz
|
||||
double pi=3.141592654,a_chi,k_B=1.3806504e-23,X_T,DELTA_lambda,dPdT,eta_B,DELTA_lambda_id,DELTA_lambda_i;
|
||||
|
||||
rho = HEOS.keyed_output(CoolProp::iDmass);
|
||||
t = fabs((T-Tc)/Tc);
|
||||
t = std::abs((T-Tc)/Tc);
|
||||
a_chi = a_zeta/0.7;
|
||||
eta_B = (2.60+1.6*t)*1e-5;
|
||||
dPdT = (2.18-0.12/exp(17.8*t))*1e5; // [Pa-K]
|
||||
@@ -831,7 +831,7 @@ long double TransportRoutines::conductivity_hardcoded_helium(HelmholtzEOSMixture
|
||||
double x0 = 0.392, E1 = 2.8461, E2 = 0.27156, beta = 0.3554, gamma = 1.1743, delta = 4.304, rhoc_crit = 69.158,
|
||||
Tc = 5.18992, pc = 2.2746e5;
|
||||
|
||||
double DeltaT = fabs(1-T/Tc), DeltaRho = fabs(1-rho/rhoc_crit);
|
||||
double DeltaT = std::abs(1-T/Tc), DeltaRho = std::abs(1-rho/rhoc_crit);
|
||||
double eta = HEOS.viscosity(); // [Pa-s]
|
||||
double K_T = HEOS.isothermal_compressibility(), K_Tprime, K_Tbar;
|
||||
double dpdT = HEOS.first_partial_deriv(CoolProp::iP, CoolProp::iT, CoolProp::iDmolar);
|
||||
|
||||
@@ -524,7 +524,7 @@ void SaturationSolvers::saturation_D_pure(HelmholtzEOSMixtureBackend *HEOS, long
|
||||
}
|
||||
while (error > 1e-9);
|
||||
long double p_error_limit = 1e-3;
|
||||
if (fabs(p_error) > p_error_limit){
|
||||
if (std::abs(p_error) > p_error_limit){
|
||||
throw SolutionError(format("saturation_D_pure solver abs error on p [%Lg] > limit [%Lg]", p_error, p_error_limit));
|
||||
}
|
||||
}
|
||||
@@ -673,16 +673,16 @@ void SaturationSolvers::saturation_T_pure_Akasaka(HelmholtzEOSMixtureBackend *HE
|
||||
throw SolutionError(format("Akasaka solver did not converge after 100 iterations"));
|
||||
}
|
||||
}
|
||||
while (error > 1e-10 && fabs(stepL) > 10*DBL_EPSILON*fabs(stepL) && fabs(stepV) > 10*DBL_EPSILON*fabs(stepV));
|
||||
while (error > 1e-10 && std::abs(stepL) > 10*DBL_EPSILON*std::abs(stepL) && std::abs(stepV) > 10*DBL_EPSILON*std::abs(stepV));
|
||||
|
||||
long double p_error_limit = 1e-3;
|
||||
long double p_error = (PL - PV)/PL;
|
||||
if (fabs(p_error) > p_error_limit){
|
||||
if (std::abs(p_error) > p_error_limit){
|
||||
options.pL = PL;
|
||||
options.pV = PV;
|
||||
options.rhoL = rhoL;
|
||||
options.rhoV = rhoV;
|
||||
throw SolutionError(format("saturation_T_pure_Akasaka solver abs error on p [%g] > limit [%g]", fabs(p_error), p_error_limit));
|
||||
throw SolutionError(format("saturation_T_pure_Akasaka solver abs error on p [%g] > limit [%g]", std::abs(p_error), p_error_limit));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -774,7 +774,7 @@ void SaturationSolvers::successive_substitution(HelmholtzEOSMixtureBackend &HEOS
|
||||
throw ValueError(format("saturation_p was unable to reach a solution within 50 iterations"));
|
||||
}
|
||||
}
|
||||
while(fabs(f) > 1e-12 || iter < options.Nstep_max);
|
||||
while(std::abs(f) > 1e-12 || iter < options.Nstep_max);
|
||||
|
||||
HEOS.SatL->update_TP_guessrho(T, p, rhomolar_liq);
|
||||
HEOS.SatV->update_TP_guessrho(T, p, rhomolar_vap);
|
||||
@@ -910,7 +910,7 @@ void SaturationSolvers::newton_raphson_VLE_GV::call(HelmholtzEOSMixtureBackend *
|
||||
IO.T = exp(log(IO.T) + v[N]);
|
||||
IO.rhomolar_liq = exp(log(IO.rhomolar_liq) + v[N+1]);
|
||||
|
||||
if (fabs(IO.T) > 1e6)
|
||||
if (std::abs(IO.T) > 1e6)
|
||||
{
|
||||
/*std::cout << "J = " << vec_to_string(J,"%16.15g");
|
||||
std::cout << "nr = " << vec_to_string(r,"%16.15g");*/
|
||||
|
||||
@@ -1305,7 +1305,7 @@ TEST_CASE("Check REFPROP and CoolProp values agree","[REFPROP]")
|
||||
CAPTURE(rho_RP);
|
||||
|
||||
double DH = (rho_RP-rho_CP)/rho_RP;
|
||||
CHECK(fabs(DH) < 0.005);
|
||||
CHECK(std::abs(DH) < 0.005);
|
||||
}
|
||||
}
|
||||
SECTION("Saturation specific heats agree within 0.5% at T/Tc = 0.9")
|
||||
@@ -1336,7 +1336,7 @@ TEST_CASE("Check REFPROP and CoolProp values agree","[REFPROP]")
|
||||
CAPTURE(0.9*Tr);
|
||||
|
||||
double Dcp = (cp_RP-cp_CP)/cp_RP;
|
||||
CHECK(fabs(Dcp) < 0.005);
|
||||
CHECK(std::abs(Dcp) < 0.005);
|
||||
}
|
||||
}
|
||||
SECTION("Enthalpy and entropy reference state")
|
||||
@@ -1371,8 +1371,8 @@ TEST_CASE("Check REFPROP and CoolProp values agree","[REFPROP]")
|
||||
double DH = (S1->hmass()-S2->hmass());
|
||||
double DS = (S1->smass()-S2->smass());
|
||||
|
||||
CHECK(fabs(DH/h_RP) < 0.001);
|
||||
CHECK(fabs(DS/s_RP) < 0.001);
|
||||
CHECK(std::abs(DH/h_RP) < 0.001);
|
||||
CHECK(std::abs(DS/s_RP) < 0.001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user