.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Thermal/Thermal2.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_Thermal_Thermal2.py: Thermal2 ======== Transient thermal simulation. .. GENERATED FROM PYTHON SOURCE LINES 11-87 .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Thermal/images/sphx_glr_Thermal2_001.png :alt: Thermal2 :srcset: /examples/Thermal/images/sphx_glr_Thermal2_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.7.1/docs/examples/Thermal/images/sphx_glr_Thermal2_001.vtksz .. image-sg:: /examples/Thermal/images/sphx_glr_Thermal2_002.gif :alt: Thermal2 :srcset: /examples/Thermal/images/sphx_glr_Thermal2_002.gif :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Volume: 0.913 0.000 s 0.010 s 0.020 s 0.030 s 0.040 s 0.050 s 0.060 s 0.070 s 0.080 s 0.090 s 0.100 s 0.110 s 0.120 s 0.130 s 0.140 s 0.150 s 0.160 s 0.170 s 0.180 s 0.190 s 0.200 s 0.210 s 0.220 s 0.230 s 0.240 s 0.250 s 0.260 s 0.270 s 0.280 s 0.290 s 0.300 s 0.310 s 0.320 s 0.330 s 0.340 s 0.350 s 0.360 s 0.370 s 0.380 s 0.390 s 0.400 s 0.410 s 0.420 s 0.430 s 0.440 s 0.450 s 0.460 s 0.470 s 0.480 s 0.490 s 0.500 s ==================== Mesh ==================== Element type: PRISM18 Ne = 288, Nn = 1512 ==================== Model ==================== Thermal : thermal conductivity (k) : 1 thermal mass capacity (c) : 1 solver : scipy ============= Boundary Conditions ============= Unspecified. =================== Results =================== Unspecified. =================== TicTac =================== Mesh : 63.064 ms Boundary Conditions : 16.451 µs Matrix : 34.667 ms Solver : 2.194 s Generate movie 01/51 (1.96 %) 12.25 s Generate movie 02/51 (3.92 %) 11.09 s Generate movie 03/51 (5.88 %) 10.78 s Generate movie 04/51 (7.84 %) 10.55 s Generate movie 05/51 (9.80 %) 10.42 s Generate movie 06/51 (11.76 %) 10.18 s Generate movie 07/51 (13.73 %) 9.93 s Generate movie 08/51 (15.69 %) 9.64 s Generate movie 09/51 (17.65 %) 9.26 s Generate movie 10/51 (19.61 %) 9.18 s Generate movie 11/51 (21.57 %) 9.03 s Generate movie 12/51 (23.53 %) 8.76 s Generate movie 13/51 (25.49 %) 8.56 s Generate movie 14/51 (27.45 %) 8.38 s Generate movie 15/51 (29.41 %) 8.14 s Generate movie 16/51 (31.37 %) 7.89 s Generate movie 17/51 (33.33 %) 7.66 s Generate movie 18/51 (35.29 %) 7.18 s Generate movie 19/51 (37.25 %) 7.19 s Generate movie 20/51 (39.22 %) 6.94 s Generate movie 21/51 (41.18 %) 6.67 s Generate movie 22/51 (43.14 %) 6.49 s Generate movie 23/51 (45.10 %) 6.27 s Generate movie 24/51 (47.06 %) 6.07 s Generate movie 25/51 (49.02 %) 5.86 s Generate movie 26/51 (50.98 %) 5.58 s Generate movie 27/51 (52.94 %) 5.33 s Generate movie 28/51 (54.90 %) 5.15 s Generate movie 29/51 (56.86 %) 4.96 s Generate movie 30/51 (58.82 %) 4.70 s Generate movie 31/51 (60.78 %) 4.45 s Generate movie 32/51 (62.75 %) 4.31 s Generate movie 33/51 (64.71 %) 4.08 s Generate movie 34/51 (66.67 %) 3.83 s Generate movie 35/51 (68.63 %) 3.59 s Generate movie 36/51 (70.59 %) 3.38 s Generate movie 37/51 (72.55 %) 3.18 s Generate movie 38/51 (74.51 %) 2.96 s Generate movie 39/51 (76.47 %) 2.72 s Generate movie 40/51 (78.43 %) 2.50 s Generate movie 41/51 (80.39 %) 2.27 s Generate movie 42/51 (82.35 %) 2.04 s Generate movie 43/51 (84.31 %) 1.82 s Generate movie 44/51 (86.27 %) 1.59 s Generate movie 45/51 (88.24 %) 1.34 s Generate movie 46/51 (90.20 %) 1.15 s Generate movie 47/51 (92.16 %) 917.25 ms Generate movie 48/51 (94.12 %) 680.62 ms Generate movie 49/51 (96.08 %) 453.20 ms Generate movie 50/51 (98.04 %) 227.30 ms Generate movie 51/51 (100.00 %) 0.00 µs | .. code-block:: Python :lineno-start: 12 from EasyFEA import Display, Folder, Models, Mesher, ElemType, Simulations, PyVista from EasyFEA.Geoms import Circle, Domain, Point if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- dim = 3 # Set the simulation dimension (2D or 3D) # outputs folder = Folder.Results_Dir() + f"{dim}D" makeMovie = True result = "thermal" # geom a = 1 # load Tmax = 0.5 N = 50 dt = Tmax / N # ---------------------------------------------- # Mesh # ---------------------------------------------- domain = Domain(Point(), Point(a, a), a / 4) circle = Circle(Point(a / 2, a / 2), diam=a / 3, isHollow=True, meshSize=a / 4) if dim == 2: mesh = Mesher().Mesh_2D(domain, [circle], ElemType.TRI6) else: mesh = Mesher().Mesh_Extrude( domain, [circle], [0, 0, -a], [4], ElemType.PRISM18 ) nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0) nodesXa = mesh.Nodes_Conditions(lambda x, y, z: x == a) nodesCircle = mesh.Nodes_Cylinder(circle, direction=[0, 0, -1]) if dim == 3: print(f"Volume: {mesh.volume:.3}") # ---------------------------------------------- # Simulation # ---------------------------------------------- thermalModel = Models.Thermal(k=1, c=1, thickness=1) simu = Simulations.Thermal(mesh, thermalModel, False) simu.rho = 1 simu.add_dirichlet(nodesX0, [0], ["t"]) simu.add_dirichlet(nodesXa, [40], ["t"]) # Set the parabolic algorithm for the solver simu.Solver_Set_Parabolic_Algorithm(alpha=0.5, dt=dt) t = -dt # init time while t < Tmax: t += dt simu.Solve() simu.Save_Iter() print(f"{t:.3f} s", end="\r") # ---------------------------------------------- # Results # ---------------------------------------------- print(simu) PyVista.Plot(simu, result, plotMesh=True, nodeValues=True).show() if makeMovie: PyVista.Movie_simu(simu, result, folder, f"{result}.gif", plotMesh=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 21.328 seconds) .. _sphx_glr_download_examples_Thermal_Thermal2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Thermal2.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Thermal2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Thermal2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_