hgrecco / pint

Operate and manipulate physical quantities in Python
http://pint.readthedocs.org/
Other
2.4k stars 472 forks source link

Scientific/Engineering libraries using Pint #1216

Closed salazardetroya closed 6 months ago

salazardetroya commented 3 years ago

I am looking for a list of successful engineering/science projects using Pint. This will be helpful for anyone writing proposals to develop software that uses Pint as one of their components. Thanks.

jthielen commented 3 years ago

I think MetPy (meteorology toolkit) would be a good example to get started.

Perhaps the Pint docs could curate a list of packages using Pint (like xarray does)?

cpascual commented 3 years ago

we use it in taurus (a library for creating control system UIs)

salazardetroya commented 3 years ago

For anyone wondering the same question: https://libraries.io/pypi/Pint/dependents

CalebBell commented 3 years ago

I use pint in:

fluids, a library for practical fluid dynamics calculations ht, a library for practical heat transfer calculations chemicals, a library for chemical property calculations and lookups thermo, a library for thermodynamic equilibrium calculations

Pint is an incredible gift and a wonder of the Python scientific community. While it is not often practical to use in high-speed systems, it is critical for prototyping, and works wonderfully with "glue" code which wraps the hard scientific or numerical code.

The libraries.io link, however it works, has not detected my libraries and is likely missing most of pint's dependents. My projects have over 500 GitHub stars between them, and most users do not have GitHub accounts either.

salazardetroya commented 3 years ago

@cpascual , @CalebBell , @jthielen how have you guys dealt with the issue of "Kind of Quantity" errors described in https://arxiv.org/ftp/arxiv/papers/1807/1807.07643.pdf ? Basically, there are some quantities that have the same units. For instance, energy and torque both have N*m. Pint by itself is not able to prevent the user from adding up together energy and torque quantities. Are there solutions to this problem?

CalebBell commented 3 years ago

@salazardetroya This is definitely a huge problem! In chemical engineering we have the quantities mole fraction, mass fraction, volume fractions; in the literature it is even common for the type of fraction to be assumed based on the context.

The fact that dimensional analysis can't help with any of these issues is not a fundamental problem with the technique; it is just a limitation. Code review, unit tests, documentation, and doing your best not to make mistakes are also very important. This limitation is much like how mypy or other static type analysis tools for Python can't prevent you from adding an integer of "1 elephant" to an integer of "1 whale"; because that's not what the tool is for.

Thank you for sharing that paper. It coherently describes a number of limitations. The truth of the mater is and always will be that errors can come in any number of places. Unit checking is an incredibly useful tool and I wouldn't stop using it for anything. However, if it upsets you that pint can't prevent this type of an error, it may be worth considering if larger opportunities for error exist.

hgrecco commented 3 years ago

@CalebBell @salazardetroya We discussed in the past the idea of having an optional "Role" annotation to quantities. See #389 and #551

cpascual commented 3 years ago

@salazardetroya: taurus being a control-system framework, it is sort of an "intermediary" between hardware and the actual scientific application. As such, it does not handle KoQ issues by itself (amongst other things because it lacks the application context knowledge to do it). It would be the responsibility of the scientific application built on top of taurus to handle KoQ issues if they are likely.

jules-ch commented 3 years ago

I think we can introduce a Ecosystem or Libraries using pint page in the docs.

I'll try to put this working on #972