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
  • Index
  • » Users
  • » bull
  • » Profile

Posts

Posts

I am trying out a very simple first order time integral and I keep having "Matrix singular!" problem during simulation.

Can someone point out what is wrong? I think something is fundamentally wrong here but I still can't figure it out for two days now >.<

The model that I try to simulate is the following:

model ModelExample
  TimeIntegral timeintegral1 annotation(Placement(visible = true, transformation(origin = {4, -6}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.TimeTable timetable1(table = [0, 0; 0.05, 1; 0.1, 2]) annotation(Placement(visible = true, transformation(origin = {-66, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.TimeTable timetable2(table = [0, 0; 0.05, 1; 0.1, 2]) annotation(Placement(visible = true, transformation(origin = {-66, 36}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.TimeTable timetable3(table = [0, 0; 0.05, 1; 0.1, 2]) annotation(Placement(visible = true, transformation(origin = {-66, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(timetable3.y, timeintegral1.dot_x[3]) annotation(Line(points = {{-55, 70}, {-22, 70}, {-22, 0}, {-6, 0}}, color = {0, 0, 127}));
  connect(timetable2.y, timeintegral1.dot_x[2]) annotation(Line(points = {{-55, 36}, {-28, 36}, {-28, 0}, {-6, 0}}, color = {0, 0, 127}));
  connect(timeintegral1.x[3], timeintegral1.x0[3]) annotation(Line(points = {{14, -6}, {34, -6}, {34, -32}, {-22, -32}, {-22, -12}, {-6, -12}, {-6, -12}, {-6, -12}, {-6, -12}}, color = {0, 0, 127}));
  connect(timeintegral1.x[2], timeintegral1.x0[2]) annotation(Line(points = {{14, -6}, {28, -6}, {28, -28}, {-18, -28}, {-18, -12}, {-6, -12}, {-6, -12}}, color = {0, 0, 127}));
  connect(timeintegral1.x[1], timeintegral1.x0[1]) annotation(Line(points = {{14, -6}, {22, -6}, {22, -24}, {-14, -24}, {-14, -12}, {-8, -12}, {-8, -12}, {-8, -12}}, color = {0, 0, 127}));
  connect(timetable1.y, timeintegral1.dot_x[1]) annotation(Line(points = {{-55, 0}, {-6, 0}, {-6, 0}, {-6, 0}}, color = {0, 0, 127}));
  annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})));
end ModelExample;


where TimeIntegral is a model defined as such:


model TimeIntegral
  import SI = Modelica.SIunits;
  parameter SI.Time delta_t = 0.01 "integration time step in seconds";
  Modelica.Blocks.Interfaces.RealInput dot_x[3] annotation(Placement(visible = true, transformation(origin = {-110, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-104, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput x0[3](start = {0, 0, 0}) annotation(Placement(visible = true, transformation(origin = {-110, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-104, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput x[3](start = {0, 0, 0}) annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {104, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  x = x0 + dot_x * delta_t;
  annotation(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 = {Text(origin = {120, 10}, extent = {{-8, 6}, {8, -6}}, textString = "x"), Text(origin = {-124, -40}, extent = {{-8, 6}, {8, -6}}, textString = "x0"), Text(origin = {-122, 60}, extent = {{-8, 6}, {8, -6}}, textString = "dot_x"), Rectangle(origin = {0, -2}, extent = {{-96, 88}, {96, -88}}), Text(origin = {7, 2}, extent = {{-53, 18}, {53, -18}}, textString = "x = x0 + delta_t*dot(x)")}));
end TimeIntegral;

It works. Thank you!! current/smile

Hi,

I am trying to call a library ext_lib.o written in C with the following:

function ext_funcname
  input Integer n;
  output Integer result;

  external "C" result = funcname(n);
  annotation(Library = "ext_lib");
end ext_funcname;

While trying to compuile to simulate, I get the following error:

L"/usr/lib/omc" -L"/usr/lib" -Wl,-rpath,"/usr/lib/omc" -Wl,-rpath,"/usr/lib"    -Wl,-Bsymbolic-functions -Wl,-z,relro -lSimulationRuntimeC -llapack -lblas -lm -lgc -lpthread -rdynamic
/usr/bin/ld: cannot find -lext_lib
collect2: error: ld returned 1 exit status
make: *** [omc_main_target] Fehler 1
Compilation process exited with code 2

The ext_lib.o and the .mo where the function is called are in the same folder, why can't the compiler find the external C function?

Thank you!


I would love to write my own FMI if it is not too time-consuming so that the bugs are more transparent to me. C or Python are my prefered languages.

Do you have in mind a good tutorial or an example code?

Thank you for your reply.

Do you know an existing FMI that allows to do so? I am currently looking at PyFMI but I haven't got anything concrete yet.

Or do I have to write my own FMI?

Hello,

I intend to use OpenModelica for modelling an aircraft and export the model to .fmu. In the simulation, a graphical UI will be used for changing in real-time certain parameters of the aircraft and to output in real-time parameters of the aircraft. The graphical UI will be programmed in C++ and not in OpenModelica.

My question is, how can I send the information provided by the operator through the graphical UI to the FMI? Can I use a network connector e.g. netcat?

I haven't found any clue on the internet and would appreciate to have some ideas. If this is not possible, I will have to program the model of the aircraft in native C which will be troublesome for any future alteration.

Thank you!
Jean

Hello, I have got replies from OpenModelica developers yesterday which had confirmed that interactive simulation to modify system parameters during simulation runtime is no longer possible with the latest version of OpenModelica.

What about the changing the inputs? A more concrete use case is as follows:
I have an external function written in C++ which controls the aircraft simulated using OpenModelica. The external control function commands during simulated runtime the simulated aircraft by changing the input variables of the system. The connection between the external control function and the simulated system is done by TCP sockets for example.

I can't find any clue as to whether this is possible with OpenModelica. Can anybody share his/her experience with me?

Thank you.

Jan-26-15 13:43:12
OpenModelica interactive simulation example

Thank you. I will try out as advised.  current/wink

Jan-26-15 12:53:54
OpenModelica interactive simulation example

Thank you for pointing that out.

Do you know if there is another workaround for my problem? I would love to change some parameters of my model during simulation. Is the function available with Dymola?

Jan-26-15 12:48:44
OpenModelica interactive simulation example

So Chap.5 of the latest user documentation is no longer true?

Jan-26-15 12:42:33
OpenModelica interactive simulation example

If interactive simulation is removed now in the latest OpenModelica version, how can one work on changing the model parameters during simulation running? Does that mean that with the latest OpenModelica, one can only have static and predefined parameters for the model used?

The users documentation that I am using in from 2014-10-24 for OpenModelica 1.9.1.

Jan-26-15 12:27:29
OpenModelica interactive simulation example

Hi everybody! I am new to OpenModelica and am currently testing out the interactive simulation as explained in Chap. 5 of the users documentation.

I tried loading the TwoTanks model with loadModel(TwoTanks); however I got the following error message:

false
Error: Failed to load package TwoTanks (default) using MODELICAPATH /usr/lib/omlibrary:/home/cosima/.openmodelica/libraries/


I could not find any file named "TwoTanks" in the installation folder and therefore, I supposed that the model is missing in my library. The .zip file of the model was downloaded and manually added to the library folder but nothing works either.

I have to admit that I haven't read every page carefully in the documentation and I am still trying to look for clues in it. However, it would be helpful if I could get a hint as to where to look first or what to do.

Thank you very much!

  • Index
  • » Users
  • » bull
  • » Profile
You are here: