Webel: Mathematica: TIP: Maintain a Package library of Quantity variables for frequently used units using a naming convention unit$[unitSymbol] and unit[DescriptiveName] or unit[Acronym]

Webel IT Australia promotes the amazing Mathematica tool and the powerful Wolfram Language and offers professional Mathematica services for computational computing and data analysis. Our Mathematica tips, issue tracking, and wishlist is offered here most constructively to help improve the tool and language and support the Mathematica user community.
DISCLAIMER: Wolfram Research does not officially endorse analysis by Webel IT Australia.
Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
Keywords

Even with the Wolfram Alpha lookup using [CTRL]= entering the unit of a Quantity can be tedious, especially for complex units, such as this for a heat transfer coefficient:


Quantity[1,(("Watts")/("Kelvins" ("Meters")^2))]

The following unit-alias naming convention works well:

For a unit that has a clear unit symbol use the name unit$[unitSymbol], where [unitSymbol] is usually the official SI (ISQ) symbol. You can then type 'unit$' and prompt on it to choose the desired unit. For example:


unit$W = Quantity[1, "Watts"];

unit$kW = Quantity[1, "Kilowatts"];

unit$m = Quantity[1,"Meters"];

unit$mm = Quantity[1,"Millimeters"];

You can also use just the prefix 'unit' together with a descriptive name to enforce uniformity across a project:


unitHeatLoad = Quantity[1, "Kilowatts"]; (* Industry-typical non-SI choice *)

unitHeatTransferCoefficient = Quantity[1,(("Watts")/("Kelvins" ("Meters")^2))];

Frequently used ones can be further aliased thus:


unitHTC = unitHeatTransferCoefficient; (* Short-cut alias *)

This makes for far more readable code, and your typing hands will be happier. You can also search easily for unit usages. And you can change unit conventions across a project more easily.

However, be aware that multiplication, addition, and division of Mathematica Quantities involving units for temperature have special treatment!

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)