Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numerical issues integrating a pulse signal that is delayed (fixedDelay)

I noted numerical issues integrating a pulse input that is delayed by a fixed amount of time in Modelica (using Wolfram System Modeler 4.3):

Model Diagram

model PulseTest "Test FixedDelay with Pulse Input";
    Modelica.Blocks.Sources.Pulse pulse(
        startTime = 1, 
        width = 100, 
        period = 1/32, 
        amplitude = 32, 
        nperiod = 1
    );
    Modelica.Blocks.Nonlinear.FixedDelay fixedDelay( delayTime = 5 );
    Modelica.Blocks.Continuous.Integrator x; // integrator for the undelayed pulse
    Modelica.Blocks.Continuous.Integrator y; // integrator for the delayed pulse
equation
    connect( pulse.y, fixedDelay.u );
    connect( fixedDelay.y, y.u );
    connect( pulse.y, x.u );
end PulseTest;

Integrating a pulse with period = 1/a, amplitude = a, and width = 100 % should give 1.0. But as can be seen from the plot, this is not what I get for the delayed pulse:

Plot of X and Y over time

Only the undelayed signal gives the correct value using DASSL. The numerical integration error will appear already for period = 1/a = 1/8 and (naturally) grow as a grows.

What is the best remedy?

like image 266
gwr Avatar asked Dec 10 '18 16:12

gwr


2 Answers

The problem is, as Markus A wrote, that that delay does not propagate the discontinuity from input to output and therefore the simulation does not handle the delayed step-change in the same way as a normal step-change, i.e. with event-detection and event-handling.

From a tool-perspective smoothly interpolation the delayed signal is not merely the simplest solution - but also avoids a cascade of events if the delayed signal is fed back.

I cannot see any simple reliable workaround when using any variable step-size solver.

like image 196
Hans Olsson Avatar answered Sep 28 '22 02:09

Hans Olsson


As Ankit posted at the Wolfram Forum, the problem is that the signal is discrete but the delay block is unaware of that. It can be fixed with a different delay block:

model DiscreteFixedDelay
  discrete input Modelica.Blocks.Interfaces.RealInput u ;
  discrete output Modelica.Blocks.Interfaces.RealOutput y ;
  parameter Modelica.SIunits.Time delayTime(start = 5) = 5 "Delay time of output with respect to input signal";
equation
  y = delay(u, delayTime);
end DiscreteFixedDelay;

Regards

like image 20
NCSNY Avatar answered Sep 28 '22 01:09

NCSNY