Elas10#

Wave propagation.

Elas10
0.000  %
5.000  %
10.000  %
15.000  %
20.000  %
25.000  %
30.000  %
35.000  %
40.000  %
45.000  %
50.000  %
55.000  %
60.000  %
65.000  %
70.000  %
75.000  %
80.000  %
85.000  %
90.000  %
95.000  %
100.000  %
Generate movie 01/21 (4.76 %) 3.37 s
Generate movie 02/21 (9.52 %) 3.32 s
Generate movie 03/21 (14.29 %) 3.12 s
Generate movie 04/21 (19.05 %) 2.96 s
Generate movie 05/21 (23.81 %) 2.84 s
Generate movie 06/21 (28.57 %) 2.61 s
Generate movie 07/21 (33.33 %) 2.43 s
Generate movie 08/21 (38.10 %) 2.26 s
Generate movie 09/21 (42.86 %) 2.08 s
Generate movie 10/21 (47.62 %) 1.90 s
Generate movie 11/21 (52.38 %) 1.84 s
Generate movie 12/21 (57.14 %) 1.59 s
Generate movie 13/21 (61.90 %) 1.49 s
Generate movie 14/21 (66.67 %) 1.28 s
Generate movie 15/21 (71.43 %) 1.05 s
Generate movie 16/21 (76.19 %) 873.62 ms
Generate movie 17/21 (80.95 %) 697.30 ms
Generate movie 18/21 (85.71 %) 520.25 ms
Generate movie 19/21 (90.48 %) 350.69 ms
Generate movie 20/21 (95.24 %) 174.44 ms
Generate movie 21/21 (100.00 %) 0.00 µs

 13 # TODO: Compare results with analytical values.
 14
 15 import matplotlib.pyplot as plt
 16
 17 from EasyFEA import (
 18     Folder,
 19     Terminal,
 20     Matplotlib,
 21     Models,
 22     Tic,
 23     ElemType,
 24     Simulations,
 25     PyVista,
 26 )
 27 from EasyFEA.Geoms import Domain, Circle, Line
 28
 29 if __name__ == "__main__":
 30     Terminal.Clear()
 31
 32     # ----------------------------------------------
 33     # Configuration
 34     # ----------------------------------------------
 35
 36     # outputs
 37     folder = Folder.Results_Dir()
 38     plotModel = False
 39     plotIter = False
 40     makeMovie = True
 41     result = "speed_norm"
 42
 43     # Define geometric parameters
 44     a = 1
 45     meshSize = a / 50
 46     diam = a / 10
 47     r = diam / 2
 48
 49     # Time parameters
 50     tMax = 1e-6
 51     Nt = 20
 52     dt = tMax / Nt
 53
 54     # Load parameters
 55     load = 1e-3
 56     f0 = 2
 57     a0 = 1
 58     t0 = dt * 4
 59
 60     # ----------------------------------------------
 61     # Mesh
 62     # ----------------------------------------------
 63
 64     # Define the domain and create the mesh
 65     domain = Domain((-a / 2, -a / 2), (a / 2, a / 2), meshSize)
 66     circle = Circle((0, 0), diam, meshSize, isFilled=True)
 67     line = Line((0, 0), (diam / 4, 0))
 68     mesh = domain.Mesh_2D([circle], ElemType.TRI6, cracks=[line])
 69
 70     # Plot the model if specified
 71     if plotModel:
 72         Matplotlib.Plot_Tags(mesh)
 73         plt.show()
 74
 75     # Get nodes for boundary conditions and loading
 76     nodesBorders = mesh.Nodes_Tags(["L0", "L1", "L2", "L3"])
 77     nodesLoad = mesh.Nodes_Point((0, 0))
 78
 79     # ----------------------------------------------
 80     # Simulation
 81     # ----------------------------------------------
 82
 83     # Define material properties
 84     material = Models.Elastic.Isotropic(
 85         2, E=210000e6, v=0.3, planeStress=False, thickness=1
 86     )
 87     lmbda = material.get_lambda()
 88     mu = material.get_mu()
 89
 90     # Create the simulation object
 91     simu = Simulations.Elastic(mesh, material)
 92     simu.Set_Rayleigh_Damping_Coefs(1e-10, 1e-10)
 93     simu.Solver_Set_Hyperbolic_Algorithm(beta=1 / 4, gamma=1 / 2, dt=dt)
 94
 95     # Plot the result at the initial iteration if specified
 96     if plotIter:
 97         ax = Matplotlib.Plot(simu, result, nodeValues=True, title=result)
 98
 99     # Create a timer object
100     tic = Tic()
101
102     # Time loop
103     t = 0
104     while t <= tMax:
105
106         simu.Bc_Init()
107
108         # Set displacement boundary conditions
109         simu.add_dirichlet(nodesBorders, [0, 0], ["x", "y"], description="[0,0]")
110
111         # Set Neumann boundary conditions (loading) at t = t0
112         if t == t0:
113             simu.add_neumann(nodesLoad, [load], ["x"])
114
115         # Solve the simulation
116         simu.Solve()
117
118         # Save the iteration results
119         simu.Save_Iter()
120
121         # Print the progress
122         print(f"{t / tMax * 100:.3f}  %", end="\r")
123
124         # Update the plot at each iteration if specified
125         if plotIter:
126             ax = Matplotlib.Plot(simu, result, nodeValues=True, ax=ax, title=result)
127             plt.pause(1e-12)
128
129         t += dt
130
131     # ----------------------------------------------
132     # Results
133     # ----------------------------------------------
134
135     if makeMovie:
136         PyVista.Movie_simu(
137             simu,
138             f"{result}",
139             folder,
140             f"{result}.gif",
141         )
142
143     plt.show()

Total running time of the script: (0 minutes 11.951 seconds)

Gallery generated by Sphinx-Gallery