在Modelica中构建简单DCDC转换器的问题

时间:2015-07-02 09:25:01

标签: modelica openmodelica

我想为DCDC转换器编写一个非常简单的模型。出于某种原因,Dymola告诉我,"模型并不适合#34;并且超过了Real元素。

这可能是一个非常简单的问题,但我无法看到它!

这是我的代码:

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库)

enter image description here

希望你能以某种方式帮助我解决这个问题!提前谢谢!

1 个答案:

答案 0 :(得分:3)

唯一的小问题是您已声明demandedVoltage但使用vehicleVoltage。您的模型没有其他任何问题。

注意:最好在问题中包含一个最小的顶级模型进行测试。

我在顶级模型TestDCDC中测试了您的模型,并在SimulationX 3.6.5中测试了电容作为电源和电阻作为负载。

下图显示了测试模型的原理图。

Schematic of the test model

使用SimulationX获得的结果如下图所示。

enter image description here

我还检查了SimulationX生成的方程系统。它看起来很好。

Dymola 2015会生成错误的错误消息,指出除了方程式之外还有两个变量。您应该向Dymola的制作人发布此模型的错误报告。请注意,Modelica模型的符号分析非常复杂,可能会出现类似问题。通常,该工具的维护者对此案例中的错误报告表示感谢。

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

W = C/2*(v.start)^2-P*time = 50Ws - 100W*time

并且电容器电压信号导致

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

time = 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;