Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modelica.Blocks.Discrete.UnitDelay does not delay input #4451

Open
JayHuLBL opened this issue Aug 15, 2024 · 2 comments
Open

Modelica.Blocks.Discrete.UnitDelay does not delay input #4451

JayHuLBL opened this issue Aug 15, 2024 · 2 comments
Labels
L: Blocks Issue addresses Modelica.Blocks

Comments

@JayHuLBL
Copy link

The Modelica.Blocks.Discrete.UnitDelay does not delay the input as described in its documents.

Given an example model as below, where the unitDelay_MSL is the delay block from MSL and the unitDelay_Corrected is the one with correction.
UnitDelayAndSampleBlock
It has the results as:
UnitDelayAndSampleBlock_Res

The unitDelay_MSL.y is the same as the output from the sampling block, while the unitDelay_Corrected .y is the expected one.

@beutlich beutlich added the L: Blocks Issue addresses Modelica.Blocks label Aug 16, 2024
@casella
Copy link
Contributor

casella commented Aug 16, 2024

@JayHuLBL where do we find the corrected model?

Could you please post the code that allows to replicate the issue?

Thanks!

@JayHuLBL
Copy link
Author

JayHuLBL commented Aug 19, 2024

@casella Thanks for your response.

Please see the test model as below:

model UnitDelayAndSampleBlock "Example model for the UnitDelay block"
  Buildings.Controls.OBC.CDL.Reals.Sources.Ramp ramp1(
    duration=1,
    offset=0,
    height=6.2831852)
    "Block that generates ramp signal"
    annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
  Buildings.Controls.OBC.CDL.Reals.Sin sin1
    "Block that outputs the sine of the input"
    annotation (Placement(transformation(extent={{-20,-10},{0,10}})));

  Buildings.Controls.OBC.CDL.Discrete.Sampler sam(
    samplePeriod=0.05)
    "sampler of a continuous signal"
    annotation (Placement(transformation(extent={{40,-50},{60,-30}})));
  Modelica.Blocks.Discrete.UnitDelay unitDelay_MSL(
    samplePeriod=0.05)
    "Unit delay from MSL"
    annotation (Placement(transformation(extent={{40,40},{60,60}})));
  Buildings.Controls.OBC.CDL.Discrete.UnitDelay unitDelay_Corrected(
    samplePeriod=0.05,
    y_start=1)
    "Unit delay with correction"
    annotation (Placement(transformation(extent={{40,-10},{60,10}})));

equation 
  connect(ramp1.y,sin1.u)
    annotation (Line(points={{-38,0},{-22,0}}, color={0,0,127}));
  connect(sin1.y, unitDelay_Corrected.u)
    annotation (Line(points={{2,0},{38,0}}, color={0,0,127}));
  connect(sin1.y, sam.u)
    annotation (Line(points={{2,0},{20,0},{20,-40},{38,-40}}, color={0,0,127}));
  connect(sin1.y, unitDelay_MSL.u)
    annotation (Line(points={{2,0},{20,0},{20,50},{38,50}}, color={0,0,127}));

annotation (
    Icon(graphics={
        Ellipse(lineColor={75,138,73}, fillColor={255,255,255},
          fillPattern=FillPattern.Solid, extent={{-100,-100},{100,100}}),
        Polygon(lineColor={0,0,255}, fillColor={75,138,73}, pattern=LinePattern.None,
          fillPattern=FillPattern.Solid, points={{-36,60},{64,0},{-36,-60},{-36,60}})}),
     uses(Modelica(version="4.0.0")),
     experiment(StopTime=1, __Dymola_Algorithm="Dassl"));
end UnitDelayAndSampleBlock;

The corrected unit delay is from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: Blocks Issue addresses Modelica.Blocks
Projects
None yet
Development

No branches or pull requests

3 participants