Hello all.
I'm trying to create a script that will take lists of loads and supports entered into excel and feed it into the Sympy Beam package so solve.
At the bottom of this message is example code of what I'm doing.
I've noticed that things get pretty picky when trying to solve for support reactions.
Like the name in string format assigned to the reaction Symbol seems like it must match the numerical value of the location.
For example, the location currently set at a value of "10.5", if that was "11", then further below I'd need R2 = Symbols('R_11). If it was a location of 12, I'd need to update R2 = Symbols('R_12) otherwise the reaction solver throws an error.
Likewise I'm getting an error if I have a decimal location like 10.5. Below I've included the typical error I get.
Is there any way to accept decimal values for location?
Any help in understanding how these functions work so that I can avoid these errors would be greatly appreciated.
Below the shared code is Alternate Code which is my attempt at being able to feed in any amount of loads without needing to manually change the names of the symbols.
The assignment of variables to symbols seems to work fine. But when it comes to feeding into the solve_for_reaction_load I get the same "tuple out of index range" even if I don't have a decimal location
######### ERROR
line 778, in solve_for_reaction_loads
+ deflection_eqs, (C3, C4) + reactions).args)[0])
IndexError: tuple index out of range
######### Code Starts Here
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, Piecewise, init_printing
from sympy.plotting import PlotGrid
init_printing(use_unicode=True, wrap_line=False)
beam_E = 5
beam_I = 2
beam_L = 12
b = Beam(beam_L, beam_E, beam_I)
supports = [[0, 'roller'], [10.5, 'roller']]
test_loads = [[1.4, 2.0, -1, None, 'D'],
[2, 2.0, -1, None, 'L'],
[3, 10.0, -1, None, 'S'],
[-1, 2.0, -1, None, 'W'],
[4, 3.0, -1, None, 'L'],
[7, 6.0, -1, None, 'W']]
# Apply Loads
for load_info in test_loads:
b.apply_load(*load_info[:4])
# Apply supports
for support_info in supports:
b.apply_support(support_info[0], support_info[1])
R1, R2 = symbols('R_0, R_10.5')
b.solve_for_reaction_loads(R1, R2)
################# ALTERNATE CODE
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, Piecewise, init_printing
from sympy.plotting import PlotGrid
init_printing(use_unicode=True, wrap_line=False)
beam_E = 5
beam_I = 2
beam_L = 12
b = Beam(beam_L, beam_E, beam_I)
supports = [[0, 'roller'], [10, 'roller']]
test_loads = [[1.4, 2.0, -1, None, 'D'],
[2, 2.0, -1, None, 'L'],
[3, 10.0, -1, None, 'S'],
[-1, 2.0, -1, None, 'W'],
[4, 3.0, -1, None, 'L'],
[7, 6.0, -1, None, 'W']]
# Apply Loads
for load_info in test_loads:
b.apply_load(*load_info[:4])
# Apply supports
for support_info in supports:
b.apply_support(support_info[0], support_info[1])
reac_str = str(b.load)
reactions = ([x for x in reac_str.replace(' ','*').split('*') if '_' in x])
reactions_qty = len(reactions)
reaction_symbols_vars = ','.join( ['R' + str(x) for x in range(len(reactions))] )
reaction_symbols_str = ','.join(reactions)
exec(reaction_symbols_vars + '= symbols("' + reaction_symbols_str +'")')
exec(b.solve_for_reaction_loads(reaction_symbols_vars))