diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index 55bdd0d0ab..f93b16cd78 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -1097,6 +1097,96 @@ class ThermoPhase : public Phase */ 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: diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index b24282630a..56a05bfce1 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -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);