barril icon indicating copy to clipboard operation
barril copied to clipboard

Automatic simplification of composed quantity types

Open nicoddemus opened this issue 6 years ago • 0 comments

Follow up: https://github.com/ESSS/barril/issues/15#issuecomment-437443557

We should discuss how to automatically simplify composing units:

Scalar(1, 'kg') * Scalar(1, 'm3') / Scalar(1, 'm3') should return a scalar with Quantity('kg').

This implies that we should not have simple units in our database which are actually composed: for example, Quantity("kg/m3") should really be handled as Quantity([("kg", 1), ("m3", 1)]) internally.

This simplification process needs to make sure to not throw away all units and get a Quantity("unitless") back, as an important feature is to have units like "m3/m3" or "g/kg" in our systems.

This also implies that scalar.GetValue("kg/m3") will need to parse "kg/m3" properly into the respective exponents [("kg", 1), ("m3", -1)], as "kg/m3" as a single unit will no longer exist.

@fabioz please let me know if I'm missing something.

cc @igortg @kfasolin @tadeu @damianimc @arthursoprana

nicoddemus avatar Nov 09 '18 18:11 nicoddemus