-
Notifications
You must be signed in to change notification settings - Fork 0
Unit systems
This page aims to discuss open questions on unit systems (sympy.physics.unitsystems
) in Sympy as well as possible improvements that can be made. You can propose your ideas and if you need help you can send me a message.
For some historical discussions you can take a look at:
- google groups discussion
- https://github.com/sympy/sympy/pull/1389 (aborted pull request)
- https://github.com/sympy/sympy/pull/2628 (current pull request)
Some articles speaking about the mathematical formulation of unit/dimension systems:
- [Page52] C. H. Page, Classes of units in the SI. Am. J. of Phys. 20, 1 (1952): 1
- [Page78] C. H. Page, Units and Dimensions in Physics. Am. J. of Phys. 46, 1 (1978): 78.
- [deBoer79] J. de Boer, Group properties of quantities and units Am. J. of Phys. 47, 9 (1979): 818.
- [LevyLeblond77] J.-M. Lévy-Leblond, On the Conceptual Nature of the Physical Constants, La Rivista Del Nuovo Cimento 7, no. 2 (1977): 187-214.
- [NIST] NIST reference on constants, units and uncertainties.
The module can already be used in daily life, but it will need some polishing in order to be fully convenient to use. In this section I suggest several points that could be improved.
Various points:
- Verify that function arg are dimensionless (there is care to take with angles, cf the papers above).
- Parse Quantity argument like "10 m".
- Should we add angles to MKS(A)?
This is the big question: currently operations with units return either a unit or an instance Add/Mul/Pow. The main problem is for add/sub: we can get units with negative scale, which has no sense with regard to the way we defined them. The solution could be that every operation implying a unit return a quantity. For example 10*m return the quantity Quantity(10, m); similarly Unit(length, 10) - Unit(length, 20) returns Quantity(-10, m).
A lot of work is needed to tie better units and unit systems. For example if one wants to define a quantity with Quantity("10 m"), we have somehow to say what is the current system. One could define a gloval variable SYSTEM which says in which system one wants to work, and then add some function in units to take this into account (but some people don't like global variables).
We can also add a method to print quantities in term of the unit that makes its factor the closest of 1. For example 1.7e6 eV will be written 1.7 MeV.
- When a system display a unit, be sure that the object is compatible with the system.
Several systems have to be defined:
- SI
- Planck system
- computer science system
- astronomical (with ua, earth mass, solar radius, etc.)
A lot of things can be done with dimensional analysis.
- Parse equations to check dimensions (there is already a function for this, but its very rough).
- Implement Buckingham Π theorem: find all adimensional quantities with n quantities and N base units.
Several kinds of new objects can be implemented:
- Units with offset (like °C).
- Logarithmic units (dB, pH, bytes, etc.) : one has to take care to allow log in different basis (cf [deBoer1979]).
- Quantities with uncertainties.
- Define sympy printing for the different objects (use the package siunitx for LaTeX).
- Allow for time system? (like hour/minutes/seconds) calendars?