Add base class functions to set density and pressure simultaneously

They have the names setState_RP, setState_RPX, and setState_RPY. These
base class functions mirror the TP, TPX, TPY set, except that RP is not
implemented, because it depends on the EOS of the system. We cannot use
the normal setPressure because it sets the state by calculating the
density, but RP will specify the density.
This commit is contained in:
Bryan W. Weber 2015-06-13 19:42:47 -04:00 committed by Ray Speth
parent 2f7e05040c
commit 5d215b7e86
2 changed files with 126 additions and 0 deletions

View file

@ -1097,6 +1097,96 @@ public:
*/
virtual void setState_SV(doublereal s, doublereal v, doublereal tol = 1.e-4);
//! Set the density (kg/m**3) and pressure (Pa) at constant
//! composition
/*!
* This method must be reimplemented in derived classes, where it
* may involve the solution of a nonlinear equation. Within %Cantera,
* the independent variable is the density. Therefore, this function
* solves for the temperature that will yield the desired input pressure
* and density. The composition is held constant during this process.
*
* This base class function will print an error, if not overwritten.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
*/
virtual void setState_RP(doublereal rho, doublereal p){
throw NotImplementedError("ThermoPhase::setState_RP");
}
//! Set the density (kg/m**3), pressure (Pa) and mole fractions
/*!
* Note, the mole fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param x Vector of mole fractions.
* Length is equal to m_kk.
*/
virtual void setState_RPX(doublereal rho, doublereal p, const doublereal* x);
//! Set the density (kg/m**3), pressure (Pa) and mole fractions
/*!
* Note, the mole fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param x Composition map of mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
virtual void setState_RPX(doublereal rho, doublereal p, const compositionMap& x);
//! Set the density (kg/m**3), pressure (Pa) and mole fractions
/*!
* Note, the mole fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param x String containing a composition map of the mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
virtual void setState_RPX(doublereal rho, doublereal p, const std::string& x);
//! Set the density (kg/m**3), pressure (Pa) and mass fractions
/*!
* Note, the mass fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param y Vector of mole fractions.
* Length is equal to m_kk.
*/
virtual void setState_RPY(doublereal rho, doublereal p, const doublereal* y);
//! Set the density (kg/m**3), pressure (Pa) and mass fractions
/*!
* Note, the mass fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param y Composition map of mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
virtual void setState_RPY(doublereal rho, doublereal p, const compositionMap& y);
//! Set the density (kg/m**3), pressure (Pa) and mass fractions
/*!
* Note, the mass fractions are set first before the density and pressure
* are set. Setting the pressure may involve the solution of a nonlinear equation.
*
* @param rho Density (kg/m^3)
* @param p Pressure (Pa)
* @param y String containing a composition map of the mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
virtual void setState_RPY(doublereal rho, doublereal p, const std::string& y);
//@}
private:

View file

@ -180,6 +180,42 @@ void ThermoPhase::setState_TP(doublereal t, doublereal p)
setPressure(p);
}
void ThermoPhase::setState_RPX(doublereal rho, doublereal p, const doublereal* x)
{
setMoleFractions(x);
setState_RP(rho, p);
}
void ThermoPhase::setState_RPX(doublereal rho, doublereal p, const compositionMap& x)
{
setMoleFractionsByName(x);
setState_RP(rho,p);
}
void ThermoPhase::setState_RPX(doublereal rho, doublereal p, const std::string& x)
{
setMoleFractionsByName(x);
setState_RP(rho,p);
}
void ThermoPhase::setState_RPY(doublereal rho, doublereal p, const doublereal* y)
{
setMassFractions(y);
setState_RP(rho,p);
}
void ThermoPhase::setState_RPY(doublereal rho, doublereal p, const compositionMap& y)
{
setMassFractionsByName(y);
setState_RP(rho,p);
}
void ThermoPhase::setState_RPY(doublereal rho, doublereal p, const std::string& y)
{
setMassFractionsByName(y);
setState_RP(rho,p);
}
void ThermoPhase::setState_PX(doublereal p, doublereal* x)
{
setMoleFractions(x);