Skip to content

Commit

Permalink
Temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
corykinney committed Jan 11, 2023
1 parent cb9b292 commit 74d7624
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 4 deletions.
57 changes: 54 additions & 3 deletions include/cantera/thermo/SoaveRedlichKwong.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class SoaveRedlichKwong : public MixtureFugacityTP
return "Soave-Redlich-Kwong";
}

//! @name Molar Thermodynamic properties
//! @{

virtual double cp_mole() const;
virtual double cv_mole() const;

//! @}
//! @name Mechanical Properties
//! @{
Expand Down Expand Up @@ -79,6 +85,49 @@ class SoaveRedlichKwong : public MixtureFugacityTP
*/
virtual double pressure() const;

//! @}

//! Returns the standard concentration \f$ C^0_k \f$, which is used to
//! normalize the generalized concentration.
/*!
* This is defined as the concentration by which the generalized
* concentration is normalized to produce the activity.
* The ideal gas mixture is considered as the standard or reference state here.
* Since the activity for an ideal gas mixture is simply the mole fraction,
* for an ideal gas, \f$ C^0_k = P/\hat R T \f$.
*
* @param k Optional parameter indicating the species. The default is to
* assume this refers to species 0.
* @return
* Returns the standard Concentration in units of m^3 / kmol.
*/
virtual double standardConcentration(size_t k=0) const;

//! Get the array of non-dimensional activity coefficients at the current
//! solution temperature, pressure, and solution concentration.
/*!
* For all objects with the Mixture Fugacity approximation, we define the
* standard state as an ideal gas at the current temperature and pressure of
* the solution. The activities are based on this standard state.
*
* @param ac Output vector of activity coefficients. Length: m_kk.
*/
virtual void getActivityCoefficients(double* ac) const;

//! @name Partial Molar Properties of the Solution
//! @{

virtual void getChemPotentials(double* mu) const;
virtual void getPartialMolarEnthalpies(double* hbar) const;
virtual void getPartialMolarEntropies(double* sbar) const;
virtual void getPartialMolarIntEnergies(double* ubar) const;
//! Calculate species-specific molar specific heats
/*!
* This function is currently not implemented for Soave-Redlich-Kwong phase.
*/
virtual void getPartialMolarCp(double* cpbar) const;
virtual void getPartialMolarVolumes(double* vbar) const;
//! @}

//! Calculate species-specific critical temperature
/*!
Expand All @@ -89,7 +138,7 @@ class SoaveRedlichKwong : public MixtureFugacityTP
* @param a species-specific coefficients used in SRK EoS
* @param b species-specific coefficients used in SRK EoS
*/
double speciesCritTemperature(double a, double b) const;
virtual double speciesCritTemperature(double a, double b) const;

//! @name Initialization Methods - For Internal use
//!
Expand Down Expand Up @@ -126,6 +175,8 @@ class SoaveRedlichKwong : public MixtureFugacityTP

protected:
// Special functions inherited from MixtureFugacityTP
virtual double sresid() const;
virtual double hresid() const;

virtual double liquidVolEst(double T, double& pres) const;
virtual double densityCalc(double T, double pressure, int phase, double rhoguess);
Expand Down Expand Up @@ -169,7 +220,7 @@ class SoaveRedlichKwong : public MixtureFugacityTP
*/
virtual void updateMixingExpressions();

//! Calculate the \f$a\f$, \f$b\f$, and \f$\a alpha\f$ parameters given the temperature
//! Calculate the \f$a\f$, \f$b\f$, and \f$a \alpha\f$ parameters given the temperature
/*!
* This function doesn't change the internal state of the object, so it is a
* const function. It does use the stored mole fractions in the object.
Expand All @@ -178,7 +229,7 @@ class SoaveRedlichKwong : public MixtureFugacityTP
* @param bCalc (output) Returns the b value.
* @param aAlpha (output) Returns the (a*alpha) value.
*/
void calculateAB(double& aCalc, double& bCalc, double& aAlphaCalc) const
void calculateAB(double& aCalc, double& bCalc, double& aAlphaCalc) const;

void calcCriticalConditions(double& pc, double& tc, double& vc) const;

Expand Down
86 changes: 85 additions & 1 deletion src/thermo/SoaveRedlichKwong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,71 @@ void SoaveRedlichKwong::setBinaryCoeffs(const std::string& species_i,
m_aAlpha_binary(ki, kj) = m_aAlpha_binary(kj, ki) = a0*alpha_ij;
}

// ------------Molar Thermodynamic Properties -------------------------

double SoaveRedlichKwong::cp_mole() const
{
return 1.0;
}

double SoaveRedlichKwong::cv_mole() const
{
_updateReferenceStateThermo();
double T = temperature();
calculatePressureDerivatives();
return (cp_mole() + T * m_dpdT * m_dpdT / m_dpdV);
}

double SoaveRedlichKwong::pressure() const
{
_updateReferenceStateThermo();
// Get a copy of the private variables stored in the State object
double T = temperature();
double mv = molarVolume();
return GasConstant * T / (mv - m_b) - m_aAlpha_mix / (mv * (mv + m_b))
return GasConstant * T / (mv - m_b) - m_aAlpha_mix / (mv * (mv + m_b));
}

double SoaveRedlichKwong::standardConcentration(size_t k) const
{
getStandardVolumes(m_tmpV.data());
return 1.0 / m_tmpV[k];
}

void SoaveRedlichKwong::getActivityCoefficients(double* ac) const
{

}

// ---- Partial Molar Properties of the Solution -----------------

void SoaveRedlichKwong::getChemPotentials(double* mu) const
{

}

void SoaveRedlichKwong::getPartialMolarEnthalpies(double* hbar) const
{

}

void SoaveRedlichKwong::getPartialMolarEntropies(double* sbar) const
{

}

void SoaveRedlichKwong::getPartialMolarIntEnergies(double* ubar) const
{

}

void SoaveRedlichKwong::getPartialMolarCp(double* cpbar) const
{

}

void SoaveRedlichKwong::getPartialMolarVolumes(double* vbar) const
{

}

double SoaveRedlichKwong::speciesCritTemperature(double a, double b) const
Expand Down Expand Up @@ -257,6 +315,32 @@ void SoaveRedlichKwong::getSpeciesParameters(const std::string& name,
}
}

double SoaveRedlichKwong::sresid() const
{ // Replace
double molarV = molarVolume();
double hh = m_b / molarV;
double zz = z();
double alpha_1 = daAlpha_dT();
double vpb = molarV + (1.0 + Sqrt2) * m_b;
double vmb = molarV + (1.0 - Sqrt2) * m_b;
double fac = alpha_1 / (2.0 * Sqrt2 * m_b);
double sresid_mol_R = log(zz*(1.0 - hh)) + fac * log(vpb / vmb) / GasConstant;
return GasConstant * sresid_mol_R;
}

double SoaveRedlichKwong::hresid() const
{ // Replace
double molarV = molarVolume();
double zz = z();
double aAlpha_1 = daAlpha_dT();
double T = temperature();
double vpb = molarV + (1 + Sqrt2) * m_b;
double vmb = molarV + (1 - Sqrt2) * m_b;
double fac = 1 / (2.0 * Sqrt2 * m_b);
return GasConstant * T * (zz - 1.0)
+ fac * log(vpb / vmb) * (T * aAlpha_1 - m_aAlpha_mix);
}

double SoaveRedlichKwong::liquidVolEst(double T, double& presGuess) const
{
double v = m_b * 1.1;
Expand Down

0 comments on commit 74d7624

Please sign in to comment.