Message Boards Message Boards

7 Replies
10 Total Likes
View groups...
Share this post:

use an external function in system modeler

Posted 10 years ago

hi, For my learning of system modeler i try to do again all examples of system-modeler-getting-started (and translate in french). But I can not re model chirp and chirpsignal in introductory examples. when i try to validate class i can see this messages:

Error: No matching function found for Chirp in component <NO COMPONENT>

Error: Class Chirp not found in scope ChirpSignal.

Error: Error occured while flattening model ChirpSignal

Check of ChirpSignal failed

and i don't understand why, does someone can help me?

POSTED BY: ludovic rouch
7 Replies

Here's a way to do it.

Browse to ExternalFunctions package in IntroductoryExamples, right click and select duplicate. This will create a copy on top level of this class. Edit the ChirpSignal model in the top level ExternalFunctions package, changing the function call from IntroductoryExamples.ExternalFunctions.Chirp(...) to ExternalFunctions.Chirp(...). Save the ExternalFunctions package in a folder. Copy the Chirp.c file from the folder where IntroductoryExamples is stored (typically C:\Program Files (x86)\Wolfram Research\SystemModeler 4.0\Libraries\IntroductoryExamples 4.0 on Windows). Create a testmodel, save it in the same folder (this is currently needed to find the Chirp.c file, and may be the reason it failed for you. This is something that will be improved in the future). Now it should work.

POSTED BY: Peter Aronsson

If you are trying to re-implement the ChirpSignal example you need to copy the Chirp function (in IntroductoryExamples.ExternalFunctions) too. If you look at the ChirpSignal model in text view you will see that the equation references the Chirp function:

block ChirpSignal "A block of an external chirp signal"
  parameter Modelica.SIunits.AngularVelocity w_start = 0 "Angular velocity at start time";
  parameter Modelica.SIunits.AngularVelocity w_end = 10 "Angular velocity at end time";
  parameter Real A = 1 "amplitude of signal";
  parameter Real M = 10 "time period for signal";
  Modelica.Blocks.Interfaces.RealOutput u annotation(Placement(visible = true, transformation(origin = {140.0, -0.0}, extent = {{-10.0, -10.0}, {10.0, 10.0}}, rotation = 0), iconTransformation(origin = {107.5, 0.0}, extent = {{-7.5, -7.5}, {7.5, 7.5}}, rotation = 0)));
  u = IntroductoryExamples.ExternalFunctions.Chirp(w_start, w_end, A, M, time);
end ChirpSignal;

The simplest way would be to copy the entire package and then do your changes there. Please note that you need to update the referenced classes in the text view manually (e.g. changing IntroductoryExamples.ExternalFunctions.Chirp to YourNewPackageName.ExternalFunctions.Chirp).

Also, to get the model running properly you need to copy the Chirp.c file from the IntroductoryExamples folder to the folder where you save your new model or package, so that the WSM Kernel can find it.

POSTED BY: Peter Aronsson
Posted 10 years ago

hi everybody, after updating to WSM 4.0, the chirpfonction model running properly... (with "my" model)

I don't know why but now i's ok!

Peter, thank you for your help.

POSTED BY: ludovic rouch

Save the model to a .mo file and attach it to to a reply here.

POSTED BY: Peter Aronsson
Posted 10 years ago

for the moment i'm not arrive to re-implement this example. the same message appear.

yet all copy are saved in the same folder.. I think that i do something wrong.

POSTED BY: ludovic rouch
Posted 10 years ago

Actually if i do as you advocate, the model work. But if I build the model from the beginning, the same messages appears. my goal is to "create" from the beginning modeling. since your last post I tried several method but to no avail .. is it possible to send you my template so your looking at?

POSTED BY: ludovic rouch
Posted 10 years ago

Normally the file is attached

POSTED BY: ludovic rouch
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract