[Python] Quantity.equilibrate updates the Quantity's state
This commit is contained in:
parent
d559af9d38
commit
032537710f
2 changed files with 17 additions and 0 deletions
|
|
@ -123,6 +123,13 @@ class Quantity(object):
|
|||
"""
|
||||
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
|
||||
|
|
|
|||
|
|
@ -979,3 +979,13 @@ class TestQuantity(utilities.CanteraTest):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue