Skip to content

Commit

Permalink
improved python test and formatting changes to doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
wandadars authored and speth committed Mar 11, 2024
1 parent bc50dd7 commit 64df109
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions include/cantera/thermo/PengRobinson.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ class PengRobinson : public MixtureFugacityTP
/*!
* @return
* Returns an AnyMap containing the following key names and values:
* - "aAlpha_mix": The value of m_aAlpha_mix
* - "b_mix": The value of the m_b
* - "daAlpha_dT": The value returned by the daAlpha_dT() method
* - "d2aAlpha_dT2": The value returned by the d2aAlpha_dT2() method
* - `aAlpha_mix`: The value of #m_aAlpha_mix
* - `b_mix`: The value of the #m_b
* - `daAlpha_dT`: The value returned by the daAlpha_dT() method
* - `d2aAlpha_dT2`: The value returned by the d2aAlpha_dT2() method
*/
AnyMap getAuxiliaryData() override;

Expand Down
21 changes: 17 additions & 4 deletions test/python/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,16 +969,29 @@ def test_add_species_duplicate(self):
with self.assertRaisesRegex(ct.CanteraError, 'already contains'):
self.phase.add_species(species)


def test_auxiliary_data(self):
"""
Should get back a dictionary with 4 keys present when calling the auxiliary_data
property for the Peng-Robinson thermo phase.
This test checks that the values of `aAlpha_mix` and `b_mix` should, when
used in the Peng-Robinson equation of state expression, yield the same
pressure as the pressure that was set for the thermodynamic state.
"""
gas = ct.Solution('co2_PR_example.yaml', 'CO2-PR')
gas.TPX = 300, 101325, 'H2:1.0'
params = gas.auxiliary_data
self.assertEqual(len(params), 4)

# Get the Peng-Robinson equation of state parameters
aAlpha_mix = params['aAlpha_mix']
b_mix = params['b_mix']

molar_volume = 1.0 / gas.density_mole
# Evaluate the pressure using the Peng-Robinson equation of state
# parameters
evaluated_pressure = (
ct.gas_constant * gas.T / (molar_volume - b_mix) -
aAlpha_mix / (molar_volume ** 2 + 2 * b_mix * molar_volume - b_mix ** 2)
)

assert abs(gas.P - evaluated_pressure) < 1e-6

class TestThermo(utilities.CanteraTest):
def setUp(self):
Expand Down

0 comments on commit 64df109

Please sign in to comment.