Skip to content

Commit

Permalink
fix issue with non-numba activity coefficients
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelcortes committed Feb 27, 2024
1 parent 8231ba7 commit 9d83feb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions thermosteam/equilibrium/dew_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,25 @@

# %% Solvers

@njit(cache=True)
def x_iter(x, x_gamma, T, P, f_gamma, gamma_args):
# Add back trace amounts for activity coefficients at infinite dilution
mask = x < 1e-32
x[mask] = 1e-32
x = fn.normalize(x)
gamma = f_gamma(x, T, *gamma_args)
denominator = gamma
try:
x = x_gamma / denominator
except:
return x
if (x < 0).any():
return x
try: x = x_gamma / denominator
except: return x
if (x < 0).any(): return x
mask = x > 1e3
if mask.any():
x[mask] = 1e3 + np.log(x[mask] / 1e3) # Avoid crazy numbers
if mask.any(): x[mask] = 1e3 + np.log(x[mask] / 1e3) # Avoid crazy numbers
return x

# @njit(cache=True)
def solve_x(x_guess, x_gamma, T, P, f_gamma, gamma_args):
args = (x_gamma, T, P, f_gamma, gamma_args)
x = flx.wegstein(x_iter, x_guess, 1e-10, args=args, checkiter=False,
checkconvergence=False, convergenceiter=3)
checkconvergence=False, convergenceiter=3)
return x

# %% Dew point values container
Expand Down

0 comments on commit 9d83feb

Please sign in to comment.