# Avoid problems with converting dimensionless units?

Posted 10 months ago
1057 Views
|
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
Sort By:
Posted 10 months ago
 re-check "DimensionlessUnit", if n->n it worksi cannot find "DimensionlessUnit" on my system, are you sure it's (still) on yours?
 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 problem...as does using QuantityUnit[n] such as eq3 = P*n/(n + 1) /. {P -> Quantity[P, "Kilopascals"], n -> QuantityUnit[n]}; UnitConvert[eq3, "Atmospheres"]