Elas9#

Wave propagation.

Elas9
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 %) 5.68 s
Generate movie 02/21 (9.52 %) 5.53 s
Generate movie 03/21 (14.29 %) 5.23 s
Generate movie 04/21 (19.05 %) 4.97 s
Generate movie 05/21 (23.81 %) 4.61 s
Generate movie 06/21 (28.57 %) 4.23 s
Generate movie 07/21 (33.33 %) 4.05 s
Generate movie 08/21 (38.10 %) 3.77 s
Generate movie 09/21 (42.86 %) 3.47 s
Generate movie 10/21 (47.62 %) 3.20 s
Generate movie 11/21 (52.38 %) 3.02 s
Generate movie 12/21 (57.14 %) 2.62 s
Generate movie 13/21 (61.90 %) 2.30 s
Generate movie 14/21 (66.67 %) 2.01 s
Generate movie 15/21 (71.43 %) 1.71 s
Generate movie 16/21 (76.19 %) 1.43 s
Generate movie 17/21 (80.95 %) 1.11 s
Generate movie 18/21 (85.71 %) 830.95 ms
Generate movie 19/21 (90.48 %) 567.01 ms
Generate movie 20/21 (95.24 %) 274.46 ms
Generate movie 21/21 (100.00 %) 0.00 µs

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

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

Gallery generated by Sphinx-Gallery