sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.49k stars 4.32k forks source link

Improving Beam Class to Handle Hinge Beams Using Singularity Functions to Describe Hinges #26570

Open mvg2002 opened 3 weeks ago

mvg2002 commented 3 weeks ago

Right now the beam class in the continuum mechanics module of SymPy can calculate beams with hinges, but it has some limitations. The method can only calculate beams with a single hinge and when a force is placed exacly on a hinge the result is not correct. Take for example the following code:

from sympy import symbols
from sympy.physics.continuum_mechanics.beam import Beam

E, I = symbols('E, I')
F = symbols('F')
R_0, R_2, R_6 = symbols('R_0, R_2, R_6')
b1 = Beam(4, E, I)
b2 = Beam(2, E, I)
b= b1.join(b2, via="hinge")
b.apply_load(-F, 4, -1)
b.apply_load(R_0, 0, -1)
b.apply_load(R_2, 2, -1)
b.apply_load(R_6, 6, -1)
b.solve_for_reaction_loads(R_0, R_2, R_6)
b.reaction_loads

This code has as output: {R_0: -2F, R_2: 4F, R_6: 0} The correct output would be: {R_0: -F, R_2: 2*F, R_6: 0}

This problem is probably the result of these lines of code, where the force F is aplied twice on the structure if it is exacly on the beam.

        for load in self.applied_loads:
            if load[1] < l:
                load_1 += load[0]*SingularityFunction(x, load[1], load[2])
                if load[2] == 0:
                    load_1 -= load[0]*SingularityFunction(x, load[3], load[2])
                elif load[2] > 0:
                    load_1 -= load[0]*SingularityFunction(x, load[3], load[2]) + load[0]*SingularityFunction(x, load[3], 0)
            elif load[1] == l:
                load_1 += load[0]*SingularityFunction(x, load[1], load[2])
                load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2])
            elif load[1] > l:
                load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2])
                if load[2] == 0:
                    load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2])
                elif load[2] > 0:
                    load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2]) + load[0]*SingularityFunction(x, load[3] - l, 0)

This problem can be solved, but the bigger picture is that this is not the most efficient way to calculate beams with hinges. In this article Falsone writes how hinges can be described with Singularity Functions to calculate beams. This method of Falsone has as big advantage that beams with multiple hinges can be solved in a structured way. This expands the possiblities of the Beam method to solve more complicated beams.

The coming weeks I will be working on implementing this into python code and, if it is wanted and good enough, merging it into SymPy. I am a Civil Engineering student at the TU Delft and have more knowledge on the mechanical side of this project than on the python implementation. So if you have any suggestions or things I might be overlooking here let me know. All the help is welcome!

As this is a school project I will tag my supervisors so they stay up-to-date: @Tom-van-Woudenberg @moorepants