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

Activity coefficients calculated incorrectly for non 1:1 salts #15

Closed
rkingsbury opened this issue Mar 2, 2016 · 2 comments
Closed
Milestone

Comments

@rkingsbury
Copy link
Member

For salts with a cation : anion ratio other than 1:1 (e.g. MgCl2, K2SO4), activity coefficients calculated by the Pitzer Model (the default method) are incorrect.

>>> import pyEQL
>>> s1 = pyEQL.Solution([['Mg+2','0.5mol/L'],['Cl-','1mol/L']])
>>> s1.get_activity_coefficient('Mg+2')
<Quantity(0.727018603664255, 'dimensionless')>

The literature value (CRC Handbook) is 0.485. Similarly large discrepanices occur at other concentrations and with other salts.

@rkingsbury rkingsbury added the bug label Mar 2, 2016
@rkingsbury rkingsbury added this to the pyEQL 0.4 milestone Mar 2, 2016
@rkingsbury
Copy link
Member Author

The problem is that the Pitzer model code has to compute the concentration of the SALT, not just the individual cation or anion. It does this by averaging the cation and anion concentration:

# determine the average molality of the salt
# this is necessary for solutions inside e.g. an ion exchange
# membrane, where the cation and anion concentrations may be
# unequal
molality = (self.get_amount(Salt.cation,'mol/kg')+self.get_amount(Salt.anion,'mol/kg'))/2

But, the above doesn't account for the stoichiometry of the salt. In 0.4-dev I've fixed it like this:

molality = (self.get_amount(Salt.cation,'mol/kg')/Salt.nu_cation+self.get_amount(Salt.anion,'mol/kg')/Salt.nu_anion)/2

With the above fix, 2:1 and 1:2 salts now work properly. Examples of these are now included in the test suite for activity coefficient as well.

@rkingsbury
Copy link
Member Author

Fixed by 5fa742b

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

No branches or pull requests

1 participant