Message Boards Message Boards


Avoid problems with converting dimensionless units?

Posted 3 months ago
2 Replies
0 Total Likes

Relatively new to Mathematica so I've been playing around with it trying to learn how to use it and came across an unusual 'bug' (most likely user error). A simplified example:

eq1 = P*n /. {
   P -> Quantity[P, "Kilopascals"],
   n -> Quantity[n, "DimensionlessUnit"]
UnitConvert[eq1, "Atmospheres"]

gives "(40 n P)/4053atm." On the other hand...

eq2 = P*n/(n + 1) /. {
   P -> Quantity[P, "Kilopascals"],
   n -> Quantity[n, "DimensionlessUnit"]
UnitConvert[eq2, "Atmospheres" ]

gives two identical errors, "Quantity::unkunit: Unable to interpret unit specification {DimensionlessUnit,Kilopascals}."

Any ideas as to what's going on and/or how to fix it? Removing the line which substitutes n as a dimensionless unit seems to help in this particular example; however, I still get the same error with my more complicated equation despite the general form being the same.

2 Replies

re-check "DimensionlessUnit", if n->n it works

i cannot find "DimensionlessUnit" on my system, are you sure it's (still) on yours?

Posted 2 months ago

Yes, "DimensionlessUnit" seems to be on my system; however, it does not autocomplete when you start to type it. I found it referenced in a forum here. I've verified by using

QuantityQ[Quantity[n, "DimensionlessUnit"]]

which outputs True. I thought that another potential unitless value may be "PureUnities" which does autocomplete, but this seems to have the same does using QuantityUnit[n] such as

eq3 = P*n/(n + 1) /. {P -> Quantity[P, "Kilopascals"], 
    n -> QuantityUnit[n]};
UnitConvert[eq3, "Atmospheres"]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract