Skip to content

Commit

Permalink
Add functions to set property pairs specified in Sub.cpp
Browse files Browse the repository at this point in the history
Add functions to set the unimplemented property pairs specified
in the Substance::Set function of Sub.cpp
  • Loading branch information
bryanwweber committed Jan 25, 2016
1 parent 31316b7 commit 63cfed1
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/cantera/thermo/PureFluidPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ class PureFluidPhase : public ThermoPhase
virtual void setState_UV(double u, double v, double tol = 1.e-8);
virtual void setState_SV(double s, double v, double tol = 1.e-8);
virtual void setState_SP(double s, double p, double tol = 1.e-8);
virtual void setState_ST(double s, double t, double tol = 1.e-8);
virtual void setState_TV(double t, double v, double tol = 1.e-8);
virtual void setState_PV(double p, double v, double tol = 1.e-8);
virtual void setState_UP(double u, double p, double tol = 1.e-8);
virtual void setState_VH(double v, double h, double tol = 1.e-8);
virtual void setState_TH(double t, double h, double tol = 1.e-8);
virtual void setState_SH(double s, double h, double tol = 1.e-8);
//@}

//! @name Critical State Properties
Expand Down
112 changes: 112 additions & 0 deletions include/cantera/thermo/ThermoPhase.h
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,118 @@ class ThermoPhase : public Phase
*/
virtual void setState_SV(doublereal s, doublereal v, doublereal tol = 1.e-4);

//! Set the specific entropy (J/kg/K) and temperature (K).
/*!
* This function fixes the internal state of the phase so that the specific
* entropy and temperature have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param s specific entropy (J/kg/K)
* @param t temperature (K)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_ST(double s, double t, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_ST");
}

//! Set the temperature (K) and specific volume (m^3/kg).
/*!
* This function fixes the internal state of the phase so that the
* temperature and specific volume have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param t temperature (K)
* @param v specific volume (m^3/kg)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_TV(double t, double v, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_TV");
}

//! Set the pressure (Pa) and specific volume (m^3/kg).
/*!
* This function fixes the internal state of the phase so that the
* pressure and specific volume have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param p pressure (Pa)
* @param v specific volume (m^3/kg)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_PV(double p, double v, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_PV");
}

//! Set the specific internal energy (J/kg) and pressure (Pa).
/*!
* This function fixes the internal state of the phase so that the specific
* internal energy and pressure have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param u specific internal energy (J/kg)
* @param p pressure (Pa)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_UP(double u, double p, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_UP");
}

//! Set the specific volume (m^3/kg) and the specific enthalpy (J/kg)
/*!
* This function fixes the internal state of the phase so that the specific
* volume and the specific enthalpy have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param v specific volume (m^3/kg)
* @param h specific enthalpy (J/kg)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_VH(double v, double h, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_VH");
}

//! Set the temperature (K) and the specific enthalpy (J/kg)
/*!
* This function fixes the internal state of the phase so that the
* temperature and specific enthalpy have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param t temperature (K)
* @param h specific enthalpy (J/kg)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_TH(double t, double h, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_TH");
}

//! Set the specific entropy (J/kg/K) and the specific enthalpy (J/kg)
/*!
* This function fixes the internal state of the phase so that the
* temperature and pressure have the value of the input parameters.
* This base class function will print an error if not overwritten.
*
* @param s specific entropy (J/kg/K)
* @param h specific enthalpy (J/kg)
* @param tol Optional parameter setting the tolerance of the calculation.
* Defaults to 1.0E-4. Important for some applications where
* numerical Jacobians are being calculated.
*/
virtual void setState_SH(double s, double h, double tol = 1.e-4) {
throw NotImplementedError("ThermoPhase::setState_SH");
}

//! Set the density (kg/m**3) and pressure (Pa) at constant composition
/*!
* This method must be reimplemented in derived classes, where it may
Expand Down
42 changes: 42 additions & 0 deletions src/thermo/PureFluidPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,48 @@ void PureFluidPhase::setState_SP(double s, double p, double tol)
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_ST(double s, double t, double tol)
{
Set(tpx::PropertyPair::ST, s, t);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_TV(double t, double v, double tol)
{
Set(tpx::PropertyPair::TV, t, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_PV(double p, double v, double tol)
{
Set(tpx::PropertyPair::PV, p, v);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_UP(double u, double p, double tol)
{
Set(tpx::PropertyPair::UP, u, p);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_VH(double v, double h, double tol)
{
Set(tpx::PropertyPair::VH, v, h);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_TH(double t, double h, double tol)
{
Set(tpx::PropertyPair::TH, t, h);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

void PureFluidPhase::setState_SH(double s, double h, double tol)
{
Set(tpx::PropertyPair::SH, s, h);
setState_TR(m_sub->Temp(), 1.0/m_sub->v());
}

doublereal PureFluidPhase::satPressure(doublereal t)
{
Set(tpx::PropertyPair::TV, t, m_sub->v());
Expand Down

0 comments on commit 63cfed1

Please sign in to comment.