OpenModelica error: an array of expandable connectors - over-determined system
OpenModelica error: an array of expandable connectors - over-determined system
任何人都可以启发我为什么以下 modelica 代码在 OpenModelica 1.12.0 上生成错误?如果我删除最后两个连接方程,它工作正常。
class A
Conn cc[3];
Real a(start=0,fixed=true);
Real b(start=0,fixed=true);
Real c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc[1].v);
connect(b,cc[2].v); // Remove this to make it work
connect(c,cc[3].v); // Remove this to make it work
end A;
可扩展连接器 cc 为空:
expandable connector Conn
end Conn;
以上代码在 OpenModelica 1.12.0 上产生错误:
[1] 15:07:44 Symbolic Error
Too many equations, over-determined system. The model has 6 equation(s) and 4 variable(s).
[2] 15:07:44 Symbolic Warning
[A: 11:3-11:21]: Equation 5 (size: 1) b = cc[2].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: b
Equations used to solve those variables:
Equation 2 (size: 1): der(b) = 2.0
[3] 15:07:44 Symbolic Warning
[A: 12:3-12:21]: Equation 6 (size: 1) c = cc[3].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: c
Equations used to solve those variables:
Equation 3 (size: 1): der(c) = 3.0
基本上,我想要一个可扩展连接器数组,我可以根据需要添加不同类型的变量。
编辑 18/08/2018
关于我只能将 "connectors" 连接到可扩展连接器,实际上我看到 modelica 规范 3.4 文档说:
All components in an expandable connector are seen as connector instances even if they are not declared as
such [i.e. it is possible to connect to e.g. a Real variable].
看来我可以将 Real 变量连接到 OpenModelica 中的可扩展连接器,但是,我在 JModelica 中遇到错误:
Error at line 13, column 11, in file 'A.mo':
Connecting to an instance of a non-connector type is not allowed
我也可以在 OpenModeica 中将 Real 变量连接到普通(不可扩展的)连接器,但这在 JModelica 中也是不允许的。所以工具以不同的方式解释语言规范!
您不能将 Real 变量连接到可扩展连接器,它需要是连接器。但不知何故,这也不起作用,似乎是一个错误。以下是有效的(在 OM 和 Dymola 中测试):
class Expandable
expandable connector Conn
Real v[3];
end Conn;
connector RealOutput = output Real "'output Real' as connector";
Conn cc;
RealOutput a(start=0,fixed=true);
RealOutput b(start=0,fixed=true);
RealOutput c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc.v[1]);
connect(b,cc.v[2]);
connect(c,cc.v[3]);
end Expandable;
任何人都可以启发我为什么以下 modelica 代码在 OpenModelica 1.12.0 上生成错误?如果我删除最后两个连接方程,它工作正常。
class A
Conn cc[3];
Real a(start=0,fixed=true);
Real b(start=0,fixed=true);
Real c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc[1].v);
connect(b,cc[2].v); // Remove this to make it work
connect(c,cc[3].v); // Remove this to make it work
end A;
可扩展连接器 cc 为空:
expandable connector Conn
end Conn;
以上代码在 OpenModelica 1.12.0 上产生错误:
[1] 15:07:44 Symbolic Error
Too many equations, over-determined system. The model has 6 equation(s) and 4 variable(s).
[2] 15:07:44 Symbolic Warning
[A: 11:3-11:21]: Equation 5 (size: 1) b = cc[2].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: b
Equations used to solve those variables:
Equation 2 (size: 1): der(b) = 2.0
[3] 15:07:44 Symbolic Warning
[A: 12:3-12:21]: Equation 6 (size: 1) c = cc[3].v is not big enough to solve for enough variables.
Remaining unsolved variables are:
Already solved: c
Equations used to solve those variables:
Equation 3 (size: 1): der(c) = 3.0
基本上,我想要一个可扩展连接器数组,我可以根据需要添加不同类型的变量。
编辑 18/08/2018
关于我只能将 "connectors" 连接到可扩展连接器,实际上我看到 modelica 规范 3.4 文档说:
All components in an expandable connector are seen as connector instances even if they are not declared as
such [i.e. it is possible to connect to e.g. a Real variable].
看来我可以将 Real 变量连接到 OpenModelica 中的可扩展连接器,但是,我在 JModelica 中遇到错误:
Error at line 13, column 11, in file 'A.mo':
Connecting to an instance of a non-connector type is not allowed
我也可以在 OpenModeica 中将 Real 变量连接到普通(不可扩展的)连接器,但这在 JModelica 中也是不允许的。所以工具以不同的方式解释语言规范!
您不能将 Real 变量连接到可扩展连接器,它需要是连接器。但不知何故,这也不起作用,似乎是一个错误。以下是有效的(在 OM 和 Dymola 中测试):
class Expandable
expandable connector Conn
Real v[3];
end Conn;
connector RealOutput = output Real "'output Real' as connector";
Conn cc;
RealOutput a(start=0,fixed=true);
RealOutput b(start=0,fixed=true);
RealOutput c(start=0,fixed=true);
equation
der(a) = 1;
der(b) = 2;
der(c) = 3;
connect(a,cc.v[1]);
connect(b,cc.v[2]);
connect(c,cc.v[3]);
end Expandable;