I get an error on Modelica saying:
All branches in if equation with non-parameter tests must have the same number of equations
The source of the error is following section of the code:
equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
end if;
Do you know how to deal with this error?
You need an else, so the obvious idea is to say that pressure doesn't change:
equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
else
der(pressure)=0;
end if;
However, this will likely not compile due to the index-problem. One possibility is to do manual index reduction and write something like:
initial equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
else
pressure=4e5;
end if;
equation
if der(Posit2.s)<=0 then
der(pressure)=((500e5-4e5)/0.0111)*(-der(Posit2.s));
else
der(pressure)=0;
end if;
Note that this equation has der(pressure)=...*der(Posit2.s);
- due to the manual index reduction.