-->

OpenModelica: “Warning: maximal number of iteratio

2020-04-20 07:22发布

问题:

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 maximum current is reached and then hold that current by reducing voltage.

This is the equation part of my code so far:

model DC_DC "Voltage source with current limiting"

  import SI = Modelica.SIunits;

  parameter SI.Voltage Vnom(start=1) "Value of nominal output voltage";
  parameter SI.Current Inom(start=1) "Value for maximum continous output current";
  parameter SI.Current Imax(start=1) "Value for maximum output current";

  Modelica.Electrical.Analog.Interfaces.PositivePin p 
    annotation (Placement(transformation(extent={{-110, -10},{-90,10}})));
  Modelica.Electrical.Analog.Interfaces.NegativePin n 
    annotation (Placement(transformation(extent={{110, -10},{90,10}})));

  SI.Voltage v;

equation 

  v = p.v - n.v;

  if n.i > Imax and v <= Vnom then
    n.i = Imax;
    0 = p.i + n.i;
  else
    Vnom = p.v - n.v;
    0 = p.i + n.i;
  end if;

end DC_DC;

Whenever I simulate, the results for the voltage and current look like I would have expected it, so the calculation seems correct. However, I get the warning

maximum number of iteration reached, but no root found.

Can one explain that to me? Thanks!

回答1:

However, I get the warning

maximum number of iteration reached, but no root found.

Can one explain that to me? Thanks!

The reason for this is, that the integrator can't solve the equation system you formulated.
The underlying problem is, that you tried to change a continuous state (here n.i) without telling the integrator.


If you want to change a value of a state variable at an event you need to use the reinit-operator which is only allowed inside a when equation.

You could do something similar to the following model:

package minExample
  model DC_DC "Voltage source with current limiting"
    import SI = Modelica.SIunits;

    parameter SI.Voltage Vnom(start=1) "Value of nominal output voltage";
    parameter SI.Current Inom(start=1) "Value for maximum continous output current";
    parameter SI.Current Imax(start=1) "Value for maximum output current";

    Modelica.Electrical.Analog.Interfaces.PositivePin p "Positive electrical pin";
    Modelica.Electrical.Analog.Interfaces.NegativePin n "Negative electrical pin";
    SI.Voltage v "Voltage drop of the two pins (= p.v - n.v)";
  equation
    when n.i > Imax then
      reinit(n.i,Imax);
    end when;

    if n.i > Imax then
      v = 0;
    else
      Vnom = p.v - n.v;
    end if;

    // Connect equations
    0 = p.i + n.i;
    v = p.v - n.v;
  end DC_DC;

  model test
    Modelica.Electrical.Analog.Basic.Ground ground1;
    Modelica.Electrical.Analog.Basic.Inductor inductor1(L = 0.5);
    DC_DC dc_dc1;
  equation
    connect(inductor1.n, ground1.p);
    connect(dc_dc1.n, ground1.p);
    connect(inductor1.p, dc_dc1.p);
  end test;
end minExample;


回答2:

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;