Skip to content

Commit

Permalink
[Python] Quantity.equilibrate updates the Quantity's state
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 24, 2015
1 parent d559af9 commit 0325377
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions interfaces/cython/cantera/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ def gibbs(self):
"""
return self.mass * self.phase.gibbs_mass

def equilibrate(self, *args, **kwargs):
"""
Set the state to equilibrium. See `ThermoPhase.equilibrate`.
"""
self.phase.equilibrate(*args, **kwargs)
self.state = self._phase.TDY

def __imul__(self, other):
self.mass *= other
return self
Expand Down
10 changes: 10 additions & 0 deletions interfaces/cython/cantera/test/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,3 +979,13 @@ def test_add(self):
self.assertNear(q1.U + q2.U, q3.U)
self.assertNear(q1.V + q2.V, q3.V)
self.assertArrayNear(q1.X*q1.moles + q2.X*q2.moles, q3.X*q3.moles)

def test_equilibrate(self):
self.gas.TPX = 300, 101325, 'CH4:1.0, O2:0.2, N2:1.0'
q1 = ct.Quantity(self.gas)
self.gas.equilibrate('HP')
T2 = self.gas.T

self.assertNear(q1.T, 300)
q1.equilibrate('HP')
self.assertNear(q1.T, T2)

0 comments on commit 0325377

Please sign in to comment.