Basic tools and definitions of quantities in thermofluids problems
Author UCLAMAEThreads
1 Star
Updated Last
1 Year Ago
Started In
March 2021


basic tools and definitions of quantities in thermofluids problems

Stable Dev Build Status codecov

The purpose of this package is to enable easy setup of quantities in thermofluids problems. It contains

  • A large set of specialized types based on common thermofluid quantities (e.g. Velocity, Pressure, etc) that enable dispatch on these quantities
  • Treatment of typical units, using the Unitful package.
  • Predefined properties for various common gases and liquids
  • Plot recipes for the associated types

Setting a quantity's value

We can set the value of a quantity through a simple interface, specifying in units with the Unitful interface, or without units, so that it obtains the default units of the quantity. E.g., pressure has default units of Pascals, so we can set it in, say, atmospheres and it will convert it automatically, or we can just supply a number:


Quantities, units, and types

Quantities of the same units can be added or subtracted, e.g.,

p = Pressure(1u"atm") + StagnationPressure(3u"atm")

The result of this operation is just a Unitful quantity. This can then be wrapped by a type with the same units:


All quantities in this package are typed and are subtypes of either DimensionalPhysicalQuantity or DimensionlessPhysicalQuantity. These are both subtypes of PhysicalQuantity.

Pressure <: DimensionalPhysicalQuantity

Quantities with the same units but different names are of different types, so dispatch can distinguish them:

f(::Pressure) = "I am pressure!"

but this would fail:


Non-dimensional variables automatically reconcile different units

If we supply a ratio of quantities that are dimensionally compatible but are in disparate units, any non-dimensional variable will automatically convert to common units in performing the ratio and provide a truly dimensionless number, e.g.,


In this example, KinematicViscosity(0.1) assumes the given value is in default units (m^2/s). Note that we also demonstrated in this example that operations with a PhysicalQuantity can be mixed with Unitful.Quantity types.

If you don't have a name for a dimensionless parameter, then DimensionlessParameter is a catch-all, e.g.,

v = Velocity(1u"m/s")
vref = Velocity(5u"m/s")

Defining new quantities

The list of predefined dimensional quantities is returned with


and non-dimensional variables with


It is simple to define a new quantity and use it. For example, a non-dimnesional variable

@nondimvar MyDimensionlessNumber

or a new dimensional quantity

@dimvar MyTimeVar TimeType

The second argument represents a 'unit type' for time, a union of types with time units. This comes with a default unit (seconds). To see the list of predefined unit types


If you don't see the one you want, then add it with @displayedunits

import ThermofluidQuantities: ๐‹, ๐“
@displayedunits MyInverseVelocityType "s/m" ๐“/๐‹

Then you can create a quantity:

@dimvar MyInverseVelocityVar MyInverseVelocityType

Gases and liquids

There are several predefined properties for gases and liquids. You can see the lists here:




For example, to see the properties of air,


You can access any of the properties individually with, e.g.,


Used By Packages