Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Peng-Robinson EoS (Revised) #1047

Merged
merged 66 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
11d5382
Implementation of Peng-Robinson equation of state
May 16, 2019
12590d5
Abstracting thermo calcs from PengRobinson and RedlichKwong up to Mix…
decaluwe Dec 21, 2019
1929d1b
Abstracting cubic solver to MixtureFugacityTP thermo class.
decaluwe Dec 30, 2019
fd24841
Fixing location of critProperties.xml referenced in thermo/PengRobins…
decaluwe Jan 16, 2020
bd1954f
Adding ThermoFromYAML:PengRobinson_CO2 test
decaluwe Jan 16, 2020
7491a2b
Remove unnecessary overrides in MixtureFugacityTP and children
speth Jan 16, 2020
8ec7326
Testing critical property lookup for PengRobinson.
decaluwe Jan 17, 2020
83e621c
Adding cubic solver test
decaluwe Jan 21, 2020
04d3cf7
Make Peng-Robinson constructible by ThermoFactory
speth Apr 19, 2021
836a2bf
Changing 'bad' to 'poorly' in MixtureFugacity TP error message
decaluwe Jan 22, 2020
34c9b50
Adding following tests to PengRobinson_Test.cpp to verify that
Jan 27, 2020
3dbe95b
Fixing indexing error in PengRobinson:d2aAlpha_dT2
decaluwe Jan 31, 2020
fcd49cf
Cleaning up thermo/PengRobinson
decaluwe Feb 4, 2020
5363a4e
Rename Nichols cubic solve methods as 'solveCubic'
decaluwe Feb 4, 2020
308920a
Removing dependancy of EoS specific omega_a, omega_b parameters from …
gkogekar Apr 8, 2020
e3d714c
Cleaning up the redundant code, correcting indentations and tabs
gkogekar Apr 8, 2020
848bd11
Removed redundant calculations using a 2D array aAlpha_coeff_vec
gkogekar Apr 8, 2020
a3ff83a
Redefined species specific internal functions as protected instead of…
gkogekar Apr 8, 2020
c03b352
Removing a_coeff_vec to avoid duplication and using m_a_vec_Curr inst…
gkogekar Apr 9, 2020
b650c41
Update documentation of PengRobinson/MixtureFugacityTP
Jun 6, 2020
1e02cf4
Modifying comments and correcting typos
Jun 15, 2020
a058c48
Modified Peng-Robinson to test file to read phase from
Jun 16, 2020
2e8a89f
Modifying the explaination for solveCubic function to be more clear and
Jun 23, 2020
7a26c3b
Changed the function name 'pressureDerivatives' to
gkogekar Oct 5, 2020
2f67b9e
Moved 'calculateAlpha' inside the 'setSpeciesCoeff' function
gkogekar Oct 5, 2020
a5b67c1
Implementation of partial internal energies
gkogekar Oct 28, 2020
6b98a24
Cleaning up functions to calculate critical properties in Redlich-Kwo…
gkogekar Oct 28, 2020
483dd6d
Defined m_a_vec_curr as the array2D type to simplify index calculations
gkogekar Oct 29, 2020
545caa6
Adding missing P-R coefficients for CO2 in co2_PR_example.yaml file
gkogekar Oct 29, 2020
37700cb
Reading w_ac (acentric factor) with a more useful message that will
gkogekar Oct 29, 2020
e0673a3
Removing redundant _updateStateThermo() call from thermodynamic
gkogekar Nov 23, 2020
5b19e15
Updating PengRobinson test from thermoFromYaml.cpp
gkogekar Mar 20, 2021
ff320f8
Cleaning up whitespaces, typos and redundant variables
gkogekar Mar 21, 2021
e20ba42
Wrapping up some error messages to keep the line length below 80
gkogekar Mar 21, 2021
61cdb7e
Cleaning up whitespaces and some comments
gkogekar Mar 21, 2021
915fdf6
Cleaning up some more indentations errors, typos and comments
gkogekar Mar 21, 2021
940e0be
Adding documentation for certain functions
gkogekar Mar 23, 2021
105a5a0
Declaring omega_a, omega_b values as private
gkogekar Mar 23, 2021
68b8d47
Merging 'calculateAlpha' function in 'setSpeciesCoeffs'.
gkogekar Mar 23, 2021
577da33
Renaming _curr vector variables
gkogekar Mar 26, 2021
da66a8e
Removing the unused function 'pressureCalc()'
gkogekar Mar 26, 2021
879ec59
Fixing indentations and removing redundant statements
gkogekar Mar 26, 2021
0f9e186
Modifying 'getPressure' test to cover a wider range of temperatures
gkogekar Apr 14, 2021
92654c7
Adding a test to validate P-R EoS with CoopProp
gkogekar Apr 15, 2021
3cd9b12
Modifying the cubic solver test
gkogekar Apr 15, 2021
90cda14
Adding a function to calculate partial molar specific heats
gkogekar Apr 15, 2021
742a776
Fixing an error in 'setBinaryCoeffs()'
gkogekar Apr 16, 2021
9c7d705
[Doc] Remove incorrect description from PengRobinson::setBinaryCoeffs
speth Apr 20, 2021
7236fc7
[Thermo] Fix argument passed to MixtureFugacityTP::solveCubic
speth Apr 20, 2021
e668cf0
Renaming YAML field w_ac to acentric-factor
gkogekar Apr 14, 2021
6605e14
Add P-R tests for partial molar properties
speth Apr 20, 2021
21df76e
Make Peng-Robinson cp validation test more robust
speth Apr 20, 2021
6c7e2b6
Add Peng-Robinson test for partial molar cp
speth Apr 20, 2021
049ac0e
Pick more challenging conditions for P-R tests
speth Apr 20, 2021
b83ab23
Add tests for Peng-Robinson species lookup
speth Apr 20, 2021
140e898
Fixing error in tests 'activityCoeffs' and 'chempotentials_RT'
gkogekar Apr 27, 2021
f9c28ca
Adding an error condition in 'getCoeff' function when the given species
gkogekar Apr 27, 2021
b8e009c
Fixing error in d2aAlphadT2() function
gkogekar Apr 28, 2021
6af3c3f
Fixing PengRobinson_CO2 test with correct values
gkogekar May 27, 2021
9a250e4
Simplifying the partial molar entropy calculation. The partial
gkogekar May 28, 2021
ecf4555
Simplifying d(aAlpha)/dT equation
Jun 6, 2021
c7cd768
Cleaning up redundant lines/variables, also renamed 'den' to 'denom' to
gkogekar Jun 7, 2021
f5293a7
Fixing an error in the partialMolarEnthalpies() function. Previously,…
gkogekar Jun 28, 2021
fe21bb3
Removing incorrect partialCp calculation (Currently, throws
gkogekar Jun 28, 2021
24bb1f7
Some formatting changes, also added a reference for the acentric factor
gkogekar Jul 20, 2021
c32fa84
Adding the name in the Authors list
gkogekar Jul 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ John Hewson (@jchewson), Sandia National Laboratory
Trevor Hickey (@luxe)
Yuanjie Jiang
Benjamin Kee (@lionkey)
Gandhali Kogekar (@gkogekar)
Daniel Korff (@korffdm), Colorado School of Mines
Jon Kristofer
Samesh Lakothia (@sameshl)
Expand Down
6 changes: 5 additions & 1 deletion data/inputs/critProperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
<Pc value="7.39e+06"/>
<Vc value="0.0948"/>
<Zc value="0.275"/>
<omega value="0.239"/>
<omega value="0.228"/>
gkogekar marked this conversation as resolved.
Show resolved Hide resolved
<source>
The acentric factor is taken from Yaws, Carl L. (2001).
Matheson Gas Data Book. McGraw-Hill.
</source>
</species>
<species name="COS">
<ChemName name="carbonyl-sulfide"/>
Expand Down
86 changes: 50 additions & 36 deletions include/cantera/thermo/MixtureFugacityTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ class MixtureFugacityTP : public ThermoPhase
throw NotImplementedError("MixtureFugacityTP::getdlnActCoeffdlnN_diag");
}


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

virtual double enthalpy_mole() const;
virtual double entropy_mole() const;

//@}
/// @name Partial Molar Properties of the Solution
//@{
Expand Down Expand Up @@ -272,37 +279,9 @@ class MixtureFugacityTP : public ThermoPhase
*/
virtual void setPressure(doublereal p);

protected:
/**
* Calculate the density of the mixture using the partial molar volumes and
* mole fractions as input
*
* The formula for this is
*
* \f[
* \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
* \f]
*
* where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are the molecular
* weights, and \f$V_k\f$ are the pure species molar volumes.
*
* Note, the basis behind this formula is that in an ideal solution the
* partial molar volumes are equal to the pure species molar volumes. We
* have additionally specified in this class that the pure species molar
* volumes are independent of temperature and pressure.
*/
virtual void calcDensity();

public:
virtual void setState_TP(doublereal T, doublereal pres);
virtual void setState_TR(doublereal T, doublereal rho);
virtual void setState_TPX(doublereal t, doublereal p, const doublereal* x);

protected:
virtual void compositionChanged();
void setMoleFractions_NoState(const doublereal* const x);

protected:
//! Updates the reference state thermodynamic functions at the current T of
//! the solution.
/*!
Expand All @@ -318,6 +297,9 @@ class MixtureFugacityTP : public ThermoPhase
* - m_s0_R;
*/
virtual void _updateReferenceStateThermo() const;

//! Temporary storage - length = m_kk.
mutable vector_fp m_tmpV;
public:

/// @name Thermodynamic Values for the Species Reference States
Expand Down Expand Up @@ -430,8 +412,6 @@ class MixtureFugacityTP : public ThermoPhase
* setState_TP() routines. Infinite loops would result if it were not
* protected.
*
* -> why is this not const?
*
* @param TKelvin Temperature in Kelvin
* @param pressure Pressure in Pascals (Newton/m**2)
* @param phaseRequested int representing the phase whose density we are
Expand Down Expand Up @@ -509,6 +489,7 @@ class MixtureFugacityTP : public ThermoPhase
* @return The saturation pressure at the given temperature
*/
virtual doublereal satPressure(doublereal TKelvin);
virtual void getActivityConcentrations(double* c) const;

protected:
//! Calculate the pressure given the temperature and the molar volume
Expand All @@ -534,9 +515,46 @@ class MixtureFugacityTP : public ThermoPhase
virtual void updateMixingExpressions();

//@}
/// @name Critical State Properties.
//@{

protected:
virtual void invalidateCache();
virtual double critTemperature() const;
virtual double critPressure() const;
virtual double critVolume() const;
virtual double critCompressibility() const;
virtual double critDensity() const;
virtual void calcCriticalConditions(double& pc, double& tc, double& vc) const;

//! Solve the cubic equation of state
/*!
*
* Returns the number of solutions found. For the gas phase solution, it returns
* a positive number (1 or 2). If it only finds the liquid branch solution,
* it will return -1 or -2 instead of 1 or 2.
* If it returns 0, then there is an error.
* The cubic equation is solved using Nickall's method
* (Ref: The Mathematical Gazette(1993), 77(November), 354--359,
* https://www.jstor.org/stable/3619777)
*
* @param T temperature (kelvin)
* @param pres pressure (Pa)
* @param a "a" parameter in the non-ideal EoS [Pa-m^6/kmol^2]
* @param b "b" parameter in the non-ideal EoS [m^3/kmol]
* @param aAlpha a*alpha (temperature dependent function for P-R EoS, 1 for R-K EoS)
* @param Vroot Roots of the cubic equation for molar volume (m3/kmol)
* @param an constant used in cubic equation
* @param bn constant used in cubic equation
* @param cn constant used in cubic equation
* @param dn constant used in cubic equation
* @param tc Critical temperature (kelvin)
* @param vc Critical volume
* @returns the number of solutions found
*/
int solveCubic(double T, double pres, double a, double b,
double aAlpha, double Vroot[3], double an,
double bn, double cn, double dn, double tc, double vc) const;

//@}

//! Storage for the current values of the mole fractions of the species
/*!
Expand All @@ -556,10 +574,6 @@ class MixtureFugacityTP : public ThermoPhase
//! Force the system to be on a particular side of the spinodal curve
int forcedState_;

//! The last temperature at which the reference state thermodynamic
//! properties were calculated at.
mutable doublereal m_Tlast_ref;

//! Temporary storage for dimensionless reference state enthalpies
mutable vector_fp m_h0_RT;

Expand Down
Loading