Sampad,
Thanks for your reply and interest. You can add Sympy group in this thread – I have no problem just send me a link.
I think my question was not very clear. I am sorry about that.
My problem is a beam fixed at both ends with a concentrated load of 6 units in the center. Theoretical answer for M1 and M2 is 6*4/8 = 3.
When I run the following script,
from sympy.physics.continuum_mechanics.beam import Beam
from sympy.functions import SingularityFunction
from sympy import symbols, Piecewise, plot
E, I, x = symbols('E, I, x')
R1, R2 = symbols('R1, R2')
M1, M2 = symbols('M1, M2')
b = Beam(4, E, I)
b.apply_load(R1, 0, -1)
b.apply_load(6, 2, -1)
b.apply_load(R2, 4, -1)
b.apply_load(M1, 0, -1)
b.apply_load(M2, 4, -1)
b.bc_deflection = [(0, 0), (4, 0)]
b.bc_slope = [(0, 0), (4, 0)]
print b.boundary_conditions
#b.solve_for_reaction_loads(R1, R2)
b.solve_for_reaction_loads(R1, R2,M1,M2)
print b.load
print b.shear_force()
print b.bending_moment()
print b.slope().subs({E:1,I:1})
print b.deflection().subs({E:1,I:1})
I get following output
In [2]: runfile('C:/UserApps/Python27/Lib/site-packages/xy/problem01.py', wdir='C:/UserApps/Python27/Lib/site-packages/xy')
{'slope': [(0, 0), (4, 0)], 'deflection': [(0, 0), (4, 0)]}
M1*SingularityFunction(x, 0, -1) + M2*SingularityFunction(x, 4, -1) + (-M1 - 3)*SingularityFunction(x, 0, -1) + (-M2 - 3)*SingularityFunction(x, 4, -1) + 6*SingularityFunction(x, 2, -1)
M1*SingularityFunction(x, 0, 0) + M2*SingularityFunction(x, 4, 0) + (-M1 - 3)*SingularityFunction(x, 0, 0) + (-M2 - 3)*SingularityFunction(x, 4, 0) + 6*SingularityFunction(x, 2, 0)
M1*SingularityFunction(x, 0, 1) + M2*SingularityFunction(x, 4, 1) + (-M1 - 3)*SingularityFunction(x, 0, 1) + (-M2 - 3)*SingularityFunction(x, 4, 1) + 6*SingularityFunction(x, 2, 1)
Traceback (most recent call last):
File "<ipython-input-2-febc462b31fc>", line 1, in <module>
runfile('C:/UserApps/Python27/Lib/site-packages/xy/problem01.py', wdir='C:/UserApps/Python27/Lib/site-packages/xy')
File "C:\UserApps\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\UserApps\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/UserApps/Python27/Lib/site-packages/xy/problem01.py", line 28, in <module>
print b.slope().subs({E:1,I:1})
File "C:\UserApps\Python27\lib\site-packages\sympy-1.0.1.dev0-py2.7.egg\sympy\physics\continuum_mechanics\beam.py", line 455, in slope
slope_curve = slope_curve.subs({C3: constants[0][0]})
IndexError: list index out of range
In [3]: b.reaction_loads
Out[3]: {M2: M2, M1: M1, R2: -M2 - 3, R1: -M1 - 3}
I expect to get something like {R2:-3,R1:-3,M1:3, M1:3}
I can understand that the problem I am trying to solve has indeterminacy of 2 and that is why my script is missing some additional statements.
Once this appears in the thread, I will pursue this because it is an intersting problem for a hobbyist like me.
Thanks for the help.
Regards,
Sanjiv Durve
Ex- I I T Kanpur (1976)
From: SAMPAD SAHA [mailto:sampa...@gmail.com]
Sent: 12 January 2017 12:34
To: Durve Sanjiv (External)
Subject: Re: SingularityFunction in sympy.physics.continuum_mechanics.beam
Sorry for the late reply.
I tried it in my system. I am getting {R2: -3, R1: -3} as output for the reaction forces.
Can you please share us your outputs and also the problem statement which you are trying to solve?
And one more thing, it is absolutely fine contacting me directly at my gmail but still it is more preferrable that you post these queries into the Sympy group and CC other developers. This way you don't have to wait for long and can get very quick response as there are many active developers working on Sympy currently.
If you don't mind Can I add Sympy Group in this thread?
Regards
Sampad Kumar Saha
Mathematics and Computing
I.I.T. Kharagpur
On Tue, Jan 10, 2017 at 10:29 PM, Durve Sanjiv (External) <Sanjiv.Du...@saipem.com> wrote:
Hello Sampad,
I have been trying to solve a fixed beam problem with concentrated load at the center of the beam using sympy. You seem to have done a wonderful job of implementing SingularityFunction. I hope you don’t mind me contacting you directly at your gmail.
I have the following code which does not give the correct bending moment at the fixed ends. The line b.bc_slope = [(0, 0), (4, 0)] seems to have no effect
Is there a quick fix or let me know if I am missing something. I also tried introducing M1, M2 and then commented out (shown in bold lines)
Your help would be appreciated.
from sympy.physics.continuum_mechanics.beam import Beam
from sympy.functions import SingularityFunction
from sympy import symbols, Piecewise, plot
E, I, x = symbols('E, I, x')
R1, R2 = symbols('R1, R2')
M1, M2 = symbols('M1, M2')
b = Beam(4, E, I)
b.apply_load(R1, 0, -1)
b.apply_load(6, 2, -1)
b.apply_load(R2, 4, -1)
#b.apply_load(M1, 0, -1)
#b.apply_load(M2, 4, -1)
b.bc_deflection = [(0, 0), (4, 0)]
b.bc_slope = [(0, 0), (4, 0)]
print b.boundary_conditions
b.solve_for_reaction_loads(R1, R2)
#b.solve_for_reaction_loads(R1, R2,M1,M2)
print b.load
print b.shear_force()
print b.bending_moment()
print b.slope().subs({E:1,I:1})
print b.deflection().subs({E:1,I:1})
p2 = plot(b.shear_force(),(x,0,4))
p3 = plot(b.bending_moment(),(x,0,4))
p1 = plot(b.slope().subs({E:1,I:1}),(x,0,4))
p4 = plot(b.deflection().subs({E:1,I:1}),(x,0,4))
Regards,
Sanjiv Durve
______________________________________________________________________________________________________
Confidentiality: This e-mail and its attachments are intended for the above named only and may be confidential. If they have come to you in error you must take no action based on them, nor must you copy or show them to anyone; please reply to this e-mail and
highlight the error.
______________________________________________________________________________________________________
******************************************************************************************
CONFIDENTIALITY NOTICE
This e-mail and any attachment are confidential and may be privileged or otherwise protected from disclosure. It is solely intended for the person(s) named above. If you are not the intended recipient, any reading, use, disclosure, copying or distribution of
all or parts of this e-mail or associated attachments is strictly prohibited. If you are not an intended recipient, please notify the sender immediately by replying to this message or by telephone and delete this e-mail and any attachments permanently from
your system.
"""
Fixed Beam of length L with concentrated load at center.
Slopes at both ends = 0
Deflections at both ends = 0
Due to indeterminacy of 2, the problem is split up in two parts
Step 1 : beam b1 is defined with far end free and concentrated load in the centre
Step 2 : beam b2 is defined with far end free and unit load and unit moment applied at the far end.
Step 3 : the two solutions are solved as a system of two equations in two unknowns.
Step 4 : beam b3 is the final solution in which M3 and M4 (fixed end moments) are input from the calculated values
"""
from sympy.physics.continuum_mechanics.beam import Beam
from sympy import symbols, linsolve, plot
from sympy import SingularityFunction
E, I, x = symbols('E, I, x')
R1, R2, R3, R4 = symbols('R1, R2 R3 R4')
M1, M2 = symbols('M1, M2')
P, L = 6.,4.