0

I would like to have a OpenModelica model like the following: Model from OMEdit

On the left side there is a "Real Input Connector" called u and on the right side there is a "Real Output Connector" called y. The Porpose of the model is just to take a value (u) multiply it with 2 and give back the output (y).

Now my questions: How do I set a value to the input variabe u?

Is the input connector the right block to do this?

jonie83
  • 1,136
  • 2
  • 17
  • 28

1 Answers1

0

This is valid if you want this gain to be a standalone submodule that you'll connect to other models. In that case you need to connect the output of a source to your input block. The standard library provides a variety in Modelica.Blocks.Sources, or you can make your own.

As a trivial example, with your example saved as My_Gain.mo, to connect to sinusoidal source:

model SampleModel
  My_Gain gain;
  Modelica.Blocks.Sources.Sine source;

equation
  connect(source.y, gain.u);
end SampleModel;

Without knowing more about what you're trying to do, it's hard to say if this is the right way to go about it, but it will work.

  • You answered the first part of my question. Thanks for that. In order to accept your answer I changed my question and made a second one which is here: http://stackoverflow.com/questions/20966511/how-can-i-call-an-openmodelica-model-in-python-with-ompython – jonie83 Jan 07 '14 at 07:56