Added saturation spline to the AbstractState and REFPROP interfaces

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-06-11 15:38:49 +02:00
parent 3127ace162
commit ca7fc30a58
5 changed files with 47 additions and 24 deletions

View File

@@ -302,6 +302,10 @@ double AbstractState::fugacity_coefficient(int i){
// TODO: Cache the fug. coeff for each component
return calc_fugacity_coefficient(i);
}
void AbstractState::build_phase_envelope(const std::string &type)
{
calc_phase_envelope(type);
}
double AbstractState::isothermal_compressibility(void){
return 1.0/_rhomolar*first_partial_deriv(iDmolar, iP, iT);
}

View File

@@ -181,6 +181,7 @@ static char default_reference_state[] = "DEF";
SATPdll_POINTER SATPdll;
SATSdll_POINTER SATSdll;
SATTdll_POINTER SATTdll;
SATSPLNdll_POINTER SATSPLNdll;
SETAGAdll_POINTER SETAGAdll;
SETKTVdll_POINTER SETKTVdll;
SETMIXdll_POINTER SETMIXdll;
@@ -307,6 +308,7 @@ double setFunctionPointers()
SATPdll = (SATPdll_POINTER) getFunctionPointer((char *)SATPdll_NAME);
SATSdll = (SATSdll_POINTER) getFunctionPointer((char *)SATSdll_NAME);
SATTdll = (SATTdll_POINTER) getFunctionPointer((char *)SATTdll_NAME);
SATSPLNdll = (SATSPLNdll_POINTER) getFunctionPointer((char *)SATSPLNdll_NAME);
SETAGAdll = (SETAGAdll_POINTER) getFunctionPointer((char *)SETAGAdll_NAME);
SETKTVdll = (SETKTVdll_POINTER) getFunctionPointer((char *)SETKTVdll_NAME);
SETMIXdll = (SETMIXdll_POINTER) getFunctionPointer((char *)SETMIXdll_NAME);
@@ -550,7 +552,8 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector<std::string> &f
}
else if (ierr > 0) // Error
{
if (k==0) continue;
if (k==0 && N > 1)
continue; // Allow us to use PPF if a pure fluid
else
throw ValueError(format("%s",herr));
}
@@ -603,11 +606,6 @@ long double REFPROPMixtureBackend::calc_melt_p_T(long double T)
long ierr;
char herr[255];
if (T > calc_melt_Tmax())
{
throw ValueError(format("Melting temperature [%g] is out of range",T));
}
MELTTdll(&_T, &(mole_fractions[0]),
&p_kPa,
&ierr,herr,errormessagelength); // Error message
@@ -672,6 +670,15 @@ long double REFPROPMixtureBackend::calc_fugacity_coefficient(int i)
return static_cast<long double>(fug_cof[i]);
}
void REFPROPMixtureBackend::calc_phase_envelope(const std::string &type)
{
long ierr;
char herr[255];
SATSPLNdll(&(mole_fractions[0]), // Inputs
&ierr, herr, errormessagelength); // Error message
if (ierr > 0) { throw ValueError(format("%s",herr).c_str()); }
}
void REFPROPMixtureBackend::update(long input_pair, double value1, double value2)
{
double rho_mol_L=_HUGE, rhoLmol_L=_HUGE, rhoVmol_L=_HUGE,

View File

@@ -24,7 +24,7 @@ protected:
std::vector<double> mole_fractions_liq, mole_fractions_vap;
public:
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);
@@ -34,10 +34,10 @@ public:
bool using_mole_fractions(){return true;}
/// 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
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
@@ -59,17 +59,19 @@ public:
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 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);
/// Check if the mole fractions have been set, etc.
void check_status();
@@ -81,7 +83,7 @@ public:
long double calc_surface_tension(void);
long double calc_fugacity_coefficient(int i);
long double calc_melt_p_T(long double T);
long double calc_melt_T_p(long double p);
long double calc_melt_rho_T(long double T);

View File

@@ -95,6 +95,7 @@
# define SATPdll SATPdll
# define SATSdll SATSdll
# define SATTdll SATTdll
# define SATSPLNdll SATSPLNdll
# define SETAGAdll SETAGAdll
# define SETKTVdll SETKTVdll
# define SETMIXdll SETMIXdll
@@ -210,6 +211,7 @@
# define SATPdll satpdll_
# define SATSdll satsdll_
# define SATTdll sattdll_
# define SATSPLNdll satsplndll_
# define SETAGAdll setagadll_
# define SETKTVdll setktvdll_
# define SETMIXdll setmixdll_
@@ -316,6 +318,7 @@
# define SATPdll satpdll_
# define SATSdll satsdll_
# define SATTdll sattdll_
# define SATSPLNdll satsplndll_
# define SETAGAdll setagadll_
# define SETKTVdll setktvdll_
# define SETMIXdll setmixdll_
@@ -420,6 +423,7 @@
# define SATPdll satpdll
# define SATSdll satsdll
# define SATTdll sattdll
# define SATSPLNdll satsplndll
# define SETAGAdll setagadll
# define SETKTVdll setktvdll
# define SETMIXdll setmixdll
@@ -536,6 +540,7 @@
#define SATPdll_NAME FUNCTION_NAME(SATPdll)
#define SATSdll_NAME FUNCTION_NAME(SATSdll)
#define SATTdll_NAME FUNCTION_NAME(SATTdll)
#define SATSPLNdll_NAME FUNCTION_NAME(SATSPLNdll)
#define SETAGAdll_NAME FUNCTION_NAME(SETAGAdll)
#define SETKTVdll_NAME FUNCTION_NAME(SETKTVdll)
#define SETMIXdll_NAME FUNCTION_NAME(SETMIXdll)
@@ -649,6 +654,7 @@ extern "C" {
typedef void (CALLCONV SATPdll_TYPE)(double *,double *,long *,double *,double *,double *,double *,double *,long *,char*,long );
typedef void (CALLCONV SATSdll_TYPE)(double *,double *,long *,long *,long *,double *,double *,double *,long *,double *,double *,double *,long *,double *,double *,double *,long *,char*,long );
typedef void (CALLCONV SATTdll_TYPE)(double *,double *,long *,double *,double *,double *,double *,double *,long *,char*,long );
typedef void (CALLCONV SATSPLNdll_TYPE)(double *,long *,char*,long );
typedef void (CALLCONV SETAGAdll_TYPE)(long *,char*,long );
typedef void (CALLCONV SETKTVdll_TYPE)(long *,long *,char*,double *,char*,long *,char*,long ,long ,long );
typedef void (CALLCONV SETMIXdll_TYPE)(char*,char*,char*,long *,char*,double *,long *,char*,long ,long ,long ,long ,long );
@@ -857,6 +863,7 @@ extern "C" {
typedef SATPdll_TYPE * SATPdll_POINTER;
typedef SATSdll_TYPE * SATSdll_POINTER;
typedef SATTdll_TYPE * SATTdll_POINTER;
typedef SATSPLNdll_TYPE * SATSPLNdll_POINTER;
typedef SETAGAdll_TYPE * SETAGAdll_POINTER;
typedef SETKTVdll_TYPE * SETKTVdll_POINTER;
typedef SETMIXdll_TYPE * SETMIXdll_POINTER;