Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible fix for some dew and bubble computations #328

Open
Sush1090 opened this issue Jan 7, 2025 · 2 comments
Open

Possible fix for some dew and bubble computations #328

Sush1090 opened this issue Jan 7, 2025 · 2 comments

Comments

@Sush1090
Copy link
Contributor

Sush1090 commented Jan 7, 2025

Hello,
As of now the following will fail:

using Clapeyron
fluids =["butane","toluene"]
global model = cPR(fluids,idealmodel = ReidIdeal)
p = 202650.0; z = [ 0.03660834309918798 ,0.5195534741939288]*100

dew_temperature(model,p,z)

This is because the interval provided to volume_from_spinodal cannot find roots.
The possible fix I have for now is not providing this interval (maybe this will mess some other cases):

function volume_from_spinodal(p,poly,vshift,v0)
    if length(v0) == 2
        v0 = v0[2]
    end
    f(v) = p - evalpoly(v,poly)
    prob = Roots.ZeroProblem(f,v0)
    return Roots.solve(prob) + vshift
end
julia> dew_temperature(model,p,z)
(406.4174457072442, 0.00012067728202751558, 0.015760540593102064, [0.0053723341003248356, 0.9946276658996752])

The root finder seems to work without providing the lower bound of 0.

@longemen3000
Copy link
Member

longemen3000 commented Jan 8, 2025

A smaller reproducer:

model = cPR("butane")
Clapeyron.x0_sat_pure(model,406.5487245045052)

the problem on the generation of the bracket itself, in this particular case, the bracket does not contain the objective spinodal mean pressure ((p_spinodal_l + p_spinodal_v)/2)

@longemen3000
Copy link
Member

08539a5 fixes the issue, but as always, this issue will be closed at the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants