1

When I tried simulating a simple model in dymola (2015) using the sample function:

model test_sample
  Integer counter(start = 0);
algorithm
  when sample(0, 0.25) then
   counter:=counter + 1;  
  end when;
 end test_sample;

I had to increase the number of intervals to a high number (ex. 5000) to be able to see the instantaneous change of counter variable at sampling intervals. even with 5000 intervals, counter starts to change its value at time 0.2496 instead of 0.25. this is not at all the case in OpenModelica (version 1.9.1+dev (r17879)) and even with 1 interval, the counter variable changes its value at exactly 0.25. I am using Dassl in both platforms. is this a bug/feature?

Shaga
  • 170
  • 8
  • 1
    I went ahead and ran the model you posted and varied the intervals over a wide range and was not able to reproduce your error. I have Dymola 2016 so it may have been a bug that was corrected. – Scott G Mar 29 '16 at 15:44

1 Answers1

1

Ok, there is no bug. According to Dassault, one just needs to enable "Store variables at events" in Simulation > setup > Output > Output selection. "With this option enabled, the exact time of the event is stored in the result file, without it you will see in the plot the interpolated value between the result point left and right of the event since the event itself is not stored."

Shaga
  • 170
  • 8