mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-02-12 23:05:18 -05:00
Replaced all tabs with spaces (finally) in C++ files
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -23,21 +23,21 @@
|
||||
namespace CoolProp {
|
||||
|
||||
REFPROPBackend::REFPROPBackend(const std::string & fluid_name) {
|
||||
// Do the REFPROP instantiation for this fluid
|
||||
// Do the REFPROP instantiation for this fluid
|
||||
|
||||
// Try to add this fluid to REFPROP - might want to think about making array of
|
||||
// components and setting mole fractions if they change a lot.
|
||||
std::vector<std::string> component_names(1,fluid_name);
|
||||
set_REFPROP_fluids(component_names);
|
||||
// Try to add this fluid to REFPROP - might want to think about making array of
|
||||
// components and setting mole fractions if they change a lot.
|
||||
std::vector<std::string> component_names(1,fluid_name);
|
||||
set_REFPROP_fluids(component_names);
|
||||
|
||||
// Set the mole fraction to 1 in the base class (we can't set the mole fraction in this class,
|
||||
// otherwise a NotImplementedError will be returned)
|
||||
std::vector<long double> x(1, 1.0); // (one element with value of 1.0)
|
||||
REFPROPMixtureBackend::set_mole_fractions(x);
|
||||
// Set the mole fraction to 1 in the base class (we can't set the mole fraction in this class,
|
||||
// otherwise a NotImplementedError will be returned)
|
||||
std::vector<long double> x(1, 1.0); // (one element with value of 1.0)
|
||||
REFPROPMixtureBackend::set_mole_fractions(x);
|
||||
}
|
||||
|
||||
REFPROPBackend::~REFPROPBackend() {
|
||||
// TODO Auto-generated destructor stub
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
@@ -20,10 +20,10 @@ and exposes just the pure fluid interface.
|
||||
class REFPROPBackend : public REFPROPMixtureBackend {
|
||||
public:
|
||||
|
||||
REFPROPBackend();
|
||||
REFPROPBackend(const std::string &fluid_name);
|
||||
|
||||
virtual ~REFPROPBackend();
|
||||
REFPROPBackend();
|
||||
REFPROPBackend(const std::string &fluid_name);
|
||||
|
||||
virtual ~REFPROPBackend();
|
||||
};
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
@@ -71,7 +71,7 @@ surface tension N/m
|
||||
#define filepathlength 255
|
||||
#define lengthofreference 3
|
||||
#define errormessagelength 255
|
||||
#define ncmax 20 // Note: ncmax is the max number of components
|
||||
#define ncmax 20 // Note: ncmax is the max number of components
|
||||
#define numparams 72
|
||||
#define maxcoefs 50
|
||||
|
||||
@@ -82,7 +82,7 @@ std::string LoadedREFPROPRef;
|
||||
#define filepathlength 255
|
||||
#define lengthofreference 3
|
||||
#define errormessagelength 255
|
||||
#define ncmax 20 // Note: ncmax is the max number of components
|
||||
#define ncmax 20 // Note: ncmax is the max number of components
|
||||
#define numparams 72
|
||||
#define maxcoefs 50
|
||||
|
||||
@@ -318,7 +318,7 @@ double setFunctionPointers()
|
||||
SETMODdll = (SETMODdll_POINTER) getFunctionPointer((char *)SETMODdll_NAME);
|
||||
SETREFdll = (SETREFdll_POINTER) getFunctionPointer((char *)SETREFdll_NAME);
|
||||
SETUPdll = (SETUPdll_POINTER) getFunctionPointer((char *)SETUPdll_NAME);
|
||||
// SPECGRdll = (SPECGRdll_POINTER) getFunctionPointer((char *)SPECGRdll_NAME); // not in library
|
||||
// SPECGRdll = (SPECGRdll_POINTER) getFunctionPointer((char *)SPECGRdll_NAME); // not in library
|
||||
SUBLPdll = (SUBLPdll_POINTER) getFunctionPointer((char *)SUBLPdll_NAME);
|
||||
SUBLTdll = (SUBLTdll_POINTER) getFunctionPointer((char *)SUBLTdll_NAME);
|
||||
SURFTdll = (SURFTdll_POINTER) getFunctionPointer((char *)SURFTdll_NAME);
|
||||
@@ -595,81 +595,81 @@ void REFPROPMixtureBackend::check_status(void)
|
||||
|
||||
void REFPROPMixtureBackend::limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax)
|
||||
{
|
||||
/*
|
||||
*
|
||||
subroutine LIMITS (htyp,x,tmin,tmax,Dmax,pmax)
|
||||
c
|
||||
c returns limits of a property model as a function of composition
|
||||
c
|
||||
c Pure fluid limits are read in from the .fld files; for mixtures, a
|
||||
c simple mole fraction weighting in reduced variables is used.
|
||||
c
|
||||
c inputs:
|
||||
c htyp--flag indicating which models are to be checked [character*3]
|
||||
c 'EOS': equation of state for thermodynamic properties
|
||||
c 'ETA': viscosity
|
||||
c 'TCX': thermal conductivity
|
||||
c 'STN': surface tension
|
||||
c x--composition array [mol frac]
|
||||
c outputs:
|
||||
c tmin--minimum temperature for model specified by htyp [K]
|
||||
c tmax--maximum temperature [K]
|
||||
c Dmax--maximum density [mol/L]
|
||||
c pmax--maximum pressure [kPa]
|
||||
*
|
||||
*/
|
||||
double Dmax_mol_L,pmax_kPa;
|
||||
/*
|
||||
*
|
||||
subroutine LIMITS (htyp,x,tmin,tmax,Dmax,pmax)
|
||||
c
|
||||
c returns limits of a property model as a function of composition
|
||||
c
|
||||
c Pure fluid limits are read in from the .fld files; for mixtures, a
|
||||
c simple mole fraction weighting in reduced variables is used.
|
||||
c
|
||||
c inputs:
|
||||
c htyp--flag indicating which models are to be checked [character*3]
|
||||
c 'EOS': equation of state for thermodynamic properties
|
||||
c 'ETA': viscosity
|
||||
c 'TCX': thermal conductivity
|
||||
c 'STN': surface tension
|
||||
c x--composition array [mol frac]
|
||||
c outputs:
|
||||
c tmin--minimum temperature for model specified by htyp [K]
|
||||
c tmax--maximum temperature [K]
|
||||
c Dmax--maximum density [mol/L]
|
||||
c pmax--maximum pressure [kPa]
|
||||
*
|
||||
*/
|
||||
double Dmax_mol_L,pmax_kPa;
|
||||
char htyp[] = "EOS";
|
||||
LIMITSdll(htyp, &(mole_fractions[0]), &Tmin, &Tmax, &Dmax_mol_L, &pmax_kPa, 3);
|
||||
pmax = pmax_kPa*1000;
|
||||
rhomolarmax = Dmax_mol_L*1000;
|
||||
LIMITSdll(htyp, &(mole_fractions[0]), &Tmin, &Tmax, &Dmax_mol_L, &pmax_kPa, 3);
|
||||
pmax = pmax_kPa*1000;
|
||||
rhomolarmax = Dmax_mol_L*1000;
|
||||
}
|
||||
long double REFPROPMixtureBackend::calc_pmax(void){
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(pmax);
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(pmax);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_Tmax(void){
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(Tmax);
|
||||
double Tmin, Tmax, rhomolarmax, pmax;
|
||||
limits(Tmin, Tmax, rhomolarmax, pmax);
|
||||
return static_cast<long double>(Tmax);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_T_critical(){
|
||||
long ierr;
|
||||
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());}
|
||||
return static_cast<long double>(Tcrit);
|
||||
return static_cast<long double>(Tcrit);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_p_critical(){
|
||||
long ierr;
|
||||
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());}
|
||||
return static_cast<long double>(pcrit_kPa*1000);
|
||||
return static_cast<long double>(pcrit_kPa*1000);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_rhomolar_critical(){
|
||||
long ierr;
|
||||
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());}
|
||||
return static_cast<long double>(dcrit_mol_L*1000);
|
||||
return static_cast<long double>(dcrit_mol_L*1000);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_Ttriple(){
|
||||
if (mole_fractions.size() != 1){throw ValueError("calc_Ttriple cannot be evaluated for mixtures");}
|
||||
long icomp = 0;
|
||||
double wmm, ttrp, tnbpt, tc, pc, Dc, Zc, acf, dip, Rgas;
|
||||
INFOdll(&icomp, &wmm, &ttrp, &tnbpt, &tc, &pc, &Dc, &Zc, &acf, &dip, &Rgas);
|
||||
return static_cast<long double>(ttrp);
|
||||
return static_cast<long double>(ttrp);
|
||||
};
|
||||
long double REFPROPMixtureBackend::calc_molar_mass(void)
|
||||
{
|
||||
double wmm_kg_kmol;
|
||||
WMOLdll(&(mole_fractions[0]), &wmm_kg_kmol); // returns mole mass in kg/kmol
|
||||
_molar_mass = wmm_kg_kmol/1000; // kg/mol
|
||||
return static_cast<long double>(_molar_mass.pt());
|
||||
return static_cast<long double>(_molar_mass.pt());
|
||||
};
|
||||
|
||||
|
||||
double REFPROPMixtureBackend::calc_melt_Tmax()
|
||||
{
|
||||
long ierr;
|
||||
@@ -687,33 +687,33 @@ double REFPROPMixtureBackend::calc_melt_Tmax()
|
||||
}
|
||||
long double REFPROPMixtureBackend::calc_melting_line(int param, int given, long double value)
|
||||
{
|
||||
long ierr;
|
||||
long ierr;
|
||||
char herr[255];
|
||||
|
||||
if (param == iP && given == iT){
|
||||
double _T = static_cast<double>(value), p_kPa;
|
||||
MELTTdll(&_T, &(mole_fractions[0]),
|
||||
if (param == iP && given == iT){
|
||||
double _T = static_cast<double>(value), p_kPa;
|
||||
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());}
|
||||
return p_kPa*1000;
|
||||
}
|
||||
else if (param == iT && given == iP){
|
||||
double p_kPa = static_cast<double>(value), _T;
|
||||
MELTPdll(&p_kPa, &(mole_fractions[0]),
|
||||
if (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){
|
||||
double p_kPa = static_cast<double>(value), _T;
|
||||
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());}
|
||||
return p_kPa*1000;
|
||||
}
|
||||
else{
|
||||
throw ValueError(format("calc_melting_line(%s,%s,%Lg) is an invalid set of inputs ",
|
||||
get_parameter_information(param,"short").c_str(),
|
||||
get_parameter_information(given,"short").c_str(),
|
||||
value
|
||||
)
|
||||
);
|
||||
}
|
||||
if (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{
|
||||
throw ValueError(format("calc_melting_line(%s,%s,%Lg) is an invalid set of inputs ",
|
||||
get_parameter_information(param,"short").c_str(),
|
||||
get_parameter_information(given,"short").c_str(),
|
||||
value
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1294,13 +1294,13 @@ void REFPROPMixtureBackend::update(CoolProp::input_pairs input_pair, double valu
|
||||
|
||||
// Use flash routine to find properties
|
||||
TQFLSHdll(&_T,&_Q,&(mole_fractions[0]),&kq,&p_kPa,&rho_mol_L,
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&rhoLmol_L,&rhoVmol_L,&(mole_fractions_liq[0]),&(mole_fractions_vap[0]), // Saturation terms
|
||||
&emol,&hmol,&smol,&cvmol,&cpmol,&w, // Other thermodynamic terms
|
||||
&ierr,herr,errormessagelength); // Error terms
|
||||
|
||||
if (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());
|
||||
throw ValueError(format("TQ(%s): %s",LoadedREFPROPRef.c_str(), 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
|
||||
|
||||
@@ -18,96 +18,96 @@ namespace CoolProp {
|
||||
class REFPROPMixtureBackend : public AbstractState {
|
||||
protected:
|
||||
std::size_t Ncomp;
|
||||
bool _mole_fractions_set;
|
||||
static bool _REFPROP_supported;
|
||||
std::vector<double> mole_fractions, mass_fractions;
|
||||
std::vector<double> mole_fractions_liq, mole_fractions_vap;
|
||||
bool _mole_fractions_set;
|
||||
static bool _REFPROP_supported;
|
||||
std::vector<double> mole_fractions, mass_fractions;
|
||||
std::vector<double> mole_fractions_liq, mole_fractions_vap;
|
||||
public:
|
||||
REFPROPMixtureBackend(){};
|
||||
REFPROPMixtureBackend(){};
|
||||
|
||||
/// The instantiator
|
||||
/// @param fluid_names The vector of strings of the fluid components, without file ending
|
||||
REFPROPMixtureBackend(const std::vector<std::string>& fluid_names);
|
||||
virtual ~REFPROPMixtureBackend();
|
||||
/// The instantiator
|
||||
/// @param fluid_names The vector of strings of the fluid components, without file ending
|
||||
REFPROPMixtureBackend(const std::vector<std::string>& fluid_names);
|
||||
virtual ~REFPROPMixtureBackend();
|
||||
|
||||
// REFPROP backend uses mole fractions
|
||||
bool using_mole_fractions(){return true;}
|
||||
bool using_mass_fractions(){return false;}
|
||||
bool using_volu_fractions(){return false;}
|
||||
|
||||
/// Updating function for REFPROP
|
||||
/**
|
||||
In this function we take a pair of thermodynamic states, those defined in the input_pairs
|
||||
enumeration and update all the internal variables that we can. REFPROP calculates
|
||||
a lot of other state variables each time you use a flash routine so we cache all the
|
||||
outputs that we can, which saves on computational time.
|
||||
/// Updating function for REFPROP
|
||||
/**
|
||||
In this function we take a pair of thermodynamic states, those defined in the input_pairs
|
||||
enumeration and update all the internal variables that we can. REFPROP calculates
|
||||
a lot of other state variables each time you use a flash routine so we cache all the
|
||||
outputs that we can, which saves on computational time.
|
||||
|
||||
@param input_pair Integer key from CoolProp::input_pairs to the two inputs that will be passed to the function
|
||||
@param value1 First input value
|
||||
@param value2 Second input value
|
||||
*/
|
||||
void update(CoolProp::input_pairs,
|
||||
double value1,
|
||||
double value2
|
||||
);
|
||||
@param input_pair Integer key from CoolProp::input_pairs to the two inputs that will be passed to the function
|
||||
@param value1 First input value
|
||||
@param value2 Second input value
|
||||
*/
|
||||
void update(CoolProp::input_pairs,
|
||||
double value1,
|
||||
double value2
|
||||
);
|
||||
|
||||
long double calc_molar_mass(void);
|
||||
|
||||
/// Returns true if REFPROP is supported on this platform
|
||||
bool REFPROP_supported(void);
|
||||
/// Returns true if REFPROP is supported on this platform
|
||||
bool REFPROP_supported(void);
|
||||
|
||||
long double calc_cpmolar_idealgas(void);
|
||||
|
||||
long double calc_first_partial_deriv(parameters Of, parameters Wrt, parameters Constant);
|
||||
|
||||
/// Set the fluids in REFPROP DLL by calling the SETUPdll function
|
||||
/**
|
||||
@param fluid_names The vector of strings of the fluid components, without file ending
|
||||
*/
|
||||
void set_REFPROP_fluids(const std::vector<std::string> &fluid_names);
|
||||
/// Set the fluids in REFPROP DLL by calling the SETUPdll function
|
||||
/**
|
||||
@param fluid_names The vector of strings of the fluid components, without file ending
|
||||
*/
|
||||
void set_REFPROP_fluids(const std::vector<std::string> &fluid_names);
|
||||
|
||||
/// Set the mole fractions
|
||||
/**
|
||||
@param mole_fractions The vector of mole fractions of the components
|
||||
*/
|
||||
void set_mole_fractions(const std::vector<long double> &mole_fractions);
|
||||
/// Set the mole fractions
|
||||
/**
|
||||
@param mole_fractions The vector of mole fractions of the components
|
||||
*/
|
||||
void set_mole_fractions(const std::vector<long double> &mole_fractions);
|
||||
|
||||
/// Set the mass fractions
|
||||
/**
|
||||
@param mass_fractions The vector of mass fractions of the components
|
||||
*/
|
||||
void set_mass_fractions(const std::vector<long double> &mass_fractions);
|
||||
/// Set the mass fractions
|
||||
/**
|
||||
@param mass_fractions The vector of mass fractions of the components
|
||||
*/
|
||||
void set_mass_fractions(const std::vector<long double> &mass_fractions);
|
||||
|
||||
void calc_phase_envelope(const std::string &type);
|
||||
void calc_phase_envelope(const std::string &type);
|
||||
|
||||
std::vector<long double> calc_mole_fractions_liquid(void){return std::vector<long double>(mole_fractions_liq.begin(), mole_fractions_liq.end());}
|
||||
std::vector<long double> calc_mole_fractions_vapor(void){return std::vector<long double>(mole_fractions_vap.begin(), mole_fractions_vap.end());}
|
||||
|
||||
/// Check if the mole fractions have been set, etc.
|
||||
void check_status();
|
||||
/// Check if the mole fractions have been set, etc.
|
||||
void check_status();
|
||||
|
||||
/// Get the viscosity [Pa-s] (based on the temperature and density in the state class)
|
||||
long double calc_viscosity(void);
|
||||
/// Get the thermal conductivity [W/m/K] (based on the temperature and density in the state class)
|
||||
long double calc_conductivity(void);
|
||||
/// Get the surface tension [N/m] (based on the temperature in the state class). Invalid for temperatures above critical point or below triple point temperature
|
||||
long double calc_surface_tension(void);
|
||||
/// Get the viscosity [Pa-s] (based on the temperature and density in the state class)
|
||||
long double calc_viscosity(void);
|
||||
/// Get the thermal conductivity [W/m/K] (based on the temperature and density in the state class)
|
||||
long double calc_conductivity(void);
|
||||
/// Get the surface tension [N/m] (based on the temperature in the state class). Invalid for temperatures above critical point or below triple point temperature
|
||||
long double calc_surface_tension(void);
|
||||
|
||||
long double calc_fugacity_coefficient(int i);
|
||||
long double calc_melting_line(int param, int given, long double value);
|
||||
long double calc_melting_line(int param, int given, long double value);
|
||||
bool has_melting_line(){return true;};
|
||||
double calc_melt_Tmax();
|
||||
long double calc_T_critical(void);
|
||||
long double calc_p_critical(void);
|
||||
long double calc_rhomolar_critical(void);
|
||||
long double calc_Ttriple(void);
|
||||
|
||||
/// A wrapper function to calculate the limits for the EOS
|
||||
void limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax);
|
||||
/// Calculate the maximum pressure
|
||||
long double calc_pmax(void);
|
||||
/// Calculate the maximum temperature
|
||||
long double calc_Tmax(void);
|
||||
|
||||
/// A wrapper function to calculate the limits for the EOS
|
||||
void limits(double &Tmin, double &Tmax, double &rhomolarmax, double &pmax);
|
||||
/// Calculate the maximum pressure
|
||||
long double calc_pmax(void);
|
||||
/// Calculate the maximum temperature
|
||||
long double calc_Tmax(void);
|
||||
};
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
Reference in New Issue
Block a user