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.
MIT License
193 stars 49 forks source link

default models? #111

Open jtravs opened 2 years ago

jtravs commented 2 years ago

Hi, we currently use CoolProp to get molar densities for noble gases and some molecules (not mixtures). E.g. helium, argon, hydrogen, nitrogen etc. We need a reasonable span of pressure and temperature, but nothing more complicated. We are considering using Clapeyron instead of CoolProp, but it is very hard for an ignorant user like me to understand which model to use for each fluid. CoolProp (and REFPROP previously) just had a default model (or perhaps only one, I never checked). Do you have a table of which model is best for each basic fluid?

pw0908 commented 2 years ago

Hi John,

There are no default models in Clapeyron perse. We provide generalised equations of state which, in theory, can be used for any fluid. That being said, depending on the conditions, I'd imagine something like Peng-Robinson would be sufficient?

If you're dealing with cryogenics, then perhaps you would need something more-advanced such as QCPR or SAFT-VRQ Mie (which are more-computational expensive). I believe most of the species you've listed are available in those equations.

To use Clapeyron to obtain the molar densities, all you would need to do is:

julia> using Clapeyron

julia> model = PR(["helium"])
PR{BasicIdeal, PRAlpha, NoTranslation, vdW1fRule} with 1 component:
 "helium"
Contains parameters: a, b, Tc, Pc, Mw

julia> molar_density(model,1e5,298.15,[1.])
40.33399603269461

The above can be done for any of the equations of state I've mentioned.

Just in case I've given you the wrong advice, what are the conditions you are looking at and for what application?

ianhbell commented 1 year ago

As someone who has developed CoolProp and REFPROP, you definitely want to be using the multiparameter EOS, at the very least to check these other EOS against them. The multiparameter EOS are the gold standard, even if other models might yield reasonable values for some properties, sometimes. Clapeyron implements the multiparameter EOS for a few species (water, propane, etc.). Clapeyron could be extended to add these EOS, as I did in teqp (https://github.com/usnistgov/teqp), which is spiritually very similar to Clapeyron.

StefanPofahl commented 1 year ago

Currently I am struggling with the mass density of liquid hydrogen. I spent some time to find by trial and error a method that seems to work, I have the impression, that Clapeyron.QCPR(["hydrogen"]) works, but I would like to know, if there is something better suited inside Clapeyron. Clapeyron.QCPR(["hydrogen"]) results in a discrepancy to CoolProp. It could be that Claperion is closer to reality or not. Unfortunately, Clapeyron.SAFTVRQMie(["hydrogen"] fails:

ERROR: MethodError: no method matching eps(::Int64)
Closest candidates are:
  eps() at float.jl:764
  eps(::FixedPointNumbers.FixedPoint) at C:\Users\stefanpofahl\.julia\packages\FixedPointNumbers\HAGk2\src\FixedPointNumbers.jl:222
  eps(::T) where T<:Dates.TimeType at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Dates\src\types.jl:417

liquid_hydrogen

longemen3000 commented 1 year ago

For hydrogen, QCPR should be better empirically than VRQ-Mie. after all, the QCPR paper takes the corrected quantum potentials present in VRQ Mie and adapt those to match the critical point (Tc(hydrogen) = 33.19 K). from the QCPR Paper:

Recently, the statistical associating fluid theory of quantum-corrected Mie potentials (SAFT-VRQ Mie) [17,18] was presented. This EoS models quantum effects by adding the so-called Feynman–Hibbs-corrections to a Mie potential, where the Mie potential represents the classical behavior of the fluid [19]. Excellent agreement with experiments was obtained for the VLE of helium–neon, except in the critical region due to the incomplete development of thermodynamic perturbation theory for mixtures [20].

CoolProp uses this: https://doi.org/10.1063/1.3160306, so probably is more accurate. We have an older model of Hydrogen, the one used in the GERG2008 (and EOS_LNG) EoS. extending your plot:

Unfortunately, Clapeyron.SAFTVRQMie(["hydrogen"] fails:

That is #131. it is fixed on master (and to be released probably today). Extending the plot results in this. image

There is also the speed on which the density is calculated. a QCPR model, because is a cubic, has a very fast density calculation in comparison with every other model:

using BenchmarkTools
julia> @btime mass_density(qcpr_model,100000,20,phase = :l)
  468.878 ns (1 allocation: 16 bytes)
71.3289942056723

julia> @btime mass_density(gerg2008_model,100000,20,phase = :l)
  5.667 μs (1 allocation: 16 bytes)
71.18260191376923

julia> @btime mass_density(vrq_model,100000,20,phase = :l)
  96.500 μs (21 allocations: 1.22 KiB)
70.65817603310407

(haven't measured teqp, in theory should be faster, but we had a performance bug that since the last measurement has been fixed)

StefanPofahl commented 1 year ago

Thank you so much for your great work!!! Now both packages calculate now similar/equal results. :-)