WOLFRAM SYSTEM MODELER
ReusableConversion |
SystemModel["SystemModelerExtras.Experimental.Units.Examples.ReusableConversion"]
By creating a new block class extending from Convert, it is possible to make a reusable conversion block with a name and an icon that can make the conversion more easily recognized in a diagram view.
In this example, there is a local definition of a To_Joules block with custom icon. (It can be noted that the unit unit of the block is made final as the block's icon corresponds to this specific choice of target unit.) The new block is then used three times in the example, being fed with three different units of energy to emphasize that the block is not restricted to a specific source unit.
Note that the const4 block differs from const2 in that const4 uses unit = "J" whereas const2 uses unit = "eV" and therefore requires a conversion before it can be added to a quantity in Joules. The reason that the two blocks look similar in the diagram view is that const4 uses displayUnit = "eV". Using displayUnit is generally preferred over selecting non-SI base units in the unit, due to lack of a standard Modelica way of safely converting between units. Sometimes, however, working with non-SI base units in the unit is unavoidable when seeking the maximum safety offered by the unit handling system, and this is when the Convert block is useful.
const1 |
Type: Constant Description: Generate constant signal of type Real |
|
---|---|---|
const2 |
Type: Constant Description: Generate constant signal of type Real |
|
const3 |
Type: Constant Description: Generate constant signal of type Real |
|
to_Joules1 |
Type: To_Joules |
|
to_Joules2 |
Type: To_Joules |
|
to_Joules3 |
Type: To_Joules |
|
const4 |
Type: Constant Description: Generate constant signal of type Real |
|
add |
Type: Add Description: Output the sum of the two inputs |