Note
Go to the end to download the full example code.
Thermal1#
Thermal simulation.

==================== Mesh ====================
Element type: TRI6
Ne = 72, Nn = 168
==================== Model ====================
Thermal :
thermal conductivity (k) : 1
thermal mass capacity (c) : 1
solver : scipy
============= Boundary Conditions =============
Unspecified.
=================== Results ===================
Unspecified.
=================== TicTac ===================
Mesh : 15.154 ms
Boundary Conditions : 10.729 µs
Matrix : 1.810 ms
Solver : 1.642 ms
12 from EasyFEA import Display, Models, Mesher, ElemType, Simulations, PyVista
13 from EasyFEA.Geoms import Circle, Domain, Point
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21 dim = 2 # Set the simulation dimension (2D or 3D)
22
23 # geom
24 a = 1
25
26 # ----------------------------------------------
27 # Mesh
28 # ----------------------------------------------
29 domain = Domain(Point(), Point(a, a), a / 4)
30 circle = Circle(Point(a / 2, a / 2), diam=a / 3, isHollow=True, meshSize=a / 4)
31
32 if dim == 2:
33 mesh = Mesher().Mesh_2D(domain, [circle], ElemType.TRI6)
34 else:
35 mesh = Mesher().Mesh_Extrude(
36 domain, [circle], [0, 0, -a], [4], ElemType.PRISM18
37 )
38
39 nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
40 nodesXa = mesh.Nodes_Conditions(lambda x, y, z: x == a)
41 nodesCircle = mesh.Nodes_Cylinder(circle, [0, 0, -1])
42
43 if dim == 3:
44 print(f"Volume: {mesh.volume:.3}")
45
46 # ----------------------------------------------
47 # Simulation
48 # ----------------------------------------------
49 thermalModel = Models.Thermal(k=1, c=1, thickness=1)
50 simu = Simulations.Thermal(mesh, thermalModel, False)
51 simu.rho = 1
52
53 simu.add_dirichlet(nodesX0, [0], ["t"])
54 simu.add_dirichlet(nodesXa, [40], ["t"])
55
56 simu.Solve()
57
58 # ----------------------------------------------
59 # Results
60 # ----------------------------------------------
61 print(simu)
62
63 PyVista.Plot(simu, "thermal", plotMesh=True, nodeValues=True).show()
Total running time of the script: (0 minutes 0.316 seconds)