Message Boards Message Boards

0
|
5688 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid problems with converting dimensionless units?

Posted 6 years ago

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.

POSTED BY: Nathanael Mayo
2 Replies
Posted 6 years 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 problem...as does using QuantityUnit[n] such as

eq3 = P*n/(n + 1) /. {P -> Quantity[P, "Kilopascals"], 
    n -> QuantityUnit[n]};
UnitConvert[eq3, "Atmospheres"]
POSTED BY: Nathanael Mayo
Anonymous User
Anonymous User
Posted 6 years ago

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

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

POSTED BY: Anonymous User
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract