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
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Solving Beam Bending with SymPy

Post by kkremitzki »

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
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Solving Beam Bending with SymPy

Post by microelly2 »

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

Re: Solving Beam Bending with SymPy

Post by looo »

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: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Solving Beam Bending with SymPy

Post by chakkree »

Wow!

SymPy-SimpleBeam.png
SymPy-SimpleBeam.png (176.42 KiB) Viewed 2606 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
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Solving Beam Bending with SymPy

Post by yorik »

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

Re: Solving Beam Bending with SymPy

Post by sgrogan »

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-)
"fight the good fight"
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Solving Beam Bending with SymPy

Post by Kunda1 »

chakkree wrote: Tue Jul 30, 2019 4:01 pmWow!
Can you share source?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Solving Beam Bending with SymPy

Post by chakkree »

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

Re: Solving Beam Bending with SymPy

Post by chakkree »

Test Continuous beam with 2 spans. Uniform load all 1000.
SymPy-ContBeam2Span.png
SymPy-ContBeam2Span.png (213.56 KiB) Viewed 2471 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: 177
Joined: Sun May 23, 2010 2:41 pm
Location: Ludhiana, Punjab, India
Contact:

Re: Solving Beam Bending with SymPy

Post by hardeeprai »

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