Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Something inside this code is confusing OpenModelica

Something inside this code is confusing OpenModelica

I expirienced a strange behavior of OMedit

I created a model with some connectors of Type RealInput and RealOutput. After some changes to code I decided to add units to the connectors via

Code:

(units="m")

This is where my problem started, cause after i saved that the input and output symbols disapeared from icon and diagram view, but are still visible in text view. So I deleted the units, but they did not come back.
I added a new connector RealInput and added again unit and it disapeared again from diagram and icon view.
The strange thing is, this problem is persistent in this model but does not appear in any other model I created, so I added the file as attachement.

After some more investigation i found out in any model that has some of following code included you can not add any new block. That is because there are no attributes written for this blocks. So if you look for the attributes of a new added block all fields are empty.
This is not specifically to the file I attached, but any other model I created using most of the code from this.

Another strange thing is, that besides the strange behavior for adding new blocks, the model can be used fine in simulation. Even added connectors without an attribute can be used to connect the model to others, altough not with the comfortable graphic connection interface but connecting via text input.

So can anyone with more expirience in programming than me look trough the code and give a hint why OpenModelica behaves this way.

Code:

model PowerProp_102_ "Model to generate a power demand of a propeller"

  extends PropellerIcon;
  import SI = Modelica.SIunits;
  import SI_conv = Modelica.SIunits.Conversions;
  outer Modelica.Fluid.System system "System wide properties";
  constant Real R_s(final unit = "J/(kg.K)") = 287.058 "Specific gas constant of dry air";
  //Variables
  // Power calculation
  Real j "Performance factor";
  Real c_p "Power coefficient";
  // Environment
  SI.Density rho = system.p_ambient / (R_s * system.T_ambient) "Density of the air specified in the system block";
  //Parameters
  // Blade parameters
  parameter SI.Diameter D(fixed = true) = 2 "Diameter of propeller" annotation(Dialog(group = "Blade parameters"));
  // Additional paramters for Cp Curves
  parameter Real mm = 0.026 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), mt = -1.72 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), tm = -0.044 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), tt = 3.13 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve"));
  //Diagnostics
  parameter SI_conv.NonSIunits.AngularVelocity_rpm n_start = 2000;
  //Connectors
  Modelica.Blocks.Interfaces.RealInput V(final unit = "m/s") "TAS" annotation(Placement(visible = true, transformation(origin = {-108, -1.33227e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-92, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput beta(final unit = "deg") "Blade angle" annotation(Placement(visible = true, transformation(origin = {-3.55271e-15, -108}, extent = {{-20, -20}, {20, 20}}, rotation = 90), iconTransformation(origin = {0, -100}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  Modelica.Blocks.Interfaces.RealInput n(final unit = "1/min") "Rotational speed" annotation(Placement(visible = true, transformation(origin = {108, -40}, extent = {{20, -20}, {-20, 20}}, rotation = 0), iconTransformation(origin = {98, -50}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput P_prop(final unit = "W") "Power demand" annotation(Placement(visible = true, transformation(origin = {112, 3.55271e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {100, 2}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
initial equation
  P_prop = 40000;
equation
  //Propellerleistung
  j = V / (n / 60 * D);
  c_p = P_prop / (rho * (n / 60) ^ 3 * D ^ 5);
  c_p = (mm * beta + mt) * j + tm * beta + tt;
  //Diagnostics
  //v = der(flange.s);
  annotation(Documentation(info = "<html>
<p>This model calculates the power demand of the propeller from true air speed V[m/s], blade angle &beta;[°], rotational speed n[1/min] and air density &rho; from the system definition.<br>
Air density is not included directly in the system definition block. So it is calculated using formula as follows.</p>
<code>&rho; = p / (R<sub>s</sub> * T)</code>
<p>with pressure p[Pa] and temperatur T[K] from the system block and specific gas constant of dry air R<sub>s</sub> = 287.058 J/Kg.K. For moist air there are several formulas that can be used e.g. Magnus-Formula, but in this iteration moist air is not considered.</p>
<p>The calculation of the power demand is done via a merely coarse interpolated propeller diagram. The propeller diagram is assumed linear and linear interpolated. Therefore there are four parameters to define this double linear system.</p>
</html>", revisions = "<html>
<ul>
<li><i>28 Jul 2015</i>
    by <a href=\"mailto:mayr19@hm.edu\">Matthias Maximilian Mayr</a><br>
       First release of model</li>
</ul>
</html>"), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Line(origin = {50, 0}, points = {{-50, 0}, {50, 0}}, thickness = 3), Line(origin = {-87, -25.14}, points = {{-13, 15.1437}, {5, 15.1437}, {13, 9.14373}, {13, -2.85627}, {7, -8.85627}, {7, -8.85627}}, color = {0, 85, 255}, thickness = 1.25, smooth = Smooth.Bezier), Line(origin = {-77, -19.14}, points = {{-13, 15.1437}, {5, 15.1437}, {13, 9.14373}, {13, -2.85627}, {7, -8.85627}, {7, -8.85627}}, color = {0, 85, 255}, thickness = 1.25, smooth = Smooth.Bezier), Line(origin = {-75, -11.14}, points = {{-13, 15.1437}, {5, 15.1437}, {13, 23.1437}, {9, 33.1437}}, color = {0, 85, 255}, thickness = 1.25, smooth = Smooth.Bezier), Line(origin = {-85, -3.14}, points = {{-13, 15.1437}, {5, 15.1437}, {13, 23.1437}, {9, 35.1437}, {-3, 35.1437}, {-3, 35.1437}}, color = {0, 85, 255}, thickness = 1.25, smooth = Smooth.Bezier), Text(origin = {1, 98}, extent = {{-109, 30}, {93, -22}}, textString = "%name"), Line(origin = {-1.99, -64.75}, points = {{-12.0087, 8.7525}, {-18.0087, -5.24753}, {1.99135, -13.2475}, {17.9913, -5.24753}, {13.9913, 8.7525}}, thickness = 1.5, arrow = {Arrow.None, Arrow.Filled}, smooth = Smooth.Bezier), Text(origin = {-60, 3}, extent = {{-6, 7}, {10, -15}}, textString = "V"), Text(origin = {32, -89}, extent = {{-16, 9}, {12, -5}}, textString = "beta"), Text(origin = {88, 15}, extent = {{-34, 31}, {14, -15}}, textString = "P_prop"), Text(origin = {82, -49}, extent = {{-16, 13}, {8, -11}}, textString = "n"), Line(origin = {42.01, -0.75}, rotation = -90, points = {{-12.0087, 8.7525}, {-18.0087, -5.24753}, {1.99135, -13.2475}, {17.9913, -5.24753}, {13.9913, 8.7525}}, thickness = 1.5, arrow = {Arrow.None, Arrow.Filled}, smooth = Smooth.Bezier)}));
end PowerProp_102_;

propmodel-102-.zip

Edited by: MProp - Jul-31-15 07:02:01

Re: Something inside this code is confusing OpenModelica

So I did some more research and found this behavior not only on my main Installation in Windows 1.9.2 (r25117), but also on Linux build 1.9.3(r25881).
Editing the attributes via rightliclick - attributes leads to crash on saving changes.

Re: Something inside this code is confusing OpenModelica

Ok, by using try and error method, I found the problem.
It is this line:

Code:

 parameter Real mm = 0.026 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), mt = -1.72 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), tm = -0.044 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")), tt = 3.13 annotation(Dialog(group = "Parameters for c_p Curve", tab = "Cp Curve")); 

By replacing it with one parameter per line, instead of all in one line, the Connectors and parameters are reappearing.
I don't know, if this is a bug or a feature, but it seems to me like a bug.

There are 0 guests and 0 other users also viewing this topic
You are here: