mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Merge branch 'master' into asan_rpversion
This commit is contained in:
@@ -942,7 +942,7 @@ void TransportRoutines::conformal_state_solver(HelmholtzEOSMixtureBackend &HEOS,
|
||||
Eigen::Vector2d r;
|
||||
Eigen::Matrix2d J;
|
||||
// Update the reference fluid with the conformal state
|
||||
HEOS_Reference.update(DmolarT_INPUTS, rhomolar0, T0);
|
||||
HEOS_Reference.update_DmolarT_direct(rhomolar0, T0);
|
||||
do{
|
||||
long double dtau_dT = -HEOS_Reference.T_critical()/(T0*T0);
|
||||
long double ddelta_drho = 1/HEOS_Reference.rhomolar_critical();
|
||||
@@ -969,7 +969,7 @@ void TransportRoutines::conformal_state_solver(HelmholtzEOSMixtureBackend &HEOS,
|
||||
double T_new = T0_init + frac*v(0);
|
||||
double rhomolar_new = rhomolar0_init + frac*v(1);
|
||||
// Update state with step
|
||||
HEOS_Reference.update(DmolarT_INPUTS, rhomolar_new, T_new);
|
||||
HEOS_Reference.update_DmolarT_direct(rhomolar_new, T_new);
|
||||
resid = sqrt(POW2(HEOS_Reference.alphar() - alphar) + POW2(HEOS_Reference.keyed_output(iZ) - Z));
|
||||
if (resid > resid_old){
|
||||
continue;
|
||||
@@ -1033,10 +1033,13 @@ long double TransportRoutines::viscosity_ECS(HelmholtzEOSMixtureBackend &HEOS, H
|
||||
// Solver for conformal state
|
||||
// **************************
|
||||
|
||||
//
|
||||
HEOS_Reference.specify_phase(iphase_gas); // something homogeneous
|
||||
|
||||
conformal_state_solver(HEOS, HEOS_Reference, T0, rhomolar0);
|
||||
|
||||
|
||||
// Update the reference fluid with the updated conformal state
|
||||
HEOS_Reference.update(DmolarT_INPUTS, rhomolar0*psi, T0);
|
||||
HEOS_Reference.update_DmolarT_direct(rhomolar0*psi, T0);
|
||||
|
||||
// Recalculate ESRR
|
||||
f = HEOS.T()/T0;
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
#include "math.h"
|
||||
#include "MatrixMath.h"
|
||||
#include "PolyMath.h"
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace CoolProp {
|
||||
|
||||
|
||||
|
||||
/// A thermophysical property provider for critical and reducing values as well as derivatives of Helmholtz energy
|
||||
/// A thermophysical property provider for all properties
|
||||
/**
|
||||
This fluid instance is populated using an entry from a JSON file
|
||||
This fluid instance is populated using an entry from a JSON file and uses
|
||||
simplified polynomial and exponential functions to calculate thermophysical
|
||||
and transport properties.
|
||||
*/
|
||||
//IncompressibleFluid::IncompressibleFluid();
|
||||
|
||||
@@ -19,12 +22,12 @@ void IncompressibleFluid::set_reference_state(double T0, double p0, double x0, d
|
||||
this->Tref = T0;
|
||||
this->rhoref = rho(T0,p0,x0);
|
||||
this->pref = p0;
|
||||
this->uref = h0 - p0/rhoref;
|
||||
this->uref = u(T0,p0,x0);
|
||||
this->href = h0; // set new reference value
|
||||
this->sref = s0; // set new reference value
|
||||
this->href = h(T0,p0,x0); // adjust offset to fit to equations
|
||||
this->sref = s(T0,p0,x0); // adjust offset to fit to equations
|
||||
this->href = h0;
|
||||
// Now we take care of the energy related values
|
||||
this->uref = 0.0;
|
||||
this->uref = u(T0,p0,x0) - h0; // (value without ref) - (desired ref)
|
||||
this->sref = 0.0;
|
||||
this->sref = s(T0,p0,x0) - s0; // (value without ref) - (desired ref)
|
||||
}
|
||||
|
||||
void IncompressibleFluid::validate(){
|
||||
@@ -646,23 +649,36 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
|
||||
//XLT.set_reference_state(25+273.15, 1.01325e5, 0.0, 0.0, 0.0);
|
||||
double Tref = 25+273.15;
|
||||
double pref = 0.0;
|
||||
double pref = 2e5;
|
||||
double xref = 0.0;
|
||||
double href = 0.0;
|
||||
double sref = 0.0;
|
||||
double href = 127.0;
|
||||
double sref = 23.0;
|
||||
XLT.set_reference_state(Tref, pref, xref, href, sref);
|
||||
|
||||
/// A function to check coefficients and equation types.
|
||||
//XLT.validate();
|
||||
|
||||
|
||||
// Prepare the results and compare them to the calculated values
|
||||
double acc = 0.0001;
|
||||
double val = 0;
|
||||
double res = 0;
|
||||
|
||||
// Compare reference state
|
||||
{
|
||||
res = XLT.h(Tref,pref,xref);
|
||||
CHECK( check_abs(href,res,acc) );
|
||||
res = XLT.s(Tref,pref,xref);
|
||||
CHECK( check_abs(sref,res,acc) );
|
||||
}
|
||||
|
||||
Tref = 25+273.15;
|
||||
pref = 0.0;
|
||||
xref = 0.0;
|
||||
href = 0.0;
|
||||
sref = 0.0;
|
||||
XLT.set_reference_state(Tref, pref, xref, href, sref);
|
||||
// Prepare the results and compare them to the calculated values
|
||||
double T = 273.15+50;
|
||||
double p = 10e5;
|
||||
double x = xref;
|
||||
double val = 0;
|
||||
double res = 0;
|
||||
|
||||
// Compare density
|
||||
val = 824.4615702148608;
|
||||
@@ -723,7 +739,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
}
|
||||
|
||||
// Compare h
|
||||
val = 46425.32011926845;
|
||||
val = 46388.7;
|
||||
res = XLT.h(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
@@ -857,7 +873,7 @@ TEST_CASE("Internal consistency checks and example use cases for the incompressi
|
||||
}
|
||||
|
||||
// Compare h
|
||||
expected = -59005.67386390795;
|
||||
expected = -58999.1;
|
||||
actual = CH3OH.h(T,p,x);
|
||||
{
|
||||
CAPTURE(T);
|
||||
|
||||
@@ -443,7 +443,7 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector<std::string> &f
|
||||
errormessagelength // Length of error message
|
||||
);
|
||||
|
||||
if (ierr == 0) // Success
|
||||
if (ierr <= 0) // Success (or a warning, which is silently squelched for now)
|
||||
{
|
||||
this->Ncomp = N;
|
||||
mole_fractions.resize(N);
|
||||
@@ -453,12 +453,12 @@ void REFPROPMixtureBackend::set_REFPROP_fluids(const std::vector<std::string> &f
|
||||
if (dbg_refprop) std::cout << format("%s:%d: Successfully loaded REFPROP fluid: %s\n",__FILE__,__LINE__, components_joined.c_str());
|
||||
return;
|
||||
}
|
||||
else if (ierr > 0 && k < number_of_endings-1){ // Keep going
|
||||
else if (k < number_of_endings-1){ // Keep going
|
||||
continue;
|
||||
}
|
||||
else // Warning
|
||||
else
|
||||
{
|
||||
throw ValueError(format("%s", herr));
|
||||
throw ValueError(format("Could not load these fluids: %s", components_joined_raw.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user