mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Merge pull request #532 from mikekaganski/master
More Coverity cleanups
This commit is contained in:
@@ -199,7 +199,7 @@ public:
|
||||
MeltingLinePiecewisePolynomialInTrData polynomial_in_Tr;
|
||||
MeltingLinePiecewisePolynomialInThetaData polynomial_in_Theta;
|
||||
int type;
|
||||
MeltingLineVariables(){type = MELTING_LINE_NOT_SET;};
|
||||
MeltingLineVariables():Tmin(_HUGE),Tmax(_HUGE),pmin(_HUGE),pmax(_HUGE),T_m(_HUGE),type(MELTING_LINE_NOT_SET){};
|
||||
};
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
@@ -146,21 +146,19 @@ struct ConductivityResidualVariables
|
||||
|
||||
struct ConductivityCriticalSimplifiedOlchowySengersData{
|
||||
CoolPropDbl T_reducing, p_reducing, k, R0, gamma, nu, qD, zeta0, GAMMA, T_ref;
|
||||
ConductivityCriticalSimplifiedOlchowySengersData(){
|
||||
// Universal constants - can still be adjusted if need be
|
||||
k = 1.3806488e-23; //[J/K]
|
||||
R0 = 1.03; //[-]
|
||||
gamma = 1.239; //[-]
|
||||
nu = 0.63; //[-]
|
||||
// Suggested default values - can be over-written
|
||||
GAMMA = 0.0496; //[-]
|
||||
zeta0 = 1.94e-10; //[m]
|
||||
qD = 2e9; //[m]
|
||||
|
||||
// Set to invalid number, can be provided in the JSON file
|
||||
// Default is 1.5*Tc
|
||||
T_ref = _HUGE;
|
||||
}
|
||||
ConductivityCriticalSimplifiedOlchowySengersData():
|
||||
// Universal constants - can still be adjusted if need be
|
||||
k(1.3806488e-23), //[J/K]
|
||||
R0(1.03), //[-]
|
||||
gamma(1.239), //[-]
|
||||
nu(0.63), //[-]
|
||||
// Suggested default values - can be over-written
|
||||
GAMMA(0.0496), //[-]
|
||||
zeta0(1.94e-10), //[m]
|
||||
qD(2e9), //[m]
|
||||
// Set to invalid number, can be provided in the JSON file
|
||||
// T_ref default is 1.5*Tc
|
||||
T_reducing(_HUGE),p_reducing(_HUGE),T_ref(_HUGE){}
|
||||
};
|
||||
struct ConductivityCriticalVariables
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ struct SsatSimpleState : public SimpleState
|
||||
{
|
||||
enum SsatSimpleStateEnum {SSAT_MAX_NOT_SET=0, SSAT_MAX_DOESNT_EXIST, SSAT_MAX_DOES_EXIST};
|
||||
SsatSimpleStateEnum exists;
|
||||
SsatSimpleState() : SimpleState() {}
|
||||
SsatSimpleState() : exists(SSAT_MAX_NOT_SET) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -155,15 +155,9 @@ public:
|
||||
|
||||
std::vector<ResidualHelmholtzGeneralizedExponentialElement> elements;
|
||||
// Default Constructor
|
||||
ResidualHelmholtzGeneralizedExponential(){N = 0;
|
||||
delta_li_in_u = false;
|
||||
tau_mi_in_u = false;
|
||||
eta1_in_u = false;
|
||||
eta2_in_u = false;
|
||||
beta1_in_u = false;
|
||||
beta2_in_u = false;
|
||||
finished = false;
|
||||
};
|
||||
ResidualHelmholtzGeneralizedExponential()
|
||||
: N(0),delta_li_in_u(false),tau_mi_in_u(false),eta1_in_u(false),
|
||||
eta2_in_u(false),beta1_in_u(false),beta2_in_u(false),finished(false) {};
|
||||
/** \brief Add and convert an old-style power (polynomial) term to generalized form
|
||||
*
|
||||
* Term of the format
|
||||
@@ -326,9 +320,6 @@ public:
|
||||
finished = true;
|
||||
};
|
||||
|
||||
///< Destructor for the class. No implementation
|
||||
~ResidualHelmholtzGeneralizedExponential(){};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc);
|
||||
|
||||
CoolPropDbl base(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){HelmholtzDerivatives deriv; all(tau,delta,deriv); return deriv.alphar;};
|
||||
@@ -409,36 +400,36 @@ class ResidualHelmholtzSAFTAssociating : public BaseHelmholtzTerm{
|
||||
protected:
|
||||
double a, m,epsilonbar, vbarn, kappabar;
|
||||
|
||||
CoolPropDbl Deltabar(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl dDeltabar_ddelta__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2Deltabar_ddelta2__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl dDeltabar_dtau__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2Deltabar_dtau2__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2Deltabar_ddelta_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3Deltabar_dtau3__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3Deltabar_ddelta_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3Deltabar_ddelta3__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3Deltabar_ddelta2_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl Deltabar(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl dDeltabar_ddelta__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2Deltabar_ddelta2__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl dDeltabar_dtau__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2Deltabar_dtau2__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2Deltabar_ddelta_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3Deltabar_dtau3__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3Deltabar_ddelta_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3Deltabar_ddelta3__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3Deltabar_ddelta2_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
|
||||
CoolPropDbl X(const CoolPropDbl &delta, const CoolPropDbl &Deltabar);
|
||||
CoolPropDbl dX_dDeltabar__constdelta(const CoolPropDbl &delta, const CoolPropDbl &Deltabar);
|
||||
CoolPropDbl dX_ddelta__constDeltabar(const CoolPropDbl &delta, const CoolPropDbl &Deltabar);
|
||||
CoolPropDbl dX_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl dX_ddelta(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2X_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2X_ddeltadtau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d2X_ddelta2(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl X(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const;
|
||||
CoolPropDbl dX_dDeltabar__constdelta(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const;
|
||||
CoolPropDbl dX_ddelta__constDeltabar(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const;
|
||||
CoolPropDbl dX_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl dX_ddelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2X_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2X_ddeltadtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d2X_ddelta2(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
|
||||
CoolPropDbl d3X_dtau3(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3X_ddelta3(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3X_ddeltadtau2(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3X_ddelta2dtau(const CoolPropDbl &tau, const CoolPropDbl &delta);
|
||||
CoolPropDbl d3X_dtau3(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3X_ddelta3(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3X_ddeltadtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
CoolPropDbl d3X_ddelta2dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const;
|
||||
|
||||
CoolPropDbl g(const CoolPropDbl &eta);
|
||||
CoolPropDbl dg_deta(const CoolPropDbl &eta);
|
||||
CoolPropDbl d2g_deta2(const CoolPropDbl &eta);
|
||||
CoolPropDbl d3g_deta3(const CoolPropDbl &eta);
|
||||
CoolPropDbl eta(const CoolPropDbl &delta);
|
||||
CoolPropDbl g(const CoolPropDbl &eta) const;
|
||||
CoolPropDbl dg_deta(const CoolPropDbl &eta) const;
|
||||
CoolPropDbl d2g_deta2(const CoolPropDbl &eta) const;
|
||||
CoolPropDbl d3g_deta3(const CoolPropDbl &eta) const;
|
||||
CoolPropDbl eta(const CoolPropDbl &delta) const;
|
||||
|
||||
public:
|
||||
/// Default constructor
|
||||
@@ -468,7 +459,7 @@ public:
|
||||
CoolPropDbl dDelta_dTau2(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){HelmholtzDerivatives deriv; all(tau,delta,deriv); return deriv.d3alphar_ddelta_dtau2;};
|
||||
CoolPropDbl dTau3(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){HelmholtzDerivatives deriv; all(tau,delta,deriv); return deriv.d3alphar_dtau3;};
|
||||
|
||||
void all(const CoolPropDbl &tau, const CoolPropDbl &delta, HelmholtzDerivatives &deriv) throw();
|
||||
void all(const CoolPropDbl &tau, const CoolPropDbl &delta, HelmholtzDerivatives &deriv) const throw();
|
||||
};
|
||||
|
||||
class ResidualHelmholtzContainer
|
||||
@@ -520,17 +511,13 @@ private:
|
||||
bool enabled;
|
||||
public:
|
||||
// Default constructor
|
||||
IdealHelmholtzLead(){enabled = false;};
|
||||
IdealHelmholtzLead() :a1(_HUGE), a2(_HUGE), enabled(false) {}
|
||||
|
||||
// Constructor
|
||||
IdealHelmholtzLead(const CoolPropDbl a1, const CoolPropDbl a2)
|
||||
:a1(a1), a2(a2)
|
||||
{enabled = true;};
|
||||
IdealHelmholtzLead(CoolPropDbl a1, CoolPropDbl a2)
|
||||
:a1(a1), a2(a2), enabled(true) {}
|
||||
|
||||
//Destructor
|
||||
~IdealHelmholtzLead(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;}
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc){
|
||||
el.AddMember("type","IdealHelmholtzLead",doc.GetAllocator());
|
||||
@@ -578,7 +565,7 @@ private:
|
||||
std::string reference;
|
||||
bool enabled;
|
||||
public:
|
||||
IdealHelmholtzEnthalpyEntropyOffset():enabled(false){}
|
||||
IdealHelmholtzEnthalpyEntropyOffset():a1(_HUGE),a2(_HUGE),enabled(false){}
|
||||
|
||||
// Constructor
|
||||
IdealHelmholtzEnthalpyEntropyOffset(CoolPropDbl a1, CoolPropDbl a2, const std::string &ref):a1(a1),a2(a2),reference(ref),enabled(true) {}
|
||||
@@ -586,10 +573,7 @@ public:
|
||||
// Set the values in the class
|
||||
void set(CoolPropDbl a1, CoolPropDbl a2, const std::string &ref){this->a1 += a1; this->a2 += a2; this->reference = ref; enabled = true;}
|
||||
|
||||
//Destructor
|
||||
~IdealHelmholtzEnthalpyEntropyOffset(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc){
|
||||
el.AddMember("type","IdealHelmholtzEnthalpyEntropyOffset",doc.GetAllocator());
|
||||
@@ -599,13 +583,11 @@ public:
|
||||
|
||||
// Term and its derivatives
|
||||
CoolPropDbl base(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){
|
||||
if (!enabled){return 0.0;}
|
||||
return a1+a2*tau;
|
||||
return enabled ? a1+a2*tau : 0.0;
|
||||
};
|
||||
CoolPropDbl dDelta(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){return 0.0;};
|
||||
CoolPropDbl dTau(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){
|
||||
if (!enabled){return 0.0;}
|
||||
return a2;
|
||||
return enabled ? a2 : 0.0;
|
||||
};
|
||||
CoolPropDbl dDelta2(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){return 0.0;};
|
||||
CoolPropDbl dDelta_dTau(const CoolPropDbl &tau, const CoolPropDbl &delta) throw(){return 0.0;};
|
||||
@@ -630,15 +612,12 @@ private:
|
||||
public:
|
||||
|
||||
/// Default constructor
|
||||
IdealHelmholtzLogTau(){enabled = false;};
|
||||
IdealHelmholtzLogTau():a1(_HUGE),enabled(false){}
|
||||
|
||||
// Constructor
|
||||
IdealHelmholtzLogTau(CoolPropDbl a1){this->a1=a1; enabled = true;};
|
||||
IdealHelmholtzLogTau(CoolPropDbl a1):a1(a1),enabled(true){}
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
|
||||
//Destructor
|
||||
~IdealHelmholtzLogTau(){};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc){
|
||||
el.AddMember("type", "IdealHelmholtzLogTau", doc.GetAllocator());
|
||||
@@ -682,19 +661,12 @@ private:
|
||||
std::size_t N;
|
||||
bool enabled;
|
||||
public:
|
||||
IdealHelmholtzPower(){enabled = false;};
|
||||
IdealHelmholtzPower():N(0),enabled(false){};
|
||||
// Constructor
|
||||
IdealHelmholtzPower(const std::vector<CoolPropDbl> &n, const std::vector<CoolPropDbl> &t)
|
||||
:n(n), t(t)
|
||||
{
|
||||
this->N = n.size();
|
||||
enabled = true;
|
||||
};
|
||||
:n(n), t(t), N(n.size()), enabled(true) {};
|
||||
|
||||
//Destructor
|
||||
~IdealHelmholtzPower(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc)
|
||||
{
|
||||
@@ -781,17 +753,10 @@ private:
|
||||
std::size_t N;
|
||||
bool enabled;
|
||||
public:
|
||||
IdealHelmholtzPlanckEinsteinGeneralized(){N = 0; enabled = false;}
|
||||
IdealHelmholtzPlanckEinsteinGeneralized():N(0),enabled(false){}
|
||||
// Constructor with std::vector instances
|
||||
IdealHelmholtzPlanckEinsteinGeneralized(const std::vector<CoolPropDbl> &n, const std::vector<CoolPropDbl> &theta, const std::vector<CoolPropDbl> &c, const std::vector<CoolPropDbl> &d)
|
||||
:n(n), theta(theta), c(c), d(d)
|
||||
{
|
||||
N = n.size();
|
||||
enabled = true;
|
||||
};
|
||||
|
||||
// Destructor
|
||||
~IdealHelmholtzPlanckEinsteinGeneralized(){};
|
||||
:n(n), theta(theta), c(c), d(d), N(n.size()), enabled(true) {}
|
||||
|
||||
// Extend the vectors to allow for multiple instances feeding values to this function
|
||||
void extend(const std::vector<CoolPropDbl> &n, const std::vector<CoolPropDbl> &theta, const std::vector<CoolPropDbl> &c, const std::vector<CoolPropDbl> &d)
|
||||
@@ -803,7 +768,7 @@ public:
|
||||
N += n.size();
|
||||
}
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc)
|
||||
{
|
||||
@@ -860,7 +825,7 @@ public:
|
||||
/// Destructor
|
||||
~IdealHelmholtzCP0Constant(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc)
|
||||
{
|
||||
@@ -902,18 +867,13 @@ private:
|
||||
std::size_t N;
|
||||
bool enabled;
|
||||
public:
|
||||
/// Destructor
|
||||
IdealHelmholtzCP0PolyT(){N = 0; enabled = false;};
|
||||
IdealHelmholtzCP0PolyT()
|
||||
: Tc(_HUGE), T0(_HUGE), tau0(_HUGE), N(0), enabled(false) {}
|
||||
|
||||
/// Constructor with std::vectors
|
||||
IdealHelmholtzCP0PolyT(const std::vector<CoolPropDbl> &c, const std::vector<CoolPropDbl> &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();
|
||||
};
|
||||
: c(c), t(t), Tc(Tc), T0(T0), tau0(Tc/T0), N(c.size()), enabled(true)
|
||||
{ assert(c.size() == t.size()); }
|
||||
|
||||
void extend(const std::vector<CoolPropDbl> &c, const std::vector<CoolPropDbl> &t)
|
||||
{
|
||||
@@ -922,10 +882,7 @@ public:
|
||||
N += c.size();
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
~IdealHelmholtzCP0PolyT(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc);
|
||||
|
||||
@@ -1002,7 +959,7 @@ public:
|
||||
/// Destructor
|
||||
~IdealHelmholtzCP0AlyLee(){};
|
||||
|
||||
bool is_enabled(){return enabled;};
|
||||
bool is_enabled() const {return enabled;};
|
||||
|
||||
void to_json(rapidjson::Value &el, rapidjson::Document &doc);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
std::vector< std::vector<CoolPropDbl> > K, lnK, x, y;
|
||||
std::vector<CoolPropDbl> T, p, lnT, lnp, rhomolar_liq, rhomolar_vap, lnrhomolar_liq, lnrhomolar_vap, hmolar_liq, hmolar_vap, smolar_liq, smolar_vap, Q;
|
||||
|
||||
PhaseEnvelopeData(){ built = false; TypeI = false; };
|
||||
PhaseEnvelopeData() : iTsat_max(-1), ipsat_max(-1), icrit(-1), built(false), TypeI(false) {}
|
||||
|
||||
void resize(std::size_t N)
|
||||
{
|
||||
|
||||
@@ -127,8 +127,7 @@ public:
|
||||
std::vector<std::vector<DepartureFunctionPointer> > DepartureFunctionMatrix;
|
||||
STLMatrix F;
|
||||
|
||||
ExcessTerm(){};
|
||||
~ExcessTerm(){};
|
||||
ExcessTerm():N(0){};
|
||||
|
||||
/// Resize the parts of this term
|
||||
void resize(std::size_t N){
|
||||
|
||||
@@ -91,18 +91,15 @@ double SaturationAncillaryFunction::invert(double value, double min_bound, doubl
|
||||
class solver_resid : public FuncWrapper1D
|
||||
{
|
||||
public:
|
||||
int other;
|
||||
SaturationAncillaryFunction *anc;
|
||||
CoolPropDbl T, value, r, current_value;
|
||||
CoolPropDbl value;
|
||||
|
||||
solver_resid(SaturationAncillaryFunction *anc, CoolPropDbl value) : anc(anc), value(value){};
|
||||
solver_resid(SaturationAncillaryFunction *anc, CoolPropDbl value) : anc(anc), value(value){}
|
||||
|
||||
double call(double T){
|
||||
this->T = T;
|
||||
current_value = anc->evaluate(T);
|
||||
r = current_value - value;
|
||||
return r;
|
||||
};
|
||||
CoolPropDbl current_value = anc->evaluate(T);
|
||||
return current_value - value;
|
||||
}
|
||||
};
|
||||
solver_resid resid(this, value);
|
||||
std::string errstring;
|
||||
|
||||
@@ -33,8 +33,11 @@ protected:
|
||||
std::size_t N; ///< Number of components
|
||||
|
||||
public:
|
||||
HelmholtzEOSMixtureBackend(){
|
||||
imposed_phase_index = iphase_not_imposed; _phase = iphase_unknown;};
|
||||
HelmholtzEOSMixtureBackend()
|
||||
: imposed_phase_index(iphase_not_imposed), is_pure_or_pseudopure(false), N(0)
|
||||
{
|
||||
_phase = iphase_unknown;
|
||||
}
|
||||
HelmholtzEOSMixtureBackend(const std::vector<CoolPropFluid> &components, bool generate_SatL_and_SatV = true);
|
||||
HelmholtzEOSMixtureBackend(const std::vector<std::string> &component_names, bool generate_SatL_and_SatV = true);
|
||||
virtual ~HelmholtzEOSMixtureBackend(){};
|
||||
|
||||
@@ -32,37 +32,38 @@ void SaturationSolvers::saturation_critical(HelmholtzEOSMixtureBackend &HEOS, pa
|
||||
HelmholtzEOSMixtureBackend *HEOS;
|
||||
parameters ykey;
|
||||
CoolPropDbl y;
|
||||
CoolPropDbl r, T, rhomolar_liq, rhomolar_vap, value, p, gL, gV, rhomolar_crit;
|
||||
int other;
|
||||
CoolPropDbl rhomolar_crit;
|
||||
|
||||
outer_resid(HelmholtzEOSMixtureBackend &HEOS, CoolProp::parameters ykey, CoolPropDbl y)
|
||||
: HEOS(&HEOS), ykey(ykey), y(y){
|
||||
rhomolar_crit = HEOS.rhomolar_critical();
|
||||
};
|
||||
: HEOS(&HEOS), ykey(ykey), y(y), rhomolar_crit(HEOS.rhomolar_critical()) {};
|
||||
double call(double rhomolar_vap){
|
||||
this->y = y;
|
||||
|
||||
// Calculate the other variable (T->p or p->T) for given vapor density
|
||||
if (ykey == iT){
|
||||
CoolPropDbl T, p, rhomolar_liq;
|
||||
switch (ykey){
|
||||
case iT: {
|
||||
T = y;
|
||||
HEOS->SatV->update(DmolarT_INPUTS, rhomolar_vap, y);
|
||||
this->p = HEOS->SatV->p();
|
||||
std::cout << format("outer p: %0.16Lg",this->p) << std::endl;
|
||||
p = HEOS->SatV->p();
|
||||
std::cout << format("outer p: %0.16Lg", p) << std::endl;
|
||||
inner_resid inner(HEOS, T, p);
|
||||
std::string errstr2;
|
||||
rhomolar_liq = Brent(inner, rhomolar_crit*1.5, rhomolar_crit*(1+1e-8), LDBL_EPSILON, 1e-10, 100, errstr2);
|
||||
rhomolar_liq = Brent(inner, rhomolar_crit*1.5, rhomolar_crit*(1 + 1e-8), LDBL_EPSILON, 1e-10, 100, errstr2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw ValueError("Wrong input for outer_resid");
|
||||
}
|
||||
HEOS->SatL->update(DmolarT_INPUTS, rhomolar_liq, T);
|
||||
HEOS->SatV->update(DmolarT_INPUTS, rhomolar_vap, T);
|
||||
|
||||
// Calculate the Gibbs functions for liquid and vapor
|
||||
gL = HEOS->SatL->gibbsmolar();
|
||||
gV = HEOS->SatV->gibbsmolar();
|
||||
CoolPropDbl gL = HEOS->SatL->gibbsmolar();
|
||||
CoolPropDbl gV = HEOS->SatV->gibbsmolar();
|
||||
|
||||
// Residual is difference in Gibbs function
|
||||
r = gL - gV;
|
||||
// r = gL - gV;
|
||||
|
||||
return this->p;
|
||||
return p;
|
||||
};
|
||||
};
|
||||
outer_resid resid(HEOS, iT, y);
|
||||
@@ -82,25 +83,21 @@ void SaturationSolvers::saturation_T_pure_1D_P(HelmholtzEOSMixtureBackend &HEOS,
|
||||
public:
|
||||
|
||||
HelmholtzEOSMixtureBackend *HEOS;
|
||||
CoolPropDbl r, T, rhomolar_liq, rhomolar_vap, value, p, gL, gV;
|
||||
int other;
|
||||
CoolPropDbl T, rhomolar_liq, rhomolar_vap;
|
||||
|
||||
solver_resid(HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl T, CoolPropDbl rhomolar_liq_guess, CoolPropDbl rhomolar_vap_guess)
|
||||
: HEOS(&HEOS), T(T), rhomolar_liq(rhomolar_liq_guess), rhomolar_vap(rhomolar_vap_guess){};
|
||||
double call(double p){
|
||||
this->p = p;
|
||||
// Recalculate the densities using the current guess values
|
||||
HEOS->SatL->update_TP_guessrho(T, p, rhomolar_liq);
|
||||
HEOS->SatV->update_TP_guessrho(T, p, rhomolar_vap);
|
||||
|
||||
// Calculate the Gibbs functions for liquid and vapor
|
||||
gL = HEOS->SatL->gibbsmolar();
|
||||
gV = HEOS->SatV->gibbsmolar();
|
||||
CoolPropDbl gL = HEOS->SatL->gibbsmolar();
|
||||
CoolPropDbl gV = HEOS->SatV->gibbsmolar();
|
||||
|
||||
// Residual is difference in Gibbs function
|
||||
r = gL - gV;
|
||||
|
||||
return r;
|
||||
return gL - gV;
|
||||
};
|
||||
};
|
||||
solver_resid resid(HEOS, T, options.rhoL, options.rhoV);
|
||||
@@ -128,25 +125,21 @@ void SaturationSolvers::saturation_P_pure_1D_T(HelmholtzEOSMixtureBackend &HEOS,
|
||||
public:
|
||||
|
||||
HelmholtzEOSMixtureBackend *HEOS;
|
||||
CoolPropDbl r, p, rhomolar_liq, rhomolar_vap, value, T, gL, gV;
|
||||
int other;
|
||||
CoolPropDbl p, rhomolar_liq, rhomolar_vap;
|
||||
|
||||
solver_resid(HelmholtzEOSMixtureBackend &HEOS, CoolPropDbl p, CoolPropDbl rhomolar_liq_guess, CoolPropDbl rhomolar_vap_guess)
|
||||
: HEOS(&HEOS), p(p), rhomolar_liq(rhomolar_liq_guess), rhomolar_vap(rhomolar_vap_guess){};
|
||||
double call(double T){
|
||||
this->T = T;
|
||||
// Recalculate the densities using the current guess values
|
||||
HEOS->SatL->update_TP_guessrho(T, p, rhomolar_liq);
|
||||
HEOS->SatV->update_TP_guessrho(T, p, rhomolar_vap);
|
||||
|
||||
// Calculate the Gibbs functions for liquid and vapor
|
||||
gL = HEOS->SatL->gibbsmolar();
|
||||
gV = HEOS->SatV->gibbsmolar();
|
||||
CoolPropDbl gL = HEOS->SatL->gibbsmolar();
|
||||
CoolPropDbl gV = HEOS->SatV->gibbsmolar();
|
||||
|
||||
// Residual is difference in Gibbs function
|
||||
r = gL - gV;
|
||||
|
||||
return r;
|
||||
return gL - gV;
|
||||
};
|
||||
};
|
||||
solver_resid resid(HEOS, p, options.rhoL, options.rhoV);
|
||||
|
||||
@@ -431,4 +431,5 @@ EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, cons
|
||||
catch(...){
|
||||
*errcode = 3;
|
||||
}
|
||||
return _HUGE;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::base(const CoolPropDbl &tau, const Coo
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl theta=(1.0-tau)+Ai*pow(pow(delta-1.0,2),1.0/(2.0*betai));
|
||||
@@ -371,7 +371,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta(const CoolPropDbl &tau, const C
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl dDELTAbi_dDelta;
|
||||
@@ -398,7 +398,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dTau(const CoolPropDbl &tau, const Coo
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl theta=(1.0-tau)+Ai*pow(pow(delta-1.0,2),1.0/(2.0*betai));
|
||||
@@ -418,7 +418,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta2(const CoolPropDbl &tau, const
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl dDELTAbi_dDelta;
|
||||
@@ -459,7 +459,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta_dTau(const CoolPropDbl &tau, co
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl dDELTAbi_dDelta;
|
||||
@@ -493,7 +493,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dTau2(const CoolPropDbl &tau, const Co
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
|
||||
@@ -515,7 +515,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta3(const CoolPropDbl &tau, const
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl dDELTAbi_dDelta;
|
||||
@@ -554,7 +554,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta_dTau2(const CoolPropDbl &tau, c
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
|
||||
@@ -598,7 +598,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dDelta2_dTau(const CoolPropDbl &tau, c
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
|
||||
@@ -651,7 +651,7 @@ CoolPropDbl ResidualHelmholtzNonAnalytic::dTau3(const CoolPropDbl &tau, const Co
|
||||
if (N==0){return 0.0;}
|
||||
for (unsigned int i=0; i<N; ++i)
|
||||
{
|
||||
ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
const ResidualHelmholtzNonAnalyticElement &el = elements[i];
|
||||
CoolPropDbl ni = el.n, ai = el.a, bi = el.b, betai = el.beta;
|
||||
CoolPropDbl Ai = el.A, Bi = el.B, Ci = el.C, Di = el.D;
|
||||
CoolPropDbl theta=(1.0-tau)+Ai*pow(pow(delta-1.0,2),1.0/(2.0*betai));
|
||||
@@ -678,73 +678,73 @@ void ResidualHelmholtzSAFTAssociating::to_json(rapidjson::Value &el, rapidjson::
|
||||
el.AddMember("vbarn",vbarn,doc.GetAllocator());
|
||||
el.AddMember("kappabar",kappabar,doc.GetAllocator());
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::Deltabar(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::Deltabar(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->g(this->eta(delta))*(exp(this->epsilonbar*tau)-1)*this->kappabar;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dDeltabar_ddelta__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dDeltabar_ddelta__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->dg_deta(this->eta(delta))*(exp(this->epsilonbar*tau)-1)*this->kappabar*this->vbarn;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_ddelta2__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_ddelta2__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->d2g_deta2(this->eta(delta))*(exp(this->epsilonbar*tau)-1)*this->kappabar*pow(this->vbarn,(int)2);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dDeltabar_dtau__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dDeltabar_dtau__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->g(this->eta(delta))*this->kappabar*exp(this->epsilonbar*tau)*this->epsilonbar;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_dtau2__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_dtau2__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->g(this->eta(delta))*this->kappabar*exp(this->epsilonbar*tau)*pow(this->epsilonbar,(int)2);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_ddelta_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2Deltabar_ddelta_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->dg_deta(this->eta(delta))*exp(this->epsilonbar*tau)*this->epsilonbar*this->kappabar*this->vbarn;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_dtau3__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_dtau3__constdelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->g(this->eta(delta))*this->kappabar*exp(this->epsilonbar*tau)*pow(this->epsilonbar,(int)3);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->dg_deta(this->eta(delta))*this->kappabar*exp(this->epsilonbar*tau)*pow(this->epsilonbar,(int)2)*this->vbarn;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta2_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta2_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->d2g_deta2(this->eta(delta))*exp(this->epsilonbar*tau)*this->epsilonbar*this->kappabar*pow(this->vbarn,(int)2);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta3__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3Deltabar_ddelta3__consttau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
return this->d3g_deta3(this->eta(delta))*(exp(this->epsilonbar*tau)-1)*this->kappabar*pow(this->vbarn,(int)3);
|
||||
}
|
||||
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::X(const CoolPropDbl &delta, const CoolPropDbl &Deltabar)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::X(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const
|
||||
{
|
||||
return 2/(sqrt(1+4*Deltabar*delta)+1);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_dDeltabar__constdelta(const CoolPropDbl &delta, const CoolPropDbl &Deltabar)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_dDeltabar__constdelta(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const
|
||||
{
|
||||
CoolPropDbl X = this->X(delta,Deltabar);
|
||||
return -delta*X*X/(2*Deltabar*delta*X+1);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_ddelta__constDeltabar(const CoolPropDbl &delta, const CoolPropDbl &Deltabar)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_ddelta__constDeltabar(const CoolPropDbl &delta, const CoolPropDbl &Deltabar) const
|
||||
{
|
||||
CoolPropDbl X = this->X(delta,Deltabar);
|
||||
return -Deltabar*X*X/(2*Deltabar*delta*X+1);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Deltabar = this->Deltabar(tau, delta);
|
||||
return this->dX_dDeltabar__constdelta(delta, Deltabar)*this->dDeltabar_dtau__constdelta(tau, delta);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_ddelta(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dX_ddelta(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Deltabar = this->Deltabar(tau, delta);
|
||||
return (this->dX_ddelta__constDeltabar(delta, Deltabar)
|
||||
+ this->dX_dDeltabar__constdelta(delta, Deltabar)*this->dDeltabar_ddelta__consttau(tau, delta));
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_dtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Deltabar = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Deltabar);
|
||||
@@ -756,7 +756,7 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_dtau2(const CoolPropDbl &tau,
|
||||
CoolPropDbl dX_dDeltabar = this->dX_dDeltabar__constdelta(delta, Deltabar);
|
||||
return d_dXdtau_dX*dX_dDeltabar*beta+d_dXdtau_dDeltabar*beta+d_dXdtau_dbeta*dbeta_dtau;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddeltadtau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddeltadtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Deltabar = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Deltabar);
|
||||
@@ -769,7 +769,7 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddeltadtau(const CoolPropDbl &
|
||||
CoolPropDbl dX_dDeltabar = this->dX_dDeltabar__constdelta(delta, Deltabar);
|
||||
return d_dXddelta_dX*dX_dDeltabar*beta+d_dXddelta_dDeltabar*beta+d_dXddelta_dalpha*dalpha_dtau;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddelta2(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddelta2(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Deltabar = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Deltabar);
|
||||
@@ -791,7 +791,7 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d2X_ddelta2(const CoolPropDbl &tau
|
||||
+ d_dXddelta_dalpha*dalpha_ddelta);
|
||||
return val;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_dtau3(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_dtau3(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Delta = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Delta);
|
||||
@@ -805,7 +805,7 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_dtau3(const CoolPropDbl &tau,
|
||||
CoolPropDbl dXtt_dDelta_tt = -pow(X, 2)*delta/(2*Delta*X*delta + 1);
|
||||
return dXtt_dX*dX_dDelta*Delta_t+dXtt_dDelta*Delta_t + dXtt_dDelta_t*Delta_tt + dXtt_dDelta_tt*Delta_ttt;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddeltadtau2(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddeltadtau2(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Delta = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Delta);
|
||||
@@ -824,7 +824,7 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddeltadtau2(const CoolPropDbl
|
||||
return dXtt_ddelta + dXtt_dX*dX_ddelta + dXtt_dX*dX_dDelta*Delta_d + dXtt_dDelta*Delta_d + dXtt_dDelta_t*Delta_dt + dXtt_dDelta_tt*Delta_dtt;
|
||||
}
|
||||
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddelta2dtau(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddelta2dtau(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Delta = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Delta);
|
||||
@@ -847,7 +847,7 @@ double Xdd(double X, double delta, double Delta, double Delta_d, double Delta_dd
|
||||
return Delta*pow(X, 2)*(2*Delta + 2*Delta_d*delta)*(Delta*pow(X, 2)*delta + X)/pow(2*Delta*X*delta + 1, 3) + Delta_d*pow(X, 2)*delta*(2*Delta + 2*Delta_d*delta)*(Delta*pow(X, 2)*delta + X)/pow(2*Delta*X*delta + 1, 3) + Delta_d*pow(X, 2)*(2*Delta_d*X*pow(delta, 2) - 1)/pow(2*Delta*X*delta + 1, 2) - Delta_dd*pow(X, 2)*delta/(2*Delta*X*delta + 1) + pow(X, 2)*(2*pow(Delta, 2)*X - Delta_d)/pow(2*Delta*X*delta + 1, 2);
|
||||
}
|
||||
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddelta3(const CoolPropDbl &tau, const CoolPropDbl &delta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddelta3(const CoolPropDbl &tau, const CoolPropDbl &delta) const
|
||||
{
|
||||
CoolPropDbl Delta = this->Deltabar(tau, delta);
|
||||
CoolPropDbl X = this->X(delta, Delta);
|
||||
@@ -865,27 +865,27 @@ CoolPropDbl ResidualHelmholtzSAFTAssociating::d3X_ddelta3(const CoolPropDbl &tau
|
||||
|
||||
return dXdd_ddelta + dXdd_dX*(dX_ddelta + dX_dDelta*Delta_d) + dXdd_dDelta*Delta_d + dXdd_dDelta_d*Delta_dd + dXdd_dDelta_dd*Delta_ddd;
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::g(const CoolPropDbl &eta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::g(const CoolPropDbl &eta) const
|
||||
{
|
||||
return 0.5*(2-eta)/pow(1-eta,(int)3);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dg_deta(const CoolPropDbl &eta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::dg_deta(const CoolPropDbl &eta) const
|
||||
{
|
||||
return 0.5*(5-2*eta)/pow(1-eta,(int)4);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2g_deta2(const CoolPropDbl &eta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d2g_deta2(const CoolPropDbl &eta) const
|
||||
{
|
||||
return 3*(3-eta)/pow(1-eta,(int)5);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3g_deta3(const CoolPropDbl &eta)
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::d3g_deta3(const CoolPropDbl &eta) const
|
||||
{
|
||||
return 6*(7-2*eta)/pow(1-eta,(int)6);
|
||||
}
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::eta(const CoolPropDbl &delta){
|
||||
CoolPropDbl ResidualHelmholtzSAFTAssociating::eta(const CoolPropDbl &delta) const {
|
||||
return this->vbarn*delta;
|
||||
}
|
||||
|
||||
void ResidualHelmholtzSAFTAssociating::all(const CoolPropDbl &tau, const CoolPropDbl &delta, HelmholtzDerivatives &deriv) throw()
|
||||
void ResidualHelmholtzSAFTAssociating::all(const CoolPropDbl &tau, const CoolPropDbl &delta, HelmholtzDerivatives &deriv) const throw()
|
||||
{
|
||||
if (disabled){return;}
|
||||
CoolPropDbl X = this->X(delta, this->Deltabar(tau, delta));
|
||||
|
||||
@@ -159,12 +159,11 @@ static double Brent_HAProps_T(givens OutputKey, double p, givens In1Name, double
|
||||
double T;
|
||||
class BrentSolverResids : public CoolProp::FuncWrapper1D
|
||||
{
|
||||
private:
|
||||
private:
|
||||
givens OutputKey;
|
||||
double p;
|
||||
givens In1Key;
|
||||
double Input1, TargetVal;
|
||||
double T, psi_w;
|
||||
std::vector<givens> input_keys;
|
||||
std::vector<double> input_vals;
|
||||
public:
|
||||
@@ -173,10 +172,10 @@ static double Brent_HAProps_T(givens OutputKey, double p, givens In1Name, double
|
||||
input_keys.resize(2); input_keys[0] = In1Key; input_keys[1] = GIVEN_T;
|
||||
input_vals.resize(2); input_vals[0] = Input1;
|
||||
};
|
||||
~BrentSolverResids(){};
|
||||
|
||||
double call(double T){
|
||||
input_vals[1] = T;
|
||||
double psi_w;
|
||||
_HAPropsSI_inputs(p, input_keys, input_vals, T, psi_w);
|
||||
return _HAPropsSI_outputs(OutputKey, p, T, psi_w) - TargetVal;
|
||||
}
|
||||
@@ -1070,18 +1069,13 @@ public:
|
||||
class WetBulbTminSolver : public CoolProp::FuncWrapper1D
|
||||
{
|
||||
public:
|
||||
double p,hair_dry,r, RHS;
|
||||
WetBulbTminSolver(double p, double hair_dry){
|
||||
this->p = p;
|
||||
this->hair_dry = hair_dry;
|
||||
};
|
||||
~WetBulbTminSolver(){};
|
||||
double p,hair_dry;
|
||||
WetBulbTminSolver(double p, double hair_dry):p(p),hair_dry(hair_dry){}
|
||||
double call(double Ts)
|
||||
{
|
||||
RHS = HAPropsSI("H","T",Ts,"P",p,"R",1);
|
||||
double RHS = HAPropsSI("H","T",Ts,"P",p,"R",1);
|
||||
if (!ValidNumber(RHS)){throw CoolProp::ValueError();}
|
||||
r = RHS - this->hair_dry;
|
||||
return r;
|
||||
return RHS - this->hair_dry;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user