mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-02-03 18:35:03 -05:00
Bunch of small changes to code to make Xcode happier
This commit is contained in:
@@ -676,8 +676,6 @@ void FlashRoutines::PT_Q_flash_mixtures(HelmholtzEOSMixtureBackend &HEOS, parame
|
||||
}
|
||||
IO.x[IO.x.size()-1] = 1 - std::accumulate(IO.x.begin(), IO.x.end()-1, 0.0);
|
||||
IO.y[IO.y.size()-1] = 1 - std::accumulate(IO.y.begin(), IO.y.end()-1, 0.0);
|
||||
std::vector<CoolPropDbl> &XX = IO.x;
|
||||
std::vector<CoolPropDbl> &YY = IO.y;
|
||||
NR.call(HEOS, IO);
|
||||
}
|
||||
}
|
||||
@@ -1034,8 +1032,12 @@ void FlashRoutines::HSU_P_flash_singlephase_Brent(HelmholtzEOSMixtureBackend &HE
|
||||
{
|
||||
// Specify the state to avoid saturation calls, but only if phase is subcritical
|
||||
switch (CoolProp::phases phase = HEOS->phase()) {
|
||||
case iphase_liquid: case iphase_gas:
|
||||
case iphase_liquid:
|
||||
case iphase_gas:
|
||||
HEOS->specify_phase(phase);
|
||||
default:
|
||||
throw ValueError(format("Could not match phase in solver_resid initializer"));
|
||||
|
||||
}
|
||||
}
|
||||
double call(double T){
|
||||
@@ -1191,7 +1193,7 @@ void FlashRoutines::HSU_P_flash(HelmholtzEOSMixtureBackend &HEOS, parameters oth
|
||||
if (!twophase){
|
||||
PY_singlephase_flash_resid resid(HEOS, HEOS._p, other, value);
|
||||
// If that fails, try a bounded solver
|
||||
CoolPropDbl rhomolar = Brent(resid, closest_state.T+10, 1000, DBL_EPSILON, 1e-10, 100, errstr);
|
||||
Brent(resid, closest_state.T+10, 1000, DBL_EPSILON, 1e-10, 100, errstr);
|
||||
HEOS.unspecify_phase();
|
||||
}
|
||||
else{
|
||||
@@ -1406,8 +1408,7 @@ void FlashRoutines::HS_flash(HelmholtzEOSMixtureBackend &HEOS)
|
||||
}
|
||||
}
|
||||
while(!good_Tmax);
|
||||
double p = Brent(resid, Tmin, Tmax, DBL_EPSILON, 1e-10, 100, errstr);
|
||||
int rr = 0;
|
||||
Brent(resid, Tmin, Tmax, DBL_EPSILON, 1e-10, 100, errstr);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_CATCH)
|
||||
|
||||
@@ -334,7 +334,6 @@ CoolPropDbl GERG2008ReducingFunction::d2Yrdxidxj(const std::vector<CoolPropDbl>
|
||||
// Table S1 from Gernert, 2014, supplemental information
|
||||
if (j == N-1 || i == N-1){ return 0.0; }
|
||||
if (i == j){ return d2Yrdxi2__constxj(x, i, beta, gamma, Y_c_ij, Yc, xN_flag); }
|
||||
CoolPropDbl xN = x[N-1];
|
||||
CoolPropDbl d2Yr_dxidxj = 2*Yc[N-1];
|
||||
d2Yr_dxidxj += c_Y_ij(i, j, beta, gamma, Y_c_ij)*d2fYijdxidxj(x,i,j,beta);
|
||||
|
||||
@@ -380,14 +379,12 @@ CoolPropDbl GERG2008ReducingFunction::d3Yrdxidxjdxk(const std::vector<CoolPropDb
|
||||
}
|
||||
}
|
||||
else if (xN_flag == XN_DEPENDENT){
|
||||
CoolPropDbl xN = x[N - 1];
|
||||
CoolPropDbl summer = 0;
|
||||
// Needed for all third partials
|
||||
for (std::size_t m = 0; m < N-1; m++)
|
||||
{
|
||||
summer -= c_Y_ij(m, N-1, beta, gamma, Y_c_ij)*d3fYkidxi3__constxk(x, m, N-1, beta);
|
||||
}
|
||||
double summer0 = summer;
|
||||
if (i != j && j != k && k != i){
|
||||
summer += c_Y_ij(i, N-1, beta, gamma, Y_c_ij)*d3fYijdxidxj2(x, i, N-1, beta);
|
||||
summer += c_Y_ij(j, N-1, beta, gamma, Y_c_ij)*d3fYijdxidxj2(x, j, N-1, beta);
|
||||
@@ -487,7 +484,6 @@ CoolPropDbl GERG2008ReducingFunction::d3fYikdxi3__constxk(const std::vector<Cool
|
||||
CoolPropDbl GERG2008ReducingFunction::d3fYkidxi3__constxk(const std::vector<CoolPropDbl> &x, std::size_t k, std::size_t i, const STLMatrix &beta)
|
||||
{
|
||||
double x_i = x[i], x_k = x[k], beta_Y = beta[k][i], beta_Y2 = beta_Y*beta_Y;
|
||||
double den = pow(beta_Y, 8)*pow(x_i, 4) + 4*pow(beta_Y, 6)*pow(x_i, 3)*x_k + 6*pow(beta_Y, 4)*pow(x_i*x_k, 2) + 4*beta_Y2*x_i*pow(x_k, 3) + pow(x_k, 4);
|
||||
return 6*beta_Y2*x_k*x_k*x_k*(1-beta_Y2)/pow(beta_Y2*x_k+x_i, 4);
|
||||
}
|
||||
|
||||
|
||||
@@ -985,7 +985,7 @@ CoolPropDbl TransportRoutines::conductivity_hardcoded_methane(HelmholtzEOSMixtur
|
||||
// Dilute
|
||||
double C[] = {0, -3.0328138281, 16.918880086, -37.189364917, 41.288861858, -24.615921140, 8.9488430959, -1.8739245042, 0.20966101390, -9.6570437074e-3};
|
||||
double OMEGA22_summer = 0;
|
||||
double t = HEOS.T()/174.0, sigma = 0.36652e-9;
|
||||
double t = HEOS.T()/174.0;
|
||||
for (int i = 1; i <= 9; ++i){
|
||||
OMEGA22_summer += C[i]*pow(t, (i-1.0)/3.0-1.0);
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ void SaturationSolvers::saturation_critical(HelmholtzEOSMixtureBackend &HEOS, pa
|
||||
HEOS->SatV->update(DmolarT_INPUTS, rhomolar_vap, T);
|
||||
|
||||
// Calculate the Gibbs functions for liquid and vapor
|
||||
CoolPropDbl gL = HEOS->SatL->gibbsmolar();
|
||||
CoolPropDbl gV = HEOS->SatV->gibbsmolar();
|
||||
//CoolPropDbl gL = HEOS->SatL->gibbsmolar();
|
||||
//CoolPropDbl gV = HEOS->SatV->gibbsmolar();
|
||||
|
||||
// Residual is difference in Gibbs function
|
||||
// r = gL - gV;
|
||||
|
||||
@@ -445,7 +445,6 @@ CoolPropDbl REFPROPMixtureBackend::calc_Ttriple(){
|
||||
// c Rgas--gas constant [J/mol-K]
|
||||
this->check_loaded_fluid();
|
||||
double wmm,ttrp,tnbpt,tc,pc,Dc,Zc,acf,dip,Rgas;
|
||||
double summer = 0;
|
||||
long icomp = 1L;
|
||||
// Check if more than one
|
||||
std::size_t size = mole_fractions.size();
|
||||
@@ -541,7 +540,7 @@ CoolPropDbl REFPROPMixtureBackend::calc_PIP(void)
|
||||
// partial derivatives of pressure, volume,and temperature without reference to saturation properties:
|
||||
// Applications in phase equilibria calculations"
|
||||
double t = _T, rho = _rhomolar/1000.0, // mol/dm^3
|
||||
x = 0,p = 0,e = 0,h = 0,s = 0,cv = 0,cp = 0,w = 0,Z = 0,hjt = 0,A = 0,G = 0,
|
||||
p = 0,e = 0,h = 0,s = 0,cv = 0,cp = 0,w = 0,Z = 0,hjt = 0,A = 0,G = 0,
|
||||
xkappa = 0,beta = 0,dPdrho = 0,d2PdD2 = 0,dPT = 0,drhodT = 0,drhodP = 0,
|
||||
d2PT2 = 0,d2PdTD = 0,spare3 = 0,spare4 = 0;
|
||||
//subroutine THERM2 (t,rho,x,p,e,h,s,cv,cp,w,Z,hjt,A,G,
|
||||
@@ -678,8 +677,6 @@ void REFPROPMixtureBackend::calc_phase_envelope(const std::string &type)
|
||||
SPLNVALdll(&isp, &iderv, &rho_molL, &y, &ierr, herr, errormessagelength);
|
||||
PhaseEnvelope.smolar_vap.push_back(y*1000);
|
||||
}
|
||||
|
||||
double rr = 0;
|
||||
}
|
||||
CoolPropDbl REFPROPMixtureBackend::calc_cpmolar_idealgas(void)
|
||||
{
|
||||
@@ -1302,9 +1299,9 @@ void REFPROPMixtureBackend::update_with_guesses(CoolProp::input_pairs input_pair
|
||||
const GuessesStructure &guesses)
|
||||
{
|
||||
this->check_loaded_fluid();
|
||||
double rho_mol_L=_HUGE, rhoLmol_L=_HUGE, rhoVmol_L=_HUGE,
|
||||
double rho_mol_L=_HUGE,
|
||||
hmol=_HUGE,emol=_HUGE,smol=_HUGE,cvmol=_HUGE,cpmol=_HUGE,
|
||||
w=_HUGE,q=_HUGE, mm=_HUGE, p_kPa = _HUGE, hjt = _HUGE;
|
||||
w=_HUGE,q=_HUGE, p_kPa = _HUGE, hjt = _HUGE;
|
||||
long ierr = 0;
|
||||
char herr[errormessagelength+1];
|
||||
|
||||
@@ -1330,6 +1327,10 @@ void REFPROPMixtureBackend::update_with_guesses(CoolProp::input_pairs input_pair
|
||||
_p = value1;
|
||||
_rhomolar = rho_mol_L*1000; // 1000 for conversion from mol/L to mol/m3
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw CoolProp::ValueError(format("Unable to match given input_pair in update_with_guesses"));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate everything else
|
||||
@@ -1358,7 +1359,7 @@ CoolPropDbl REFPROPMixtureBackend::call_phixdll(long itau, long idel)
|
||||
CoolPropDbl REFPROPMixtureBackend::call_phi0dll(long itau, long idel)
|
||||
{
|
||||
this->check_loaded_fluid();
|
||||
double val = 0, tau = _tau, delta = _delta, __T = T(), __rho = rhomolar()/1000;
|
||||
double val = 0, tau = _tau, __T = T(), __rho = rhomolar()/1000;
|
||||
if (PHI0dll == NULL){throw ValueError("PHI0dll function is not available in your version of REFPROP. Please upgrade");}
|
||||
PHI0dll(&itau, &idel, &__T, &__rho, &(mole_fractions[0]), &val);
|
||||
return static_cast<CoolPropDbl>(val)/pow(tau,itau); // Not multplied by delta^idel
|
||||
|
||||
@@ -266,7 +266,6 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v
|
||||
}
|
||||
case PQ_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl hL = 0, hV = 0;
|
||||
_p = val1; _Q = val2;
|
||||
|
||||
using_single_phase_table = false;
|
||||
@@ -289,7 +288,6 @@ void CoolProp::BicubicBackend::update(CoolProp::input_pairs input_pair, double v
|
||||
}
|
||||
case QT_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl dummyL = 0, dummyV = 0;
|
||||
_Q = val1; _T = val2;
|
||||
|
||||
using_single_phase_table = false;
|
||||
@@ -443,8 +441,6 @@ void CoolProp::BicubicBackend::invert_single_phase_x(const SinglePhaseGriddedTab
|
||||
|
||||
// Get the alpha coefficients
|
||||
const std::vector<double> &alpha = cell.get(other_key);
|
||||
|
||||
std::size_t NNN = alpha.size();
|
||||
|
||||
// Normalized value in the range (0, 1)
|
||||
double yhat = (y - table.yvec[j])/(table.yvec[j+1] - table.yvec[j]);
|
||||
@@ -456,7 +452,7 @@ void CoolProp::BicubicBackend::invert_single_phase_x(const SinglePhaseGriddedTab
|
||||
double c = alpha[1+0*4]*y_0+alpha[1+1*4]*y_1+alpha[1+2*4]*y_2+alpha[1+3*4]*y_3; // factors of xhat
|
||||
double d = alpha[0+0*4]*y_0+alpha[0+1*4]*y_1+alpha[0+2*4]*y_2+alpha[0+3*4]*y_3 - other; // constant factors
|
||||
int N = 0;
|
||||
double xhat0, xhat1, xhat2, val, xhat;
|
||||
double xhat0, xhat1, xhat2, val, xhat = _HUGE;
|
||||
solve_cubic(a, b, c, d, N, xhat0, xhat1, xhat2);
|
||||
if (N == 1){
|
||||
xhat = xhat0;
|
||||
@@ -500,8 +496,6 @@ void CoolProp::BicubicBackend::invert_single_phase_y(const SinglePhaseGriddedTab
|
||||
|
||||
// Get the alpha coefficients
|
||||
const std::vector<double> &alpha = cell.get(other_key);
|
||||
|
||||
std::size_t NNN = alpha.size();
|
||||
|
||||
// Normalized value in the range (0, 1)
|
||||
double xhat = (x - table.xvec[i])/(table.xvec[i+1] - table.xvec[i]);
|
||||
@@ -513,7 +507,7 @@ void CoolProp::BicubicBackend::invert_single_phase_y(const SinglePhaseGriddedTab
|
||||
double c = alpha[0+1*4]*x_0 + alpha[1+1*4]*x_1 + alpha[2+1*4]*x_2 + alpha[3+1*4]*x_3; // factors of yhat
|
||||
double d = alpha[0+0*4]*x_0 + alpha[1+0*4]*x_1 + alpha[2+0*4]*x_2 + alpha[3+0*4]*x_3 - other; // constant factors
|
||||
int N = 0;
|
||||
double yhat0, yhat1, yhat2, val, yhat;
|
||||
double yhat0, yhat1, yhat2, val, yhat = _HUGE;
|
||||
solve_cubic(a, b, c, d, N, yhat0, yhat1, yhat2);
|
||||
if (N == 1){
|
||||
yhat = yhat0;
|
||||
|
||||
@@ -181,7 +181,6 @@ void CoolProp::TTSEBackend::update(CoolProp::input_pairs input_pair, double val1
|
||||
}
|
||||
case PQ_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl hL = 0, hV = 0;
|
||||
_p = val1; _Q = val2;
|
||||
|
||||
using_single_phase_table = false;
|
||||
@@ -204,7 +203,6 @@ void CoolProp::TTSEBackend::update(CoolProp::input_pairs input_pair, double val1
|
||||
}
|
||||
case QT_INPUTS:{
|
||||
std::size_t iL = 0, iV = 0;
|
||||
CoolPropDbl dummyL = 0, dummyV = 0;
|
||||
_Q = val1; _T = val2;
|
||||
|
||||
using_single_phase_table = false;
|
||||
|
||||
@@ -459,7 +459,7 @@ CoolPropDbl CoolProp::TabularBackend::calc_cvmolar(void){
|
||||
}
|
||||
|
||||
CoolPropDbl CoolProp::TabularBackend::calc_viscosity(void){
|
||||
PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
//PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
PureFluidSaturationTableData &pure_saturation = dataset->pure_saturation;
|
||||
if (using_single_phase_table){
|
||||
switch (selected_table){
|
||||
@@ -474,7 +474,7 @@ CoolPropDbl CoolProp::TabularBackend::calc_viscosity(void){
|
||||
}
|
||||
}
|
||||
CoolPropDbl CoolProp::TabularBackend::calc_conductivity(void){
|
||||
PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
//PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
PureFluidSaturationTableData &pure_saturation = dataset->pure_saturation;
|
||||
if (using_single_phase_table){
|
||||
switch (selected_table){
|
||||
@@ -489,7 +489,7 @@ CoolPropDbl CoolProp::TabularBackend::calc_conductivity(void){
|
||||
}
|
||||
}
|
||||
CoolPropDbl CoolProp::TabularBackend::calc_first_partial_deriv(parameters Of, parameters Wrt, parameters Constant){
|
||||
PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
//PhaseEnvelopeData & phase_envelope = dataset->phase_envelope;
|
||||
PureFluidSaturationTableData &pure_saturation = dataset->pure_saturation;
|
||||
if (using_single_phase_table){
|
||||
CoolPropDbl dOf_dx, dOf_dy, dWrt_dx, dWrt_dy, dConstant_dx, dConstant_dy;
|
||||
|
||||
@@ -680,7 +680,7 @@ class TabularBackend : public AbstractState
|
||||
std::vector<CoolPropDbl> mole_fractions;
|
||||
public:
|
||||
shared_ptr<CoolProp::AbstractState> AS;
|
||||
TabularBackend(shared_ptr<CoolProp::AbstractState> AS) : tables_loaded(false), using_single_phase_table(false), AS(AS), is_mixture(false) {
|
||||
TabularBackend(shared_ptr<CoolProp::AbstractState> AS) : tables_loaded(false), using_single_phase_table(false), is_mixture(false), AS(AS) {
|
||||
selected_table = SELECTED_NO_TABLE;
|
||||
// Flush the cached indices (set to large number)
|
||||
cached_single_phase_i = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
@@ -276,7 +276,7 @@ bool is_valid_first_saturation_derivative(const std::string &name, parameters &i
|
||||
if (!((i0 > 0) && (i0 != std::string::npos) && (i1 > (i0+1)) && (i1 != std::string::npos))){ return false; }
|
||||
std::string den = split_at_slash[1].substr(i0+1, i1-i0-1);
|
||||
|
||||
parameters Of, Wrt, Constant;
|
||||
parameters Of, Wrt;
|
||||
if (is_valid_parameter(num, Of) && is_valid_parameter(den, Wrt) && upper(split_at_bar[1]) == "SIGMA"){
|
||||
iOf = Of; iWrt = Wrt; return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user