Skip to content

Make internal hinge detection independent of element order - #492

Open
mitchell-tesch wants to merge 3 commits into
anastruct:masterfrom
mitchell-tesch:fix/464-order-dependent-hinges
Open

mitchell-tesch wants to merge 3 commits into
anastruct:masterfrom
mitchell-tesch:fix/464-order-dependent-hinges

Conversation

@mitchell-tesch

Copy link
Copy Markdown
Contributor

Fixes #464.

Since 102cb38, check_internal_hinges() runs on every add_element() so hinges show before solve(). 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.
  • Internal hinges are matched by node id, because the post-processing replaces the Node objects. Before, every solve() appended the node again.
  • add_element() copies the spring dict, so a dict shared by several elements isn't modified.

Result (#464 model, dead load, moment at node 3)

Beam 2 Beam 3 (released) Column 7
1.7.x 0.00 0.00 0.00
this PR, and before 102cb38 -4.75 0.00 4.75

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.

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>
@brookshsmith

brookshsmith commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

@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.

brookshsmith and others added 2 commits November 22, 2026 20:24
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.
@mitchell-tesch

Copy link
Copy Markdown
Contributor Author

Thanks @brookshsmith, yes, agree that does seem like a much cleaner model, I have reworked the PR to be as follows:

  • A node is an internal hinge only when every element connected to it is released there, or when it was passed to add_internal_hinge(). Its rotation is then restrained in process_supports(), which already handled internal hinges as a rotation-only restraint.
  • Springs are never modified, so there's no original state to track and the result can't depend on element order.
  • The check no longer modifies the elements, so it's safe to re-run. I kept it on add_element(), and hinges still show in show_structure() before solve() (Add internal hinge in plots #402). Since the circle is now only drawn at nodes that really are hinges, I left the symbol as is. I didn't use supports_rotational, because those nodes would then appear in reaction_forces and be plotted as supports.
    Let me know what you think.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange behaviour of release - Forces all elements at node to be released

2 participants