I am new to modelica. I would like to add two static numbers in OpenModelica and display the result in the Modeling view.
source1 = 10 # Modelica.Blocks.Sources.Constant
source2 = 20 # Modelica.Blocks.Sources.Constant
result = source1 + source2 # Modelica.Blocks.Math.Add
In order to do so, I created two sources with a constant real value and included a Math block for addition (also see full model code below).
I am able to run the simulation and select the result of the add block to show it as a plot in the Plotting view:
However, I would prefer to stay in the Modeling view and have some display element, showing the resulting value of 30:
=> Are there display components in OpenModelica? (could not find any)
Or do I always need to switch to the plotting view (even for static models that would not need to include a time variable)?
If there is no display component... is it possible to create it on my own? (Then components would need to be able to access simulation results.)
model demo
Modelica.Blocks.Sources.Constant source1(k = 10) annotation(
Placement(visible = true, transformation(origin = {-70, 52}, extent = {{-10, 10}, {10, -10}}, rotation = 0)));
Modelica.Blocks.Sources.Constant source2(k = 20) annotation(
Placement(visible = true, transformation(origin = {-70, -12}, extent = {{-10, 10}, {10, -10}}, rotation = 0)));
Modelica.Blocks.Math.Add add annotation(
Placement(visible = true, transformation(origin = {-12, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(source1.y, add.u1) annotation(
Line(points = {{-58, 52}, {-24, 52}, {-24, 16}}, color = {0, 0, 127}));
connect(source2.y, add.u2) annotation(
Line(points = {{-58, -12}, {-24, -12}, {-24, 4}}, color = {0, 0, 127}));
annotation(
uses(Modelica(version = "4.0.0")),
Diagram);
end demo;
Related questions: