Note
Go to the end to download the full example code.
Elas7#
Control lever for a molding machine used to blow plastic bottles.
References#
This example comes from:
A French research article: MMC et RDM comparées sur un cas de dimensionnement de levier
The book: Mécanique des systèmes et des milieux déformables (3rd edition)


==================== Mesh ====================
Element type: PRISM6
Ne = 6108, Nn = 4315
==================== Model ====================
Isotropic:
E = 2.10e+05, v = 0.25
solver:scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
W def = 615.59
Svm max = 43.45
Evm max = 0.03 %
Ux max = 2.07e-02
Ux min = -2.05e-02
Uy max = 1.98e-03
Uy min = -1.13e-01
Uz max = 4.60e-04
Uz min = -4.60e-04
=================== TicTac ===================
Mesh: 177.093 ms
Boundary Conditions: 74.148 µs
Matrix: 251.486 ms
Solver: 1.752 s
PostProcessing: 5.452 ms
Generate paraview 1/5 (20.00 %) 91.10 ms
Generate paraview 2/5 (40.00 %) 68.49 ms
Generate paraview 3/5 (60.00 %) 45.34 ms
Generate paraview 4/5 (80.00 %) 22.77 ms
Generate paraview 5/5 (100.00 %) 0.00 µs
21 import numpy as np
22
23 from EasyFEA import Display, Folder, Models, ElemType, Simulations, PyVista, Paraview
24 from EasyFEA.Geoms import Points, Point, Circle
25
26 if __name__ == "__main__":
27 Display.Clear()
28
29 # ----------------------------------------------
30 # Configuration
31 # ----------------------------------------------
32
33 # outputs
34 folder = Folder.Results_Dir()
35 makeMovie = False
36 makeParaview = True
37
38 # geom
39 dim = 3
40 thickness = 25
41
42 # sinusoidal load
43 F = 13000 # N
44 area = np.pi * 25 / 2 * thickness
45 coefs = np.linspace(0, 1, 5)
46 loads = F * np.sin(np.pi / 2 * coefs)
47
48 # ----------------------------------------------
49 # Mesh
50 # ----------------------------------------------
51 meshSize = 42 / 5
52
53 # get the contour
54 pt1 = Point(0, 80)
55 pt2 = Point(-245, 21)
56 pt3 = Point(-245, -21)
57 pt4 = Point(0, -80)
58 pt5 = Point(114, -80)
59 pt6 = Point(114 + 13, -80 + 13)
60 pt7 = Point(114 + 13, -67 / 2)
61 pt8 = Point(114 + 13 + 25, -67 / 2)
62 pt9 = Point(114 + 13 + 25, -34 / 2)
63 pt10 = Point(114 + 13, -34 / 2, r=10)
64 pt11 = Point(114 + 13, 34 / 2, r=10)
65 pt12 = Point(114 + 13 + 25, 34 / 2)
66 pt13 = Point(114 + 13 + 25, 67 / 2)
67 pt14 = Point(114 + 13, 67 / 2)
68 pt15 = Point(114 + 13, 80 - 13)
69 pt16 = Point(114, 80)
70
71 # fmt: off
72 contour = Points([
73 pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10,
74 pt11, pt12, pt13, pt14, pt15, pt16,
75 ],
76 meshSize,
77 )
78 # fmt: on
79
80 # get circles
81 circle1 = Circle(Point(-220), 25, meshSize)
82 circle2 = Circle(Point(), 25, meshSize)
83 circle3 = Circle(Point(114 + 13 - 25, 80 - 25), 25, meshSize)
84 circle4 = Circle(Point(114 + 13 - 25, -80 + 25), 25, meshSize)
85 circle5 = Circle(Point(67), 84, meshSize)
86
87 inclusions = [circle1, circle2, circle3, circle4, circle5]
88
89 # get the mesh
90 if dim == 2:
91 mesh = contour.Mesh_2D(inclusions, ElemType.TRI3)
92 else:
93 mesh = contour.Mesh_Extrude(inclusions, [0, 0, thickness], [4], ElemType.PRISM6)
94
95 # get loading nodes
96 nodesLoad = mesh.Nodes_Cylinder(circle1)
97 nodesLoad = nodesLoad[mesh.coord[nodesLoad, 1] <= 0]
98
99 # get fixed nodes
100 nodesCircle2 = mesh.Nodes_Cylinder(circle2)
101 nodesCircle3 = mesh.Nodes_Cylinder(circle3)
102 nodesCircle4 = mesh.Nodes_Cylinder(circle4)
103 fixedNodes = np.concat((nodesCircle2, nodesCircle3, nodesCircle4))
104
105 # PyVista.Plot_Mesh(mesh).show()
106
107 # ----------------------------------------------
108 # Simulation
109 # ----------------------------------------------
110
111 material = Models.Elastic.Isotropic(
112 dim, E=210000, v=0.25, planeStress=True, thickness=thickness
113 )
114
115 simu = Simulations.Elastic(mesh, material)
116
117 fixed = [0] * dim
118 unknowns = simu.Get_unknowns()
119
120 # loop over the load
121 for load in loads:
122 # Apply boundary conditions
123 simu.Bc_Init()
124 simu.add_dirichlet(fixedNodes, fixed, unknowns)
125 simu.add_surfLoad(nodesLoad, [-load / area], ["y"])
126
127 # Solve the simulation
128 simu.Solve()
129
130 # Save the iteration results
131 simu.Save_Iter()
132
133 # ----------------------------------------------
134 # Results
135 # ----------------------------------------------
136
137 print(simu)
138
139 PyVista.Plot_BoundaryConditions(simu).show()
140
141 PyVista.Plot(simu, "Svm", deformFactor=200, plotMesh=True, nodeValues=False).show()
142
143 if makeMovie:
144 PyVista.Movie_simu(
145 simu,
146 "Svm",
147 folder,
148 "Svm.gif",
149 deformFactor=200,
150 nodeValues=False,
151 plotMesh=True,
152 )
153
154 if makeParaview:
155 Paraview.Save_simu(
156 simu, folder, elementFields=["Svm", "Stress", "Strain", "Wdef_e"]
157 )
Total running time of the script: (0 minutes 2.716 seconds)