Solving Beam Bending with SymPy

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
kkremitzki
Posts: 1679
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Solving Beam Bending with SymPy

Postby kkremitzki » Tue Oct 02, 2018 11:19 pm

If you've ever had to hand-draw a shear & moment diagram, you'll love this:

https://docs.sympy.org/dev/modules/phys ... blems.html
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
microelly2
Posts: 4329
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Solving Beam Bending with SymPy

Postby microelly2 » Fri Oct 05, 2018 9:19 am

+1
its worth to embed sympy. there are other nice tools too.
looo
Posts: 2749
Joined: Mon Nov 11, 2013 5:29 pm

Re: Solving Beam Bending with SymPy

Postby looo » Fri Oct 05, 2018 4:04 pm

microelly2 wrote:
Fri Oct 05, 2018 9:19 am
its worth to embed sympy
No need to embed anything if freecad stays more closely to the python ecosystem...(conda, pip)
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Solving Beam Bending with SymPy

Postby chakkree » Tue Jul 30, 2019 4:01 pm

Wow!

SymPy-SimpleBeam.png
SymPy-SimpleBeam.png (176.42 KiB) Viewed 477 times
Source Code. (installed SymPy before used)

Code: Select all

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

E, I = symbols('E, I')
R1, R2 = symbols('R1, R2')
b = Beam(4, E, I)
b.apply_load(R1, 0, -1)
b.apply_load(-1000, 0, 0)
b.apply_load(R2, 4, -1)
b.bc_deflection.append((0, 0))
b.bc_deflection.append((4, 0))
b.solve_for_reaction_loads(R1, R2)
Msg(b.reaction_loads)


b.plot_shear_force() 
b.plot_bending_moment() 

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17477 (Git)
Build type: Release
Branch: master
Hash: 8806e4490606d7a1be52c831049b17d8c8d9c320
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Last edited by chakkree on Wed Jul 31, 2019 6:19 am, edited 2 times in total.
User avatar
yorik
Site Admin
Posts: 11458
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Solving Beam Bending with SymPy

Postby yorik » Tue Jul 30, 2019 10:17 pm

Wow! (2)
User avatar
sgrogan
Posts: 5253
Joined: Wed Oct 22, 2014 5:02 pm

Re: Solving Beam Bending with SymPy

Postby sgrogan » Tue Jul 30, 2019 10:22 pm

looo wrote:
Fri Oct 05, 2018 4:04 pm
No need to embed anything if freecad stays more closely to the python ecosystem...(conda, pip, UCRT)
Prophetic 8-)
User avatar
Kunda1
Posts: 5228
Joined: Thu Jan 05, 2017 9:03 pm

Re: Solving Beam Bending with SymPy

Postby Kunda1 » Tue Jul 30, 2019 10:56 pm

chakkree wrote:
Tue Jul 30, 2019 4:01 pm
Wow!
Can you share source?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Solving Beam Bending with SymPy

Postby chakkree » Wed Jul 31, 2019 6:18 am

Kunda1 wrote:
Tue Jul 30, 2019 10:56 pm
Can you share source?
I already re-edit.
User avatar
chakkree
Posts: 288
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Solving Beam Bending with SymPy

Postby chakkree » Thu Aug 01, 2019 5:53 am

Test Continuous beam with 2 spans. Uniform load all 1000.
SymPy-ContBeam2Span.png
SymPy-ContBeam2Span.png (213.56 KiB) Viewed 342 times

Source Code

Code: Select all

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

L1 = 4.0
L2 = 3.0

E, I = symbols('E, I')
R1, R2 , R3 = symbols('R1, R2, R3')
b = Beam(L1+L2, E, I)
b.apply_load(R1, 0, -1)
b.apply_load(R2, L1, -1)
b.apply_load(R3, L1+L2, -1)

b.apply_load(-1000, 0, 0)

b.bc_deflection.append((0, 0))
b.bc_deflection.append((L1, 0))
b.bc_deflection.append((L1+L2, 0))

b.solve_for_reaction_loads(R1, R2 , R3)
Msg(b.reaction_loads)

b.plot_shear_force() 
b.plot_bending_moment() 

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17477 (Git)
Build type: Release
Branch: master
Hash: 8806e4490606d7a1be52c831049b17d8c8d9c320
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
hardeeprai
Posts: 167
Joined: Sun May 23, 2010 2:41 pm
Location: Ludhiana, Punjab, India
Contact:

Re: Solving Beam Bending with SymPy

Postby hardeeprai » Fri Aug 02, 2019 2:56 pm

chakkree wrote:
Thu Aug 01, 2019 5:53 am
Test Continuous beam with 2 spans. Uniform load all 1000
Wonderful!
--
H.S.Rai