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 #641

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
83080a1
Implementation of Peng-Robinson equation of state.
May 16, 2019
f9145df
Updating PengRobinsonMFTP_Test to clarify test composition.
decaluwe Dec 20, 2019
151a486
Removing MFTP suffix from PengRobinson class
decaluwe Dec 20, 2019
3fbb73f
Renaming TKelvin and cleaning up unused variables in PengRobinson.cpp
decaluwe Dec 20, 2019
b0d1333
Abstracting thermo calcs from PengRobinson and RedlichKwong up to Mix…
decaluwe Dec 21, 2019
1bee6cf
Abstracting cubic solver to MixtureFugacityTP thermo class.
decaluwe Dec 30, 2019
0ffbe6b
Add capability to load Peng Robinson via YAML.
decaluwe Jan 10, 2020
fa3c776
Removing xml and cti capabilities from thermo::PengRobinson.
decaluwe Jan 10, 2020
bc06b6d
Fix species coefficient updates in PengRobinson.
decaluwe Jan 16, 2020
bf5102a
Deleting test/data/co2_PR_example.cti
decaluwe Jan 16, 2020
4680886
Fixing location of critProperties.xml referenced in thermo/PengRobins…
decaluwe Jan 16, 2020
9f59243
Deleting commented code in thermo/PengRobinson.cpp
decaluwe Jan 16, 2020
c40bd53
Adding ThermoFromYAML:PengRobinson_CO2 test
decaluwe Jan 16, 2020
8ee1372
Remove unnecessary overrides in MixtureFugacityTP and children
speth Jan 16, 2020
09d520a
Creating python test for PengRobinson thermo class.
decaluwe Jan 17, 2020
759e738
Fixing indent error in PengRobinson::updateMixingExpressions
decaluwe Jan 17, 2020
ffee0f7
Testing critical property lookup for PengRobinson.
decaluwe Jan 17, 2020
defe2df
Adding cubic solver test
decaluwe Jan 21, 2020
835198e
Add functions for factory alias management
speth Nov 12, 2019
8edf261
Implementation of Peng-Robinson equation of state.
May 16, 2019
fc650ad
Removing MFTP suffix from PengRobinson class
decaluwe Dec 20, 2019
6ecfec3
Changing 'bad' to 'poorly' in MixtureFugacity TP error message
decaluwe Jan 22, 2020
d2ec337
Fixing typo in previous commit.
decaluwe Jan 27, 2020
8828ef9
Fixing up merge conflicts in PengRobinson_Test.cpp
decaluwe Jan 27, 2020
ef8b92c
Cleaning up typos and merge conflicts.
decaluwe Jan 27, 2020
b8ff389
Fixing Peng-Robinson aliasing in ThermoFactory.
decaluwe Jan 27, 2020
dfdaa82
Fixing merge conflicts in PengRobinson_Test
decaluwe Jan 27, 2020
32af524
Adding following tests to PengRobinson_Test.cpp to verify that
Jan 27, 2020
1eca522
Fixing indexing error in PengRobinson:d2aAlpha_dT2
decaluwe Jan 31, 2020
26149ca
Cleaning up thermo/PengRobinson
decaluwe Feb 4, 2020
7402961
Rename Nichols cubic solve methods as `cubicSolve`
decaluwe Feb 4, 2020
bb97af2
Adding detailed comments for cubic solver
gkogekar Feb 5, 2020
5032994
Modifying pengRobinson test from thermoFromYAML
gkogekar Apr 8, 2020
423154f
Moved setToEquil function to the parent class, 'MixtureFugacityTP".
gkogekar Apr 8, 2020
e6f6b9d
Removing dependancy of EoS specific omega_a, omega_b parameters from …
gkogekar Apr 8, 2020
04f0a80
Cleaning up the redundant code, correcting indentations and tabs
gkogekar Apr 8, 2020
92b66d5
Removed redundant calculations using a 2D array aAlpha_coeff_vec
gkogekar Apr 8, 2020
29c6844
Redefined species specific internal functions as protected instead of…
gkogekar Apr 8, 2020
83bc2be
Removing getChemPotentials_RT function from PengRobinsonMFTP since it is
gkogekar Apr 8, 2020
768053c
Removing a_coeff_vec to avoid duplication and using m_a_vec_Curr inst…
gkogekar Apr 9, 2020
7e69a65
Fixing indentation and white spaces
Jun 6, 2020
fded715
Modifying comments and correcting typos
Jun 15, 2020
df22aa7
Replacing line endings with LF instead of CRLF
Jun 16, 2020
891ce6c
Modified Peng-Robinson to test file to read phase from
Jun 16, 2020
f8d7ee0
clearing the merge-conflict
Jun 16, 2020
4fe68b6
Modifying the explaination for solveCubic function to be more clear and
Jun 23, 2020
fcab6f2
Adding a python test in interface/cython test suite
Jun 23, 2020
ffaaa77
Fixing error in test_thermo.py
Jun 24, 2020
5d67a47
Indentation changes in the PengRobinson.cpp
Jun 27, 2020
59e13a8
Update include/cantera/thermo/PengRobinson.h
Jun 27, 2020
8562bb7
Removing unused parameter m_formTempParam
gkogekar Oct 5, 2020
fdfcc31
Removed the changes for P-R EoS model in ctml_writer.py, since the
gkogekar Oct 5, 2020
bfaae6d
Replacing doublereal with double in entropy_mole function declaration
gkogekar Oct 5, 2020
71f124e
Removing documentation for getChemPotential function
gkogekar Oct 5, 2020
2e46979
Correcting the documentation for 'setSpeciesCoeff' and 'setBinaryCoeff'
gkogekar Oct 5, 2020
61d1fe4
Removing duplication of a temp array declaration from the child classes
gkogekar Oct 5, 2020
0e81424
Replacing tab character with spaces
gkogekar Oct 5, 2020
b57740a
Correcting the documentation for 'setBinaryCoeff' function
gkogekar Oct 5, 2020
f2cd14d
Correcting documentation in PengRobinson.h file
gkogekar Oct 5, 2020
7d1ad7e
Added dimensions of certain vectors in the documentation
gkogekar Oct 5, 2020
137deb6
Changed the function name 'pressureDerivatives' to
gkogekar Oct 5, 2020
157291d
Moved 'calculateAlpha' inside the 'setSpeciesCoeff' function
gkogekar Oct 5, 2020
46f3115
Changing InitThermo() to remove unused parameter a1
gkogekar Oct 5, 2020
21bd4e0
Removing 'PengRobinsonMFTP' alias
gkogekar Oct 5, 2020
131fa19
Cleaning up unnessesary comments.
gkogekar Oct 5, 2020
5e83651
Removing 'setToEquil' function from mixtureFugacityTP class
gkogekar Oct 27, 2020
91cc8df
Changing operating conditions in the pengRobinson test case
gkogekar Oct 27, 2020
0687e6d
Removing redundant test from PengRobinson class tests
gkogekar Oct 27, 2020
5b2e0f8
Correcting the commented documentation
gkogekar Oct 27, 2020
76bb6bf
Implementation of partial internal energies
gkogekar Oct 28, 2020
5d3e6df
Cleaning up functions to calculate critical properties in Redlich-Kwong
gkogekar Oct 28, 2020
a180bab
Defined m_a_vec_curr as the array2D type to simplify index calculations
gkogekar Oct 29, 2020
1e142e4
Adding missing P-R coefficients for CO2 in co2_PR_example.yaml file
gkogekar Oct 29, 2020
d620b1a
Redefined variable type for coefficient `a' in P-R EoS as scalar from…
gkogekar Oct 29, 2020
6823f68
Reading w_ac (acentric factor) with a more useful message that will
gkogekar Oct 29, 2020
6a7f2b2
Correcting CRLF Line endings.
decaluwe Oct 12, 2020
666f285
Rebasing with Cantera/main
gkogekar Nov 1, 2020
404a5f7
Removing redundant _updateStateThermo() call from thermodynamic
gkogekar Nov 23, 2020
4ea8da6
Combining file-base and default constructors for PengRobinson class
gkogekar Mar 19, 2021
9508428
Fixing error for Peng-Robinson alias in ThermoFactory.cpp
gkogekar Mar 19, 2021
5e3fb4c
Cleaning up 'thermoFromYaml.cpp'
gkogekar Mar 19, 2021
7fee130
Updating PengRobinson test from thermoFromYaml.cpp
gkogekar Mar 20, 2021
52e2212
Update include/cantera/thermo/PengRobinson.h
Mar 21, 2021
67f22f6
Update include/cantera/thermo/PengRobinson.h
Mar 21, 2021
4e07743
Moving declaration of the protected variable m_pp from MixtureFugacity
gkogekar Mar 21, 2021
6b14db5
Cleaning up whitespaces, typos and redundant variables
gkogekar Mar 21, 2021
c766a9d
Wrapping up some error messages to keep the line length below 80
gkogekar Mar 21, 2021
fb7386f
Cleaning up whitespaces and some comments
gkogekar Mar 21, 2021
ec17b30
Cleaning up some more indentations errors, typos and comments
gkogekar Mar 21, 2021
1f5dbe7
Update src/thermo/PengRobinson.cpp
Mar 21, 2021
1539bd1
Removing mistakenly added functions from RedlichKwongMFTP class.
gkogekar Mar 21, 2021
8f0adc6
Adding documentation for certain functions
gkogekar Mar 23, 2021
d17641c
Declaring omega_a, omega_b values as private
gkogekar Mar 23, 2021
a0dd0c0
Renaming 'cubicSolve' to 'solveCubic'
gkogekar Mar 23, 2021
2478999
Merging 'calculateAlpha' function in 'setSpeciesCoeffs'.
gkogekar Mar 23, 2021
95f9a65
Removing python test for PengRobinson class
gkogekar Mar 23, 2021
dee71c1
Added documentation for the 'solvecubic' function
gkogekar Mar 23, 2021
aef53e5
Renaming _curr vector variables
gkogekar Mar 26, 2021
f934e50
Removing the unused function 'pressureCalc()'
gkogekar Mar 26, 2021
e835d17
Fixing error in 'getPartialMolarIntEnergies' function
gkogekar Mar 26, 2021
2ea6496
Fixing indentations and removing redundant statements
gkogekar Mar 26, 2021
ffafe40
Modifying comment
Mar 25, 2021
228d802
Fixing indentation
Mar 25, 2021
9789555
Renaming w_ac to acentric_factor
gkogekar Apr 14, 2021
c5d4061
Modifying 'getPressure' test to cover a wider range of temperatures
gkogekar Apr 14, 2021
88a10c0
Adding a test to validate P-R EoS with CoopProp
gkogekar Apr 15, 2021
d0f66ce
Modifying the cubic solver test
gkogekar Apr 15, 2021
f892c20
Adding a function to calculate partial molar specific heats
gkogekar Apr 15, 2021
a9e8c4d
Fixing indentation
gkogekar Apr 16, 2021
5a7a938
Fixing an error in 'setBinaryCoeffs()'
gkogekar Apr 16, 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
2 changes: 1 addition & 1 deletion data/inputs/critProperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<Pc value="7.39e+06"/>
<Vc value="0.0948"/>
<Zc value="0.275"/>
<omega value="0.239"/>
<omega value="0.228"/>
</species>
<species name="COS">
<ChemName name="carbonyl-sulfide"/>
Expand Down
86 changes: 51 additions & 35 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;
gkogekar marked this conversation as resolved.
Show resolved Hide resolved
public:

/// @name Thermodynamic Values for the Species Reference States
Expand Down Expand Up @@ -430,7 +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)
Expand Down Expand Up @@ -509,6 +490,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 +516,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 +575,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 All @@ -571,6 +586,7 @@ class MixtureFugacityTP : public ThermoPhase

//! Temporary storage for dimensionless reference state entropies
mutable vector_fp m_s0_R;

};
}

Expand Down
Loading