Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Modelica/Blocks/Sources.mo
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,13 @@ The Real output y is a step signal:
block Ramp "Generate ramp signal"
parameter Real height=1 "Height of ramp"
annotation(Dialog(groupImage="modelica://Modelica/Resources/Images/Blocks/Sources/Ramp.png"));
parameter SI.Time duration(min=0.0, start=2)
"Duration of ramp (= 0.0 gives a Step)";
parameter SI.Time duration(min=Constants.small, start=2)
"Duration of ramp";
extends Interfaces.SignalSource;

equation
y = offset + (if time < startTime then 0 else if time < (startTime +
duration) then (time - startTime)*height/duration else height);
y = smooth(0, offset + (if time < startTime then 0 else if time < (startTime +
duration) then (time - startTime)*height/duration else height));
Comment on lines +252 to +253
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one necessarily wants to rewrite it, obviously want to avoid evaluating duration, and use smooth when appropriate why not write:

Suggested change
y = smooth(0, offset + (if time < startTime then 0 else if time < (startTime +
duration) then (time - startTime)*height/duration else height));
y = offset+(if duration>0 then smooth(0, (if time < startTime then 0 else if time < (startTime +
duration) then (time - startTime)*height/duration else height)) else (if time < startTime then 0 else height);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I wouldn't know what to do with the smoothness information unless duration > 0 was evaluated.

annotation (
Icon(coordinateSystem(
preserveAspectRatio=true,
Expand Down Expand Up @@ -281,10 +281,6 @@ The Real output y is a ramp signal:
<img src=\"modelica://Modelica/Resources/Images/Blocks/Sources/Ramp.png\"
alt=\"Ramp.png\">
</div>

<p>
If parameter duration is set to 0.0, the limiting case of a Step signal is achieved.
</p>
</html>"));
end Ramp;

Expand Down
7 changes: 3 additions & 4 deletions Modelica/Fluid/Examples/BranchingDynamicPipes.mo
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,16 @@ replaceable package Medium=Modelica.Media.Air.MoistAir constrainedby
p=100000) annotation (Placement(
transformation(extent={{10,-10},{-10,10}}, rotation=90,
origin={0,60})));
Modelica.Blocks.Sources.Ramp ramp1(
Modelica.Blocks.Sources.Step step1(
offset=1e5,
startTime=2,
height=1e5,
duration=0) annotation (Placement(transformation(extent={{-40,70},{-20,90}})));
height=1e5) annotation (Placement(transformation(extent={{-40,70},{-20,90}})));
Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow[
pipe2.nNodes] heat2(Q_flow=200*
pipe2.dxs, alpha=-1e-2*ones(pipe2.n))
annotation (Placement(transformation(extent={{-60,-20},{-40,0}})));
equation
connect(ramp1.y, boundary4.p_in) annotation (Line(
connect(step1.y, boundary4.p_in) annotation (Line(
points={{-19,80},{-8,80},{-8,72}},
color={0,0,127},
thickness=0.5));
Expand Down