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

Full unit safety #148

Open
ikicic opened this issue Oct 19, 2020 · 0 comments
Open

Full unit safety #148

ikicic opened this issue Oct 19, 2020 · 0 comments

Comments

@ikicic
Copy link
Collaborator

ikicic commented Oct 19, 2020

At the moment, support for pint and unit-qualified values is rudimentary. Mirheo knows how to transform Quantity objects to Mirheo's units, but it does not know if the dimensionality is correct. Concretely, when Mirheo receives a Quantity as an argument, it transforms it to the (mirL, mirT, mirM) unit system, takes the magnitude and discards the dimension.
This leads to hard to find bugs, e.g.: mole is not converted to N_avogadro, the fact that mesh scale depends on mirL may be forgotten etc.

We should find a way to add strict unit checking. To make that possible, either Python or the pybind C++ code somehow has to know the dimensionalities of all parameters of all APIs. The most robust solution I can think of is to replace real parameters (in bindings, not in the core) with Length, Duration, Energy and other similar types, each representing one dimensionality. Then we somehow define implicit conversions from pint Quantity to these types.

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