Group Abstract Group Abstract

Message Boards Message Boards

Fixed and Variable Delay

GROUPS:
Dear members of this group, I am using SystemModeler to simulate power electronic circuits and their controls. In particular I have designed a circuit that fires a Thyristor. In the design of such firing circuit I am using Fixed and Variable Delays. However, in some circuits and not in all of them the simulation fails giving the following error message:

ERROR: Could not read result file "/var/folders/9p/1lyllwcj6kd0qd4hh5fx1kb00000gn/T/sme_1393028997_16807.mat". Missing data_2 matrix, the file might be corrupt.

I have done some trial and error and its seeems that the error is present at including fixed or variable delays blocks

I have no idea how to solve this problem neither I could finf information about it.

Any ideas?

Jesus
Answer
5 months ago
I would contact Wolfram Technical Support for help (support@wolfram.com). This isn't an issue that I've personally seen yet. Please remember to send in your license number or activation key when contacting them, alongside a description of your problem. 

You may want to check the permissions on the file that the error message says it cannot read. This might be useful. Additionally, does this happen for a very simple example with the Delay blocks?
POSTED BY: Sean Clarke
Answer
5 months ago
Hello Jesus,

It's hard to know the exact problem without looking the model. But is seems that the result file is corrupted when simulating.

I have attached a few examples of how to use the delay operator. I also included an example on how to delay discrete variables and get more accurate timing. This method is much better when delaying for example triggering signals for thyristors.

 model DelayExamples
 
   Real x(start = 10);
   Real fixedDelay,variableDelay;
   Real y;
   discrete Real z;
   discrete Real discreteDelay,discreteDelay_future,discreteDelay_time;
   parameter Real delay_z = 1;
 equation
  der(x) = -x;
  y = if time < 3 then 0.5 else 1;
  /*---Delaying continuous variables----*/
  /* Fixed delay:
       delay(exp,delayTime)
  */
  fixedDelay = delay(x, 1);
  /* Variable delay:
       delay(exp,delayTime,maxDelay)
       NOTE: variable delays require ti specify the maximum delay
  */
  variableDelay = delay(x, y, 1);

  /*---Delaying discrete variables---*/
  /* This is equivalent to:
        discreteDelay=delay(z,delay_z)
     but it's more precise and do not miss the event
  */

  when x < 0.5 then  // at time 0.5 z changes
    z = 1;
    discreteDelay_future = 1;            // sets the future value for the delayed variable
    discreteDelay_time = time + delay_z; // sets the time at which the delayed variable has to change
  end when;

  when time > discreteDelay_time then
      discreteDelay = discreteDelay_future;  // when time reaches the time of change set the value
  end when;

end DelayExamples;


Leonardo
Answer
5 months ago
I have attached the model I am working on. It works without the FixedDelay while it does not with it.
The error is not easy to catch. I have used delay blocks in some other models without troubles.

Sean I will contact Wolfram support to discrebe my model for them. Thanks.

Leonardo I will check the code, Thanks!

Jesús
Answer
5 months ago
This is my model.
Jesús
Answer
5 months ago
Seems that the delay blocks are failing because there is no initial equation. Here you can find an alternative delay model that you can use.

 model fixedDelayAlt
 
   Modelica.Blocks.Interfaces.RealInput u;
   Modelica.Blocks.Interfaces.RealOutput y;
   parameter Real delay_time=1;
 initial equation
   y=0;
 equation
   y=delay(u, delay_time);
end fixedDelayAlt;


The main difference is that it adds the 'initial equation'. 

The same case applies to the variable delay.
Answer
5 months ago
Thanks Leonardo,

It seems to work better!

Best regards

Jesus
Answer
5 months ago
Here's another delay model that seems to work much better that my previous alternative.

You just have to take into consideration that this delay starts woking when time>1e-12 so you will not get any value until that.

model fixedDelayAlt

  parameter Real delay_time=1;
  Modelica.Blocks.Interfaces.RealInput u;
  Modelica.Blocks.Interfaces.RealOutput y;
equation
  y=if time>1e-12 then delay(u, delay_time) else 0;
end fixedDelayAlt;

Leonardo
Answer
4 months ago
Thanks
I will also try the new suggestion.

Best regards

Jesús
Answer
4 months ago
Thanks
I will also try the new suggestion.

Best regards

Jesús
Answer
4 months ago