user1216408
user1216408

Reputation: 65

model a periodic time-varing real variable in OpenModelica

What I want to model is a periodic time-varing real variable, the following code can not be simulated. Does somebody have suggestion?

class try
discrete Real x(start = 1);
algorithm
when sample(0,4) then 
   x :=  1; // reinit(x, 1) also does not work
end when;
equation
      der(x) = 1;
end try;

All the error message is listed as follows:
Translation 18:32:29 0:0-0:0 Internal error Transformation Module failed!
Translation 18:32:29 0:0-0:0 Internal error BackendDAETransform.reduceIndexDummyDer failed!
Translation 18:32:29 0:0-0:0 Internal error BackendDAETransform.selectDummyState: no state to select
Symbolic 18:32:29 10:3-10:13 Model is structurally singular, error found sorting equations 0.0 = 1.0; for variables

Upvotes: 1

Views: 709

Answers (1)

Marco Romanoni
Marco Romanoni

Reputation: 471

The problem is that if you want the variable x to be continue between the sampling time istants you have to remove the discrete keyword, this will work fine:

class try
 Real x(start = 1);
algorithm 
when sample(0,4) then
   reinit(x, 1);
end when;
equation 
      der(x) = 1;
end try;

Ciao, Marco

Upvotes: 2

Related Questions