Comments (12)
Hi Andrés,
This is quite interesting; we can definitely try and implement it into our code. How quickly does this tend to converge? Have you considering using other cubics such as RK and keeping the b parameter, but relating to the existing parameters in the eos (such as sigma in SAFT)? If you can implement this with slightly more accurate cubics, it might be interesting to see if this strategy could work in the liquid phase as well (which would be amazing!).
from clapeyron.jl.
@pw0908 @longemen3000 How much have you folks played with solvers on the liquid side? For complex organic mixtures I find myself having a tough time solving for the liquid root. This could be due to simple thermodynamics - the EOS simply doesn't find a liquid root, which is fine, but on a scale of 1 to 10, how confident are you in the solvers ability to find the liquid root? I doubt I will believe anything over a 7 haha :)
from clapeyron.jl.
We use that volume solver everywhere, and where it failed, it was always an EoS problem (an initial point that is not in the correct vdW loop). The solver normally thows NaN when it founds a mechanical instability (dpdv > 0).it could be that our initial point for SAFT gamma Mie in your particular case is to high.
The internal iteration algorithm can be called with volume_compress(model, P, T, z;V0=x0_volume_liquid(model, T, z)
. You can try different values of V0
to see if the initial point is bad or the algorithm is.
Looking at our initial point for SAFT gamma Mie, it could take some improvements, maybe the assoc solver fails at the starting liquid conditions (it happened before with VRMie, and gamma Mie inherits from VRMie)
from clapeyron.jl.
Adding to what Andrés said, we also know there is a problem when additional roots appear in the eos (such as GERG-2008 or SAFT at very low temperatures). We haven't found a way to deal with these yet but we know there are strategies for it in the literature.
For your case however, I'd be curious to see what examples you have where our solvers fail? Complex organic mixtures really could mean anything; it seems that the failure of our method relies more on the conditions than the system as well.
from clapeyron.jl.
Here is a completely gutted, minimum example of the script I am running. I go through alot more molecules, as well as mixtures, but we can look at the single case of azelaic acid, which has a melting point of 109 celcius. I am calculating thermodynamic properties I find interesting. I would prefer the subcooled zone, but in this example we should be in a stable liquid zone (I don't know how accurate the GammaMie is with liquids flirting with the solid equilibria line).
using Clapeyron
A_list = [("azelaic acid", ["COOH"=>2, "CH2"=>7])]
model = SAFTgammaMie(A_list)
pad = 25
T = 109 + 273.15 + pad
P = 1e5
Z = compressibility_factor(model, P, T, [1.0]; phase=:liquid)
println(Z)
A typical error looks like this:
ERROR: LoadError: DomainError with -0.5481253908259618:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(f::Symbol, x::Float64)
@ Base.Math .\math.jl:33
[2] log(x::Float64)
@ Base.Math .\special\log.jl:285
[3] log (repeats 2 times)
@ C:\Users\bkelly\.julia\packages\ForwardDiff\PBzup\src\dual.jl:208 [inlined]
[4] ÂHS(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#647#648"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\models\eos\SAFT\SAFTgammaMie\SAFTgammaMie.jl:72
[5] a_mono(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#647#648"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\models\eos\SAFT\SAFTgammaMie\SAFTgammaMie.jl:47
[6] a_res(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#647#648"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\models\eos\SAFT\SAFTgammaMie\SAFTgammaMie.jl:43
[7] eos(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#647#648"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}}, ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\models\eos.jl:25
[8] #647
@ C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\differentials.jl:25 [inlined]
[9] derivative
@ C:\Users\bkelly\.julia\packages\ForwardDiff\PBzup\src\derivative.jl:14 [inlined]
[10] ∂f∂V(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\differentials.jl:25
[11] pressure(model::SAFTgammaMie{BasicIdeal}, V::ForwardDiff.Dual{ForwardDiff.Tag{Clapeyron.var"#f#650"{SAFTgammaMie{BasicIdeal}, Float64, Vector{Float64}}, Float64}, Float64, 1}, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\VT.jl:2
[12] f
@ C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\differentials.jl:73 [inlined]
[13] static_dual_eval
@ C:\Users\bkelly\.julia\packages\ForwardDiff\PBzup\src\apiutils.jl:32 [inlined]
[14] vector_mode_gradient!
@ C:\Users\bkelly\.julia\packages\ForwardDiff\PBzup\src\gradient.jl:125 [inlined]
[15] gradient!
@ C:\Users\bkelly\.julia\packages\ForwardDiff\PBzup\src\gradient.jl:48 [inlined]
[16] p∂p∂V(model::SAFTgammaMie{BasicIdeal}, V::Float64, T::Float64, z::Vector{Float64})
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\differentials.jl:75
[17] (::Clapeyron.var"#f_fixpoint#664"{SAFTgammaMie{BasicIdeal}, Float64, Float64, Vector{Float64}})(_V::Float64)
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\property_solvers\volume.jl:21
[18] _fixpoint(f::Clapeyron.var"#f_fixpoint#664"{SAFTgammaMie{BasicIdeal}, Float64, Float64, Vector{Float64}}, x0::Float64, method::Clapeyron.Solvers.SimpleFixPoint{Float64}, atol::Float64, rtol::Float64, max_iters::Int64, norm::Function, antinan::Bool)
@ Clapeyron.Solvers C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\solvers\fixpoint\fixpoint.jl:48
[19] #fixpoint#22
@ C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\solvers\fixpoint\fixpoint.jl:33 [inlined]
[20] volume_compress(model::SAFTgammaMie{BasicIdeal}, p::Float64, T::Float64, z::Vector{Float64}; V0::Float64, max_iters::Int64)
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\property_solvers\volume.jl:29
[21] volume(model::SAFTgammaMie{BasicIdeal}, p::Float64, T::Float64, z::Vector{Float64}; phase::Symbol, threaded::Bool)
@ Clapeyron C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\property_solvers\volume.jl:95
[22] #chemical_potential#694
@ C:\Users\bkelly\.julia\packages\Clapeyron\li4cA\src\methods\pT.jl:7 [inlined]
[23] get_dG(coformer_list::Vector{Tuple{String, Vector{Pair{String, Int64}}}}, T::Float64, P::Float64)
@ Main C:\Users\bkelly\Julia\test.jl:66
[24] top-level scope
@ C:\Users\bkelly\Julia\test.jl:76
in expression starting at C:\Users\bkelly\Julia\test.jl:76
It could be that I am simply asking the EOS to calculate a liquid property where it feels quite certain, there is no liquid. I don't want to infer this is the algorithms fault, I am just ...curious. If I don't force it to calculate liquid properties, it does not find the any root for me. But if I bump up pad=125
, then is finds a root a Z~0.8
. But, specifying either vapor or liquid, leads to the above error.
from clapeyron.jl.
What version of Clapeyron are you using? Both Andrés and I were able to run this code and get about Z=0.0055?
from clapeyron.jl.
cannot reproduce the error:
julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, haswell)
julia> using Pkg; Pkg.status("Clapeyron")
Status `C:\Users\andres\.julia\environments\v1.7\Project.toml`
[7c7805af] Clapeyron v0.3.4 `C:\Users\andres\.julia\dev\Clapeyron`
julia> Z = compressibility_factor(model, P, T, [1.0]; phase=:liquid)
0.0055271245008312875
from clapeyron.jl.
I am running Julia Version 1.6.1 (2021-04-23)
using Clapeyron version 0.2.1.
Shiza. Okay, I have 1.7.2 on a desktop and am adding Clapeyron to it. It will take awhile, VPN's are silly things, but so are hackers :S
At least I have some light to look forward too
from clapeyron.jl.
Oh boy, you have a lot to look forward to... we've made some significant speed ups to SAFT-gamma Mie specifically
from clapeyron.jl.
significant is an understatement on how fast SAFTgammaMie got:
julia> @btime Z = compressibility_factor(model, P, T; phase=:liquid)
78.300 μs (69 allocations: 13.45 KiB)
the only breaking change between 0.2.x and 0.3.x is that sat_pure
was renamed saturation_pressure
from clapeyron.jl.
I have puttered with Gamma Mie on my own laptop at home a bit, awhile ago, and definitely remembered it being a lot faster than what I was experiencing here haha.
I will have to respond to this tomorrow. The VPN is asking me to calm down and not bother it with importing from the outside world. I am proceeding with negotiations. VPN's are incredibly hard to bribe.
@longemen3000 when I was running it (successfully) it was taking several minutes. significant is indeed an understatement. I imagine there must have been a lot of evil allocations. MB worth, maybe even GB.
Also, the first example I gave in the script, did run for me once at pad=25
when I didn't specify phase. I am sure of it now.
from clapeyron.jl.
It purrs along really nicely now that it is running Clapeyron v0.3.4. There is still a steep precompile time, but its quick after that. Everything is different now. The properties I was calculating before, have all changed in values. They make alot more sense now.
from clapeyron.jl.
Related Issues (20)
- Feature Request for PCSAFT Temperature-dependent kij for Unlike Interactions HOT 4
- PPC-SAFT Database Butene Isomer Parameters HOT 6
- Including Cp parameter along side Tm and ΔHfus for sle_solubility HOT 5
- Data extraction from csv file HOT 7
- Parameter Estimation for sle_solubility HOT 14
- UNIFAC ether and aldehyde groups error HOT 3
- Defining a custom alpha HOT 2
- COFFEE equation of state
- EOS-CG 2021 HOT 7
- user defined eos HOT 2
- Induced-Association Interactions in SAFT HOT 16
- Saturation solves fail moving from 0.5.7 to 0.5.8 HOT 4
- Move CPA input to use SI values
- Units of property functions HOT 8
- Help with modelling activity coefficients in UNIFAC HOT 3
- Wrong conversion of parameters for water in CPA HOT 10
- Installation problems with precompilation (`Setfield` not defined) HOT 4
- Surprising default combining rule in association term HOT 3
- Evaluation of CPA at too high a density yields no error, just NaN HOT 4
- Possible issue with bubble and dew point estimation (or SAFT-gamma Mie) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clapeyron.jl.