Repository navigation
Make internal hinge detection independent of element order - #492
mitchell-tesch wants to merge 3 commits into
Conversation
Since 102cb38, check_internal_hinges() runs on every add_element(). It released the remaining elements of a node as soon as the elements added so far met the hinge criteria, and never undid this. A joint where only one of three elements is released became a hinge if the released element was added before the third one (anastruct#464). check_internal_hinges() now records the releases it adds and undoes them before re-evaluating a node. Internal hinges are matched by node id, as the post-processing replaces the node objects, and add_element() copies the spring dict, as it may be shared by several elements. Fixes anastruct#464 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@mitchell-tesch : The bug you're fixing is definitely very real, but I want to correct the reason, and propose a different fix. The reason has nothing to do with plotting; it's because, in FEA maths, if you release every element from a node, then you technically have an unstable structure. Because the node itself can freely rotate. While advanced users have always been able to freely set releases on elements, a common use case for less-advanced users is to try to create a truss for analysis by releasing the ends of every or most elements - which would then often result in an unrestrained nodal rotation and an unstable solve, and can legitimately be a fairly big PIA to diagnose and fix. The original solution to that problem was to try to ensure that at least one element always maintained a fixed connection to every node. However, you're correct in observing that there's a bug in that, in that it didn't keep track of which elements it artificially fixed to a node in this manner, and so could unintentionally mutate a system based upon the order in which elements were created. An alternate solution to this problem, that I think would be cleaner and more rational, would be to instead create a rotation-only "support" at nodes that have unrestrained rotation - and to then just delete all the logic around trying to fix one element to a node, or even around reassessing the need for such fixity upon element add (we could assess it only once, immediately before solve()). Since rotation-only supports are incredibly uncommon in real analyses people do, we could probably not even bother plotting them (or if we do, just something subtle, like maybe drawing the node as a dark blue instead of black). And we'd need not check for them until immediately before a solve, making the need for tracking an "original" state moot. |
check_internal_hinges() treated a node as an internal hinge when at most one element was rigidly connected to it, and released that element too by writing 0 into its springs. As it runs on every add_element(), the result depended on the order in which the elements were added (anastruct#464). A node is now an internal hinge only if every element connected to it is released there, or it was passed to add_internal_hinge(). Its rotation is then restrained, and element springs are never modified. add_internal_hinge() nodes are kept by discretize(), and solve() raises for a moment load on an internal hinge whose rotation no support restrains, instead of silently losing it.
|
Thanks @brookshsmith, yes, agree that does seem like a much cleaner model, I have reworked the PR to be as follows:
|
Fixes #464.
Since 102cb38,
check_internal_hinges()runs on everyadd_element()so hinges show beforesolve(). It released the remaining elements of a node as soon as the elements added so far met the hinge criteria, and never undid this. In #464, node 3 connects beam 2, beam 3 (released at node 3) and column 7. Beam 3 is added before column 7, so node 3 became a hinge and beam 2 and column 7 were released too.Change
check_internal_hinges()records the releases it adds and undoes them before re-evaluating a node. The hinge criteria are unchanged.Nodeobjects. Before, everysolve()appended the node again.add_element()copies thespringdict, so a dict shared by several elements isn't modified.Result (#464 model, dead load, moment at node 3)
The new test builds the joint in three element orders; it fails on
master. pytest, pylint, mypy and black pass.Related: #482 also fixes this, with a different hinge model (springs are never modified). I'm happy to close this PR if #482 is merged first. This PR merges cleanly with #487, #490 and #491.