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

HideResult and protected in OMedit

HideResult and protected in OMedit

Hello,
I am new to Modelica and OMedit and not sure if this is the right place to post so I apologize in advance if it isn't.
I want to create my own package based on the MSL.
A lot of my models are nested models. I would like to hide the results for specific parameters and variables in the variables browser.
(The user will use them as black boxes and is only interested in the in- and output)

But it seems I don't understand the usage of protected and HideResult.

For example:

Code:


model HideResult
  parameter Real param = 1;
  Real var annotation(HideResult = true);
equation
  var = param;
end HideResult;

Despite "HideResult = true", "var" shows up in the variables browser.

I tried to declare the parameter and variable as "protected"

Code:


model HideResult
protected
  parameter Real param = 1;
  Real var;
equation
  var = param;
end HideResult;

But this doesn't change the visibilty either.

The only way to hide at least the variable "var" is to further add an initial equation.
In this case "var" doesn't show up in the variable browser.

Code:


model HideResult
protected
  parameter Real param = 1;
  Real var;
initial equation
  var = param;
equation
  var = param;
end HideResult;

Also the filter option in the simulation settings has no effect.

Can somebody explain this to me?

I am afraid "HideResult" or the variable filter doesn't apply to the variable browser in OMedit, but rather to the created file.
In this case is it possible to hide specific parameters and variables in OMedit?

Thanks!

Edited by: lumaxo - Aug-27-14 17:01:34

Re: HideResult and protected in OMedit

OpenModelica does not support HideResult. So adding it does nothing. Even if a variable is protected, OpenModelica will sometimes allow you to change its start value (which is what is shown in the variables browser).
Parameters are always output to the result-file since they are so small. Alias variables are also always output if the main variable is. So:

Code:

model HideResult

protected
  parameter Real param = 1;
  Real var;
equation
  var = 3 * param;
end HideResult;

If you only have var = param, param does not take up space in the mat file and is output anyway.

Re: HideResult and protected in OMedit

Thanks, now I know how to hide variables in my own models.
But the MSL models I'm using are declared as public. So I have to use the filter option, right?
Is it possible to define the filter as an annotation?
How would you create a "black box" like model consisting of MSL models?

Edited by: lumaxo - Aug-28-14 13:35:15

Re: HideResult and protected in OMedit

You could always add the MSL components as protected components.

Re: HideResult and protected in OMedit

Then I am doing it wrong.

For example: I created a simple circuit with 2 parallel resistors, a constant voltage and a ground.
I'm not interested in the current in each resistor. The only thing I would like to see in the variables browser
is the total resistance and the current from the constant voltage.
Declaring the ground and the resistors as protected doesn't change anything.

Code:

model SimpleCircuit

  Modelica.Electrical.Analog.Sources.ConstantVoltage constantvoltage(V = 10);
  Modelica.SIunits.Resistance R_Total;
protected
  Modelica.Electrical.Analog.Basic.Ground ground;
  Modelica.Electrical.Analog.Basic.Resistor resistor2(R = 10);
  Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 20);
equation
  R_Total = resistor1.R * resistor2.R / (resistor1.R + resistor2.R);
  connect(constantvoltage.n,ground.p);
  connect(constantvoltage.p,resistor1.p);
  connect(constantvoltage.p,resistor2.p);
  connect(resistor1.n,ground.p);
  connect(resistor2.n,ground.p);
end SimpleCircuit;

https://www.openmodelica.org/images/agorapro/attachments/3990/mini_variable-browser.png

Re: HideResult and protected in OMedit

Hi lumaxo,
I know your post is pretty old now, but I'm wondering if you finally found a way to hide "this all". I have almost the same problem and neither the prefix "protected" nor the annotation (HideResult=true) changes a thing. If you've found a solution, I would be happy you hear it!
Thanks in advance,
Amelia

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