Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

semiLinear(x, positiveSlope, negativeSlope)

semiLinear(x, positiveSlope, negativeSlope)

In Modelica Specifications 3.2 ( page 23 )  the  semiLinear- command is described as :

semiLinear(x, positiveSlope,  negativeSlope) :
Returns:  if    x>=0    then    positiveSlope*x    else  negativeSlope*x.   

I wrote a model to test the semiLinear- command. If I simulate this model, semiLinear only returns postiveSlope or negativeSlope. It doesn't  multiply positiveSlope (negativeSlope) with x.
In my opinion this is an error.

Thanks in advance.
Best regards.


The model :

model Testsemilinear
  Real result;
  parameter Real positve = 5;
  parameter Real negative = 70;
  Modelica.Blocks.Sources.Ramp ramp2(height = 2, duration = 5, offset = 0, startTime = 0) annotation(Placement(visible = true, transformation(origin = {-56,-19.5}, extent = {{-15,-15},{15,15}}, rotation = 0)));
  Modelica.Blocks.Sources.Ramp ramp1(height = -4, duration = 10, offset = 0, startTime = 10) annotation(Placement(visible = true, transformation(origin = {-54.5,44.5}, extent = {{-15,-15},{15,15}}, rotation = 0)));
  Modelica.Blocks.Math.Add add1 annotation(Placement(visible = true, transformation(origin = {-3,15}, extent = {{-15,-15},{15,15}}, rotation = 0)));

equation
  connect(ramp2.y,add1.u2) annotation(Line(points = {{-39.5,-19.5},{-27.5,-19.5},{-27.5,5},{-23,5},{-23,6},{-21,6}}));
  connect(ramp1.y,add1.u1) annotation(Line(points = {{-38,44.5},{-33,44.5},{-33,24.5},{-21,24.5},{-21,24}}));
  result = semiLinear(add1.y, positve, negative);
end Testsemilinear;

Edited by: Lisa - Apr-25-11 14:21:57

Re: semiLinear(x, positiveSlope, negativeSlope)

Hello Lisa,

this is now fixed in rev9119.

so long.
Willi

Re: semiLinear(x, positiveSlope, negativeSlope)

Hello Willi,

Thanks a lot.

Best regards.
Lisa

There are 0 guests and 0 other users also viewing this topic
You are here: