Thermal Unit Conversions
About Affine Units
Thermal units often require an affine conversion, that is, a conversion that performs both multiplication and addition. To convert from the old value Told to the new value Tnew, we need a linear conversion coefficient L and an offset O:
Tnew = L * Told + O
For example, to convert a temperature reading from degrees Celsius into degrees Fahrenheit, the linear term equals 9/5, and the offset equals 32:
TFahr = 9 / 5 * TCels + 32
Simscape™ unit manager defines kelvin
K) as the fundamental
temperature unit. This makes Celsius
degC) and Fahrenheit
degF) affine units because
they are both related to kelvin with an affine
conversion. Rankine (
defined in terms of kelvin with a zero linear
offset and, therefore, is not an affine unit.
The following are the default Simscape unit registry definitions for temperature units:
pm_adddimension('temperature', 'K'); % defines kelvin as fundamental temperature unit pm_addunit('degC', [1 273.15], 'K'); % defines Celsius in terms of kelvin pm_addunit('degF', [5/9 -32*5/9], 'degC'); % defines Fahrenheit in terms of Celsius pm_addunit('degR', [5/9 0], 'K'); % defines rankine in terms of kelvin
When to Apply Affine Conversion
In dealing with affine units, sometimes you need to convert them using just the linear term. Usually, this happens when the value you convert represents relative, rather than absolute, temperature, ΔT = T1 – T2.
ΔTnew = L * ΔTold
In this case, adding the affine offset would yield incorrect conversion results.
For example, the outdoor temperature rose by 18 degrees Fahrenheit, and you need to input this value into your model. When converting this value into kelvin, use linear conversion
ΔTkelvin = 5 / 9 * ΔTFahr
and you get 10 K, that is, the outdoor temperature changed by 10 kelvin. If you apply affine conversion, you will get a temperature change of approximately 265 kelvin, which is incorrect.
This is even better illustrated if you use degrees Celsius for the input units because the linear term for conversion between Celsius and kelvin is 1:
If the outdoor temperature changed by 10 degrees Celsius (relative temperature value), then it changed by 10 kelvin (do not apply affine conversion).
If the outdoor temperature is 10 degrees Celsius (absolute temperature value), then it is 283 kelvin (apply affine conversion).
For relative temperatures, you can also use
the relative temperature units:
deltadegR. These units are
consistent with the Simulink® unit database (see Units in Simulink). If you use these
units, affine conversion does not apply.