Number of variables vs number of equations in Simscape components

4 次查看(过去 30 天)
When I define a new custom component in Simscape, as a general rule I take care that the number of equations in the "equations" section match the number of variables in the "variables" section. So far so good.
However, while studying the source code of some components of the Foundation Library, I discovered that this requirement is not always satisfied. For example: "convection_port.ssc" is the source code for a convection port component, which is part of the "Thermal Liquids" library. The code shows a clear mismatch between the number of variables and the number of equations (specifically: there are more variables than equations). However, this component is obviously a valid one.
In conclusion, I was wondering if there is a general rule that must be followed when setting the number of variables & equations for a custom Simscape component, so that its validity is guaranteed.
I searched the documentation online, but I could not find a detailed answer so far
Thanks

回答(1 个)

J Chen
J Chen 2023-3-20
编辑:J Chen 2023-3-21
For a Simscape component, the variables include variables in the variables AND nodes sections as in this example. The number of equations in the "equations" section doesn't need to match the number of variables in the "variables" section. Look at the resistor example: there are 6 variables (p.v, p.i, n.v, n.i, i, v), 2 eqs in the equations section and 2 eq in the branches section (i=p.i, p.i=-n.i). So we need to know 2 variables (e.g., p.v, n.v) in order to solve the problem. This is consistent with a real resistor, i.e., if two variables are specified (e.g., voltages at the two terminal), all the variables are defined.
  1 个评论
Federico Toso
Federico Toso 2023-3-20
According to Simscape documentation, branches section does not introduce new equations, it only modifies the already-present node equations.
Even in the resistor example you quoted, the number of variables declared inside the component file (i and v) matches the number of equations in the equations section (if you exclude the assert statement)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Foundation and Custom Domains 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by