mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Implemented more partial derivatives, still need a proper mapping of the additional quantities.
This commit is contained in:
@@ -155,25 +155,30 @@ corresponds to the new mixture syntax in CoolProp v5.
|
||||
Partial Derivatives
|
||||
-------------------
|
||||
|
||||
A limited subset of partial derivatives is available for the incompressible fluids. As of
|
||||
October 2015, the following inputs are supported by the ``PropsSI`` function:
|
||||
A limited subset of partial derivatives is available for the incompressible fluids. Currently,
|
||||
the following inputs are supported by the ``PropsSI`` function:
|
||||
:math:`\left( \partial \rho / \partial p \right)_{T,x}=0`,
|
||||
:math:`\left( \partial \rho / \partial h \right)_{p,x}`,
|
||||
:math:`\left( \partial \rho / \partial s \right)_{p,x}`,
|
||||
:math:`\left( \partial \rho / \partial T \right)_{p,x}`,
|
||||
:math:`\left( \partial h / \partial p \right)_{T,x}`,
|
||||
:math:`\left( \partial h / \partial s \right)_{T,x}`,
|
||||
:math:`\left( \partial h / \partial T \right)_{p,x}`,
|
||||
:math:`\left( \partial s / \partial p \right)_{T,x}`,
|
||||
:math:`\left( \partial s / \partial T \right)_{p,x}`,
|
||||
:math:`\left( \partial h / \partial T \right)_{p,x}`,
|
||||
:math:`\left( \partial s / \partial p \right)_{T,x}` and
|
||||
:math:`\left( \partial h / \partial p \right)_{T,x}`.
|
||||
and their inverse functions.
|
||||
|
||||
Note that all partial derivatives require a constant concentration, which is denoted by the
|
||||
``x``, but this ``x`` is not included in the derivative string notation for ``PropsSI``:
|
||||
:math:`x`, but this :math:`x` is not included in the derivative string notation for ``PropsSI``:
|
||||
:math:`\left( \partial \rho / \partial T \right)_{p,x}` translates to ``d(Dmass)/d(T)|P``.
|
||||
|
||||
.. note::
|
||||
You can compute other properties from the partial derivatives available. At this point, not
|
||||
You can calculate other properties from the partial derivatives available. At this point, not
|
||||
all derived properties have been implemented even though some of them can be computed like the
|
||||
isobaric expansion coefficient, which would be :math:`-1/\rho \left( \partial \rho / \partial T \right)_{p,x}`.
|
||||
isobaric expansion coefficient, which would be :math:`-\left( \partial \rho / \partial T \right)_{p,x}/\rho`.
|
||||
|
||||
For more general information on the partial derivatives, please have a look at the
|
||||
:ref:`documentation<_partial_derivatives_high_level>` for the high level interface.
|
||||
:ref:`documentation<partial_derivatives_high_level>` for the high level interface.
|
||||
|
||||
|
||||
.. _FittingReports:
|
||||
|
||||
@@ -482,17 +482,27 @@ CoolPropDbl IncompressibleBackend::raw_calc_smass(double T, double p, double x){
|
||||
/// Calculate the first partial derivative for the desired derivative
|
||||
CoolPropDbl IncompressibleBackend::calc_first_partial_deriv(parameters Of, parameters Wrt, parameters Constant){
|
||||
// TODO: Can this be accelerated?
|
||||
if ( (Of==iDmass) && (Wrt==iT) && (Constant==iP) ) return drhodTatPx();
|
||||
if ( (Of==iSmass) && (Wrt==iT) && (Constant==iP) ) return dsdTatPx();
|
||||
if ( (Of==iHmass) && (Wrt==iT) && (Constant==iP) ) return dhdTatPx();
|
||||
if ( (Of==iDmass) && (Wrt==iP) ) return 0.0; // incompressible!
|
||||
if ( (Of==iDmass) && (Wrt==iHmass) && (Constant==iP) ) return drhodTatPx()/dhdTatPx();
|
||||
if ( (Of==iHmass) && (Wrt==iDmass) && (Constant==iP) ) return dhdTatPx()/drhodTatPx();
|
||||
if ( (Of==iDmass) && (Wrt==iSmass) && (Constant==iP) ) return drhodTatPx()/dsdTatPx();
|
||||
if ( (Of==iSmass) && (Wrt==iDmass) && (Constant==iP) ) return dsdTatPx()/drhodTatPx();
|
||||
if ( (Of==iDmass) && (Wrt==iT) && (Constant==iP) ) return drhodTatPx();
|
||||
if ( (Of==iT) && (Wrt==iDmass) && (Constant==iP) ) return 1.0/drhodTatPx();
|
||||
//
|
||||
if ( (Of==iHmass) && (Wrt==iP) && (Constant==iT) ) return dhdpatTx();
|
||||
if ( (Of==iP) && (Wrt==iHmass) && (Constant==iT) ) return 1.0/dhdpatTx();
|
||||
if ( (Of==iHmass) && (Wrt==iSmass) && (Constant==iT) ) return dhdpatTx()/dsdpatTx();
|
||||
if ( (Of==iSmass) && (Wrt==iHmass) && (Constant==iT) ) return dsdpatTx()/dhdpatTx();
|
||||
if ( (Of==iHmass) && (Wrt==iT) && (Constant==iP) ) return dhdTatPx();
|
||||
if ( (Of==iT) && (Wrt==iHmass) && (Constant==iP) ) return 1.0/dhdTatPx();
|
||||
//
|
||||
if ( (Of==iSmass) && (Wrt==iP) && (Constant==iT) ) return dsdpatTx();
|
||||
if ( (Of==iP) && (Wrt==iSmass) && (Constant==iT) ) return 1.0/dsdpatTx();
|
||||
if ( (Of==iSmass) && (Wrt==iT) && (Constant==iP) ) return dsdTatPx();
|
||||
if ( (Of==iT) && (Wrt==iSmass) && (Constant==iP) ) return 1.0/dsdTatPx();
|
||||
//if ( (Of==iHmass) && (Wrt==iP) && (Constant==iT) ) return dsdTatPxdT();
|
||||
//if ( (Of==iHmass) && (Wrt==iP) && (Constant==iT) ) return dhdTatPxdT();
|
||||
if ( (Of==iSmass) && (Wrt==iP) && (Constant==iT) ) return dsdpatTx();
|
||||
if ( (Of==iHmass) && (Wrt==iP) && (Constant==iT) ) return dhdpatTx();
|
||||
|
||||
if ( (Of==iDmass) && (Wrt==iHmass) && (Constant==iP) ) return drhodTatPx()/dhdTatPx();
|
||||
if ( (Of==iDmass) && (Wrt==iP) ) return 0.0; // incompressible!
|
||||
|
||||
throw ValueError("Incompressible fluids only support a limited subset of partial derivatives.");
|
||||
}
|
||||
|
||||
|
||||
@@ -214,22 +214,22 @@ protected:
|
||||
/// Partial derivative of enthalpy with respect to temperature at constant pressure and composition
|
||||
double calc_dhdTatPx (double T, double p, double x){return fluid->c(T,p,x);};
|
||||
/// Partial derivative of entropy
|
||||
// with respect to temperature at constant pressure and composition
|
||||
// integrated in temperature
|
||||
/// with respect to temperature at constant pressure and composition
|
||||
/// integrated in temperature
|
||||
double calc_dsdTatPxdT(double T, double p, double x){return fluid->dsdTatPxdT(T,p,x);};
|
||||
/// Partial derivative of enthalpy
|
||||
// with respect to temperature at constant pressure and composition
|
||||
// integrated in temperature
|
||||
/// with respect to temperature at constant pressure and composition
|
||||
/// integrated in temperature
|
||||
double calc_dhdTatPxdT(double T, double p, double x){return fluid->dhdTatPxdT(T,p,x);};
|
||||
|
||||
|
||||
/* Other useful derivatives
|
||||
*/
|
||||
/// Partial derivative of entropy with respect to pressure at constant temperature and composition
|
||||
// \f[ \left( \frac{\partial s}{\partial p} \right)_T = - \left( \frac{\partial v}{\partial T} \right)_p = \rho^{-2} \left( \frac{\partial \rho}{\partial T} \right)_p \right) \f]
|
||||
/// \f[ \left( \frac{\partial s}{\partial p} \right)_T = - \left( \frac{\partial v}{\partial T} \right)_p = \rho^{-2} \left( \frac{\partial \rho}{\partial T} \right)_p \right) \f]
|
||||
double calc_dsdpatTx (double rho, double drhodTatPx);
|
||||
/// Partial derivative of enthalpy with respect to pressure at constant temperature and composition
|
||||
// \f[ \left( \frac{\partial h}{\partial p} \right)_T = v - T \left( \frac{\partial v}{\partial T} \right)_p = \rho^{-1} \left( 1 + T \rho^{-1} \left( \frac{\partial \rho}{\partial T} \right)_p \right) \f]
|
||||
/// \f[ \left( \frac{\partial h}{\partial p} \right)_T = v - T \left( \frac{\partial v}{\partial T} \right)_p = \rho^{-1} \left( 1 + T \rho^{-1} \left( \frac{\partial \rho}{\partial T} \right)_p \right) \f]
|
||||
double calc_dhdpatTx (double T, double rho, double drhodTatPx);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user