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 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:
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?
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