42 std::string PengRobinsonEoS::className =
44 "PengRobinson", PengRobinsonEoS::create,
45 "Peng-Robinson equation of state.");
47 PengRobinsonEoS::PengRobinsonEoS(
51 pSession->LoadParameter(
"Tcrit",
m_Tc);
52 pSession->LoadParameter(
"Pcrit",
m_Pc);
53 pSession->LoadParameter(
"AcentricFactor",
m_omega);
74 C =
m_a / (
m_b * 2 * sqrt2) * logTerm * (1 +
m_fw) * (1 +
m_fw) - e;
77 NekDouble sqrtT = (-B + sqrt(B * B - 4 * A * C)) / (2 * A);
108 deltaS +=
m_a * sqrtA *
m_fw * logTerm * (sqrtTr / T) / (
m_b * sqrt(8));
127 2 *
m_a * alpha * rho * (1 +
m_b * rho) /
128 ((denom * rho * rho) * (denom * rho * rho));
132 -
m_a * sqrt(alpha) * (1.0 +
m_fw) / (denom * rho * rho);
135 return dPdrho_T - dPde * dedrho_T;
156 m_a / sqrt(T * m_Tc) *
m_fw * sqrtA / denom;
173 B = 2 *
m_a / denom * m_fw * (1.0 +
m_fw) / sqrt(
m_Tc);
174 C = -
m_a * (1.0 +
m_fw) * (1 + m_fw) / denom -
p;
177 NekDouble T = (-B + sqrt(B * B - 4 * A * C)) / (2 * A);
186 m_a / (
m_b * sqrt(8)) * logTerm *
187 (alpha + sqrt(alpha) * m_fw * sqrtTr);
203 NekDouble k3 = -A * B + B * B + B * B * B;
212 unsigned int cnt = 0;
213 while (abs(residual) > tol && cnt < maxIter)
215 f = Z * Z * Z + k1 * Z * Z + k2 * Z + k3;
216 df = 3 * Z * Z + 2 * k1 * Z + k2;
223 cout <<
"Newton-Raphson in PengRobinsonEoS::v_GetRhoFromPT did not " 225 << maxIter <<
" iterations (residual = " << residual <<
")" 236 return sqrtAlpha * sqrtAlpha;
241 return log((1.0 / rho +
m_b -
m_b * sqrt(2)) /
242 (1.0 / rho +
m_b +
m_b * sqrt(2)));
NekDouble LogTerm(const NekDouble &rho)
NekDouble GetDPDe_rho(const NekDouble &rho, const NekDouble &e)
Calculate the partial derivative of P(rho,e) with respect to e.
Encapsulates equations of state allowing us to obtain thermodynamic properties: most relations are in...
virtual NekDouble v_GetEntropy(const NekDouble &rho, const NekDouble &e)
virtual NekDouble v_GetTemperature(const NekDouble &rho, const NekDouble &e)
NekDouble Alpha(const NekDouble &T)
EquationOfStateFactory & GetEquationOfStateFactory()
Declaration of the equation of state factory singleton.
virtual NekDouble v_GetEFromRhoP(const NekDouble &rho, const NekDouble &p)
NekDouble GetTemperature(const NekDouble &rho, const NekDouble &e)
Calculate the temperature.
virtual NekDouble v_GetDPDrho_e(const NekDouble &rho, const NekDouble &e)
virtual NekDouble v_GetPressure(const NekDouble &rho, const NekDouble &e)
virtual NekDouble v_GetDPDe_rho(const NekDouble &rho, const NekDouble &e)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual NekDouble v_GetRhoFromPT(const NekDouble &rho, const NekDouble &p)