Note
Go to the end to download the full example code.
Elas5#
A cylindrical conduit exposed to uniform pressure.
==================== Mesh ====================
Element type: TRI6
Ne = 438, Nn = 942
==================== Model ====================
ElasIsot:
E = 2.10e+05, v = 0.3
planeStress = False
thickness = 1.00e+02
solver : pypardiso
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
W def = 2.12
Svm max = 22.71
Evm max = 0.01 %
Ux max = 6.00e-04
Ux min = 0.00e+00
Uy max = 6.00e-04
Uy min = 0.00e+00
=================== TicTac ===================
Mesh : 359.175 ms
Boundary Conditions : 762.939 µs
Matrix : 2.221 s
Solver : 5.467 s
Display : 613.241 ms
PostProcessing : 236.296 ms
Resolution hyperelastic : 6.641 s
PyVista_Interface : 18.472 s
12 from EasyFEA import Display, Models, np, ElemType, Simulations
13 from EasyFEA.Geoms import Point, Line, Circle, CircleArc, Contour
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21
22 dim = 2
23 isSymmetric = True
24 openCrack = True
25
26 # geom
27 r = 10
28 e = 5
29 thickness = 100
30
31 # load
32 sig = 5 # bar
33 sig *= 1e-1 # 1 bar = 0.1 MPa
34
35 # ----------------------------------------------
36 # Mesh
37 # ----------------------------------------------
38 meshSize = e / 5
39
40 center = Point()
41 if isSymmetric:
42 p1 = Point(r, 0)
43 p2 = Point(e + r, 0)
44 p3 = Point(0, e + r)
45 p4 = Point(0, r)
46
47 line1 = Line(p1, p2, meshSize)
48 line2 = CircleArc(p2, p3, center, meshSize=meshSize)
49 line3 = Line(p3, p4, meshSize)
50 line4 = CircleArc(p4, p1, center, meshSize=meshSize)
51
52 contour = Contour([line1, line2, line3, line4])
53 inclusions = []
54 else:
55 contour = Circle(center, (r + e) * 2, meshSize)
56 inclusions = [Circle(center, 2 * r, meshSize, isHollow=True)]
57
58 extrude = [0, 0, -thickness]
59
60 l = e / 4
61 p = r + e / 2
62 alpha = np.pi / 3
63 pc1 = Point((p - l / 2) * np.cos(alpha), (p - l / 2) * np.sin(alpha))
64 pc2 = Point((p + l / 2) * np.cos(alpha), (p + l / 2) * np.sin(alpha))
65
66 if dim == 2:
67 crack = Line(pc1, pc2, meshSize / 6, isOpen=openCrack)
68 mesh = contour.Mesh_2D(inclusions, elemType=ElemType.TRI6, cracks=[crack])
69 else:
70 pc3 = pc2.copy()
71 pc3.Translate(*extrude)
72 pc4 = pc1.copy()
73 pc4.Translate(*extrude)
74 l1 = Line(pc1, pc2, meshSize / 6, isOpen=openCrack)
75 l2 = Line(pc2, pc3, meshSize / 6)
76 l3 = Line(pc3, pc4, meshSize / 6, isOpen=openCrack)
77 l4 = Line(pc4, pc1, meshSize / 6)
78 crack = Contour([l1, l2, l3, l4], isOpen=openCrack)
79 mesh = contour.Mesh_Extrude(
80 inclusions, extrude, [], ElemType.TETRA4, cracks=[crack]
81 )
82
83 # ----------------------------------------------
84 # Simulation
85 # ----------------------------------------------
86 material = Models.ElasIsot(
87 dim, E=210000, v=0.3, planeStress=False, thickness=thickness
88 )
89 simu = Simulations.ElasticSimu(mesh, material)
90
91 if isSymmetric:
92 nodes_x0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
93 nodes_y0 = mesh.Nodes_Conditions(lambda x, y, z: y == 0)
94 simu.add_dirichlet(nodes_x0, [0], ["x"])
95 simu.add_dirichlet(nodes_y0, [0], ["y"])
96
97 nodes_load = mesh.Nodes_Cylinder(Circle(center, r * 2), extrude)
98
99 if dim == 2 and not isSymmetric:
100 sig *= -1
101
102 simu.add_pressureLoad(nodes_load, sig)
103
104 simu.Solve()
105 simu.Save_Iter()
106
107 # ----------------------------------------------
108 # Results
109 # ----------------------------------------------
110 factorDef = r / 5 / simu.Result("displacement_norm").max()
111
112 Display.Plot_Mesh(simu, deformFactor=factorDef)
113 Display.Plot_BoundaryConditions(simu)
114 Display.Plot_Result(simu, "ux", ncolors=10, nodeValues=True)
115 Display.Plot_Result(simu, "uy", ncolors=10, nodeValues=True)
116 Display.Plot_Result(
117 simu, "Svm", ncolors=10, nodeValues=True, deformFactor=factorDef, plotMesh=True
118 )
119
120 print(simu)
121
122 # PyVista.Plot_BoundaryConditions(simu).show()
123
124 Display.plt.show()
Total running time of the script: (0 minutes 0.411 seconds)




