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

Closed
Sush1090 opened this issue Jan 7, 2025 · 7 comments
Closed

Possible fix for some dew and bubble computations #328

Sush1090 opened this issue Jan 7, 2025 · 7 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

@jamiecripwell
Copy link

Hi there

My student picked up this is still an issue in the SAFT_eos.ipynb example file when using the default methanol (i.e. the fix wasn't global, so might pop up elsewhere as well) - just for your reference.

Thanks!

@longemen3000
Copy link
Member

Hello,

This issue is still open because we haven't released a new version of Clapeyron with the commit that fixes this issue. I checked with all models in SAFT.ipynb and did not encounter any errors in the master branch of the repository.

There was an (unrelated) error in the CKSAFT EoS when calculating critical point, that error is also fixed in the latest master.

I'm planning to release a new version this week, but if fixing the issue can't wait, you can use the master branch of this repository in the following way:

using Pkg
Pkg.add("Clapeyron",rev = "master")
Pkg.add(url = "https://github.com/ClapeyronThermo/Clapeyron.jl, rev = "master")

or from the Pkg prompt (one of those two should work):

(@v1.11) pkg> add Clapeyron#master
(@v1.11) pkg> add https://github.com/ClapeyronThermo/Clapeyron.jl#master

@Sush1090
Copy link
Contributor Author

Hello,
This is not a bug post.
I think it probably worth adding a warning or assertion for bubble temperature if by chance the user provides pressure above critical pressure.
It leads to abnormal answers or NaN.

using Clapeyron
fluids =["butane","toluene"]
global model = cPR(fluids,idealmodel = ReidIdeal)
_,p_,_ = crit_mix(model,[1.5,1.5])

bubble_temperature(model,p_*1.1,[1.5,1.5])
(1960.5811538774678, 0.004855433165462302, 0.005506594621675661, [0.601711213873475, 0.39828878612652496])

The same does not apply for dew temperature (atleast not always)

using Clapeyron
fluids =["butane","toluene"]
global model = cPR(fluids,idealmodel = ReidIdeal)
_,p_,_ = crit_mix(model,[1.5,1.5])
dew_temperature(model,p_*1.5,[1.5,1.5])
(553.9695067276397, 0.00016685848692124782, 0.00022722814575264715, [0.22610825063197718, 0.7738917493680229])

@longemen3000
Copy link
Member

In those two particular cases, a relaxed check allowed to return those results, fixed in caa4006 .

@longemen3000
Copy link
Member

The original issue and subsequent ones are fixed in Clapeyron 0.6.8.

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

3 participants