Message Boards Message Boards

3 Replies
2 Total Likes
View groups...
Share this post:

TableCurrent with WSMLink

Posted 11 years ago
I am trying to use the TableCurrent block in SystemModeler with WSMLink.  The idea is to define a current profine in Mathematica and then use it to trigger the simulation in SystemModeler.  Has anyone done this successfully?  I cannot assign the table of values inside Mathematica.

3 Replies
WSMInputFunctions takes rules where the targets are functions. If you have measured current data you can create a function with e.g. the Interpolation function in Mathematica.
Also, make sure that you name the input u in your model, the error message indicates that it is not found.
POSTED BY: Peter Aronsson
Thanks for the response.  I only saw it today.  I still have no success.  I changed the component to SignalCurrent, but keep getting the message:

WSMSimulate::invu: The inputs {u} were not recognized.

Irrespective of the function I provide to the input.  Ideally I would like to use it as 

sim = WSMSimulate["Battery.BatteryDischarge_FdP", {0, 1775},
  WSMInputFunctions -> {"u" -> current}]

Where current is a vector containing measured current data that I want to use to stimulate the simulation.


The table is a parameter in the TableCurrent block. You can set parameters by using
WSMSimulate["mymodel", {tstart,tend}, WSMParameterValues-> {"tableCurrent.table[1,1"->1,...}]
The drawback here is that you need to allocate the correct size of the table in the model before calling WSMSimulate. WSMParameterValues can only set values that already exist, i.e. it doesn't automatically expand the table matrix.

Thus, a better alternative would be to use the SignalCurrent component. Like this:
 model Model1
   Modelica.Electrical.Analog.Basic.Ground ground;
   Modelica.Electrical.Analog.Basic.Resistor resistor;
   Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent;
   Modelica.Blocks.Interfaces.RealInput u;
  connect(resistor.n,ground.p) ;
end Model1;
Then you can use WSMInputFunctions to control the input signal from WSMSimulate, like this:
WSMSimulate["Model1", {0, 10}, WSMInputFunctions -> {"u" -> Sin}]
Here, Sin can be replaced with an arbitrary Mathematica function.

I hope this helps.
POSTED BY: Peter Aronsson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract