-
Notifications
You must be signed in to change notification settings - Fork 44
Local balance #3750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
HansOlsson
wants to merge
6
commits into
modelica:master
Choose a base branch
from
HansOlsson:LocalBalance
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Local balance #3750
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
becf054
Correcting the issues in #3732
HansOlsson 7b1e0c9
Rename "number of variables" to "number of potential variables" to re…
HansOlsson 747815d
Break tie for input/output causality.
HansOlsson e8afd7e
For N2 case.
HansOlsson 4b3d58d
Update chapters/classes.tex
HansOlsson 522444e
Update chapters/classes.tex
HansOlsson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overly abstract and as I explained before the only way I am signing off on it is if other people prefer this formulation to what I proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that others can find that alternative (which responded to a previous variant of this text):
Originally posted by @qlambert-pro in #3750 (comment)
I have a hard time understanding how that description really works, as Connections.root and Connections.potentialRoot don't directly contribute to the global equation count (for potentialRoot there is normally an if-equation based on whether it is selected as root or not).
However, I can understand that this problem is abstract and complicated to get right.
The following are four cases that seem to covert this:
Modelica.Mechanics.MultiBody.Forces.WorldForceModelica.Mechanics.MultiBody.Parts.BodyModelica.Mechanics.MultiBody.Forces.SpringThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some additional thinking:
I still don't think that describing local variable and equation sizes in that way for the local check would be good, as it creates a different way of counting even for a simple model with overdetermined connectors and without sub-components.
However, it indicates that it is locally and globally possible to check balancing without generating the spanning tree and the corresponding equations, and that seems seems like something that could be documented in general. I would slightly rewrite it as (and view that as a separate pull-request):
-Start-
For checking the number of variables and equations for overdetermined connectors an alternative to generating equations from the spanning tree is the following (note that this often generates fewer variables and equations, but both counts are decreased by the same amount):
For over-determined variables and equations, where the cardinality of the type is
cand the size of the residual isn(wherec>=n):nvariables.c.c-nvariables.c-nvariables if the root is selected and 0 otherwise.nequations.The balance should hold for all legal selections of potential roots, and also for all possibilities for Connections.isRooted. For local check only the local Connections.root etc are considered.
The addition of
c-nvariables effectively mean that roots (and one of the arguments to branch) are counted as having the cardinality of its type,c.-End-
Notes:
ccorrespond to branches being in parallel with equations for the entire over-determined connector (i.e., of sizec) and roots having equations for the entire over-determined connector, i.e.,cequations, not only equations for the residual.For simulation models this is consistent with the equation count in for the spanning tree since:
c-nvariables (unless already done), and based on the spanning tree a corresponding number of equations:c, i.e., addingc-nequations.c-nvariables.nresidual equations.An alternative that is more intuitive, except for one minor issue, would be to reduce the changes to:
cvariables, if they are (locally) selected as root (potential or otherwise) or the target of Connections.branch; in all other cases asnvariables.nequations (regardless of whether the branch is broken or not).The only issue is that the Connections.branch "target" must be a non-root to avoid double-counting. So, if you have two potential roots and a branch between them you may have to adjust the target depending on the root-selection (both cannot be selected). Trivial, but that is sort of looking at the spanning tree).
That model is an issue also for the proposal above, that is hidden in the "all legal selection of roots", so if someone has such a model and writes
if Connections.isRoot(f_a.o) then ... else if Connections.isRoot(f_b.o) then else ... end ifbased on the understanding that only one of them will be a root we need to use the spanning tree information to rule out both being selected as roots, since otherwise it will be unbalanced in that case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the cases above with an over-constrained connector, Frame, with
nflows andcvariables in the over-determined type. To me one major benefit of this way of thinking is that one can adjust this to not only have a local balance in terms of number of variables and equations, but also construct structurally non-singular equations based on this, which may find structurally singular sub-components even if they are balanced.Modelica.Mechanics.MultiBody.Parts.Body(with potential root we also coverModelica.Mechanics.MultiBody.Forces.WorldForce). The thing that makes it complicated is the quaternions which are due to the same underlying issue with over-determined types, so I thought it best to include that as well in a general setting:It has if
nQ+n+cvariables and the same number of equations:if isRoot(frame_a.R) then c+(nQ-n) else nQnif isRoot(frame_a.R) then 0 else c-nNote: This works both if the over-determined type describe rotation as rotation matrix (c=9) or as quaternion(c=4).
Connection from a sub-component (half of
Modelica.Mechanics.MultiBody.Forces.Spring- it would be straightforward to add the other half):It has
n+c+nvariables (we only consider flow-variables for connectors in sub-components) and the same number of equations:n+cequations.nConnection from a sub-component (half of spring-damper built in the same way`):
Since both of the inside over-determined connectors are seen as roots it has to break of the connections.
It has
n+c+n*2variables (we only consider flow-variables for connectors in sub-components), and the same number of equations:ncequationsnresidual equationsnHowever, even if I could include that in the specification as examples (with both halves) I now think it would be too much.