Merge branch 'master' into eigenPolynomials

This commit is contained in:
jowr
2014-06-11 17:54:03 +02:00
53 changed files with 1129 additions and 139 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

@@ -427,6 +427,9 @@ protected:
else if (!target.compare("n-Hexane")){
fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEXANE; return;
}
else if (!target.compare("n-Heptane")){
fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEPTANE; return;
}
else if (!target.compare("Ethane")){
fluid.transport.viscosity_higher_order.type = CoolProp::ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_ETHANE; return;
}

View File

@@ -189,6 +189,8 @@ long double HelmholtzEOSMixtureBackend::calc_viscosity_background(long double et
delta_eta_h = TransportRoutines::viscosity_hydrogen_higher_order_hardcoded(*this); break;
case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEXANE:
delta_eta_h = TransportRoutines::viscosity_hexane_higher_order_hardcoded(*this); break;
case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_HEPTANE:
delta_eta_h = TransportRoutines::viscosity_heptane_higher_order_hardcoded(*this); break;
case ViscosityHigherOrderVariables::VISCOSITY_HIGHER_ORDER_ETHANE:
delta_eta_h = TransportRoutines::viscosity_ethane_higher_order_hardcoded(*this); break;
default:

View File

@@ -280,6 +280,7 @@ long double TransportRoutines::viscosity_hydrogen_higher_order_hardcoded(Helmhol
long double TransportRoutines::viscosity_hexane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS)
{
long double Tr = HEOS.T()/507.82, rhor = HEOS.keyed_output(CoolProp::iDmass)/233.182;
// Output is in Pa-s
@@ -287,6 +288,16 @@ long double TransportRoutines::viscosity_hexane_higher_order_hardcoded(Helmholtz
return pow(rhor,static_cast<long double>(2.0/3.0))*sqrt(Tr)*(c[0]/Tr+c[1]/(c[2]+Tr+c[3]*rhor*rhor)+c[4]*(1+rhor)/(c[5]+c[6]*Tr+c[7]*rhor+rhor*rhor+c[8]*rhor*Tr));
}
long double TransportRoutines::viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS)
{
/// From Michailidou-JPCRD-2014-Heptane
long double Tr = HEOS.T()/540.13, rhor = HEOS.rhomass()/232;
// Output is in Pa-s
double c[] = {0, 22.15000/1e6, -15.00870/1e6, 3.71791/1e6, 77.72818/1e6, 9.73449, 9.51900, -6.34076, -2.51909};
return pow(rhor,2.0L/3.0L)*sqrt(Tr)*(c[1]*rhor+c[2]*pow(rhor,2)+c[3]*pow(rhor,3)+c[4]*rhor/(c[5]+c[6]*Tr+c[7]*rhor+rhor*rhor+c[8]*rhor*Tr));
}
long double TransportRoutines::viscosity_higher_order_friction_theory(HelmholtzEOSMixtureBackend &HEOS)
{
if (HEOS.is_pure_or_pseudopure)

View File

@@ -20,7 +20,7 @@ public:
with \f$T^* = \frac{T}{\varepsilon/k}\f$ and \f$\sigma\f$ in nm, M is in kg/kmol. Yields viscosity in Pa-s.
*/
static long double viscosity_dilute_kinetic_theory(HelmholtzEOSMixtureBackend &HEOS);
/**
\brief The dilute gas viscosity term that is based on collision integral or effective cross section
@@ -34,7 +34,7 @@ public:
*/
static long double viscosity_dilute_collision_integral(HelmholtzEOSMixtureBackend &HEOS);
/**
/**
\brief A dilute gas viscosity term formed of summation of power terms
\f[
@@ -46,7 +46,7 @@ public:
static long double viscosity_dilute_collision_integral_powers_of_T(HelmholtzEOSMixtureBackend &HEOS);
/**
/**
\brief The initial density dependence term \f$B_{\eta}\f$ from Rainwater-Friend theory
The total contribution from this term is given by
@@ -68,17 +68,17 @@ public:
*/
static long double viscosity_initial_density_dependence_Rainwater_Friend(HelmholtzEOSMixtureBackend &HEOS);
/**
/**
\brief The modified Batschinski-Hildebrand contribution to the viscosity
\f[
\Delta\eta = \displaystyle\sum_{i}a_{i}\delta^{d1_i}\tau^{t1_j}+\left(\displaystyle\sum_{i}f_i\delta^{d2_i}\tau^{t2_i}\right)\left(\frac{1}{\delta_0(\tau)-\delta}-\frac{1}{\delta_0(\tau)}\right)
\f]
where \f$\tau = T_c/T\f$ and \f$\delta = \rho/\rho_c\f$
where \f$\tau = T_c/T\f$ and \f$\delta = \rho/\rho_c\f$
\f[
\delta_0(\tau) = \displaystyle\frac{\displaystyle\sum_{i}g_i\tau^{h_i}}{\displaystyle\sum_{i}p_i\tau^{q_i}}
\f]
The more general form of \f$\delta_0(\tau)\f$ is selected in order to be able to handle all the forms in the literature
The more general form of \f$\delta_0(\tau)\f$ is selected in order to be able to handle all the forms in the literature
*/
static long double viscosity_higher_order_modified_Batschinski_Hildebrand(HelmholtzEOSMixtureBackend &HEOS);
@@ -91,6 +91,7 @@ public:
static long double viscosity_ethane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS);
static long double viscosity_hydrogen_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS);
static long double viscosity_hexane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS);
static long double viscosity_heptane_higher_order_hardcoded(HelmholtzEOSMixtureBackend &HEOS);
static long double viscosity_higher_order_friction_theory(HelmholtzEOSMixtureBackend &HEOS);
/**
@@ -110,7 +111,7 @@ public:
\Delta\lambda(\rho,T) = \displaystyle\sum_iA_i\tau^{t,i}\delta^{d_i}
\f]
As used by Assael, Perkins, Huber, etc., the residual term is given by
As used by Assael, Perkins, Huber, etc., the residual term is given by
\f[
\Delta\lambda(\rho,T) = \displaystyle\sum_i(B_{1,i}+B_{2,i}(T/T_c))(\rho/\rho_c)^i
\f]
@@ -135,9 +136,9 @@ public:
\f[
\zeta = \zeta_0\left(\frac{p_c\rho}{\Gamma\rho_c^2}\right)^{\nu/\gamma}\left[\left.\frac{\partial \rho(T,\rho)}{\partial p} \right|_{T}- \frac{T_R}{T}\left.\frac{\partial \rho(T_R,\rho)}{\partial p} \right|_{T} \right]^{\nu/\gamma},
\f]
where \f$\lambda^{(c)}\f$ is in W\f$\cdot\f$m\f$^{-1}\f$\f$\cdot\f$K\f$^{-1}\f$, \f$\zeta\f$ is in m,
\f$c_p\f$ and \f$c_v\f$ are in J\f$\cdot\f$kg\f$^{-1}\cdot\f$K\f$^{-1}\f$, \f$p\f$ and \f$p_c\f$ are in Pa,
\f$\rho\f$ and \f$\rho_c\f$ are in mol\f$\cdot\f$m\f$^{-3}\f$, \f$\eta\f$ is the viscosity in Pa\f$\cdot\f$s,
where \f$\lambda^{(c)}\f$ is in W\f$\cdot\f$m\f$^{-1}\f$\f$\cdot\f$K\f$^{-1}\f$, \f$\zeta\f$ is in m,
\f$c_p\f$ and \f$c_v\f$ are in J\f$\cdot\f$kg\f$^{-1}\cdot\f$K\f$^{-1}\f$, \f$p\f$ and \f$p_c\f$ are in Pa,
\f$\rho\f$ and \f$\rho_c\f$ are in mol\f$\cdot\f$m\f$^{-3}\f$, \f$\eta\f$ is the viscosity in Pa\f$\cdot\f$s,
and the remaining parameters are defined in the following tables.
It should be noted that some authors use slightly different values for the "universal" constants
@@ -145,9 +146,9 @@ public:
Coefficients for use in the simplified Olchowy-Sengers critical term
Parameter | Variable | Value
--------- | -------- | ------
Boltzmann constant | \f$k\f$ | \f$1.3806488\times 10^{-23}\f$ J\f$\cdot\f$K\f$^{-1}\f$
Universal amplitude | \f$R_D\f$ | 1.03
Critical exponent | \f$\nu\f$ | 0.63
Boltzmann constant | \f$k\f$ | \f$1.3806488\times 10^{-23}\f$ J\f$\cdot\f$K\f$^{-1}\f$
Universal amplitude | \f$R_D\f$ | 1.03
Critical exponent | \f$\nu\f$ | 0.63
Critical exponent | \f$\gamma\f$ | 1.239
Reference temperature | \f$T_R\f$ | 1.5\f$T_c\f$
@@ -182,7 +183,7 @@ public:
Bell, I. H.; Wronski, J.; Quoilin, S. & Lemort, V. (2014), Pure and Pseudo-pure Fluid Thermophysical Property Evaluation and the Open-Source Thermophysical Property Library CoolProp, Industrial & Engineering Chemistry Research, 53, (6), 2498-2508
which is originally based on the methods presented in
which is originally based on the methods presented in
Huber, M. L., Laesecke, A. and Perkins, R. A., (2003), Model for the Viscosity and Thermal Conductivity of Refrigerants, Including a New Correlation for the Viscosity of R134a, Industrial & Engineering Chemistry Research, v. 42, pp. 3163-3178
@@ -200,4 +201,4 @@ public:
}; /* class TransportRoutines */
}; /* namespace CoolProp */
#endif
#endif

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;

View File

@@ -108,6 +108,14 @@ vel("Hexane", "T", 250, "Dmass", 700, "V", 528.2e-6, 1e-3),
vel("Hexane", "T", 400, "Dmass", 600, "V", 177.62e-6, 1e-3),
vel("Hexane", "T", 550, "Dmass", 500, "V", 95.002e-6, 1e-3),
// From Assael, JPCRD, 2014
vel("Heptane", "T", 250, "Dmass", 1e-14, "V", 4.9717e-6, 1e-3),
vel("Heptane", "T", 400, "Dmass", 1e-14, "V", 7.8361e-6, 1e-3),
vel("Heptane", "T", 550, "Dmass", 1e-14, "V", 10.7394e-6, 1e-3),
vel("Heptane", "T", 250, "Dmass", 720, "V", 725.69e-6, 1e-3),
vel("Heptane", "T", 400, "Dmass", 600, "V", 175.94e-6, 1e-3),
vel("Heptane", "T", 550, "Dmass", 500, "V", 95.105e-6, 1e-3),
// From Fenghour, JPCRD, 1998
vel("CO2", "T", 220, "Dmass", 2.440, "V", 11.06e-6, 1e-3),
vel("CO2", "T", 300, "Dmass", 1.773, "V", 15.02e-6, 1e-3),
@@ -263,10 +271,10 @@ vel("Hexane", "T", 400, "Dmass", 650, "L", 129.28e-3, 2e-4),
vel("Hexane", "T", 510, "Dmass", 2, "L", 36.772e-3, 1e-4),
// From Assael, JPCRD, 2013
//vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4),
//vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4),
//vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4),
//vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 1e-4),
vel("Heptane", "T", 250, "Dmass", 720, "L", 137.09e-3, 1e-4),
vel("Heptane", "T", 400, "Dmass", 2, "L", 21.794e-3, 1e-4),
vel("Heptane", "T", 400, "Dmass", 650, "L", 120.75e-3, 1e-4),
vel("Heptane", "T", 535, "Dmass", 100, "L", 51.655e-3, 3e-3), // Relaxed tolerance because conductivity was fit using older viscosity correlation
// From Assael, JPCRD, 2013
vel("Ethanol", "T", 300, "Dmass", 850, "L", 209.68e-3, 1e-4),