mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-01-22 20:38:01 -05:00
Fixed weird bug with long<0 in REFPROP wrapper; Closes #401
This commit is contained in:
@@ -426,7 +426,7 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector<std::string> &f
|
||||
errormessagelength // Length of error message
|
||||
);
|
||||
|
||||
if (ierr <= 0) // Success (or a warning, which is silently squelched for now)
|
||||
if (static_cast<int>(ierr) <= 0) // Success (or a warning, which is silently squelched for now)
|
||||
{
|
||||
this->Ncomp = N;
|
||||
mole_fractions.resize(N);
|
||||
@@ -438,11 +438,12 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector<std::string> &f
|
||||
return;
|
||||
}
|
||||
else if (k < number_of_endings-1){ // Keep going
|
||||
if (CoolProp::get_debug_level() > 5){std::cout << "REFPROP error/warning:" << herr << std::endl;}
|
||||
if (CoolProp::get_debug_level() > 5){std::cout << format("REFPROP error/warning [ierr: %d]: %s",ierr, herr) << std::endl;}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CoolProp::get_debug_level() > 5){std::cout << format("k: %d #endings: %d", k, number_of_endings) << std::endl;}
|
||||
throw ValueError(format("Could not load these fluids: %s", components_joined_raw.c_str()));
|
||||
}
|
||||
}
|
||||
@@ -517,21 +518,21 @@ long double REFPROPMixtureBackend::calc_T_critical(){
|
||||
char herr[255];
|
||||
double Tcrit, pcrit_kPa, dcrit_mol_L;
|
||||
CRITPdll(&(mole_fractions[0]),&Tcrit,&pcrit_kPa,&dcrit_mol_L,&ierr,herr,255);
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return static_cast<long double>(Tcrit);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_p_critical(){
|
||||
long ierr = 0;
|
||||
char herr[255];
|
||||
double Tcrit, pcrit_kPa, dcrit_mol_L;
|
||||
CRITPdll(&(mole_fractions[0]),&Tcrit,&pcrit_kPa,&dcrit_mol_L,&ierr,herr,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
CRITPdll(&(mole_fractions[0]),&Tcrit,&pcrit_kPa,&dcrit_mol_L,&ierr,herr,255); if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return static_cast<long double>(pcrit_kPa*1000);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_rhomolar_critical(){
|
||||
long ierr = 0;
|
||||
char herr[255];
|
||||
double Tcrit, pcrit_kPa, dcrit_mol_L;
|
||||
CRITPdll(&(mole_fractions[0]),&Tcrit,&pcrit_kPa,&dcrit_mol_L,&ierr,herr,255); if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
CRITPdll(&(mole_fractions[0]),&Tcrit,&pcrit_kPa,&dcrit_mol_L,&ierr,herr,255); if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return static_cast<long double>(dcrit_mol_L*1000);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_T_reducing(){
|
||||
@@ -575,7 +576,7 @@ double REFPROPMixtureBackend::calc_melt_Tmax()
|
||||
MELTPdll(&pmax_kPa, &(mole_fractions[0]),
|
||||
&Tmax_melt,
|
||||
&ierr,herr,errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
//else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return Tmax_melt;
|
||||
}
|
||||
@@ -589,7 +590,7 @@ long double REFPROPMixtureBackend::calc_melting_line(int param, int given, long
|
||||
MELTTdll(&_T, &(mole_fractions[0]),
|
||||
&p_kPa,
|
||||
&ierr,herr,errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return p_kPa*1000;
|
||||
}
|
||||
else if (param == iT && given == iP){
|
||||
@@ -597,7 +598,7 @@ long double REFPROPMixtureBackend::calc_melting_line(int param, int given, long
|
||||
MELTPdll(&p_kPa, &(mole_fractions[0]),
|
||||
&_T,
|
||||
&ierr,herr,errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); } //else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return p_kPa*1000;
|
||||
}
|
||||
else{
|
||||
@@ -619,7 +620,7 @@ long double REFPROPMixtureBackend::calc_viscosity(void)
|
||||
TRNPRPdll(&_T,&rhomol_L,&(mole_fractions[0]), // Inputs
|
||||
&eta,&tcx, // Outputs
|
||||
&ierr,herr,errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
//else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
_viscosity = 1e-6*eta;
|
||||
_conductivity = tcx;
|
||||
@@ -639,7 +640,7 @@ long double REFPROPMixtureBackend::calc_surface_tension(void)
|
||||
SURFTdll(&_T, &rho_mol_L, &(mole_fractions[0]), // Inputs
|
||||
&sigma, // Outputs
|
||||
&ierr, herr, errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
//else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
_surface_tension = sigma;
|
||||
return static_cast<double>(_surface_tension);
|
||||
@@ -654,7 +655,7 @@ long double REFPROPMixtureBackend::calc_fugacity_coefficient(int i)
|
||||
FUGCOFdll(&_T, &rho_mol_L, &(mole_fractions[0]), // Inputs
|
||||
&(fug_cof[0]), // Outputs
|
||||
&ierr, herr, errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
//else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
return static_cast<long double>(fug_cof[i]);
|
||||
}
|
||||
@@ -665,7 +666,7 @@ void REFPROPMixtureBackend::calc_phase_envelope(const std::string &type)
|
||||
char herr[255];
|
||||
SATSPLNdll(&(mole_fractions[0]), // Inputs
|
||||
&ierr, herr, errormessagelength); // Error message
|
||||
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("%s",herr).c_str()); }
|
||||
}
|
||||
long double REFPROPMixtureBackend::calc_cpmolar_idealgas(void)
|
||||
{
|
||||
@@ -704,7 +705,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions[0]), // Saturation terms
|
||||
&q,&emol,&hmol,&smol,&cvmol,&cpmol,&w,
|
||||
&ierr,herr,errormessagelength); //
|
||||
if (ierr > 0) { throw ValueError(format("PT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("PT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = value1;
|
||||
@@ -726,7 +727,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&emol,&hmol,&smol,&cvmol,&cpmol,&w,
|
||||
&ierr,herr,errormessagelength);
|
||||
if (ierr > 0) { throw ValueError(format("DmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("DmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000;
|
||||
@@ -755,7 +756,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&emol,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
if (ierr > 0) { throw ValueError(format("DmolarP: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("DmolarP: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_rhomolar = value1;
|
||||
@@ -785,7 +786,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&emol,&smol,&cvmol,&cpmol,&w,
|
||||
&ierr,herr,errormessagelength);
|
||||
if (ierr > 0) { throw ValueError(format("DmolarHmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("DmolarHmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000;
|
||||
@@ -815,7 +816,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&emol,&hmol,&cvmol,&cpmol,&w,
|
||||
&ierr,herr,errormessagelength);
|
||||
if (ierr > 0) { throw ValueError(format("DmolarSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("DmolarSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000;
|
||||
@@ -845,7 +846,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&hmol,&hmol,&cvmol,&cpmol,&w,
|
||||
&ierr,herr,errormessagelength);
|
||||
if (ierr > 0) { throw ValueError(format("DmolarUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("DmolarUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000;
|
||||
@@ -874,7 +875,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&q,&emol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
if (ierr > 0) { throw ValueError(format("HmolarPmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("HmolarPmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = value2;
|
||||
@@ -904,7 +905,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&emol,&hmol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("PSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("PSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = value1;
|
||||
@@ -935,7 +936,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("PUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("PUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = value1;
|
||||
@@ -964,7 +965,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&emol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("HmolarSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("HmolarSmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000; // 1000 for conversion from kPa to Pa
|
||||
@@ -995,7 +996,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("SmolarUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("SmolarUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000; // 1000 for conversion from kPa to Pa
|
||||
@@ -1034,7 +1035,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&emol,&hmol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("SmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("SmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000; // 1000 for conversion from kPa to Pa
|
||||
@@ -1072,7 +1073,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&emol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("HmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("HmolarT: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000; // 1000 for conversion from kPa to Pa
|
||||
@@ -1110,7 +1111,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&q,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("TUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("TUmolar: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = p_kPa*1000; // 1000 for conversion from kPa to Pa
|
||||
@@ -1148,7 +1149,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&emol,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) { throw ValueError(format("PQ: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
if (static_cast<int>(ierr) > 0) { throw ValueError(format("PQ: %s",herr).c_str()); }// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());}
|
||||
|
||||
// Set all cache values that can be set with unit conversion to SI
|
||||
_p = value1;
|
||||
@@ -1179,7 +1180,7 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
&emol,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (ierr > 0) {
|
||||
if (static_cast<int>(ierr) > 0) {
|
||||
throw ValueError(format("TQ(%s): %s",LoadedREFPROPRef.c_str(), herr).c_str());
|
||||
}// TODO: else if (ierr < 0) {set_warning(format("%s",herr).c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user