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

bug in SAFT-VR SW? #165

Closed
TermeHansen opened this issue Apr 6, 2023 · 6 comments
Closed

bug in SAFT-VR SW? #165

TermeHansen opened this issue Apr 6, 2023 · 6 comments

Comments

@TermeHansen
Copy link

Just started to look around in this very nice module - great work!

As a first I have tried to reproduce the Cp of CO2 plot from the frontpage.
image

using:

compounds = ["carbon dioxide"]

model1 = SRK(compounds; idealmodel=ReidIdeal)
model2 = GERG2008(compounds)
model3 = SAFTVRSW(compounds; idealmodel=ReidIdeal);
model4 = PCSAFT(compounds; idealmodel=ReidIdeal);
model5 = SAFTVRMie(compounds; idealmodel=ReidIdeal);

I get:
image

Which seems fine except for the SAFT-VR SW. Any pointers to why I see that difference to your plot?

@longemen3000
Copy link
Member

longemen3000 commented Apr 6, 2023

hmm, no idea. SAFT-VR-SW is one of those "legacy" SAFT eos, that are superseeded by more modern approaches (like SAFT-VR-Mie). also, looking at the code, seems that there wasn't any (functional) changes since last year.
Maybe it was an error on labelling? the the original plot image seems really old (sep 2021, around v0.2.1)

@longemen3000
Copy link
Member

on a preliminary testing, SAFTVRSW seems consistent:

#tests that the gibbs energy and chemical potential have the same values. the first number is the difference
julia> Clapeyron.gibbs_duhem(model3,0.03,300.) 
(0.0, 11561.822765804463, 11561.822765804463)

#test that the ideal model returns an ideal pressure,the result is the difference of pressures
julia> Clapeyron.ideal_consistency(model3,0.03,300.)
0.0

so, if any bugs present, seems to be a subtle one

@pw0908
Copy link
Member

pw0908 commented Apr 6, 2023

It's been a while since I made that figure but, based on the figure we used in our paper, it seems like we removed SAFT-VR SW from it. I believe that may have been because the results had changed to something like TermeHansen is showing. Ill quickly benchmark SAFT-VR SW to the original paper and see if we can still replicate their results.

@pw0908
Copy link
Member

pw0908 commented Apr 6, 2023

I've now done the benchmark and can confirm that the current implementation of SAFT-VR SW replicates the original papers. There must have been something wrong at the time with the code.

@TermeHansen
Copy link
Author

Good to know, then I suggest to either remove or update the plot here on GitHub, to avoid that misunderstanding again :)

Maybe using a plot using plotly which is really nice in giving options to inspect data a bit closer with hovering and zooming.

Cp_CO2.html

Regards!

longemen3000 added a commit that referenced this issue Mar 25, 2024
@longemen3000
Copy link
Member

after a long time, i finally found the bug.

function gHS(model::SAFTVRSWModel,V, T, z, i, j)
σ = model.params.sigma.values
ζ3 = @f(ζn,3)
D = σ[i]*σ[j]/(σ[i]+σ[j])*(@f(x_S,k)*σ[k]^2 for k @comps)/(@f(x_S,k)*σ[k]^3 for k @comps)
return 1/(1-ζ3)+3*D*ζ3/(1-ζ3)^2+2*(D*ζ3)^2/(1-ζ3)^3
end

here, σ[i] should be σ[i,i]. It is fixed on the master branch.

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