Group Abstract Group Abstract

Message Boards Message Boards

0
|
8K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

About WSMCreateModel

Dear Colleagues Working with WSMCreate model has giving me some problems. For instance, could you help me to understand why the Mathematica code rises a syntax error in the following statement?

APF = WSMCreateModel[
  "APFModel", {Derivative[1][if][t] == -0.055555555555 if[t] - 
     55.55555555555556 swt[t] vc[t] - 55.55555555555556 Vs[t], 
   Derivative[1][vc][t] == 1000 if[t] swt[t]}, 
  t, {swt[t] \[Element] "Modelica.Blocks.Interfaces.RealInput", 
   Vs[t] \[Element] "Modelica.Blocks.Interfaces.RealInput",
   if[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput",
   vc[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput"}]

I have double check this without finding the possible error. Thanks in advance. Jesus

4 Replies
POSTED BY: Patrik Ekenberg

Ooh, yes! So in WSM If and if are the same? Thanks a lot

Jesus

POSTED BY: Patrik Ekenberg

Hello Jesus!

Thank you for reporting this. The syntax error arises since "if" is a reserved keyword in Modelica, denoting if-statements. Thus you cannot have variables named "if" (or other reserved keywords). The easiest work-around is to use another name for your variable. The code below, where I renamed "if", "x" should work.

APF = WSMCreateModel[
  "APFModel", {Derivative[1][x][t] == -0.055555555555 x[t] - 
     55.55555555555556 swt[t] vc[t] - 55.55555555555556 Vs[t], 
   Derivative[1][vc][t] == 1000 x[t] swt[t]}, 
  t, {swt[t] \[Element] "Modelica.Blocks.Interfaces.RealInput", 
   Vs[t] \[Element] "Modelica.Blocks.Interfaces.RealInput", 
   x[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput", 
   vc[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput"}]

Regards, Patrik

POSTED BY: Patrik Ekenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard