Fluids using IIR reference state now all agree with REFPROP

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-06-02 13:03:17 +02:00
parent f830d93b33
commit 409e2a2d1f
34 changed files with 223 additions and 35 deletions

View File

@@ -181,9 +181,10 @@
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -14.49798188289838,
"a2": 8.820179669088471,
"type": "IdealGasEnthalpyEntropyOffset"
"a1": -9.20482556461383,
"a2": 5.33930790626966,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -168,6 +168,12 @@
4
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -5.8744265562982,
"a2": 6.20999715674064,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -161,6 +161,12 @@
3
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": 12.0321093183046,
"a2": -6.36756620155532,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -181,9 +181,10 @@
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -17.60843812203014,
"a2": 10.31357488125467,
"type": "IdealGasEnthalpyEntropyOffset"
"a1": -10.6176788623373,
"a2": 6.88514458886201,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -174,6 +174,12 @@
11.85301926630442
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -5.11295044650128,
"a2": 1.75576391667209,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -178,6 +178,12 @@
4
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -6.18582150073625,
"a2": 6.53176084341793,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -192,6 +192,12 @@
0.7360191462715714
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -3.46143051269673,
"a2": 5.60542532549845,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -171,6 +171,12 @@
3.29670446
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -12.4676884656992,
"a2": 8.09676898052432,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -175,6 +175,12 @@
4
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -7.71227716096457,
"a2": 7.63006492791018,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -173,6 +173,12 @@
1.07087607
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -10.1855125183786,
"a2": 6.51519136530849,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -177,6 +177,12 @@
3
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -8.28406664756038,
"a2": 8.00843244470562,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -160,6 +160,12 @@
4.330484330484331
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -1.15714201814723,
"a2": 5.10465640895579,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -162,6 +162,12 @@
11.02164592701035
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 0.85309349094503,
"a2": 0.385031495925059,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -169,6 +169,12 @@
-3
],
"type": "IdealGasHelmholtzPower"
},
{
"a1": 16.4141514232817,
"a2": -8.30203002449525,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -175,6 +175,12 @@
4
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -4.70147467359404,
"a2": 5.39527702491361,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -180,6 +180,12 @@
2.379596191489546
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -10.305014971571,
"a2": -1.84499312905667,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -171,6 +171,12 @@
-4
],
"type": "IdealGasHelmholtzPower"
},
{
"a1": 7.93834875128042,
"a2": -4.10681809203532,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -172,6 +172,12 @@
10.34510326449034
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 5.7802649054724,
"a2": -3.08073617461255,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -175,6 +175,12 @@
4
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -7.1706255131862,
"a2": 7.15574544804595,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -200,6 +200,12 @@
1.437630674663887
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 11.5767418685512,
"a2": -6.25428015326267,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -173,6 +173,12 @@
3.809015737530008
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 4.62066027816592,
"a2": 0.178496372662916,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -169,6 +169,12 @@
4.852173913043479
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 1.46690190075666,
"a2": 2.54580919243753,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -162,6 +162,7 @@
{
"a1": -15.43197779494592,
"a2": 11.90245830296599,
"reference": "IIR",
"type": "IdealGasEnthalpyEntropyOffset"
}
],

View File

@@ -176,6 +176,12 @@
13.33837619768028
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 4.09473741595023,
"a2": -2.58374047330277,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -169,6 +169,12 @@
5.14305
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": 11.8898434084695,
"a2": -6.91754471427476,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -173,6 +173,12 @@
3
],
"type": "IdealGasHelmholtzCP0PolyT"
},
{
"a1": -8.45917550941048,
"a2": 8.39377061631628,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -143,6 +143,12 @@
4.874639449744842
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -2.33911681574654,
"a2": 0.0442616554096881,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -174,6 +174,12 @@
4.232907175
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -9.48116163251935,
"a2": 6.18439894480951,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -176,6 +176,12 @@
9.975553778
],
"type": "IdealGasHelmholtzPlanckEinstein"
},
{
"a1": -10.9833028475357,
"a2": 7.10059070097953,
"reference": "IIR",
"type": "IdealGasHelmholtzEnthalpyEntropyOffset"
}
],
"alphar": [

View File

@@ -316,7 +316,7 @@ public:
double rhomass(void){return _rhomolar*molar_mass();};
/// Return the pressure in Pa
double p(void) {return _p;};
/// Return the vapor quality (mol/mol) Q = 0 for saturated liquid
/// Return the vapor quality (mol/mol); Q = 0 for saturated liquid
double Q(void) {return _Q;};
/// Return the reciprocal of the reduced temperature (\f$\tau = T_c/T\f$)

View File

@@ -639,14 +639,15 @@ class IdealHelmholtzEnthalpyEntropyOffset : public BaseHelmholtzTerm{
private:
long double a1,a2; // Use these variables internally
bool enabled;
std::string reference;
public:
IdealHelmholtzEnthalpyEntropyOffset(){enabled = false;};
// Constructor
IdealHelmholtzEnthalpyEntropyOffset(long double a1, long double a2):a1(a1), a2(a2){enabled = true;};
IdealHelmholtzEnthalpyEntropyOffset(long double a1, long double a2, std::string reference):a1(a1), a2(a2){this->reference = reference; enabled = true;};
// Set the values in the class
void set(long double a1, long double a2){this->a1 = a1; this->a2 = a2; enabled = true;}
void set(long double a1, long double a2, std::string reference){this->a1 = a1; this->a2 = a2; this->reference = reference; enabled = true;}
//Destructor
~IdealHelmholtzEnthalpyEntropyOffset(){};
@@ -979,6 +980,7 @@ public:
IdealHelmholtzCP0PolyT(const std::vector<long double> &c, const std::vector<long double> &t, double Tc, double T0)
: c(c), t(t), Tc(Tc), T0(T0)
{
assert(c.size() == t.size());
tau0 = Tc/T0;
enabled = true;
N = c.size();

View File

@@ -158,13 +158,6 @@ protected:
std::vector<long double> c = cpjson::get_long_double_array(contribution["c"]);
EOS.alpha0.PlanckEinstein2 = IdealHelmholtzPlanckEinstein2(n, t, c);
}
else if (!type.compare("IdealGasHelmholtzEnthalpyEntropyOffset"))
{
if (EOS.alpha0.EnthalpyEntropyOffset.is_enabled() == true){throw ValueError("Cannot add ");}
long double a1 = cpjson::get_double(contribution, "a1");
long double a2 = cpjson::get_double(contribution, "a2");
EOS.alpha0.EnthalpyEntropyOffset = IdealHelmholtzEnthalpyEntropyOffset(a1, a2);
}
else if (!type.compare("IdealGasHelmholtzCP0Constant"))
{
if (EOS.alpha0.CP0Constant.is_enabled() == true){throw ValueError("Cannot add ");}
@@ -190,6 +183,13 @@ protected:
long double T0 = cpjson::get_double(contribution, "T0");
EOS.alpha0.CP0AlyLee = IdealHelmholtzCP0AlyLee(c, Tc, T0);
}
else if (!type.compare("IdealGasHelmholtzEnthalpyEntropyOffset"))
{
long double a1 = cpjson::get_double(contribution, "a1");
long double a2 = cpjson::get_double(contribution, "a2");
std::string reference = cpjson::get_string(contribution, "reference");
EOS.alpha0.EnthalpyEntropyOffset = IdealHelmholtzEnthalpyEntropyOffset(a1, a2, reference);
}
else
{
std::cout << format("Unsupported ideal-gas Helmholtz type: %s\n",type.c_str());

View File

@@ -649,13 +649,11 @@ int set_reference_stateS(std::string Ref, std::string reference_state)
HEOS->update(QT_INPUTS, 0, 273.15);
// Get current values for the enthalpy and entropy
double h1 = HEOS->keyed_output(CoolProp::iHmass); // [J/kg]
double s1 = HEOS->keyed_output(CoolProp::iSmass); // [J/kg/K]
double deltah = h1-200000; // offset from 200000 J/kg enthalpy
double deltas = s1-1000; // offset from 1000 J/kg/K entropy
double deltah = HEOS->hmass() - 200000; // offset from 200000 J/kg enthalpy
double deltas = HEOS->smass() - 1000; // offset from 1000 J/kg/K entropy
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "IIR");
return 0;
}
else if (!reference_state.compare("ASHRAE"))
@@ -663,13 +661,11 @@ int set_reference_stateS(std::string Ref, std::string reference_state)
HEOS->update(QT_INPUTS, 0, 243.15);
// Get current values for the enthalpy and entropy
double h1 = HEOS->keyed_output(CoolProp::iHmass); // [J/kg]
double s1 = HEOS->keyed_output(CoolProp::iSmass); // [J/kg/K]
double deltah = h1 - 0; // offset from 0 J/kg enthalpy
double deltas = s1 - 0; // offset from 0 J/kg/K entropy
double deltah = HEOS->hmass() - 0; // offset from 0 J/kg enthalpy
double deltas = HEOS->smass() - 0; // offset from 0 J/kg/K entropy
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "ASHRAE");
return 0;
}
else if (!reference_state.compare("NBP"))
@@ -677,15 +673,12 @@ int set_reference_stateS(std::string Ref, std::string reference_state)
// Saturated liquid boiling point at 1 atmosphere
HEOS->update(PQ_INPUTS, 101325, 0);
// Get current values for the enthalpy and entropy
double h1 = HEOS->keyed_output(CoolProp::iHmass); // [J/kg]
double s1 = HEOS->keyed_output(CoolProp::iSmass); // [J/kg/K]
double deltah = h1 - 0; // offset from 0 kJ/kg enthalpy
double deltas = s1 - 0; // offset from 0 kJ/kg/K entropy
double deltah = HEOS->hmass() - 0; // offset from 0 kJ/kg enthalpy
double deltas = HEOS->smass() - 0; // offset from 0 kJ/kg/K entropy
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "NBP");
return 0;
}
else if (!reference_state.compare("DEF"))
@@ -695,7 +688,7 @@ int set_reference_stateS(std::string Ref, std::string reference_state)
}
else if (!reference_state.compare("RESET"))
{
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(0,0);
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(0, 0, "");
}
else
{

View File

@@ -1,6 +1,7 @@
#include "Backends/Helmholtz/HelmholtzEOSBackend.h"
#include "Backends/Helmholtz/HelmholtzEOSMixtureBackend.h"
#include "Backends/REFPROP/REFPROPMixtureBackend.h"
#include "Backends/REFPROP/REFPROPBackend.h"
#include <time.h>
@@ -57,6 +58,39 @@ struct element
int main()
{
set_debug_level(0);
if (1)
{
std::string NBP_refs[] = {"Helium","Ethylene","Ethanol","n-Dodecane","Benzene","n-Undecane","Neon","Fluorine","Methanol","Acetone","Methane","Ethane","n-Pentane","n-Hexane","n-Heptane","n-Octane","CycloHexane","MD3M","MM","D4","MethylPalmitate","MethylStearate","MethylOleate","MethylLinoleate","MethylLinolenate","m-Xylene","Air"};
std::string IIR_refs[] = {"SES36","R143a","CycloPropane","Propylene","R227EA","R365MFC","R161","HFE143m","SulfurHexafluoride","CarbonDioxide","R1234ze(E)","R22","R124","Propyne","R507A","R152A","R123","R11","n-Butane","IsoButane","RC318","R21","R114","R13","R12","R113","R1233zd(E)","R41"};
for (std::size_t i = 0; i < sizeof(NBP_refs)/sizeof(NBP_refs[0]); ++i)
{
/*try{*/
HelmholtzEOSMixtureBackend HEOS(std::vector<std::string>(1,NBP_refs[i]));
HEOS.update(PQ_INPUTS, 101325, 0);
double delta_a1 = HEOS.smass()/(8.314472/HEOS.molar_mass());
double delta_a2 = -HEOS.hmass()/(8.314472/HEOS.molar_mass()*HEOS.get_reducing().T);
std::cout << format("%s,%s,%16.15g,%16.15g\n",NBP_refs[i].c_str(),"NBP",delta_a1, delta_a2);
/*}
catch(const std::exception &e)
{
std::cout << "ERROR FOR " << NBP_refs[i] << std::endl;
}*/
}
for (std::size_t i = 0; i < sizeof(IIR_refs)/sizeof(IIR_refs[0]); ++i)
{
try{
HelmholtzEOSMixtureBackend HEOS(std::vector<std::string>(1,IIR_refs[i]));
HEOS.update(QT_INPUTS, 0, 273.15);
double delta_a1 = HEOS.smass()/(8.314472/HEOS.molar_mass());
double delta_a2 = -HEOS.hmass()/(8.314472/HEOS.molar_mass()*HEOS.get_reducing().T);
std::cout << format("%s,%s,%16.15g,%16.15g\n",IIR_refs[i].c_str(),"IIR",delta_a1, delta_a2);
}
catch(const std::exception &e)
{
std::cout << "ERROR FOR " << IIR_refs[i] << std::endl;
}
}
}
if (0)
{
generate_melting_curve_data("Ethylene-I.mlt","ethylene",103.989,110.369);