CalebBell / thermo

Thermodynamics and Phase Equilibrium component of Chemical Engineering Design Library (ChEDL)
MIT License
638 stars 117 forks source link

Add MOSCED for infinite dilution activity coefficients #115

Open edgarsmdn opened 2 years ago

edgarsmdn commented 2 years ago

Hi Caleb,

I implemented the solvation model "Modified Separation of Cohesive Energy Density" (MOSCED) from the original paper. It is used for calculating activity coefficients at infinite dilution. It overcomes UNIFAC and COSMO-RS (e.g., see this paper) for the systems that can be applied to. So, I thought it could be of interest to the community :)

I also included a test file comparing my implementation with the one available from the DDBST. The comparison shows that my implementation is consistent.

Let me know if you need something else regarding this little model, and I am happy to contribute.

CalebBell commented 2 years ago

Hello Edgar! Wow, this is quite impressive. I am not very farmiliar with MOSCED. I did once read about it six years ago, but it's been a while and the brief time I spent reading about it didn't allow me to use it successfully (2016). It is very generous and kind of you to share your code with the world.

Your validation data is quite impressive - I agree, this is enough evidence to know it is correctly implemented. Using BeautifulSoup and figuring out a web API is no small feat either. In my opinion, you definitely have an aptitutde for coding.

I don't have a generic framework implemented for activity coefficient models that work only for the infinite dilution mole fraction. There isn't a proper MOSCED model for any concentration of a solute, and/or for ternary and higher systems, is there? My limited googling didn't turn up anything. That means this functionality would be unique in thermo, which is cool.

I can provide lengthy feedback in terms of performance, reliability, compatibility, documentation rendering, and testing, but those are all fairly small details. Before merging this pull request, there are some feature things to talk about.

  1. Are there other sets of MOSCED parameters published in different papers? I think so, right? In those cases, like in UNiFAC, it seems important to have an argument for the source of the data; even if only one source is implemented now. This makes upgrading the default data source or adding another option much easier later. For example, the UNIFAC model has data from 8 different publications.
  2. Are there other models that are for binary only systems at infinite dilution? If so, the parts of the functionality that are generic should be part of a subclass.
  3. How does the activity coefficient at infinite dillution integrate with the rest of themo? I know it can be used along with some other parameters to calculate solubility according to this equation https://chemicals.readthedocs.io/chemicals.solubility.html#chemicals.solubility.solubility_eutectic. Are there other properties it is used to calculate?

Cheers, Caleb

edgarsmdn commented 2 years ago

Thanks for the comments! :)

There isn't a proper MOSCED model for any concentration of a solute, and/or for ternary and higher systems, is there?

No, MOSCED has only been used for predicting infinite dilution activity coefficients of binary systems as far as I know.

  1. Are there other sets of MOSCED parameters published in different papers? I think so, right? In those cases, like in UNiFAC, it seems important to have an argument for the source of the data; even if only one source is implemented now. This makes upgrading the default data source or adding another option much easier later. For example, the UNIFAC model has data from 8 different publications.

You are right! Until now, all the MOSCED parameters are taken from the original paper. I am aware of some works with parameters for new compounds (e.g., ionic liquids). This will enlarge the list of parameters, rather than having different versions of it. But, I will add the argument to choose the parameters just in case new parameters pop-up.

I copy here the MOSCED parameter extensions that I know to have them in one place:

  1. Are there other models that are for binary only systems at infinite dilution? If so, the parts of the functionality that are generic should be part of a subclass.

I am not aware of a model whose only purpose is to estimate infinite dilution activity coefficients of binary systems other than MOSCED. The only one that comes to my mind is the Abraham model. But, this model estimates the partition coefficient which can be later related to the infinite dilution activity coefficient. Also, I know the Hildebrand and Hanssen solubility parameters can be used to calculate infinite dilution activity coefficients, but it is not very clear to me how to do it.

  1. How does the activity coefficient at infinite dillution integrate with the rest of themo? I know it can be used along with some other parameters to calculate solubility according to this equation https://chemicals.readthedocs.io/chemicals.solubility.html#chemicals.solubility.solubility_eutectic. Are there other properties it is used to calculate?

This is a nice point! Yes, solubilities and infinite dilution activity coefficients can be related. Maybe the most important one is the extended Margules equation which relates infinite dilution activity coefficients of binary mixtures to activity coefficients (finite dilution) for multicomponent systems (e.g., see equations 4-7 of this paper). I had a quick look into thermo, and did not find the Margules equation(?), which can be also a nice adding to the library given the above mentioned (very useful) relationship.