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

How to do the flow control in openModelica?

How to do the flow control in openModelica?

Hi friends,

Recently, I did some exercises in OpenModelica, in order to get a better understanding. I was thinking that how can we do the flow control in openModelica, especially in the graphical interface. As I know, there is a if-else block in simulink. So is there a similar one in modelica? I only found a switch component. However, it seems not flexible, and it cannot accept multiplexed inputs. So another question is how to make this component able to accept multiplexed inputs.

The following is a simple example for my second question. Just in case my poor English. Many thanks!

model ttt

  Modelica.Blocks.Routing.DeMultiplex2 deMultiplex2_1
    annotation (Placement(transformation(extent={{64,-25},{74,-15}})));
  Modelica.Blocks.Sources.Constant const(k=15)
    annotation (Placement(transformation(extent={{-68,22},{-48,42}})));
  Modelica.Blocks.Sources.Constant const1(k=8)
    annotation (Placement(transformation(extent={{-68,-10},{-48,10}})));
  Modelica.Blocks.Routing.Multiplex2 multiplex2_1
    annotation (Placement(transformation(extent={{-20,-4},{0,16}})));
  Modelica.Blocks.Logical.Switch switch1
    annotation (Placement(transformation(extent={{22,-30},{42,-10}})));
  Modelica.Blocks.Sources.BooleanConstant booleanConstant
    annotation (Placement(transformation(extent={{-100,-30},{-80,-10}})));
  Modelica.Blocks.Sources.Constant const2(k=10)
    annotation (Placement(transformation(extent={{-32,-58},{-12,-38}})));
equation
  connect(const.y, multiplex2_1.u1[1]) annotation (Line(
      points={{-47,32},{-34,32},{-34,12},{-22,12}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(const1.y, multiplex2_1.u2[1]) annotation (Line(
      points={{-47,0},{-22,0}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(booleanConstant.y, switch1.u2) annotation (Line(
      points={{-79,-20},{20,-20}},
      color={255,0,255},
      smooth=Smooth.None));
  connect(const2.y, switch1.u3) annotation (Line(
      points={{-11,-48},{10,-48},{10,-28},{20,-28}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(switch1.y, deMultiplex2_1.u[1]) annotation (Line(
      points={{43,-20},{53,-20},{53,-20.5},{63,-20.5}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(multiplex2_1.y[1], switch1.u1) annotation (Line(
      points={{1,5.5},{10,5.5},{10,-12},{20,-12}},
      color={0,0,127},
      smooth=Smooth.None));
  annotation (uses(Modelica(version="3.2")), Diagram(graphics));
end ttt;

Kind regards,

Rui

Re: How to do the flow control in openModelica?

Could anybody give me some advises? Do I need to code these components by myself?

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