I love the units system in Mathematica, it's an extremely useful addition to the language. Unfortunately there are still some sharp corners that I run into on a daily basis. For example, if I want to do a stoichiometry calculation, I would like to be able to do the following:
Vol = Quantity[300,"Microliters"]Concentration = Quantity[2,"Millimolar"]CdMW = ChemicalData["CadmiumOxide","MolecularWeight"]mgCd = UnitConvert[Concentration*Vol*CdMW,"Milligrams"]
But this does not work, because "MolecularWeight"
reports units of AtomicMassUnit
, which Mathematica indicates is incompatible with "Grams"/"Moles"
, even though in practice (at least for stoichiometry calculations) they are effectively the same.
I have a workaround using the following code:
CdMW = Quantity[QuantityMagnitude[ChemicalData["CadmiumOxide","MolecularWeight]],"Grams"/"Moles"]
But I find this to be quite inelegant, and somewhat less than readable.
Is this the best way to do this, or is there a better approach?