-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use 2019 SI base units #86
Conversation
The old units were experimentally determined and had fluctuating precision. Each textbook had a slightly different value. We are currently using the old values, and they have a tiny deviation from the new values. For example, the ratio of pyMBE Boltzmann constant and the corresponding 2019 constant deviates from unity by three times the machine-precision of single-precision floating point values: import pyMBE, numpy as np, scipy.constants
eps = scipy.constants.k / pyMBE.pymbe_library.Kb.magnitude - 1.
print(eps / np.finfo(np.float32).eps) For the electric charge, it's one order of magnitude smaller than machine precision. I don't think it makes much of a difference in long simulations due to thermal fluctuations, but it may cause test failures in unit tests if the |
@jngrad it looks to good to me. I ran the functional tests and everything seems to work fine. Should we add a small unit tests that checks that pyMBE uses the same fundamental constants as the ones in scipy, just to ensure that this does not break again in the future? |
Good point. I didn't realize the values of the constants were overridden in Side-note: I personally find using |
Yes, the problem is that in The Pint documentation is not very extensive regarding this definitions of new units docs. The solution that we have right now is not perfect because a user could still define particles with an old unit registry then set a different set of reduced units and then proceed to define new pyMBE objects with the new unit registry. If we could simply redefine the reduced units without creating a new
I agree, we should deal with this issue before the pyMBE 1.0.0 release. There is no major reason for having the global variables and we only need to have them defined by the class constructor instead.
I have not realized of this issue. You are right that it might be a bit missleading. Feel free to change the notation in this PR if you like. |
We could let the user provide the unit registry as an argument to the constructor. That would require users to write two extra lines to import pint and create their unit registry, but only if they don't use the default reduced units system. That would also make it clear that the unit registry belongs to the user, and pyMBE keeps a reference to it. This is probably out of scope for this PR, though.
Done. |
I am not completely convinced by this solution either, but let's think about it and address it on another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The SI base units have been redefined as natural constants with exact precision in 2019.