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




