Number of variables vs number of equations in Simscape components

조회 수: 5 (최근 30일)
Federico Toso
Federico Toso 2023년 3월 10일
편집: J Chen 2023년 3월 21일
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