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

Real Inputs not connected

Real Inputs not connected

Hi there,

I want to use a model which has several real Inputs (for several sensor signals). But I don't always need all of them. It would be great if modelica would ignore the Inputs that are not connected. Otherwise, I have more variables than equations.

The "cardinality" command doesn't work (is it just for connectors?) and I would like to avoid creating a bool for every Input that has to be set on "true" by the user if a real Input is needed.

Can anyone help? Thanks a lot
Zwieback

Re: Real Inputs not connected

I'm not entirely sure what you want to accomplish (an example would be good), but maybe it's conditional components you're looking for? When you declare a component you can give it a condition that determines whether it's enabled or not:

Code:


model M
  RealInput x if some_condition;
end M;

some_condition should be a scalar Boolean parameter expression (i.e. a Boolean expression that can be evaluated at compile-time by the compiler). A conditional component (x in this case) may only be modified or used in a connection (not in normal equations), and if the condition is false it will be removed from the model along with any connections to it.

Re: Real Inputs not connected

Thanks a lot for your response.

It's not a conditional component I was looking for. Let me first try to explain the application a bit more in detail:
Let's consider a whole oil circuit. Now, I'd like to measure several system pressures in order to control a pump.
For this reason, I'd like to create a "control unit" with 4 Input signals where I can connect 4 pressure sensors. But there are also situations where I just need one or two of them. Since I don't want to create one control unit for every situation, I'd like to deactivate the inputs which I don't need. In other words: I was looking for a code like "If the real Input is not connected to a sensor, ignore this input in order to balacne the equation system" (obviously, there are connect-equations missing if some of the inputs are left unconnected).

Until now, I couldn't find such a code. What I did is the following:
I use one more internal variable ("press1_internal") and connect this one to the real Input (which is for the pressure sensor actually).
The value of press1_internal is choosen large enough that the following process runs without complication.
This solution is in the style of the "presribed pump" out of the standard library (Fluid --> Machines).
One disadvantage is that the user has to choose whether a pressure sensor Input shall be used or not (boolean use_p1, ..._p2, ...). I hoped that there is a better solution for this problem...

Here is n extract of my code:

model SensorControl
  parameter Boolean use_p1 = false annotation(Dialog(group = "Pressure Sensor 1"));
  parameter Boolean use_p2 = false annotation(Dialog(group = "Pressure Sensor 2"));
    "..."
  Modelica.Blocks.Interfaces.RealInput press1 annotation(Placement(visible = true, transformation(origin = {-70, -110}, extent = {{-10, -10}, {10, 10}}, rotation = 90), iconTransformation(origin = {-70, -55}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  Modelica.Blocks.Interfaces.RealInput press2 annotation(Placement(visible = true, transformation(origin = {0, -110}, extent = {{-10,
      "..."
protected
  Modelica.Blocks.Interfaces.RealInput press1_internal "Needed to connect to conditional connector";
  Modelica.Blocks.Interfaces.RealInput press2_internal "Needed to connect to conditional connector";
    "..."
equation
  connect(press1, press1_internal);
  if not use_p1 then
    press1_internal = 99999999;
  end if;
  connect(press2, press2_internal);
  if not use_p2 then
    press2_internal = 99999999;
  end if;
    "..."
end SensorControl;

Thank you very much. Regards, Zwieback

There are 0 guests and 0 other users also viewing this topic