Hi,
We have recently been working with if equations, below is a summary of the development status:
- If equations are now supported, with some limitations, see below.
- When equations are supported, also with some limitations, see below.
To illustrate the limitation with regards to if-equations, consider the example:
model M1
function F
input Real x;
input Real y;
output Real u;
output Real v;
algorithm
u :=2*x;
v :=5*y + x;
end F;
Real x;
Real y;
equation
if time>=1 then
x = time;
y = 2*time;
else
(x,y) = F(time,time*2);
end if;
end M1;This model gives a compliance error:
Error: in file 'IfTest.mo': Compliance error at line 14, column 4: If equations that has non-parameter tests and contains function calls using multiple outputs are not supported
When it comes to when equations, elsewhen clauses are not supported:
model M2
function F
input Real x;
input Real y;
output Real u;
output Real v;
algorithm
u :=2*x;
v :=5*y + x;
end F;
Real x;
Real y;
equation
when sample(0,1) then
(x,y) = F(time,time*2);
elsewhen sample(0,0.5) then
(x,y) = F(time*3,-2*time);
end when;
end M2;JModelica.org here gives a compliance error:
Error: in file 'IfTest.mo': Compliance error at line 14, column 3: Else clauses in when equations are currently not supported
In summary, we are making good progress in closing the compliance gap for if and when equations as far as MSL goes.
Best regards
/Johan