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 ====================
Isotropic:
E = 2.10e+05, v = 0.3
planeStress = False
thickness = 1.00e+02
solver : scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
W def = 0.03
Svm max = 2.59
Evm max = 0.00 %
Ux max = 6.69e-05
Ux min = 0.00e+00
Uy max = 6.68e-05
Uy min = 0.00e+00
=================== TicTac ===================
Mesh : 26.954 ms
Boundary Conditions : 31.710 µs
Matrix : 16.222 ms
Solver : 24.723 ms
Display : 175.191 ms
PostProcessing : 1.303 ms
12 import matplotlib.pyplot as plt
13 import numpy as np
14
15 from EasyFEA import Display, Models, ElemType, Simulations
16 from EasyFEA.Geoms import Point, Line, Circle, CircleArc, Contour
17
18 if __name__ == "__main__":
19 Display.Clear()
20
21 # ----------------------------------------------
22 # Configuration
23 # ----------------------------------------------
24
25 dim = 2
26 isSymmetric = True
27 openCrack = True
28
29 # geom
30 r = 10
31 e = 5
32 thickness = 100
33
34 # load
35 sig = 5 # bar
36 sig *= 1e-1 # 1 bar = 0.1 MPa
37
38 # ----------------------------------------------
39 # Mesh
40 # ----------------------------------------------
41 meshSize = e / 5
42
43 center = Point()
44 if isSymmetric:
45 p1 = Point(r, 0)
46 p2 = Point(e + r, 0)
47 p3 = Point(0, e + r)
48 p4 = Point(0, r)
49
50 line1 = Line(p1, p2, meshSize)
51 line2 = CircleArc(p2, p3, center, meshSize=meshSize)
52 line3 = Line(p3, p4, meshSize)
53 line4 = CircleArc(p4, p1, center, meshSize=meshSize)
54
55 contour = Contour([line1, line2, line3, line4])
56 inclusions = []
57 else:
58 contour = Circle(center, (r + e) * 2, meshSize)
59 inclusions = [Circle(center, 2 * r, meshSize, isHollow=True)]
60
61 extrude = [0, 0, -thickness]
62
63 l = e / 4
64 p = r + e / 2
65 alpha = np.pi / 3
66 pc1 = Point((p - l / 2) * np.cos(alpha), (p - l / 2) * np.sin(alpha))
67 pc2 = Point((p + l / 2) * np.cos(alpha), (p + l / 2) * np.sin(alpha))
68
69 if dim == 2:
70 crack = Line(pc1, pc2, meshSize / 6, isOpen=openCrack)
71 mesh = contour.Mesh_2D(inclusions, elemType=ElemType.TRI6, cracks=[crack])
72 else:
73 pc3 = pc2.copy()
74 pc3.Translate(*extrude)
75 pc4 = pc1.copy()
76 pc4.Translate(*extrude)
77 l1 = Line(pc1, pc2, meshSize / 6, isOpen=openCrack)
78 l2 = Line(pc2, pc3, meshSize / 6)
79 l3 = Line(pc3, pc4, meshSize / 6, isOpen=openCrack)
80 l4 = Line(pc4, pc1, meshSize / 6)
81 crack = Contour([l1, l2, l3, l4], isOpen=openCrack)
82 mesh = contour.Mesh_Extrude(
83 inclusions, extrude, [], ElemType.TETRA4, cracks=[crack]
84 )
85
86 # ----------------------------------------------
87 # Simulation
88 # ----------------------------------------------
89 material = Models.Elastic.Isotropic(
90 dim, E=210000, v=0.3, planeStress=False, thickness=thickness
91 )
92 simu = Simulations.Elastic(mesh, material)
93
94 if isSymmetric:
95 nodes_x0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
96 nodes_y0 = mesh.Nodes_Conditions(lambda x, y, z: y == 0)
97 simu.add_dirichlet(nodes_x0, [0], ["x"])
98 simu.add_dirichlet(nodes_y0, [0], ["y"])
99
100 nodes_load = mesh.Nodes_Cylinder(Circle(center, r * 2), direction=extrude)
101
102 if dim == 2 and not isSymmetric:
103 sig *= -1
104
105 simu.add_pressureLoad(nodes_load, sig)
106
107 simu.Solve()
108 simu.Save_Iter()
109
110 # ----------------------------------------------
111 # Results
112 # ----------------------------------------------
113 factorDef = r / 5 / simu.Result("displacement_norm").max()
114
115 Display.Plot_Mesh(simu, deformFactor=factorDef)
116 Display.Plot_BoundaryConditions(simu)
117 Display.Plot_Result(simu, "ux", ncolors=10, nodeValues=True)
118 Display.Plot_Result(simu, "uy", ncolors=10, nodeValues=True)
119 Display.Plot_Result(
120 simu, "Svm", ncolors=10, nodeValues=True, deformFactor=factorDef, plotMesh=True
121 )
122
123 print(simu)
124
125 # PyVista.Plot_BoundaryConditions(simu).show()
126
127 plt.show()
Total running time of the script: (0 minutes 0.714 seconds)




