Documentation |
On this page… |
---|
Thermal units often require an affine conversion, that is, a conversion that performs both multiplication and addition. To convert from the old value T_{old} to the new value T_{new}, we need a linear conversion coefficient L and an offset O:
T_{new} = L * T_{old} + 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:
T_{Fahr} = 9 / 5 * T_{Cels} + 32
Simscape™ unit manager defines kelvin (K) as the fundamental temperature unit. This makes Celsius (C) and Fahrenheit (Fh) affine units because they are both related to kelvin with an affine conversion. Rankine (R) is 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('C', [1 273.15], 'K'); % defines Celsius in terms of kelvin pm_addunit('Fh', [5/9 -32*5/9], 'C'); % defines Fahrenheit in terms of Celsius pm_addunit('R', [5/9 0], 'K'); % defines rankine in terms of kelvin
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 = T_{1} – T_{2}.
ΔT_{new} = L * ΔT_{old}
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
ΔT_{kelvin} = 5 / 9 * ΔT_{Fahr}
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).
When you specify affine units for an input temperature signal, it is important to consider whether you need to apply affine conversion. Usually this decision depends on whether the signal represents absolute or relative temperature (see When to Apply Affine Conversion).
For example, you model a house-heating system, and you need to input the outdoor temperature. In the following diagram, the Constant source block represents the average outdoor temperature, in degrees Celsius, and the Sine source block adds the daily temperature variation. The average outdoor temperature, in this case, is 12 degrees Celsius. Daily variation with an amplitude of 8 makes the input outdoor temperature vary between 4 and 20 degrees Celsius.
This signal is an absolute temperature reading. Therefore, when the signal converts into kelvin for further computations, you need to specify that it should use affine conversion. Double-click the Simulink-PS Converter block, type C in the Input signal unit field, and select the Apply affine conversion check box.
As a result, the Simulink-PS Converter block outputs a value varying between 277 K and 293 K.