Debian Codegraph @

src/Mod/Fem/femexamples/buckling_lateraltorsionalbuckling.py

raw symbols SCIP
1 # ***************************************************************************
2 # * Copyright (c) 2021 Bernd Hahnebach <[email protected]> *
3 # * *
4 # * This file is part of the FreeCAD CAx development system. *
5 # * *
6 # * This program is free software; you can redistribute it and/or modify *
7 # * it under the terms of the GNU Lesser General Public License (LGPL) *
8 # * as published by the Free Software Foundation; either version 2 of *
9 # * the License, or (at your option) any later version. *
10 # * for detail see the LICENCE text file. *
11 # * *
12 # * This program is distributed in the hope that it will be useful, *
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 # * GNU Library General Public License for more details. *
16 # * *
17 # * You should have received a copy of the GNU Library General Public *
18 # * License along with this program; if not, write to the Free Software *
19 # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
20 # * USA *
21 # * *
22 # ***************************************************************************
23
24 import FreeCAD
25
26 import Fem
27 import ObjectsFem
28
29 from . import manager
30 from .manager import get_meshname
31 from .manager import init_doc
32 from .meshes import generate_mesh
33
34
35 def get_information():
36 return {
37 "name": "Lateral Torsional Buckling",
38 "meshtype": "face",
39 "meshelement": "Tria6",
40 "constraints": ["displacement", "force"],
41 "solvers": ["ccxtools"],
42 "material": "solid",
43 "equations": ["buckling"],
44 }
45
46
47 def get_explanation(header=""):
48 return (
49 header
50 + """
51
52 To run the example from Python console use:
53 from femexamples.buckling_lateraltorsionalbuckling import setup
54 setup()
55
56
57 See forum topic post:
58 https://forum.freecad.org/viewtopic.php?f=18&t=20217&start=110#p510526
59
60 Simple supported I-beam with a fork support modelled with shell elements.
61 Loaded with constant bending moment.
62 The moment loads are done by line loads at the end of flanges.
63
64 analytical solution:
65 Mcr = 43.28 kNm = 43'280'000 Nmm
66
67 flange load for a buckling factor of 1.00:
68 43280000 Nmm / 278.6 mm = 155348 N
69
70 """
71 )
72
73
74 def setup(doc=None, solvertype="ccxtools"):
75
76 # init FreeCAD document
77 if doc is None:
78 doc = init_doc()
79
80 # explanation object
81 # just keep the following line and change text string in get_explanation method
82 manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))
83
84 # geometric objects
85 bottom_flange = doc.addObject("Part::Plane", "Bottom_Flange")
86 bottom_flange.Length = 10000
87 bottom_flange.Width = 150
88 top_flange = doc.addObject("Part::Plane", "Top_Flange")
89 top_flange.Length = 10000
90 top_flange.Width = 150
91 top_flange.Placement.Base = (0, 0, 278.6)
92 web = doc.addObject("Part::Plane", "Top_Flange")
93 web.Length = 10000
94 web.Width = 278.6
95 web.Placement = FreeCAD.Placement(
96 FreeCAD.Vector(0, 75, 0),
97 FreeCAD.Rotation(0, 0, 90),
98 FreeCAD.Vector(0, 0, 0),
99 )
100
101 geom_obj = doc.addObject("Part::MultiFuse", "Fusion")
102 geom_obj.Shapes = [bottom_flange, top_flange, web]
103
104 doc.recompute()
105 if FreeCAD.GuiUp:
106 geom_obj.ViewObject.Document.activeView().viewAxonometric()
107 geom_obj.ViewObject.Document.activeView().fitAll()
108
109 # analysis
110 analysis = ObjectsFem.makeAnalysis(doc, "Analysis")
111
112 # solver
113 if solvertype == "ccxtools":
114 solver_obj = ObjectsFem.makeSolverCalculiXCcxTools(doc, "CalculiXCcxTools")
115 solver_obj.WorkingDir = ""
116 else:
117 FreeCAD.Console.PrintWarning(
118 "Unknown or unsupported solver type: {}. "
119 "No solver object was created.\n".format(solvertype)
120 )
121 if solvertype == "ccxtools":
122 solver_obj.SplitInputWriter = False
123 solver_obj.AnalysisType = "buckling"
124 solver_obj.GeometricalNonlinearity = "linear"
125 solver_obj.ThermoMechSteadyState = False
126 solver_obj.MatrixSolverType = "default"
127 solver_obj.IterationsControlParameterTimeUse = False
128 solver_obj.BucklingFactors = 1
129 analysis.addObject(solver_obj)
130
131 # shell thicknesses
132 thickness_flanges = ObjectsFem.makeElementGeometry2D(doc, 10.7, "Thickness_Flanges")
133 thickness_flanges.References = [(geom_obj, ("Face1", "Face2", "Face3", "Face4"))]
134 analysis.addObject(thickness_flanges)
135 thickness_web = ObjectsFem.makeElementGeometry2D(doc, 7.1, "Thickness_Web")
136 thickness_web.References = [(geom_obj, "Face5")]
137 analysis.addObject(thickness_web)
138
139 # material
140 material_obj = ObjectsFem.makeMaterialSolid(doc, "Steel")
141 mat = material_obj.Material
142 mat["Name"] = "CalculiX-Steel"
143 mat["YoungsModulus"] = "210000 MPa"
144 mat["PoissonRatio"] = "0.30"
145 material_obj.Material = mat
146 analysis.addObject(material_obj)
147
148 # constraints displacement
149 con_disp_x = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacement_X")
150 con_disp_x.References = [(geom_obj, "Vertex2")]
151 con_disp_x.xDisplacement = 0
152 con_disp_x.xFree = False
153 analysis.addObject(con_disp_x)
154
155 con_disp_yz = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacement_YZ")
156 con_disp_yz.References = [(geom_obj, ("Edge15", "Edge16"))]
157 con_disp_yz.yDisplacement = 0
158 con_disp_yz.yFree = False
159 con_disp_yz.zDisplacement = 0
160 con_disp_yz.zFree = False
161 analysis.addObject(con_disp_yz)
162
163 # constraints force
164 con_force_in_x = ObjectsFem.makeConstraintForce(doc, "Force_in_X")
165 con_force_in_x.References = [(geom_obj, ("Edge3", "Edge7", "Edge8", "Edge12"))]
166 con_force_in_x.Force = "155350 N"
167 con_force_in_x.Reversed = False
168 con_force_in_x.Direction = (geom_obj, ["Edge4"])
169 analysis.addObject(con_force_in_x)
170
171 con_force_rev_x = ObjectsFem.makeConstraintForce(doc, "Force_rev_X")
172 con_force_rev_x.References = [(geom_obj, ("Edge1", "Edge5", "Edge10", "Edge14"))]
173 con_force_rev_x.Force = "155350 N"
174 con_force_rev_x.Reversed = True
175 con_force_rev_x.Direction = (geom_obj, ["Edge4"])
176 analysis.addObject(con_force_rev_x)
177
178 # mesh
179 from .meshes.mesh_buckling_ibeam_tria6 import create_nodes, create_elements
180
181 fem_mesh = generate_mesh.mesh_from_existing(create_nodes, create_elements)
182 femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0]
183 femmesh_obj.FemMesh = fem_mesh
184 femmesh_obj.Shape = geom_obj
185 femmesh_obj.SecondOrderLinear = False
186 femmesh_obj.CharacteristicLengthMax = "50.0 mm"
187 femmesh_obj.ElementDimension = "2D"
188
189 doc.recompute()
190 return doc