mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
n-Propane viscosity can mostly be read from JSON, all that remains is the higher order terms, some thinking remains on that front
Signed-off-by: Ian bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -257,6 +257,57 @@ protected:
|
||||
fluid.pEOS = &(fluid.EOSVector[0]);
|
||||
};
|
||||
|
||||
/// Parse the transport properties
|
||||
void parse_dilute_viscosity(rapidjson::Value &dilute, CoolPropFluid & fluid)
|
||||
{
|
||||
std::string type = cpjson::get_string(dilute, "type");
|
||||
if (!type.compare("collision_integral")){
|
||||
// Get a reference to the entry in the fluid instance
|
||||
CoolProp::ViscosityDiluteGasCollisionIntegralData &CI = fluid.transport.viscosity_dilute.collision_integral;
|
||||
|
||||
// Load up the values
|
||||
CI.a = cpjson::get_long_double_array(dilute["a"]);
|
||||
CI.t = cpjson::get_long_double_array(dilute["t"]);
|
||||
CI.molar_mass = cpjson::get_double(dilute, "molar_mass");
|
||||
CI.C = cpjson::get_double(dilute, "C");
|
||||
}
|
||||
else{
|
||||
throw ValueError(format("type [%s] is not understood for fluid %s",type.c_str(),fluid.name.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
/// Parse the transport properties
|
||||
void parse_initial_density_viscosity(rapidjson::Value &dilute, CoolPropFluid & fluid)
|
||||
{
|
||||
std::string type = cpjson::get_string(dilute, "type");
|
||||
if (!type.compare("Rainwater-Friend")){
|
||||
// Get a reference to the entry in the fluid instance
|
||||
CoolProp::ViscosityRainWaterFriendData &RF = fluid.transport.viscosity_initial.rainwater_friend;
|
||||
|
||||
// Load up the values
|
||||
RF.b = cpjson::get_long_double_array(dilute["b"]);
|
||||
RF.t = cpjson::get_long_double_array(dilute["t"]);
|
||||
}
|
||||
else{
|
||||
throw ValueError(format("type [%s] is not understood for fluid %s",type.c_str(),fluid.name.c_str()));
|
||||
}
|
||||
};
|
||||
|
||||
/// Parse the transport properties
|
||||
void parse_viscosity(rapidjson::Value &viscosity, CoolPropFluid & fluid)
|
||||
{
|
||||
if (viscosity.HasMember("dilute")){
|
||||
parse_dilute_viscosity(viscosity["dilute"], fluid);
|
||||
}
|
||||
if (viscosity.HasMember("initial_density")){
|
||||
parse_initial_density_viscosity(viscosity["initial_density"], fluid);
|
||||
}
|
||||
};
|
||||
/// Parse the thermal conductivity data
|
||||
void parse_thermal_conductivity(rapidjson::Value &conductivity, CoolPropFluid & fluid)
|
||||
{
|
||||
};
|
||||
|
||||
/// Parse the transport properties
|
||||
void parse_transport(rapidjson::Value &transport, CoolPropFluid & fluid)
|
||||
{
|
||||
@@ -267,6 +318,15 @@ protected:
|
||||
fluid.transport.sigma_eta = cpjson::get_double(transport, "sigma_eta");
|
||||
fluid.transport.epsilon_over_k = cpjson::get_double(transport, "epsilon_over_k");
|
||||
}
|
||||
// Parse viscosity
|
||||
if (transport.HasMember("viscosity")){
|
||||
parse_viscosity(transport["viscosity"],fluid);
|
||||
}
|
||||
|
||||
// Parse thermal conductivity
|
||||
if (transport.HasMember("conductivity")){
|
||||
parse_thermal_conductivity(transport["conductivity"],fluid);
|
||||
}
|
||||
};
|
||||
|
||||
void default_transport(CoolPropFluid & fluid)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "TransportRoutines.h"
|
||||
#include "CoolPropFluid.h"
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
@@ -20,28 +21,24 @@ long double TransportRoutines::general_dilute_gas_viscosity(HelmholtzEOSMixtureB
|
||||
return 26.692e-9*sqrt(molar_mass_kgkmol*HEOS.T())/(pow(sigma_nm, 2)*OMEGA22); // Pa-s
|
||||
}
|
||||
else{
|
||||
throw NotImplementedError("TransportRoutines::GeneralDiluteGasViscosity is only for pure and pseudo-pure");
|
||||
throw NotImplementedError("TransportRoutines::general_dilute_gas_viscosity is only for pure and pseudo-pure");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
long double TransportRoutines::dilute_gas_viscosity(HelmholtzEOSMixtureBackend &HEOS)
|
||||
{
|
||||
if (HEOS.is_pure_or_pseudopure)
|
||||
{
|
||||
// HARD CODED FOR PROPANE FOR TESTING PURPOSES
|
||||
double _a[]={0.25104574,-0.47271238,0,0.060836515}, _t[] = {0,1,2,3}, C = 0.141824e-6/sqrt(44.0956), D = sqrt(44.0956)*C;
|
||||
std::vector<long double> a(_a,_a+sizeof(_a)/sizeof(_a[0]));
|
||||
std::vector<long double> t(_t,_t+sizeof(_t)/sizeof(_t[0]));
|
||||
HEOS.components[0]->transport.epsilon_over_k = 263.88;
|
||||
HEOS.components[0]->transport.sigma_eta = 0.49748e-9;
|
||||
long double molar_mass = 44.0956/1000;
|
||||
// Retrieve values from the state class
|
||||
CoolProp::ViscosityDiluteGasCollisionIntegralData &data = HEOS.components[0]->transport.viscosity_dilute.collision_integral;
|
||||
const std::vector<long double> &a = data.a, &t = data.t;
|
||||
const long double C = data.C, molar_mass = data.molar_mass;
|
||||
|
||||
long double S;
|
||||
long double Tstar = HEOS.T()/HEOS.components[0]->transport.epsilon_over_k;
|
||||
long double sigma_nm = HEOS.components[0]->transport.sigma_eta*1e9; // 1e9 to convert from m to nm
|
||||
long double molar_mass_kgkmol = molar_mass*1000; // 1000 to convert from kg/mol to kg/kmol
|
||||
// Unit conversions and variable definitions
|
||||
const long double Tstar = HEOS.T()/HEOS.components[0]->transport.epsilon_over_k;
|
||||
const long double sigma_nm = HEOS.components[0]->transport.sigma_eta*1e9; // 1e9 to convert from m to nm
|
||||
const long double molar_mass_kgkmol = molar_mass*1000; // 1000 to convert from kg/mol to kg/kmol
|
||||
|
||||
/// Both the collision integral \f$\mathfrak{S}^*\f$ and effective cross section \f$\Omega^{(2,2)}\f$ have the same form,
|
||||
/// in general we don't care which is used. The are related through \f$\Omega^{(2,2)} = (5/4)\mathfrak{S}^*\f$
|
||||
@@ -113,7 +110,7 @@ long double TransportRoutines::modified_Batschinski_Hildebrand_viscosity_term(He
|
||||
return S+F*delta*(1/(delta0-delta)-1/delta0); // Pa-s
|
||||
}
|
||||
else{
|
||||
throw NotImplementedError("TransportRoutines::GeneralDiluteGasViscosity is only for pure and pseudo-pure");
|
||||
throw NotImplementedError("TransportRoutines::modified_Batschinski_Hildebrand_viscosity_term is only for pure and pseudo-pure");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,14 +118,9 @@ long double TransportRoutines::initial_density_dependence_viscosity_term(Helmhol
|
||||
{
|
||||
if (HEOS.is_pure_or_pseudopure)
|
||||
{
|
||||
//// HARD CODED FOR PROPANE FOR TESTING PURPOSES
|
||||
double _b[]={-19.572881,219.73999,-1015.3226,2471.01251,-3375.1717,2491.6597,-787.26086,14.085455,-0.34664158};
|
||||
std::vector<long double> b(_b,_b+sizeof(_b)/sizeof(_b[0]));
|
||||
double _c[]={0,-0.25,-0.5,-0.75,-1.0,-1.25,-1.5,-2.5,-5.5};
|
||||
std::vector<long double> c(_c,_c+sizeof(_c)/sizeof(_c[0]));
|
||||
HEOS.components[0]->transport.epsilon_over_k = 263.88;
|
||||
HEOS.components[0]->transport.sigma_eta = 0.49748e-9;
|
||||
//// END HARD CODED
|
||||
// Retrieve values from the state class
|
||||
CoolProp::ViscosityRainWaterFriendData &data = HEOS.components[0]->transport.viscosity_initial.rainwater_friend;
|
||||
const std::vector<long double> &b = data.b, &t = data.t;
|
||||
|
||||
long double B_eta, B_eta_star;
|
||||
long double Tstar = HEOS.T()/HEOS.components[0]->transport.epsilon_over_k; // [no units]
|
||||
@@ -136,14 +128,14 @@ long double TransportRoutines::initial_density_dependence_viscosity_term(Helmhol
|
||||
|
||||
long double summer = 0;
|
||||
for (int i = 0; i < b.size(); ++i){
|
||||
summer += b[i]*pow(Tstar, c[i]);
|
||||
summer += b[i]*pow(Tstar, t[i]);
|
||||
}
|
||||
B_eta_star = summer; // [no units]
|
||||
B_eta = 6.02214129e23*pow(sigma,3)*B_eta_star; // [m^3/mol]
|
||||
B_eta = 6.02214129e23*pow(sigma, 3)*B_eta_star; // [m^3/mol]
|
||||
return B_eta; // [m^3/mol]
|
||||
}
|
||||
else{
|
||||
throw NotImplementedError("TransportRoutines::GeneralDiluteGasViscosity is only for pure and pseudo-pure");
|
||||
throw NotImplementedError("TransportRoutines::initial_density_dependence_viscosity_term is only for pure and pseudo-pure");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
where \f$N_A\f$ is Avogadros number \f$6.022\times 10^{23}\f$ mol\f$^{-1}\f$ and \f$\sigma_{\eta}\f$ is in m.
|
||||
|
||||
\f[
|
||||
B_{\eta}^*(T^*) = \displaystyle\sum_ib_i(T^*)^{c_i}
|
||||
B_{\eta}^*(T^*) = \displaystyle\sum_ib_i(T^*)^{t_i}
|
||||
\f]
|
||||
|
||||
IMPORTANT: This function returns \f$B_{\eta}\f$, not \f$\eta_{RF}\f$
|
||||
|
||||
Reference in New Issue
Block a user