-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unyt is using a truncated version of Avogadro's number? #226
Comments
Here's where the constant is hardcoded. Line 103 in ec5b330
As you can see, it has a couple more digits than you were guessing. It's also stored as a float , which limits the precision with which we can write itwe could change it from 6.0221408577399995e+23 (effective current value)to 6.022141410704091e+23 though this may qualify as a breaking change for other users. Personally I would agree to update it anyway, since it's technically a fix. |
The downstream compatibility issue is akin to #144 |
Thank you for your quick response and information. I added by additional thought below. The chemistry, chemical engineers, and molecular simulations people use Avogadro's number a lot as it is key to chemistry, so we have noticed the slight difference. Therefore, we believe it is vital to use the correct number. When checking the accuracy of our Unyt calculations compared to manual checks, the manual constants must be modified to account for the error in the Unyt Avogadro's number, or other measures are taken (for example, using "isclose" to make the comparison). At a minimum, I believe this error in Avogadro's number should be listed in the Uynt documents because it is likely to be noticed by others and will help them quickly find the discrepancy. |
I understand. Do you use the constant directly or is it used under the hood of some application (unyt itself ?) that you have no control over ? Whatever the situation, I'll make sure this matter is discussed and that we have a solution for the next release. |
We use it in both cases. Users can use Unyt and put the values into our software, and/or under the hood of the software that we write and distribute. |
While on the topic of Avagadro's number, I will bring up one other modification that the computational chemistry groups made to the Unyt conversions. We use Kelvin as energy sometimes and need to convert it to normal energy units "kcal/mol" or "kJ/mol". This is fine using Unyt when Kelvin is the only unit; however, this is not possible in Unyt directly if trying to convert Kelvin/nm^2 to kcal/mol/nm^2, which is required in many situations. We have developed a workaround and wanted to share it in case it is helpful to your team or other users. |
I think that we should update the value of Avogadro's number--I don't think it will cause a downstream issue. As constants are better known / change, their values should be updated and we should document these changes in our changelog. @bc118 could you make a PR? As far as the issue with converting from temperature to energy, it looks like you've already figured out the use of unit equivalences, but we could think about exploring uses of your example code. |
It seems like Unyt is using a truncated version of Avogadro's number, being 6.0221e23. Is this the case? If so, I recommend the following.
The seemingly more accurate Avogadro's number is 602,214,141,070,409,084,099,072 and located here (https://www.americanscientist.org/article/an-exact-value-for-avogadros-number).
I recommend double-checking and adding the most accurate value of Avogadro's number above if this is indeed the issue.
The text was updated successfully, but these errors were encountered: