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
194 stars 50 forks source link

How to compute bulk properties of mixtures in the two-phase region (isobaric process)? #295

Open Sush1090 opened 1 day ago

Sush1090 commented 1 day ago

Hello,

I am working on computing bulk properties of mixtures during an isobaric process in the two-phase region. The bulk properties typically "glide" between the bubble point and dew point due to non-isothermal phase change.

Currently, Clapeyron.jl computes the bulk property in a stable state (e.g., entropy) using the following function:

function entropy(model::EoSModel, p, T, z=SA[1.]; phase=:unknown, threaded=true, vol0=nothing)
    V = volume(model, p, T, z; phase, threaded, vol0)
    return VT_entropy(model, V, T, z)
end

My understanding is that it computes the Gibbs energy and returns the branch with the lowest Gibbs energy (hence returning the volume), but this does not account for the "glide" behavior.

I have been using linear interpolation between the bubble and dew points as a workaround, but I am looking for a more accurate solution. Example: image

I am unsure how to incorporate the glide behavior correctly. My guess for now is finding the volume of gas and liquid phase and interpolating the property with it but it is not completely clear to me yet.

Is there a way to achieve this within Clapeyron.jl?

Thank you for your insights!

Thanking you Sushrut

longemen3000 commented 1 day ago

You would need a TP flash, and then you could calculate the enthalpy for each phase and add those, something like this:

x, N, dG = tp_flash(model, p, T, z)
h = 0.0
for i in 1:size(N,1)
  ni = N[i, :] 
  h += enthalpy(model, p, T, ni)
end

but we need a better api for this (working on it)