I am an OpenModelica beginner trying to model a DC/DC converter with constant voltage and current limiting. Basically the output is supposed to give a constant voltage until the
Unfortunately you have to learn about s-parametrization to solve this, as is found in e.g. Modelica.Electrical.Analog.Ideal.IdealDiode.
Except for unit-checking you should do something like:
Real s;
equation
v = p.v - n.v;
if s<0 then
s=v-Vnom;
n.i=Imax;
else
Vnom = v;
s=Imax-n.i;
end if;
0 = p.i + n.i;
I believe the original reference for this is https://ieeexplore.ieee.org/document/808640
This model can also be rewritten sin this style by adding a new variable and rewriting the if-equations
Boolean saturatedCurrent=s<0;
equation
v-vNom=if saturatedCurrent then s else 0;
Imax-n.i=if saturatedCurrent then 0 else s;