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

Consider using a library for physical units/conversions #2

Closed
aktwo opened this issue Oct 31, 2021 · 4 comments · Fixed by #27
Closed

Consider using a library for physical units/conversions #2

aktwo opened this issue Oct 31, 2021 · 4 comments · Fixed by #27

Comments

@aktwo
Copy link
Collaborator

aktwo commented Oct 31, 2021

Some examples:

Also, this paper has some more examples/libraries: https://arxiv.org/pdf/1807.07643.pdf.

@ngam
Copy link
Contributor

ngam commented Nov 1, 2021

I am tempted by this. However, a potentially much simpler solution is to rely on standard units for everything (kg, m, s, etc.) except perhaps when outputting a domain-specific output in diagnostics or plots, e.g. for chamber experiments, concentration is often reported in /cc and coagulation coefficient rate in (cubic centimeter or cm^3 per second) cc/s, but condensation growth in nm/s and sizes (most often diameters, not radii) in nm; yet for wall-specific distances we use cm, and so on; in fact, the actual "normalized" concentration unit is ... /cc/nm. Anyway, you get the total mess. That's why, I would personally vote to do everything in standard units in the backend, avoiding conversions altogether except in the io. Anyway something to consider. This will obviously become a serious issue as we will rely on a lot of parameterizations and global constants, as well as dimensionless quantities. Moving all to standard units can be easier than having to worry about conversions.

@aktwo
Copy link
Collaborator Author

aktwo commented Nov 9, 2021

Keeping everything in standard units is great! That said, the intent of this issue was to add unit types to numerical quantities to give us a way to programmatically validate that we haven't accidentally used a non-standard unit somewhere. I see automatic conversion between units as a secondary benefit.

@ngam
Copy link
Contributor

ngam commented Nov 9, 2021

Sorry, I misunderstood that. Yes, fully endorse!

@wkchuang
Copy link
Collaborator

wkchuang commented Nov 13, 2021

Thanks for the paper! I really like the goal of Quant, covering even the 'kind-of-quantity' errors that I've struggled with before in dimension evaluation. Unfortunately, there hasn't been further development beyond the proof of concept 4 years ago. Similar situation with units, which hasn't seen development since 2017. I think that leaves us with pint,

I sifted through some of pint's open issues and found something that may interest us. We deal with a lot of "dimensionless" fractions, like "molecules of ozone / molecules of air", which pint currently has trouble handling. There are open issues with a suggested solution: How to handle ppm and ppmv
Someone is trying to tackle this problem: Added units for atmospheric chemistry applications, but also we need to be aware that ppb and ppt have different meanings in different countries

The Quant paper was referenced in Issue 1216, so the repo owner and collaborators know about the 'kind-of-quantity' problem.

Thoughts on going with pint?

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

Successfully merging a pull request may close this issue.

3 participants