Skip to content

Comments

fix: Reaction calculation#7

Merged
angelsolaorbaiceta merged 3 commits intomasterfrom
fix/reactions
Apr 14, 2025
Merged

fix: Reaction calculation#7
angelsolaorbaiceta merged 3 commits intomasterfrom
fix/reactions

Conversation

@angelsolaorbaiceta
Copy link
Owner

@angelsolaorbaiceta angelsolaorbaiceta commented Apr 14, 2025

Description

Fixes the reaction calculation for the structures package.

Details

The structures.solution.structure class' reaction_for_node() method was incorrectly calculating the reaction force in an externally constrained node like so:

    def reaction_for_node(self, node: StrNodeSolution) -> Vector:
        if not node.is_constrained:
            return Vector(0, 0)

        forces = [bar.force_in_node(node) for bar in self.bars if bar.has_node(node)]

        if node.is_loaded:
            forces.append(node.net_load.opposite())

        return reduce(operator.add, forces)

But, to calculate the reactions correctly, the constrained direction have to be taken into account:

    def reaction_for_node(self, node: StrNodeSolution) -> Vector:
        if not node.is_constrained:
            return Vector(0, 0)

        forces = [bar.force_in_node(node) for bar in self.bars if bar.has_node(node)]

        if node.is_loaded:
            forces.append(node.net_load.opposite())

--      return reduce(operator.add, forces)
++      net_force = reduce(operator.add, forces)

++      # The reaction can only have the components of the constrained directions
++      return Vector(
++          u=net_force.u if node.dx_constrained else 0.0,
++          v=net_force.v if node.dy_constrained else 0.0,
++      )

@angelsolaorbaiceta angelsolaorbaiceta merged commit e677a10 into master Apr 14, 2025
4 checks passed
@angelsolaorbaiceta angelsolaorbaiceta deleted the fix/reactions branch April 14, 2025 17:17
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.

1 participant