首页 > 解决方案 > OpenModelica:“警告:达到最大迭代次数但未找到根”,带有条件方程

问题描述

我是一名 OpenModelica 初学者,试图对具有恒定电压和电流限制的 DC/DC 转换器进行建模。基本上,输出应该提供恒定电压,直到达到最大电流,然后通过降低电压来保持该电流。

到目前为止,这是我的代码的方程式部分:

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;

每当我模拟时,电压和电流的结果看起来就像我预期的那样,所以计算似乎是正确的。但是,我收到警告

达到最大迭代次数,但未找到根。

谁能给我解释一下?谢谢!

标签: simulationmodelicaopenmodelicadymola

解决方案


不幸的是,您必须了解 s 参数化来解决这个问题,例如 Modelica.Electrical.Analog.Ideal.IdealDiode 中的内容。

除了单元检查,您应该执行以下操作:

 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;

我相信这个的原始参考是https://ieeexplore.ieee.org/document/808640

这个模型也可以通过添加一个新变量并重写 if 方程来重写这种风格

  Boolean saturatedCurrent=s<0;
equation
  v-vNom=if saturatedCurrent then s else 0;
  Imax-n.i=if saturatedCurrent then 0 else s; 

推荐阅读