1

我正在尝试构建一个继电器,但我总是收到一个对我来说没有任何意义的错误。

该错误表示缺少地面对象或未连接组件,
但我找不到任何丢失的东西。

我尝试以不同的方式构建继电器,但总是出现相同的错误......

在此处输入图像描述

我测试继电器的课程:

model test

Relay relay  annotation (Placement(transformation(extent={{-20,4},{0,24}})));
ConstantVoltage constantVoltage annotation (Placement(transformation(
    extent={{-10,-10},{10,10}},
    rotation=-90,
    origin={-74,10})));
ConstantVoltage constantVoltage1 annotation (Placement(transformation(
    extent={{-10,-10},{10,10}},
    rotation=-90,
    origin={52,12})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-42,-30},{-22,-10}})));
equation 
connect(relay.n1, constantVoltage.n)  annotation (Line(
  points={{-20,9},{-46,9},{-46,0},{-74,0}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantVoltage.p, relay.p1)  annotation (Line(
  points={{-74,20},{-48,20},{-48,19},{-20,19}},
  color={0,0,255},
  smooth=Smooth.None));
connect(relay.n1, ground.p)  annotation (Line(
  points={{-20,9},{-26,9},{-26,-10},{-32,-10}},
  color={0,0,255},
  smooth=Smooth.None));
connect(relay.p2, constantVoltage1.p)  annotation (Line(
  points={{0,19},{26,19},{26,22},{52,22}},
  color={0,0,255},
  smooth=Smooth.None));
connect(constantVoltage1.n, relay.n2)  annotation (Line(
  points={{52,2},{26,2},{26,9},{0,9}},
  color={0,0,255},
  smooth=Smooth.None));
connect(ground.p, relay.n2)  annotation (Line(
  points={{-32,-10},{-16,-10},{-16,9},{0,9}},
  color={0,0,255},
  smooth=Smooth.None));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
        -100},{100,100}}), graphics));
 end test;

继电器类:很简单,我只看v1,如果电压为正,继电器应该让电流通过。

model Relay
extends Modelica.Electrical.Analog.Interfaces.TwoPort;

Boolean off;

equation 
off = v1 < 0;

v2 = if off then 0 else v2;
i2 = if off then 0 else i2;

annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
        -100},{100,100}}), graphics));
end Relay;

错误日志:

Check of MTS.test:

The model has the same number of unknowns and equations: 27

The problem is structurally singular.
It has 27 scalar unknowns and 27 scalar equations.
The Real part has 26 unknowns and 26 equations.
The Integer part has 0 unknowns and 0 equations.
The Boolean part has 1 unknowns and 1 equations.
The String part has 0 unknowns and 0 equations.

Attempting to further localize singularity.

Singularity of MTS.test is at the top level.

The model MTS.test is structurally singular.

The problem is structurally singular for the element type Real.
The number of scalar Real unknown elements are 26.
The number of scalar Real equation elements are 26.

The model includes the following hints:
An electrical current cannot be uniquely calculated.
The reason could be that
- a ground object is missing (Modelica.Electrical.Analog.Basic.Ground)
to define the zero potential of the electrical circuit, or
- a connector of an electrical component is not connected.

The problem has no elements of type Integer.

The problem is structurally regular for the element type Boolean.
The number of scalar Boolean elements are 1.

The problem has no elements of type String.

ERROR: 2 errors were found

WARNING: 2 warnings were issued
4

3 回答 3

2

Here is a different approach that may be worth investigating:

Using a variable resistor on the switch side, and if the switch is open then set the resistance to very large and if it is closed set the resistance to very small.

There are probably more accurate methods but you could probably implement this in such a way to avoid events.

于 2013-04-05T12:22:36.087 回答
1

At a glance, the thing that strikes me is that you don't have any load in either circuit. It says it cannot compute the current but the ground issue is only a hint. Looking at the circuit, you have to ask yourself, what would these circuits do if there was no ground? Without a load of some kind in the circuit, I don't see a way to compute the currents in either loop.

So try putting some resistors in each loop and see if that helps.

于 2013-03-31T12:31:53.443 回答
1

我不认为 i2 和 v2 在您的继电器模型中应该同时为零。试试这个。一方面是理想的电压传感器。另一个在设定电压以下开路,在其之上短路。正如另一个响应指出的那样,您需要添加一个串联负载来解决电流问题。模型继电器扩展了 Modelica.Electrical.Analog.Interfaces.TwoPort;布尔关闭;参数 Modelica.SIunits.Voltage disconnectVoltage = 0;

   equation 
     off = v1 < disconnectVoltage;
     i1=0;
     if off then
       i2 = 0;
     else
       v2 = 0;
     end if;
   end Relay;

如果您必须避免模型中的任何负载,您可以使用 Modelica 标准库中的理想开关之一构建类似的东西。它们包括小电阻和电导,因此在您的示例中应该可以在不增加负载的情况下求解电流。

model relay2

  Modelica.Electrical.Analog.Ideal.IdealOpeningSwitch idealOpeningSwitch 
    annotation (Placement(transformation(
        extent={{-10,10},{10,-10}},
        rotation=-90,
        origin={60,0})));
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor annotation (
      Placement(transformation(
        extent={{-10,10},{10,-10}},
        rotation=-90,
        origin={-60,0})));
  Modelica.Blocks.Logical.GreaterThreshold greaterThreshold(threshold=0) 
    annotation (Placement(transformation(
        extent={{10,-10},{-10,10}},
        rotation=180,
        origin={0,0})));
  Modelica.Electrical.Analog.Interfaces.PositivePin p1
    annotation (Placement(transformation(extent={{-110,50},{-90,70}})));
  Modelica.Electrical.Analog.Interfaces.NegativePin n1
    annotation (Placement(transformation(extent={{-110,-70},{-90,-50}})));
  Modelica.Electrical.Analog.Interfaces.PositivePin p2
    annotation (Placement(transformation(extent={{90,50},{110,70}})));
  Modelica.Electrical.Analog.Interfaces.NegativePin n2
    annotation (Placement(transformation(extent={{90,-70},{110,-50}})));
  annotation (Diagram(coordinateSystem(preserveAspectRatio=true,extent={{-100,-100},
            {100,100}}), graphics), uses(Modelica(version="3.2")));
equation 

  connect(greaterThreshold.u, voltageSensor.v) annotation (Line(
      points={{-12,0},{-12,0},{-50,0},{-50,0}},
      color={0,0,127},
      smooth=Smooth.None));
  connect(idealOpeningSwitch.control, greaterThreshold.y) annotation (Line(
      points={{50,0},{45,0},{15,0},{15,0},{15,0}},

      color={255,0,255},
      smooth=Smooth.None));

  connect(idealOpeningSwitch.n, n2) annotation (Line(
      points={{60,-10},{60,-60},{100,-60}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(idealOpeningSwitch.p, p2) annotation (Line(
      points={{60,10},{60,60},{100,60}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(voltageSensor.p, p1) annotation (Line(
      points={{-60,10},{-60,60},{-100,60}},
      color={0,0,255},
      smooth=Smooth.None));
  connect(voltageSensor.n, n1) annotation (Line(
      points={{-60,-10},{-60,-60},{-100,-60}},
      color={0,0,255},
      smooth=Smooth.None));
end relay2
于 2013-04-13T00:46:47.750 回答