Is there a straightforward way to write an inverse of UnitDimensions
to get the SI unit from dimensions?
For example,
inverseUnitDimensions[{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]
should return "Newtons"
.
Is there a straightforward way to write an inverse of UnitDimensions
to get the SI unit from dimensions?
For example,
inverseUnitDimensions[{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]
should return "Newtons"
.
You can use QuantityVariableCanonicalUnit
:
QuantityVariableCanonicalUnit[QuantityVariable[
{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]]
(* ("Kilograms" "Meters")/("Seconds")^2 *)
Now you need a combination of UnitSimplify
and UnitConvert
:
QuantityUnit[UnitConvert[UnitSimplify[Quantity[1, %]], "SI"]]
(* "Newtons" *)
Using answer from Domen:
In[16]
si[dimensions_]:=
UnitSimplify[
UnitConvert[
QuantityVariableCanonicalUnit[
QuantityVariable[dimensions]],
"SI"]]
si[{{"LengthUnit", 1}, {"MassUnit", 1}, {"TimeUnit", -2}}]
si[{{"ElectricCurrentUnit", 1}, {"TimeUnit", 1}}]
Out[17]= Quantity[1, "Newtons"]
Out[18]= Quantity[1, "Coulombs"]
unitSimplify[Quantity[1, "Meters" "Kilograms"/"Seconds"^2], Join[SIbase, SIderived]]
returns{Quantity[1, "Newtons"]}
as desired. $\endgroup$