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

Enhancement: prevent accidental double-setting of pH #201

Open
rkingsbury opened this issue Nov 7, 2024 · 2 comments · May be fixed by #205
Open

Enhancement: prevent accidental double-setting of pH #201

rkingsbury opened this issue Nov 7, 2024 · 2 comments · May be fixed by #205

Comments

@rkingsbury
Copy link
Member

Currently, it is possible to specify pH by including H+ in the composition dictionary:

>>> initial_conditions = {
    'HCO3-': 1.0e-3,
    'CO3--': 1.0e-4,
    'H+': 1.0e-7 # Note: instead of including H+ here, you could use the pH keyword argument
}
>>> Solution(initial_conditions).pH
4.00

However, this overrides whatever is specified in the pH keyword argument, which is the intended way to set the pH:

>>> Solution(initial_conditions, pH=10).pH
4.000

I think it's OK that the composition dictionary overrides the pH keyword argument, but there should be a warning raised when this happens (at a minimum). Also, I think if a user specifies a non-default pH AND has H+ in their composition dictionary, there should probably be a ValueError since the user's intent is not clear in that case.

This should be fixed in Solution.__init__ here .

@gnuhpdiem
Copy link

Hello, can I work on this issue?

@rkingsbury
Copy link
Member Author

Hi @gnuhpdiem , yes, please feel welcome to give it a try!

@gnuhpdiem gnuhpdiem linked a pull request Nov 14, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants