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

TP-Flash with activity models #164

Closed longemen3000 closed 1 year ago

longemen3000 commented 1 year ago

this PR enables the use of tp_flash with activity models in MichelsenTPFlash. there is support for non-volatiles/non-condensables and LLE. on VLE, performs the full approach for the calculation for K. (including Poynting Correction Factors).

what is missing at the moment is the optimization part, on LLE, i can just take the code for LLE_point,but code for VLE is missing.

solves #144 as originally intended.

Because of the refactoring required to do this, RRTPFlash now supports the same (LLE,VLE,non-volatiles,non-condensables, and activities), because it now uses the same function to calculate those.

codecov[bot] commented 1 year ago

Codecov Report

Merging #164 (f3778b5) into master (5dd6433) will increase coverage by 0.44%. The diff coverage is 93.28%.

@@            Coverage Diff             @@
##           master     #164      +/-   ##
==========================================
+ Coverage   85.85%   86.30%   +0.44%     
==========================================
  Files         216      219       +3     
  Lines       14503    14687     +184     
==========================================
+ Hits        12451    12675     +224     
+ Misses       2052     2012      -40     
Impacted Files Coverage Δ
src/Clapeyron.jl 100.00% <ø> (ø)
src/methods/initial_guess.jl 86.30% <ø> (ø)
...ethods/property_solvers/multicomponent/tp_flash.jl 70.58% <ø> (ø)
...y_solvers/singlecomponent/saturation/AntoineSat.jl 90.90% <ø> (ø)
...lvers/singlecomponent/saturation/ChemPotDensity.jl 87.95% <ø> (ø)
...rty_solvers/singlecomponent/saturation/ChemPotV.jl 90.42% <ø> (ø)
src/models/Activity/COSMOSAC/COSMOSAC02.jl 100.00% <ø> (ø)
src/models/Activity/COSMOSAC/COSMOSAC10.jl 100.00% <ø> (ø)
src/models/Activity/COSMOSAC/COSMOSACdsp.jl 86.48% <ø> (ø)
src/models/Activity/NRTL/NRTL.jl 100.00% <ø> (ø)
... and 41 more

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

longemen3000 commented 1 year ago

this is ready for review/merge. the gibbs energy optimizer is pending, but rachford rice seems to handle the problem well (the solver was changed from a bracketed Halley to bracketed Chebyshev, see Roots.jl/#359.

On UNIFAC, i did a second take on how to optimize it, this time using thermopack notes. the code changes made UNIFAC around 10x faster (and this time seem correct (they respect γi(xi = 0) -> 1).

A lot of the changes in other files was on removing kwargs... that were left from the multiple estimation branches. they cause problems because you could pass a mispelled keyword (uselrocations) and it will be silently dropped instead of explicitly erroring