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

Clarification/issue in SoftSAFT implementation #279

Open ianhbell opened 3 months ago

ianhbell commented 3 months ago

I can't figure out whether I am not understanding things or whether there is a typo in the implementation in Clapeyron.jl, but in the Soft-SAFT model, the implementation has:

https://github.com/ClapeyronThermo/Clapeyron.jl/blob/0a2ea2162603c83a8726f70150d49e6eded4c9cf/src/models/SAFT/softSAFT/softSAFT.jl#L165C1-L169C4

while the paper from Johnson has

image

and at contact, $r=\sigma$ and thus $\phi{LJ}=0$ so $y{LJ}=g_{LJ}$. Or?

The implementation in Clapeyron.jl assumes that the potential would have a value of $-\epsilon$ to get the result in Clapeyron.jl which doesn't make sense to me.

pw0908 commented 3 months ago

Huh, good catch. Not quite sure what happened there. Logically, this won't affect phase equilibrium calculations since it just adds a constant in both phases; perhaps that's why we never noticed the issue.

I remember spending a week trying to figure out the soft-SAFT implementation and desperately trying whatever seemed reasonable at the time.

ianhbell commented 3 months ago

Ok, seems like a typo then.

Related: the chain term seems to be evaluated by different methods in the literature, and they don't seem consistent. For instance in Blas, what is referenced in the docs:

image

where one should use the value of $\sigma$ for each component $i$ to evaluate the $g{LJ}$ with the corresponding $\rho{S}^*$ if I understand correctly, the energy being the same for all components (or should all $T^*$, $\rho^*$ going into $g_{LJ}$ be for the component rather than the mixture)?

ianhbell commented 3 months ago

One of the soft-SAFT people will be at the Boulder conference next week so perhaps we can get some clarity

pw0908 commented 3 months ago

Oh yes, there are a few versions of soft-SAFT. In Clapeyron, we have two (see softSAFT2016). The primarily differ by what reference EoS they use.

ianhbell commented 3 months ago

Yes, but the chain approach should be the same always, no?

pw0908 commented 3 months ago

Do you mean the expression should be the same (i.e. use the Johnson correlation) or the use of WTPT1? If its the latter then yes, that's a hard requirement for all SAFTs. However, I do believe different correlations exist for the PDF of an LJ.

ianhbell commented 3 months ago

I mean whether what arguments go into $g{LJ}$. It takes a $T^*$ and a $\rho^*$ as arguments. If they are always the same, things are clear enough (I think) as the $\ln(g{LJ})$ factors out of the summation and you are left with:

alpha_chain = (1-m)*ln(g_LJ)
longemen3000 commented 3 months ago

Yes, the chain approach is the same, softSAFT2016only changes the reference model to the thol one

ianhbell commented 3 months ago

You sort of already have this in your model hierarchy, but I am working on a generic SAFT model in teqp at the moment that allows you to specify the nonpolar contribution, the polar contribution (not yet implemented) and the association contribution independently so you can plug-and-play with models and don't have to name each individual model combination uniquely. The model permutations result in a lot of names as I know you realize.

pw0908 commented 3 months ago

I see what you mean now. I think I got those mixing rules from one of the papers... Your idea of being able to swap out the different terms sounds very powerful! For the association term, Im guessing it will just be the association strength that changes?

ianhbell commented 3 months ago

I think that is correct about association.

But it is implemented very generically in the code - you just provide T, rho, mole_fraction to each contribution, and JSON is used to select models at construction-time, to instantiate type-generic std::variants. I think all of that should be possible in Julia too. Probably even easier I expect. I can show you my code once I push it.

longemen3000 commented 2 months ago

i just saw the code, impressive. i was thinking on doing something like that, some thoughts:

ianhbell commented 1 month ago

I have added more to the generic SAFT approach, it is quite nice. You can pass any flags you want to each portion via the JSON data structure that the portion consumes. I have been doing model parameterization with this new approach and it is working well. Adding all the things you mention would be possible, if the underlying sub-model supports it. This overall structure makes adding model variants very easy. The compilation time is a killer though with all the different options.

I have explicitly not considered volume translation for two reasons: 1) it impacts properties in subtle ways that are not trivial and not always consistent (see the papers from the group of Jaubert) 2) it requires major changes to the library to account for which densities (volumes) are shifted and which are not. I figure it makes sense to force the user to engage their brain as a post-processing step so that they think about the consequences of volume translation.