Modelica中建立简单DCDC变换器的问题

Modelica中建立简单DCDC变换器的问题,modelica,openmodelica,Modelica,Openmodelica,我想为DCDC转换器编写一个非常简单的模型。出于某种原因,Dymola告诉我“模型不适定”,并且对真实元素进行了过度确定 这可能是一个相当简单的问题,但我看不出来 这是我的密码: model DCDC extends Modelica.Electrical.Analog.Interfaces.TwoPort; parameter Real demandedVoltage; Modelica.Electrical.Analog.Sensors.VoltageSensor sekV

我想为DCDC转换器编写一个非常简单的模型。出于某种原因,Dymola告诉我“模型不适定”,并且对真实元素进行了过度确定

这可能是一个相当简单的问题,但我看不出来

这是我的密码:

model DCDC

  extends Modelica.Electrical.Analog.Interfaces.TwoPort;

  parameter Real demandedVoltage;

  Modelica.Electrical.Analog.Sensors.VoltageSensor sekVolt annotation (
      Placement(transformation(
        extent={{-10,-10},{10,10}},
        rotation=270,
        origin={80,0})));
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor annotation (
      Placement(transformation(
        extent={{-10,10},{10,-10}},
        rotation=270,
        origin={-50,-30})));
  Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent annotation (
      Placement(transformation(
        extent={{-10,-10},{10,10}},
        rotation=270,
        origin={-50,30})));
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=
        vehicleVoltage)
    annotation (Placement(transformation(
        extent={{-10,10},{10,-10}},
        rotation=270,
        origin={50,30})));
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor1 annotation (
      Placement(transformation(
        extent={{-10,-10},{10,10}},
        rotation=270,
        origin={50,-30})));
  Modelica.Blocks.Math.Division division
    annotation (Placement(transformation(extent={{6,22},{-10,38}})));
  Modelica.Blocks.Math.Product product
    annotation (Placement(transformation(extent={{8,-8},{-8,8}},
        rotation=270,
        origin={30,8})));
  Modelica.Blocks.Math.Gain gain(k=-1)
    annotation (Placement(transformation(extent={{-20,22},{-36,38}})));
  Modelica.Electrical.Analog.Sensors.VoltageSensor primVolt
                                                           annotation (
      Placement(transformation(
        extent={{-10,10},{10,-10}},
        rotation=270,
        origin={-80,0})));
equation 

  connect(currentSensor.p, signalCurrent.n) annotation (Line(
      points={{-50,-20},{-50,20}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(constantVoltage.n, currentSensor1.p) annotation (Line(
      points={{50,20},{50,-20}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(signalCurrent.p, p1) annotation (Line(
      points={{-50,40},{-50,50},{-100,50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(currentSensor.n, n1) annotation (Line(
      points={{-50,-40},{-50,-50},{-100,-50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(constantVoltage.p, p2) annotation (Line(
      points={{50,40},{50,50},{100,50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(currentSensor1.n, n2) annotation (Line(
      points={{50,-40},{50,-50},{100,-50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(primVolt.n, n1) annotation (Line(
      points={{-80,-10},{-80,-50},{-100,-50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(primVolt.p, p1) annotation (Line(
      points={{-80,10},{-80,50},{-100,50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(sekVolt.p, p2) annotation (Line(
      points={{80,10},{80,50},{100,50}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(sekVolt.n, n2) annotation (Line(
      points={{80,-10},{80,-50},{100,-50}},
      color={0,0,255},
      smooth=Smooth.None));

  connect(gain.y, signalCurrent.i) annotation (Line(
      points={{-36.8,30},{-43,30}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(division.y, gain.u) annotation (Line(
      points={{-10.8,30},{-18.4,30}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(currentSensor1.i, product.u2) annotation (Line(
      points={{40,-30},{25.2,-30},{25.2,-1.6}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(sekVolt.v, product.u1) annotation (Line(
      points={{70,0},{62,0},{62,-10},{34.8,-10},{34.8,-1.6}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(product.y, division.u1) annotation (Line(
      points={{30,16.8},{30,34.8},{7.6,34.8}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(primVolt.v, division.u2) annotation (Line(
      points={{-70,0},{14,0},{14,20},{14,20},{14,25.2},{7.6,25.2}},
      color={0,0,127},
      smooth=Smooth.None));
  annotation (
      Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,
            100}}), graphics), Icon(coordinateSystem(preserveAspectRatio=false,
          extent={{-100,-100},{100,100}}), graphics={
        Rectangle(
          extent={{-100,100},{100,-100}},
          lineColor={0,0,127},
          lineThickness=0.5,
          fillPattern=FillPattern.Solid,
          fillColor={215,215,215}),
        Line(
          points={{-100,100}},
          color={0,0,255},
          smooth=Smooth.None),
        Line(
          points={{-100,100},{-100,-100},{100,-100},{100,100},{-100,100}},
          color={0,0,127},
          thickness=0.5,
          smooth=Smooth.None),
        Line(
          points={{-100,-100},{100,100}},
          color={0,0,127},
          thickness=0.5,
          smooth=Smooth.None),
        Text(
          extent={{-60,80},{0,20}},
          lineColor={0,0,0},
          lineThickness=0.5,
          textString="DC"),
        Text(
          extent={{0,-20},{60,-80}},
          lineColor={0,0,0},
          lineThickness=0.5,
          textString="DC")}));
end DCDC;
希望有人能在这里解决我的问题。 提前谢谢你

编辑: 回答之后,我决定稍微改变一下我的型号,因为我需要一个混合(能量/电源)电源转换器。产生的转换器在以下代码中给出:

model DCDC2 "Component with two electrical ports, including current"

Real v_energy "Voltage drop over the energy port";
Real v_power "Voltage drop over the power port";
Real v_output "Voltage drop over the output port";
Real i_energy "Current flowing from pos. to neg. pin of the energy port";
Real i_power "Current flowing from pos. to neg. pin of the power port";
Real i_output "Current flowing from pos. to neg. pin of the output port";
Real p_energy;
Real p_power;
Real p_output;

parameter Real demandedVoltage;
parameter Real efficiency = 1;

Modelica.Electrical.Analog.Interfaces.PositivePin pinP_Energy
annotation (Placement(transformation(extent={{-110,50},{-90,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pinN_Energy
annotation (Placement(transformation(extent={{-110,-70},{-90,-50}})));
Modelica.Electrical.Analog.Interfaces.PositivePin pinP_Power
annotation (Placement(transformation(extent={{90,50},{110,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pinN_Power
annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
Modelica.Electrical.Analog.Interfaces.PositivePin pinP_Output
annotation (Placement(transformation(extent={{-20,80},{20,120}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pinN_Output
annotation (Placement(transformation(extent={{-20,-120},{20,-80}})));

equation 
  v_energy = pinP_Energy.v - pinN_Energy.v;
  v_power = pinP_Power.v - pinN_Power.v;
  v_output = pinP_Output.v - pinN_Output.v;

  0 = pinP_Energy.i + pinN_Energy.i;
  0 = pinP_Power.i + pinN_Power.i;
  0 = pinP_Output.i + pinN_Output.i;

  i_energy = pinP_Energy.i;
  i_power = pinP_Power.i;
  i_output = pinP_Output.i;

  p_energy = v_energy * i_energy;
  p_power = v_power * i_power;
  p_output = v_output * i_output;

  p_output = efficiency*(p_energy + p_power);
  i_output = i_energy + i_power;
  v_output = demandedVoltage;

  annotation (
  Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-   100},{100,
        100}}), graphics), Icon(coordinateSystem(preserveAspectRatio=false,
      extent={{-100,-100},{100,100}}), graphics={
    Rectangle(
      extent={{-100,100},{100,-100}},
      lineColor={0,0,127},
      lineThickness=0.5,
      fillPattern=FillPattern.Solid,
      fillColor={215,215,215}),
    Line(
      points={{-100,100}},
      color={0,0,255},
      smooth=Smooth.None),
    Line(
      points={{-100,100},{-100,-100},{100,-100},{100,100},{-100,100}},
      color={0,0,127},
      thickness=0.5,
      smooth=Smooth.None),
    Text(
      extent={{-68,60},{70,-66}},
      lineColor={0,0,0},
      textString="Hybrid
  DC
   Converter")}));
   end DCDC2;
如果我用两个简单的恒流源和一个恒流负载测试转换器,我会再次得到一个奇异性误差。Dymola 2015告诉我,可能存在不可确定的理由,但事实并非如此

model test2

Modelica_EnergyStorages.Sources.Loads.BooleanConstantCurrent
booleanConstantCurrent(I=40)
annotation (Placement(transformation(extent={{46,0},{26,20}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-84,-40},{-64,-20}})));
Modelica.Blocks.Sources.BooleanConstant booleanConstant
annotation (Placement(transformation(extent={{66,0},{46,20}})));
Modelica.Electrical.Analog.Basic.Ground ground1
annotation (Placement(transformation(extent={{26,-86},{46,-66}})));
ElectricalEnergyStorageSystem.Components.DCDC2 dCDC2_1(efficiency=1,
  demandedVoltage=15)
annotation (Placement(transformation(extent={{-44,0},{-24,20}})));
Modelica.Electrical.Analog.Sources.ConstantCurrent constantCurrent(I=5) 
annotation (Placement(transformation(
    extent={{-10,-10},{10,10}},
    rotation=270,
    origin={-74,10})));
Modelica.Electrical.Analog.Sources.ConstantCurrent   constantCurrent1(I=15) 
annotation (Placement(transformation(
    extent={{-10,-10},{10,10}},
    rotation=270,
    origin={6,10})));
Modelica.Electrical.Analog.Basic.Ground ground2
annotation (Placement(transformation(extent={{-4,-40},{16,-20}})));
equation 
connect(booleanConstantCurrent.on, booleanConstant.y) annotation (Line(
  points={{45,10},{45,10}},
  color={255,0,255},
  smooth=Smooth.None));
connect(booleanConstantCurrent.pin_n, ground1.p) annotation (Line(
  points={{36,0},{36,-66}},
  color={0,0,255},
  smooth=Smooth.None));
connect(dCDC2_1.pinP_Output, booleanConstantCurrent.pin_p) annotation (Line(
  points={{-34,20},{-34,76},{36,76},{36,20}},
  color={0,0,255},
  smooth=Smooth.None));
connect(booleanConstantCurrent.pin_n, dCDC2_1.pinN_Output) annotation (Line(
  points={{36,0},{36,-54},{-34,-54},{-34,0}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantCurrent1.p, dCDC2_1.pinP_Power) annotation (Line(
  points={{6,20},{-24,20},{-24,16}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantCurrent1.n, dCDC2_1.pinN_Power) annotation (Line(
  points={{6,0},{-24,0},{-24,4}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantCurrent.p, dCDC2_1.pinP_Energy) annotation (Line(
  points={{-74,20},{-44,20},{-44,16}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantCurrent.n, dCDC2_1.pinN_Energy) annotation (Line(
  points={{-74,0},{-44,0},{-44,4}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantCurrent1.n, ground2.p) annotation (Line(
  points={{6,0},{6,-20}},
  color={0,0,255},
  smooth=Smooth.None));
connect(ground.p, constantCurrent.n) annotation (Line(
  points={{-74,-20},{-74,0}},
  color={0,0,255},
  smooth=Smooth.None));
annotation (uses(
  Modelica_EnergyStorages(version="3.2.1"),
  Modelica(version="3.2.1"),
  Buildings(version="2.0.0")),    Diagram(coordinateSystem(preserveAspectRatio
      =false, extent={{-100,-100},{100,100}}), graphics));
end test2;
代码将生成以下模型。(恒流负载来自Modelica_EnergyStorages库)


希望你能帮我解决这个问题!提前谢谢

唯一的小问题是您已经声明了
demandedVoltage
,但您使用的是
vehicleVoltage
。你的模型没有其他问题

注意:最好在问题中包含一个用于测试的最小顶层模型

在SimulationX 3.6.5中,我在一个顶级型号
TestDCDC
中测试了您的模型,并将电容器作为电源,电阻器作为负载

下图显示了测试模型的示意图

通过SimulationX获得的结果如下图所示

我还检查了SimulationX生成的方程组。看起来不错

Dymola 2015生成了一条错误的错误消息,指出有两个变量比方程多。您应该向Dymola的生产商发布此模型的错误报告。请注意,Modelica模型的符号分析非常复杂,可能会出现类似的问题。通常,在这种情况下,工具的维护者会感谢bug报告

解决方案讨论: DCDC转换器要求电容器提供
P=100W
的恒定功率,电容器的初始电压为
电容器1.v.start=10V
。 这给出了能量-时间信号

W=C/2*(v.start)^2-p*时间=50Ws-100W*时间

电容器电压信号的结果是

capacitor1.v=2*sqrt(W)/C=2V/As*sqrt(50Ws-100Ws*时间)

时间=0.5s时,电容器为空,电流发散。
SimulationX在时间=0.5时正确停止,并显示错误消息

复制结果的完整模型:

model TestDCDC
    model DCDC
        extends Modelica.Electrical.Analog.Interfaces.TwoPort;
        parameter Real demandedVoltage;
        Modelica.Electrical.Analog.Sensors.VoltageSensor sekVolt annotation(Placement(transformation(
            origin={80,0},
            extent={{-10,-10},{10,10}},
            rotation=270)));
        Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor annotation(Placement(transformation(
            origin={-50,-30},
            extent={{-10,10},{10,-10}},
            rotation=270)));
        Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent annotation(Placement(transformation(
            origin={-50,30},
            extent={{-10,-10},{10,10}},
            rotation=270)));
        Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=demandedVoltage) annotation(Placement(transformation(
            origin={50,30},
            extent={{-10,10},{10,-10}},
            rotation=270)));
        Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor1 annotation(Placement(transformation(
            origin={50,-30},
            extent={{-10,-10},{10,10}},
            rotation=270)));
        Modelica.Blocks.Math.Division division annotation(Placement(transformation(extent={{6,22},{-10,38}})));
        Modelica.Blocks.Math.Product product annotation(Placement(transformation(
            origin={30,8},
            extent={{8,-8},{-8,8}},
            rotation=270)));
        Modelica.Blocks.Math.Gain gain(k=-1) annotation(Placement(transformation(extent={{-20,22},{-36,38}})));
        Modelica.Electrical.Analog.Sensors.VoltageSensor primVolt annotation(Placement(transformation(
            origin={-80,0},
            extent={{-10,10},{10,-10}},
            rotation=270)));
        equation
            connect(currentSensor.p,signalCurrent.n) annotation(Line(points={{-50,-20},{-50,-15},{-50,15},{-50,20}}));

            connect(constantVoltage.n,currentSensor1.p) annotation(Line(points={{50,20},{50,15},{50,-15},{50,-20}}));

            connect(signalCurrent.p,p1) annotation(Line(points={{-50,40},{-50,45},{-50,50},{-95,50},{-100,50}}));

            connect(currentSensor.n,n1) annotation(Line(points={{-50,-40},{-50,-45},{-50,-50},{-95,-50},{-100,-50}}));

            connect(constantVoltage.p,p2) annotation(Line(points={{50,40},{50,45},{50,50},{95,50},{100,50}}));

            connect(currentSensor1.n,n2) annotation(Line(points={{50,-40},{50,-45},{50,-50},{95,-50},{100,-50}}));

            connect(primVolt.n,n1) annotation(Line(points={{-80,-10},{-80,-15},{-80,-50},{-95,-50},{-100,-50}}));

            connect(primVolt.p,p1) annotation(Line(points={{-80,10},{-80,15},{-80,50},{-95,50},{-100,50}}));

            connect(sekVolt.p,p2) annotation(Line(points={{80,10},{80,15},{80,50},{95,50},{100,50}}));

            connect(sekVolt.n,n2) annotation(Line(points={{80,-10},{80,-15},{80,-50},{95,-50},{100,-50}}));


            connect(gain.y,signalCurrent.i) annotation(Line(
                points={{-36.7,30},{-41.7,30},{-38,30},{-43,30}},
                color={0,0,127}));

            connect(division.y,gain.u) annotation(Line(
                points={{-10.7,30},{-15.7,30},{-13.3,30},{-18.3,30}},
                color={0,0,127}));

            connect(currentSensor1.i,product.u2) annotation(Line(
                points={{40,-30},{35,-30},{25.3,-30},{25.3,-6.7},{25.3,-1.7}},
                color={0,0,127}));

            connect(sekVolt.v,product.u1) annotation(Line(
                points={{70,0},{65,0},{65,-6.7},{34.7,-6.7},{34.7,-1.7}},
                color={0,0,127}));

            connect(product.y,division.u1) annotation(Line(
                points={{30,16.7},{30,21.7},{30,34.7},{12.7,34.7},{7.7,34.7}},
                color={0,0,127}));

            connect(primVolt.v,division.u2) annotation(Line(
                points={{-70,0},{-65,0},{12.7,0},{12.7,25.3},{7.7,25.3}},
                color={0,0,127}));
        annotation(
            Icon(
                coordinateSystem(preserveAspectRatio=false),
                graphics={
                    Rectangle(
                        lineColor={0,0,127},
                        fillColor={215,215,215},
                        fillPattern=FillPattern.Solid,
                        lineThickness=0.5,
                        extent={{-100,100},{100,-100}}),
                    Line(
                        points={{-100,100}}),
                    Line(
                        points={{-100,100},{-100,-100},{100,-100},{100,100},{-100,100}},
                        color={0,0,127},
                        thickness=0.5),
                    Line(
                        points={{-100,-100},{100,100}},
                        color={0,0,127},
                        thickness=0.5),
                    Text(
                        textString="DC",
                        lineThickness=0.5,
                        extent={{-60,80},{0,20}}),
                    Text(
                        textString="DC",
                        lineThickness=0.5,
                        extent={{0,-20},{60,-80}})}),
            Diagram(coordinateSystem(preserveAspectRatio=false)));
    end DCDC;
    DCDC dcdc(demandedVoltage=10) annotation(Placement(transformation(extent={{-30,30},{-10,50}})));
    Modelica.Electrical.Analog.Basic.Ground ground1 annotation(Placement(transformation(extent={{-85,-5},{-65,15}})));
    Modelica.Electrical.Analog.Basic.Resistor resistor1(R=2) annotation(Placement(transformation(
        origin={35,40},
        extent={{-10,-10},{10,10}},
        rotation=-90)));
    Modelica.Electrical.Analog.Basic.Ground ground2 annotation(Placement(transformation(extent={{0,-5},{20,15}})));
    Modelica.Electrical.Analog.Basic.Capacitor capacitor1(
        v(
            start=10,
            fixed=true),
        C=1) annotation(Placement(transformation(
        origin={-75,40},
        extent={{-10,-10},{10,10}},
        rotation=-90)));
    equation
        connect(resistor1.p,dcdc.p2) annotation(Line(
            points={{35,50},{35,55},{15,55},{15,45},{-5,45},{-10,
            45}},
            thickness=0.0625));
        connect(resistor1.n,dcdc.n2) annotation(Line(
            points={{35,30},{35,25},{15,25},{15,35},{-5,35},{-10,
            35}},
            thickness=0.0625));
        connect(ground2.p,dcdc.n2) annotation(Line(
            points={{10,15},{10,20},{10,35},{-5,35},{-10,35}},
            thickness=0.0625));
        connect(dcdc.p1,capacitor1.p) annotation(Line(
            points={{-30,45},{-35,45},{-35,55},{-75,55},{-75,50}},
            thickness=0.0625));
        connect(dcdc.n1,capacitor1.n) annotation(Line(
            points={{-30,35},{-35,35},{-35,25},{-75,25},{-75,30}},
            thickness=0.0625));
        connect(ground1.p,capacitor1.n) annotation(Line(
            points={{-75,15},{-75,20},{-75,25},{-75,30}},
            thickness=0.0625));
end TestDCDC;

注意,您已声明了
demandedVoltage
,但使用了
vehicleVoltage
。此外,我还为端口1添加了一个容量为1F、初始电压为10V的电容器,并为端口2添加了一个1欧姆的电阻器(加上两个所需的接地引脚)。该模型在SimulationX 3.6.5中运行了0.5s,并给出了预期的结果。在0.5秒时,由于电容器被放电,电容器电流发散(如预期的那样),会出现收敛误差。只是一个注释…对于Modelica,基本符号操作的一个优点是,您可以构建一个“理想”的DC-DC转换器。这意味着不需要动力(如电容器)。如果您对细节感兴趣,请告诉我。@MichaelTiller该模型作为顶级模型不完整。需要向dc-dc转换器的端口添加组件。很明显,可以向端口1添加一个恒压源,而不是电容器。然而,从
车辆电压
一词中可以清楚地看出应用程序。因此,在测试模型中,一些充电/放电效应对我来说是合适的。此外,通过这种方式,测试模型更有趣。当电容器放电时,获得电压信号和预期故障的预期
sqrt
-特性。由于恒定的功率需求,电流会发生发散。非常感谢,托比亚斯。混合电压的故障是由于我稍微改变了模型,将其张贴在这里。事实上,我在Dymola中遇到了奇点问题,这让我很困惑。谢谢你的帮助!