2D structures basic calculations

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!
Post Reply
oddtopus
Posts: 142
Joined: Tue Sep 20, 2016 6:17 pm

2D structures basic calculations

Post by oddtopus »

I found this https://anastruct.readthedocs.io/en/latest/index.html python module which may be interesting.
Since it is working for Python versions >3 I guess now it's possible to use it in some way into FreeCAD.
Similar to the use of fluids/thermo modules inside flamingo, one possible application could be
  • draw the line diagram of the structure in a Sketch
  • lay down the beams over it (for example with "frameBranch")
  • calculate the inertia properties of the section respect to the plane of the sketch and rotation of beams around to centerlines
  • draw the force diagrams N-S-M or deflection lines with anastruct
Regards
(BTW: it seems fluids/thermo will no more run with py3 builds :( but most of their functions has been duplicated with explicit formulas)
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: 2D structures basic calculations

Post by chakkree »

After I install "anaStuct" to FreeCAD 0.19.16523 PY3(dev).
It can be run a macro for a test example.

Test01.png
Test01.png (184.56 KiB) Viewed 3357 times

Code: Select all

"""
    Test anaStruct for FreeCAD
    Version: 0.19.16523 (Git)
    Python version: 3.6.6
"""

from anastruct.fem.system import SystemElements

# Create a new system object.
ss = SystemElements()

# Add beams to the system.
ss.add_element(location=[[0, 0], [3, 4]], EA=5e9, EI=8000)
ss.add_element(location=[[3, 4], [8, 4]], EA=5e9, EI=4000)

# get a visual of the element IDs and the node IDs
#ss.show_structure()

# add loads to the element ID 2
ss.q_load(element_id=2, q=-10)

# add hinged support to node ID 1
ss.add_support_hinged(node_id=1)

# add fixed support to node ID 2
ss.add_support_fixed(node_id=3)

# solve
ss.solve()

showFlag=5

if showFlag==1:
    # show the structure
    ss.show_structure()
elif showFlag==2:
    # show the reaction forces
    ss.show_reaction_force()
elif showFlag==3:
    # show the axial forces
    ss.show_axial_force()
elif showFlag==4:
    # show the shear force
    ss.show_shear_force()
elif showFlag==5:
    # show the bending moment
    ss.show_bending_moment()
elif showFlag==6:
    # show the displacements
    ss.show_displacement()
anaStrut_Example1.py
(1.06 KiB) Downloaded 96 times
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: 2D structures basic calculations

Post by chakkree »

Test for continous beam with 2 spans.

Test02.png
Test02.png (159.17 KiB) Viewed 3356 times

Code: Select all

"""
    Test anaStruct for FreeCAD
    Version: 0.19.16523 (Git)
    Python version: 3.6.6
"""

from anastruct.fem.system import SystemElements



ss = SystemElements()


ss.add_element(location=[[0, 0], [4, 0]], EA=5e9, EI=8000)
ss.add_element(location=[[4, 0], [7, 0]], EA=5e9, EI=4000)


ss.q_load(element_id=1, q=-1000)
ss.q_load(element_id=2, q=-1200)


ss.add_support_hinged(node_id=1)
ss.add_support_roll(node_id=2)
ss.add_support_roll(node_id=3)


ss.solve()


#ss.show_structure()
#ss.show_reaction_force()
#ss.show_axial_force()
#ss.show_shear_force()
ss.show_bending_moment()
#ss.show_displacement()
ContBeam1.py
(610 Bytes) Downloaded 77 times
oddtopus
Posts: 142
Joined: Tue Sep 20, 2016 6:17 pm

Re: 2D structures basic calculations

Post by oddtopus »

Hi, there. I made a little step ahead with anastruct creating a macro which takes the structure from the FreeCAD document and solve it with anastruct.
Below a short gallery with an example.

Image
Image
Image

There are few dependencies:
  • a release of FC python 3
  • python library anastruct
  • dodo workbench (for the class "FrameBranch")
    [\list]

    Summarizing you can select the framebranch (the Base must be a sketch; not a dwire) from the drop-down box, input the loads (distributed) and constraints in a separate window and perform a static analysis.
    The next step could be to bring both input and output inside the window of FreeCAD and add other loads.
    Final target is to solve also 3D structures with the principle of superposition of effects.

    @bernd: this library is very basic but may that interest you for the 1D analysis?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 2D structures basic calculations

Post by vocx »

oddtopus wrote: Sun Sep 29, 2019 7:46 am Hi, there. I made a little step ahead with anastruct creating a macro which takes the structure from the FreeCAD document and solve it with anastruct.

dodo workbench (for the class "FrameBranch")
Is it possible to include this macro directly as part of the Dodo workbench? Then we can give it more prominence in the release notes.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
oddtopus
Posts: 142
Joined: Tue Sep 20, 2016 6:17 pm

Re: 2D structures basic calculations

Post by oddtopus »

@vocx. Up to now I don't want to include this stuff in the workbench because it relies on an optional python module which is not within the package of FC. I made something similar before to compute pressure losses in pipes with the modules "fluids" and "thermo" but since the project of FC progress quickly, the compatibility could not be always guaranteed.

Nevertheless I made one step further integrating better the macro (anastruct6.py) in the gui:
https://github.com/oddtopus/macros
Image
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 2D structures basic calculations

Post by vocx »

oddtopus wrote: Sat Oct 12, 2019 5:41 pm @vocx. Up to now I don't want to include this stuff in the workbench because it relies on an optional python module which is not within the package of FC....
That it is optional is not a problem, you can always add a note somewhere that says, "to use this feature you need to install this requisite first".
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
lhmp170284
Posts: 1
Joined: Mon Oct 04, 2021 12:16 pm

Re: 2D structures basic calculations

Post by lhmp170284 »

hi everyone.

hi everyone. I can't run anastruct6.py macro in my freecad 0.20. I attach a imagen with the error that i obtain. octopus can you explain me how insstall and run a anastruct and anastruct6?
Attachments
Captura.PNG
Captura.PNG (99.03 KiB) Viewed 956 times
Post Reply