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
  • » bjdekruif
  • » Profile

Posts

Posts

Hello Andy,

I like that you want to model the conversion by equal power, but you are missing an equation. I think you still need to specify that there is a relation between force and current (if you go for a motor type of actuator).  There are these kind of models already available. Might Modelica.Electrical.Analog.EMF or Modelica.Electrical.Analog.Gyrator not be ok for you?

Good luck
Bas

Hello Viatorus,

With the filter you just have set the spectrum. Changing the standard deviation can be done by multiplying the output signal. In the Noise library there is an example on how to calculate the std.

Hope it helps
Bas

Apr-10-15 05:30:04
I would like to change the color in an animation dynamically.

Hello Adrian,

Thanks for your help (again). This does the trick. Now I can show when I lock a joint visually.

I was hoping for a solution that could be used to change all the properties of a visualization component (eg width, etc)  but I can try to discover this based on the signal arrow model..

Bas

Hello Viatorus,

I can think of two approaches:

1) use the white noise source and filter it. In Modelica.Blocks.Continuous.Filter several filters, including bandpass are defined. This would give you the noise with the correct spectrum

2) define a PSD (power spectral density) in the Noise toolbox. This is more involved, but you have a better control on what you do (so you have to understand it better too.)  If you look in Noise.Example.ComparePSD, you find how you can redeclare the PSD. You need the PSD_Interpolation. For this, you have to determine the convolution terms yourself.(google: bandpass filter coefficients).

Hope this helps
Bas

Apr-07-15 07:27:36
I would like to change the color in an animation dynamically.

Hello all,

I have been working for some time with the multibody library and its animations and this works great. Thanks for all the time people have put in here. I can now simulate exoskeletons and have them moving, showing everyone what is going on.

Of course, with the animations working, I would make it even more clear. For this I would like to change values of the visualization objects dynamically. In the documentation it is written that this is possible, when 'appropriate expressions in the input fields' are given. I cannot get this to work, and hope I do something stupid so that it is easily corrected.

The minimal example below should give an arrow changing from red to green. However, the arrow is always red. In the results I do see that the values of the fa.color change as specified. I hope somebody can give a pointer to the correct solution?

Thanks in advance
Bas

-------------------------------------------------------------------------------------------------
model tst
  inner ModelicaServices.Modelica3D.Controller m3d_control;
  inner Modelica.Mechanics.MultiBody.World world;
  Integer clr[3];
  Modelica.Mechanics.MultiBody.Visualizers.FixedArrow fa(color = clr);
equation
  connect(world.frame_b, fa.frame_a);
  clr = if time < 0.5 then {250, 0, 0} else {0, 250, 0};
end tst;

Hello,

It is working now for me! (r25022)
Thanks for all your work!

Bas

Mar-09-15 10:34:57
On a win32 system, the visualization gives me a new(?) error

Hello all,

I try to get the visualization working for the multibody dynamics toolbox. For this I tried two routes:

- the one described in the manual: (https://build.openmodelica.org/Document … ca3D.html)
- the one described in the forums: (https://www.openmodelica.org/forum/defa … ain#p5284)

Some time ago, I got it working with the approach suggested in the forums, but now it won't work anymore. I am using nightly release r24986.

The error that I now get, and previously didn't is the following
[1] 10:06:11 Translation Error
No system for the symbolic initialization was generated.

The dbus-server is running on the background, so this doesn;t seem to be the problem.
Can someone give me some pointers on how to get the visualization working on a windows system?

Thanks for any help.
Bas

Mar-09-15 10:33:42
On a win32 system, the visualization gives me a new(?) error

Hello all,

I try to get the visualization working for the multibody dynamics toolbox. For this I tried two routes:

- the one described in the manual: (https://build.openmodelica.org/Document … ca3D.html)
- the one described in the forums: (https://www.openmodelica.org/forum/defa … ain#p5284)

Some time ago, I got it working with the approach suggested in the forums, but now it won't work anymore...

The error that I now get, and previously didn't is the following
[1] 10:06:11 Translation Error
No system for the symbolic initialization was generated.

The dbus-server is running on the background, so this doesn;t seem to be the problem.
Can someone give me some pointers on how to get the visualization working on a windows system?

Thanks for any help.
Bas

Hello Gregory,

I made a mechanical switching rod that might be useful for you. It has a boolean input 'fixed' in which case the connection is a solid rod. If the boolean is false, the connection is open. I've used it for two colliding masses, but you can use it to make one the world.

The code of the switching element and the model are below. (They get messy here due to the annotations.)
Hopefully it helps.

Bas

model SwitichingRod "A connection between two masses that can be on or off. Can be used for non-elastic collision."
  parameter Real small = 1e-12;
  import Modelica.Mechanics.Translational.Interfaces.Flange_a;
  import Modelica.Mechanics.Translational.Interfaces.Flange_b;
  import Modelica.Blocks.Interfaces.BooleanInput;
  Real t;
  Real f, dv;
  Flange_a flange_a annotation(Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Flange_b flange_b annotation(Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  BooleanInput fixed annotation(Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {0, 100}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
equation
  f = t * (if fixed then 1 else 0);
  dv = t * (if fixed then small else 1);
  flange_a.f = -f;
  flange_b.f = f;
  der(flange_b.s) - der(flange_a.s) = dv;
  annotation(Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}), graphics = {Line(points = {{-100, 0}, {-55, 0}}, color = {0, 127, 0}), Line(points = {{54, 0}, {100, 0}}, color = {0, 127, 0}), Polygon(points = {{50, -90}, {20, -80}, {20, -100}, {50, -90}}, lineColor = {128, 128, 128}, fillColor = {128, 128, 128}, fillPattern = FillPattern.Solid), Line(points = {{-60, -90}, {20, -90}}, color = {0, 0, 0}), Rectangle(extent = {{-55, 3}, {53, -4}}, lineColor = {160, 160, 164}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid), Line(points = {{-100, -29}, {-100, -61}}, color = {0, 0, 0}), Line(points = {{100, -61}, {100, -28}}, color = {0, 0, 0}), Line(points = {{-98, -60}, {98, -60}}, color = {0, 0, 0}), Polygon(points = {{-101, -60}, {-96, -59}, {-96, -61}, {-101, -60}}, lineColor = {0, 0, 0}, fillColor = {0, 0, 0}, fillPattern = FillPattern.Solid), Polygon(points = {{100, -60}, {95, -61}, {95, -59}, {100, -60}}, lineColor = {0, 0, 0}, fillColor = {0, 0, 0}, fillPattern = FillPattern.Solid), Text(extent = {{-44, -41}, {51, -57}}, textString = "Length L", lineColor = {0, 0, 255})}), Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2}), graphics = {Line(points = {{-100, 0}, {-55, 0}}, color = {0, 127, 0}), Line(points = {{53, 0}, {99, 0}}, color = {0, 127, 0}), Polygon(lineColor = {128, 128, 128}, fillColor = {128, 128, 128}, fillPattern = FillPattern.Solid, points = {{50, -90}, {20, -80}, {20, -100}, {50, -90}}), Line(points = {{-60, -90}, {20, -90}}), Rectangle(lineColor = {160, 160, 164}, fillColor = {192, 192, 192}, fillPattern = FillPattern.Solid, extent = {{-55, 10}, {53, -10}}), Text(lineColor = {0, 0, 255}, extent = {{-150, 80}, {150, 40}}, textString = "%name"), Line(origin = {-14.61, 1.04}, points = {{-12.7733, 22.6698}, {12.7733, -20.5984}}, thickness = 3), Line(origin = {2.6282, 1.93758}, points = {{-12.7733, 22.6698}, {12.7733, -20.5984}}, thickness = 3)}), experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02));
end SwitichingRod;

model test
  Modelica.Mechanics.Translational.Components.Mass mass1(m = 1, s(start = 0), v(start = 1)) annotation(Placement(visible = true, transformation(origin = {-80, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Fixed fixed1 annotation(Placement(visible = true, transformation(origin = {-140, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Components.Spring spring1(c = 1) annotation(Placement(visible = true, transformation(origin = {-120, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  SwitichingRod switichingrod1 annotation(Placement(visible = true, transformation(origin = {-40, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Logical.Hysteresis hysteresis1(uLow = 0.49, uHigh = 0.5) annotation(Placement(visible = true, transformation(origin = {-60, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionsensor1 annotation(Placement(visible = true, transformation(origin = {-100, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(positionsensor1.flange, mass1.flange_a) annotation(Line(points = {{-110, 80}, {-136.232, 80}, {-136.232, 57.971}, {-90.4348, 57.971}, {-90.4348, 40}, {-90, 40}}, color = {0, 127, 0}));
  connect(positionsensor1.s, hysteresis1.u) annotation(Line(points = {{-89, 80}, {-93.3333, 80}, {-72, 80}, {-72, 80}}, color = {0, 0, 127}));
  connect(hysteresis1.y, switichingrod1.fixed) annotation(Line(points = {{-49, 80}, {-39.4203, 80}, {-39.4203, 50}, {-40, 50}}, color = {255, 0, 255}));
  connect(switichingrod1.flange_b, fixed1.flange) annotation(Line(points = {{-30, 40}, {-26.087, 40}, {-26.087, 0}, {-139.13, 0}, {-139.13, 0}}, color = {0, 127, 0}));
  connect(mass1.flange_b, switichingrod1.flange_a) annotation(Line(points = {{-70, 40}, {-49.4822, 40}, {-49.4822, 39.8159}, {-49.4822, 39.8159}}, color = {0, 127, 0}));
  connect(spring1.flange_a, fixed1.flange) annotation(Line(points = {{-130, 40}, {-140.161, 40}, {-140.161, 0.460299}, {-140.161, 0.460299}}, color = {0, 127, 0}));
  connect(spring1.flange_b, mass1.flange_a) annotation(Line(points = {{-110, 40}, {-90.2186, 40}, {-90.2186, 39.8159}, {-90.2186, 39.8159}}, color = {0, 127, 0}));
  annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 90}}, preserveAspectRatio = true, initialScale = 0.1, grid = {1, 1})), Diagram(coordinateSystem(extent = {{-150, -100}, {150, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {0.02, 0.02})), experiment(StartTime = 0, StopTime = 10, Tolerance = 1e-06, Interval = 0.02));
end test;



Oct-31-14 06:50:08
The examples in the Modelica_synchronous library won't run

When I use the +std=3.3 at the simulation flags in OMedit, it still won't flatten.

This flag is to specify the language version it uses for compilation, if I understand correctly. The error is just that it cannot find the class 'Clock'.  It seems that this wouldn't be solved by specifying the language. I don't start a simulation yet.

Thanks
Bas

Oct-30-14 19:54:01
The examples in the Modelica_synchronous library won't run

ok,

thanks for the quick reply!

bas

Oct-30-14 19:40:50
The examples in the Modelica_synchronous library won't run

Hello,

I would like to use the elements in the Modelica_synchronous library.  However, if I try to flatten Modelica_Synchronous.Examples.RealSignals.Sample1 (or any other example) I get the error message:


[C:/OpenModelica1.9.1/lib/omlibrary/Modelica_Synchronous 0.92/ClockSignals.mo:642:3-674:11] Error: Class Clock not found in scope Modelica_Synchronous.ClockSignals.Interfaces.

It is completely true that this class doesn't exist.
Does anybody has any pointers to solve this?
Thanks in advance
Bas

Oct-23-14 05:25:24
Initialise the num/den of a transferfunction with a function call
Category: Programming

Hello,

I got it working, and just wanted to post the result if anybody want do the same in the future. If somebody knows a better solution, please feel free to comment on the solution. Anyway:

model PD
   extends Modelica.Blocks.Continuous.TransferFunction(a = p, b = q);
    parameter Real[2] p(start = {1, 1},fixed = false);
    parameter Real[2] q(start = {1, 1},fixed = false);
  initial equation
    (p, q) = getA(m=10.3);
end PD;

With the function getA I can calculate the num and den for a PD controller based on the mass, bandwidth and phase margin.  These are passed to the transferfunction and it simulates now with these coefficients.


Bas

Oct-22-14 08:54:50
Initialise the num/den of a transferfunction with a function call
Category: Programming

Hello,

I want to create a transferfunction in which I initialise the coefficients a,b with an external function call. I do this with:

extends Modelica.Blocks.Continuous.TransferFunction((a,b) =getA(m=26.0))

However, this gives me the error message "missing token ')'". The function getA is rather trivial a:

function getA
  input Real m;
  output Real a[2];
  output Real b[2];
algorithm
  a := {4, 2 * m};
  b := {9, 10};
end getA;

If I try it with one output, it works fine, but I would like to initialise both with one function. Does anyone know how this can be approached?

----------
addition: The goal of this whole exercise is to initialise the transfer function based on some other parameters. With these first parameters, I do some calculations, and this results in the coefficients of the transferfunction. Any other way of implementing this, is perfectly fine with me, of course
----------

Thanks for any pointer.
Bas

May-02-14 15:35:05
Cannot simulate FMU as the integer parameter contains a /*ENUM:StateS

Hello Adeel,

I am running r19512, so I have to update. Did not see the other ticket.

Thanks
Bas

May-02-14 14:00:59
Cannot simulate FMU as the integer parameter contains a /*ENUM:StateS

Hello,

I try to simulate a FMU that I made with OpenModelica with PySimulator. When the model contains some masses, I get into troubles. I get an error:

invalid literal for int() with base 10: '3 /*ENUM:StateSelect.default*/'

This looks very much like the (closed) ticket  at https://trac.openmodelica.org/OpenModelica/ticket/2441
I run the version 1.9.2beta which has a higher release number, so I didn't expect this error.

Can somebody help me to overcome this problem?

Thanks in advance
Bas

Apr-20-14 09:56:19
problems with getting a bode plot/ cannot get import to work in OMShel

Hello,

Thanks for your help.
I found how I could linearize the system and then read it in Matlab. Still, I didn't find my happy work flow to get a bode plot. I see several routes to get there:

i)  use 'linearize(model)'  in OMShell, and read the result in Matlab. --> I don't understand the format of the matrices. 'name' and   'description'  give 64 items, but my data matrices are  18x2 and 27x502. With these dimensions I find it difficult to go to a state space system.

ii) use the commands available in OMShell. This would be my preferred approach, but don't know how to do this. Can this be done?

iii) use exportDAEtoMatlab / dumpXMLDEA and work from there. The output of these files are not clear to me.

What would be the 'best' approach? Could someone point me to some manuals to understand this better? (I've read the user manual and some of the tutorials and could find it there. Also in the book of Peter Fritzson I couldn't find this)

Thanks for all help!

Bas de Kruif

Apr-18-14 14:00:32
problems with getting a bode plot/ cannot get import to work in OMShel

Hello all,

I am a newbe in OpenModelica and I hope you can help me with my problem.

I would like to have a plot depicting the frequency response of a linear system, a bode plot. In the standard libraries I found the Modelica_LinearSystems2 that would be able to give me such a plot. So I started with the documentation of this library. First you have to import the needed functions. I tried this in OMShell with

>>>  import Modelica_LinearSystems2.Math.Complex
Error occurred building AST
Syntax Error
[<interactive>:1:0-1:6:writable] Error: Parser error: Unexpected token near: import (IMPORT)

So, it seems that I am not allowed to directly import this functions. In order to get a bode plot, I hope someone can help me how I can import the Modelica_LinearSystems2 library and use it ? Is this the best way, or should I do this differently?

Thanks in advance
Bas

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