Skip to content

Commit

Permalink
use flash to solve LL
Browse files Browse the repository at this point in the history
  • Loading branch information
fedebenelli committed Jan 29, 2025
1 parent cf1444a commit 0697809
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 1 addition & 2 deletions python/yaeos/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,7 @@ def saturation_pressure(
}

def saturation_temperature(
self, z, pressure: float, kind: str = "bubble", t0: float = 0,
y0=None
self, z, pressure: float, kind: str = "bubble", t0: float = 0, y0=None
) -> dict:
"""Saturation temperature at specified pressure.
Expand Down
18 changes: 14 additions & 4 deletions python/yaeos/fitting/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ def solve_pt(model, p, t):
"""Solve a point at a given P and T."""
from scipy.optimize import root

x10, y10 = find_init_binary_ll(model, p, t)
try:
x10, y10 = find_init_binary_ll(model, p, t)
except ValueError:
x10, y10 = 0.1, 0.9

x0 = [x10, y10]
sol = root(binary_isofugacity_x1y1pt, x0, (p, t, model))
x1, y1 = sol.x
mean = (x10 + y10) / 2

z = [mean, 1 - mean]
y0 = np.array([y10, 1 - y10])
x0 = np.array([x10, 1 - x10])

flash = model.flash_pt(z, pressure=p, temperature=t, k0=y0 / x0)

x1 = flash["x"][0]
y1 = flash["y"][0]

return x1, y1

Expand Down

0 comments on commit 0697809

Please sign in to comment.