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

added improved x0_sat_pure #38

Merged
merged 5 commits into from
Aug 26, 2021
Merged

added improved x0_sat_pure #38

merged 5 commits into from
Aug 26, 2021

Conversation

longemen3000
Copy link
Member

@longemen3000 longemen3000 commented Aug 26, 2021

basically we have a Solvers.log that works like NaNMath.log for Base Floats and Ints, but allows using other number types.
we also fail earlier. in eos if a negative volume or temperature is passed, it will return NaN inmediately.
For some bizarre reason i couldnt reproduce the failings on system = BACKSAFT(["decane"]), but with some investigation, i found that our initial conditions were not good enough. the new algorithm uses some sort of corresponding states theory to transform a (V0,P0,T,B(T)) into (a,b (van der Vals) . with a and b we actually calculate a Tc and Pc, and those are used to calculate v_liquid and v_vapor according to 0.1007/s10910-007-9272-4 The van der Waals equation: Analytical and approximate solutions
Thanks to those Pc and Tc, we can also "know" in what temperature regime we are. so we can give different results for near critical T, moderate T and very low T. all those at almost the same cost at the initial x0_sat_pure (1 virial coefficient and 1 liquid volume at P = Pvirial(-2B).
We could use any Cubic EoS for this, but VdW is chosen because with a we could obtain Tc (it doesnt depend of more parameters, we could also use RK for this) and there is paper for aproximate solutions at saturation conditions (here we could use another EoS initial points. for example, PropaneRef provides v_liquid and v_vapor for a given Tr.

On the practical side, this improves greatly sat_pure at absolute low temperatures (triple point and below) and improves a bit near the critical point. also improves the results way over the critical point by failing earlier and skipping the first saturation calculation

For example, with the new initial points this converges:

julia> system = PCSAFT(["decane"])
PCSAFT{BasicIdeal} with 1 component:
 "decane"
Contains parameters: Mw, segment, sigma, epsilon, 
epsilon_assoc, bondvol
#triple point
julia> sat_pure(system,243.4)
(1.3689196372899646, 0.00018623782979399546, 1478.342844794574)
# 1 Pa

at the moment, i deactivated the SPUNG tests, as i plan to fix that later

@codecov-commenter
Copy link

codecov-commenter commented Aug 26, 2021

Codecov Report

Merging #38 (06a4e24) into master (73f56af) will decrease coverage by 0.46%.
The diff coverage is 70.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #38      +/-   ##
==========================================
- Coverage   80.29%   79.83%   -0.47%     
==========================================
  Files          71       71              
  Lines        5091     5302     +211     
==========================================
+ Hits         4088     4233     +145     
- Misses       1003     1069      +66     
Impacted Files Coverage Δ
src/Clapeyron.jl 100.00% <ø> (ø)
src/models/eos.jl 60.00% <0.00%> (-6.67%) ⬇️
src/models/eos/EmpiricHelmholtz/IAPWS95.jl 86.40% <ø> (+0.33%) ⬆️
src/models/eos/SPUNG/SPUNG.jl 42.02% <23.07%> (-47.04%) ⬇️
src/solvers/Solvers.jl 67.34% <33.33%> (-7.66%) ⬇️
src/utils/misc.jl 80.00% <50.00%> (-2.61%) ⬇️
src/models/eos/EmpiricHelmholtz/PropaneRef.jl 88.67% <66.66%> (+0.32%) ⬆️
src/methods/initial_guess.jl 91.04% <77.58%> (-5.67%) ⬇️
src/methods/property_solvers/singlecomponent.jl 95.55% <84.61%> (+18.63%) ⬆️
src/methods/property_solvers/volume.jl 95.00% <100.00%> (+0.17%) ⬆️
... and 34 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73f56af...06a4e24. Read the comment docs.

@longemen3000 longemen3000 merged commit d6d6d63 into master Aug 26, 2021
pw0908 pushed a commit that referenced this pull request Apr 28, 2022
added improved x0_sat_pure
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

Successfully merging this pull request may close these issues.

None yet

2 participants