ClapeyronThermo / Clapeyron.jl

Clapeyron provides a framework for the development and use of fluid-thermodynamic models, including SAFT, cubic, activity, multi-parameter, and COSMO-SAC.
https://clapeyronthermo.github.io/Clapeyron.jl/
MIT License
210 stars 52 forks source link

Wrong conversion of parameters for water in CPA #256

Closed ianhbell closed 8 months ago

ianhbell commented 9 months ago

Previously, the default units for epsilon_assoc were J/mol. In https://github.com/ClapeyronThermo/Clapeyron.jl/commit/8f3bb4a29aa917f2fa6a914ad2a405b255864a01 the default was changed to K, but the coefficients for water were not properly converted. epsilon_assoc was previously 16655.0 J/mol, and dividing by R of 8.314462618 J/mol/K should yield 2003.136073273521 K, but the value is instead 1700.3053894468114 K. Also the bond volume was changed, but it should not have been.

The consequence is different volumes, and very different pressures. See the previous value in https://github.com/ClapeyronThermo/Clapeyron.jl/discussions/239#discussioncomment-7857946 which I believe is the correct answer for volume from the previous version.

longemen3000 commented 9 months ago

sCPA (or CPA with radial_dist = :KG) seems to invoke the correct parameters (in CPA/sCPA/sCPA_assoc.csv). the ones in CPA/CPA_assoc.jl are the ones that are used with the :CS rdf

ianhbell commented 9 months ago

The same script (that I linked in the initial post) gives different results in version 0.4.0 and 0.5.10, so the defaults must be getting crossed up. I see your point about CPA with CS versus CPA with KG, they have different parameter sets.

Related aside: the references for the sources of CPA and sCPA parameters are not provided.

ianhbell commented 9 months ago

And 0.5.9 and 0.4.13 give the same results, so the bisection shows that 0.5.10 is the breaking change.

longemen3000 commented 9 months ago

can you give me an MVE? i can check that and fix the discrepancy that way

ianhbell commented 9 months ago

With the script

using Clapeyron
using Unitful
using Pkg
println(Pkg.status("Clapeyron"))
water = Clapeyron.CPA(["Water"])
println(volume(water, 1e5u"Pa", 303.15u"K"))

I get:

⌃ [7c7805af] Clapeyron v0.5.9
Info Packages marked with ⌃ have new versions available and may be upgradable.
nothing
1.7915123921401366e-5 m³

and in the new version:

  [7c7805af] Clapeyron v0.5.10
nothing
1.8096728067736136e-5 m³
ianhbell commented 9 months ago

It looks like a small difference, but it turns into an enormous difference in pressure

longemen3000 commented 9 months ago

i checked, and the only difference was the water parameters. it is fixed in https://github.com/ClapeyronThermo/Clapeyron.jl/pull/254/commits/6a8bb93172d19c4ed2ba29e51d832d2052d70bd5

ianhbell commented 9 months ago

Thanks for looking into it. I think you fixed the energy, but the volume should also not change, and it was previously 0.0692 and is now 0.0608

ianhbell commented 8 months ago

Did you fix the volume parameters too? Otherwise this issue should not be closed

longemen3000 commented 8 months ago

Yes, the volume parameter was fixed too