- Index
- » Users
- » rui
- » Profile
Posts
Posts
Hi everyone,
I met a error, when I simulate the following codes in openmodelica. I thought it might be a bug of openmodelica, as the codes can be simulated in dymola2013(demo) without any problems. Can somebody fix it or tell me how to avoid this error? Many thanks!
The simulation time is set to 2 seconds.
Code:
model rr
Real v(start =0);
Real H;
equation
der(H)=H+1;
when time > 1 then
v = max(H);
end when;
end rr;
The error information:
base_array.c: the number of array dimensions are < 0!
Assertion failed: base_array_ok(a), file util/real_array.c, line 1473
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Hi everybody,
I was trying to execute 2 models one by one in a simulation via state chart. The pseudo-code follows. In model test, there are two blocks, stateA and stateB. At the beginning of the simulation, stateA is activated. 10 seconds later, stateA is deactivated while stateB is activated. Could anybody give me some advises? Thanks a lot!
model test
inner Integer v(start = 1);
block StateA
outer output Integer v;
equation
v = previous(v) + 2;
end StateA;
StateA stateA;
block StateB
outer output Integer v;
equation
v = previous(v) - 1;
end StateB;
StateB stateB;
equation
initialState(stateA);
transition(stateA, stateB, t >= t0, immediate=false);
end test;
Hi guys,
Is there an IF Block (just like in Simulink) in Modelica? If not, how can I achieve this functionality. I have three models and depending on time, only one of these needs to be executed at that particular time. Can we use "When" or "If" clauses for this problem?
Rui
Could anybody give me some advises? Do I need to code these components by myself?
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
Hi friends,
I have created a sub-model successfully by using the graphic tool provided by OMEdit. However another question arose in my mind. If I use modelica language to code a model, how can I add connectors for this model? Actually, I tried several times, it didn't work as I thought.
Kind regards,
Rui
Thank you, sjoelund.se!
To be honest, I did not realize I needed connectors until yesterday. Thanks a lot!
Hi guys,
Can anyone tell me how I can do the co-simulation in OpenModelica? That means if I have created several models in openmodelica, how I can connect them together to do the co-simulation. Just like connect the components of modelica standard library in the OMEdit.
Please forgive my stupid question, I am just a beginner.
Kind regards,
Rui
- Index
- » Users
- » rui
- » Profile