Skip to content

Commit

Permalink
fix tests and minor issue in energy balance fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
cortespea committed Nov 13, 2023
1 parent 785cc65 commit a57ab38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_vlle():
xl = s.imol['l'].sum() / total
xL = s.imol['L'].sum() / total
xg = s.imol['g'].sum() / total
assert_allclose(xl + xL, 0.7361640850059188, atol=0.05) # Convergence
assert_allclose(xg, 0.26383591499408116, atol=0.05)
assert_allclose(xl + xL, 0.6773951226773982, atol=0.05) # Convergence
assert_allclose(xg, 0.32260487732260174, atol=0.05)
# Make sure past equilibrium conditions do not affect result of vlle
s = tmo.Stream(None, Water=1, Ethanol=1, Octane=2, T=350)
s.vle(T=350, P=101325)
Expand All @@ -47,8 +47,8 @@ def test_vlle():
xl = s.imol['l'].sum() / total
xL = s.imol['L'].sum() / total
xg = s.imol['g'].sum() / total
assert_allclose(xl + xL, 0.7361640850059188, atol=0.05) # Convergence
assert_allclose(xg, 0.26383591499408116, atol=0.05)
assert_allclose(xl + xL, 0.6773951226773982, atol=0.05) # Convergence
assert_allclose(xg, 0.32260487732260174, atol=0.05)

s = tmo.Stream(None, Water=1, Ethanol=1, Octane=2, vlle=True, T=300)
assert set(s.phases) == set(['l', 'L']) # No gas phase
Expand Down
6 changes: 3 additions & 3 deletions thermosteam/equilibrium/bubble_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def solve_Ty(self, z, P):
>>> chemicals = tmo.Chemicals(['Water', 'Ethanol'], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> BP = tmo.equilibrium.BubblePoint(chemicals)
>>> BP.solve_Ty(z=np.array([0.6, 0.4]), P=101325)
(353.8284421715317, array([0.383, 0.617]))
>>> tmo.docround(BP.solve_Ty(z=np.array([0.6, 0.4]), P=101325))
(353.8284, array([0.383, 0.617]))
"""
positives = z > 0.
Expand Down Expand Up @@ -245,7 +245,7 @@ def solve_Py(self, z, T):
>>> tmo.settings.set_thermo(chemicals)
>>> BP = tmo.equilibrium.BubblePoint(chemicals)
>>> tmo.docround(BP.solve_Py(z=np.array([0.703, 0.297]), T=352.28))
(91592.7839, array([0.42, 0.58]))
(91592.781, array([0.42, 0.58]))
"""
positives = z > 0.
Expand Down
2 changes: 1 addition & 1 deletion thermosteam/equilibrium/vle.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class VLE(Equilibrium, phases='lg'):
H_hat_tol = 1e-6
S_hat_tol = 1e-6
V_tol = 1e-6
x_tol = 1e-9
x_tol = 1e-8
y_tol = 1e-8
default_method = 'fixed-point'

Expand Down
8 changes: 4 additions & 4 deletions thermosteam/mixture/mixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def solve_T_at_HP(self, phase, mol, H, T_guess, P):
lambda T: self.H(phase, mol, T, P) - H,
x0=T_guess, x1=T, xtol=self.T_tol, ytol=0.
)
if abs(T - T_guess) < self.T_tol else T
if abs(T - T_guess) > self.T_tol else T
)

def xsolve_T_at_HP(self, phase_mol, H, T_guess, P):
Expand All @@ -357,7 +357,7 @@ def xsolve_T_at_HP(self, phase_mol, H, T_guess, P):
lambda T: self.xH(phase_mol, T, P) - H,
x0=T_guess, x1=T, xtol=self.T_tol, ytol=0.
)
if abs(T - T_guess) < self.T_tol else T
if abs(T - T_guess) > self.T_tol else T
)

def solve_T_at_SP(self, phase, mol, S, T_guess, P):
Expand All @@ -370,7 +370,7 @@ def solve_T_at_SP(self, phase, mol, S, T_guess, P):
lambda T: self.S(phase, mol, T, P) - S,
x0=T_guess, x1=T, xtol=self.T_tol, ytol=0.
)
if abs(T - T_guess) < self.T_tol else T
if abs(T - T_guess) > self.T_tol else T
)

def xsolve_T_at_SP(self, phase_mol, S, T_guess, P):
Expand All @@ -384,7 +384,7 @@ def xsolve_T_at_SP(self, phase_mol, S, T_guess, P):
lambda T: self.xS(phase_mol, T, P) - S,
x0=T_guess, x1=T, xtol=self.T_tol, ytol=0.
)
if abs(T - T_guess) < self.T_tol else T
if abs(T - T_guess) > self.T_tol else T
)

def xCn(self, phase_mol, T, P=None):
Expand Down

0 comments on commit a57ab38

Please sign in to comment.