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

Molecule count for hydronium and hydroxide ions different at pH = 7 #225

Closed
Tracked by #677 ...
Nancy-Salpepi opened this issue Jul 19, 2021 · 21 comments
Closed
Tracked by #677 ...
Labels

Comments

@Nancy-Salpepi
Copy link

Test device
iMac

Operating System
10.15.7

Browser
Safari 14.1.1 (also seen on MacBook Air with M1 chip + chrome)

Problem description
phetsims/qa#669

After initially moving OH- slider to maximum quantity of 5.0 mol (pH = 15), the molecule counts for hydroxide and hydronium ions were not equal when pH was returned to 7 using hydroxide slider. This was only seen when slider was used and not when number adjuster in pH panel was manipulated. If the pH was manipulated using the hydroxide slider after the number adjusters were used, molecule counts were equal at pH = 7.

Steps to reproduce

  1. select My Solution screen
  2. Set toggle to quantity
  3. check molecule count checkbox
  4. Move OH- slider all the way up the scale to 5.0 mol
  5. move the OH- slider back down until the pH = 7.

Visuals

https://drive.google.com/file/d/1x5Nrnp-dSAalCpTGHzLpm6uX7MY_fCod/view?usp=sharing

Troubleshooting information:
!!!!! DO NOT EDIT !!!!!
Name: ‪pH Scale‬
URL: https://phet-dev.colorado.edu/html/ph-scale/1.5.0-rc.1/phet/ph-scale_all_phet.html
Version: 1.5.0-rc.1 2021-07-13 18:33:46 UTC
Features missing: touch
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15
Language: en
Window: 1409x778
Pixel Ratio: 1/1
WebGL: WebGL 1.0
GLSL: WebGL GLSL ES 1.0 (1.0)
Vendor: WebKit (WebKit WebGL)
Vertex: attribs: 16 varying: 31 uniform: 1024
Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32)
Max viewport: 8192x8192
OES_texture_float: true
Dependencies JSON: {}

@pixelzoom
Copy link
Contributor

Thanks @Nancy-Salpepi. Reproduced in 1.5.0-rc.1 and master.

I'll investigate, but here's my best guess. Because the slider is continuous, the pH is not exactly 7.00 in the model. It's probably something like 7.005, but we're only displaying 7.00.

@Nancy-Salpepi
Copy link
Author

I thought it might be due to rounding, but since the molecule count was equal in all other instances, I thought it was odd for it to be different here.

@pixelzoom
Copy link
Contributor

Yep, pH is not exactly 7.00 in the model.

For example, in this case pH=6.997477692908731. And you can see that the H3O+ and OH- sliders have different values.

screenshot_1064

If I fiddle with the OH- slider a bit, I can make the H30+ and OH- sliders have the same value, and the pH is still not 7.00, it's actually 6.999667798625693.

screenshot_1066

So there's a signicant problems here. We have a continous slider that has a precision that allows us to set pH values that can't be differentiated by 2 decimal place. I'm not sure how to resolve this. Maybe make the sliders snap to one decimal place for the coefficient?

@arouinfar thoughts?

@pixelzoom pixelzoom assigned arouinfar and pixelzoom and unassigned pixelzoom Jul 19, 2021
@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 19, 2021

Notes to self: If we want to constrain the slider coefficients to 2 decimal places, then that can be done in either GraphIndicatorDragListener (in drag function) or in LogarithmicGraphNode (in yToValue function). The idea would be round any slider value to 2 non-zero decimal places. E.g. 0.0003456789 would become 0.00035

@pixelzoom
Copy link
Contributor

Maybe make the sliders snap to one decimal place for the coefficient?

I went ahead and implemented this approach in the above commit. @arouinfar if you can think of any problems with this, please jump in asap.

@Nancy-Salpepi please verify this fix in master. Then assign back to me, so that I can patch the 1.5 branches.

@Nancy-Salpepi
Copy link
Author

Still looks the same to me. Mole values are still different at pH = 7 and the "molecule count" values for the ions in the beaker are still not equal.
Screen Shot 2021-07-19 at 2 45 02 PM

@pixelzoom
Copy link
Contributor

@Nancy-Salpepi I could easily reproduce the problem before, and I'm unable to now in master. I see from your screenshot that you're using phettest to test master. So I suspect that phettest may not have pulled the latest changes, or you're experiencing caching in your browser. If you think that may be the case and aren't familiar with those issues, ask one of the other QA team to fill you in. In the meantime, please give it a try in 1.6.0-dev.1. Thanks!

@Nancy-Salpepi
Copy link
Author

Nancy-Salpepi commented Jul 19, 2021

Sorry that was my fault. I was not in incognito mode. I couldn't reproduce the problem in master or in 1.6.0-dev.1

@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 19, 2021

No, master is sufficient, thanks. I'll assign this back to me for patching in 1.5.

Note to self: While this feature is only used in ph-scale, I think I'll also patch ph-scale-basics, so that they continue to share the same code base. The sha is e7b9bf4.

@pixelzoom
Copy link
Contributor

Patched in 1.5 branches for ph-scale and ph-scale-basics. Ready for verification in next RC.

@pixelzoom pixelzoom self-assigned this Jul 26, 2021
pixelzoom added a commit that referenced this issue Jul 26, 2021
@arouinfar
Copy link
Contributor

@Nancy-Salpepi this was a really great find and I think the change @pixelzoom made to constrain the values set by the graph indicators was necessary.

Adding a decimal place to the pH meter trade one precision problem for another. Changing the pH spinner by 0.001 increments is tedious, and doesn't change the H3O+ and OH- values. And diluting a solution (e.g. Spit) in Micro screen also is problematic. So I'll revert that change.

Here are some examples that demonstrate the dilution issue on the Micro screen.

  • In the latest published version, it's possible to dilute the solution to 7.00 but have unequal H3O+ and OH- concentrations:
    image

  • In master, it's possible to dilute the solution to 7.002 but the displayed H3O+ and OH- concentrations are equal:
    image

pixelzoom added a commit that referenced this issue Jul 26, 2021
pixelzoom added a commit that referenced this issue Jul 26, 2021
pixelzoom added a commit that referenced this issue Jul 26, 2021
@pixelzoom
Copy link
Contributor

Workaround implemented in the above 3 commits, which I'll need to cherry-pick to 1.5 branches.

This workaround is needed only when the graph is set to Concentration. For Quantity, neutral pH corresponds to H3O+ and OH- quantities of 5.0e-8 mol. And 4.9e-8 has no similar problem, as it results in a pH of 6.99.

@arouinfar please review in master, and let me know if this looks OK.

@arouinfar arouinfar mentioned this issue Jul 26, 2021
2 tasks
@arouinfar
Copy link
Contributor

Looks good in master @pixelzoom. I've created an issue to update the Teacher Tips (referenced above).

@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 26, 2021

Patched in ph-scale 1.5. Not necessary to patch in ph-scale-basics 1.5, because this feature (and code) does not appear in that sim.

Ready for verification in the next RC.

@KatieWoe
Copy link
Contributor

This looks ok in rc.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants