I don't entirely understand the intent of this model. It is not clear to me whether you expect to find the minimum of all u
values over time or just the current value of u
vs. p
? If the former, then that isn't what min is for. If the latter, then you are on the right track...
Assuming the latter, then your main misconception seems to be about the semantics of equations. It looks to me like you are assuming that you start with one value of u
. Then you "reassign" that value to be the min(u,p)
. Then, finally, you assign y
to this "reassigned" value of u
.
All that would be fine if you had an algorithm
section in your model. This is because an algorithm
section has assignment semantics (this is the "imperative" semantic in most programming languages).
But you have an equation section. The thing about an equation section is that the statements you wrote are equations. The important thing about equations is that they always apply. So in you model you have stated that u=min(u,p)
. This is not "overwriting" the value of u
, it is stating an additional mathematical constraint. It is a bit like trying to solve the equation x=x*x
. If you put this equation in your model it is the equivalent of saying x=0
because that is the only value of x
that can satisfy the equation.
So the error about too many equations comes because if you look at your myBlock
model, it has one input and one output. That means it has only one "unknown" to compute and therefore requires only one equation. You've given two equations (one too many).
I think what you want is:
model myBlock
input Modelica.Blocks.Interfaces.RealInput u;
output Modelica.Blocks.Interfaces.RealOutput y;
parameter Real p;
equation
y = min(u,p);
end myBlock;
This will "limit" the output, y
, to be no less than p
. Is that what you wanted?
Alternatively, you could write your model with an algorithm
section and get something like this:
model myBlock
input Modelica.Blocks.Interfaces.RealInput u;
output Modelica.Blocks.Interfaces.RealOutput y;
parameter Real p;
algorithm
u := min(u,p) "This is assignment";
y := u;
end myBlock;
Note the behavior should be the same (although I confess I didn't test either model).
I hope that helps.