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 %) 2.59 s
Generate movie 02/21 (9.52 %) 2.21 s
Generate movie 03/21 (14.29 %) 2.08 s
Generate movie 04/21 (19.05 %) 2.02 s
Generate movie 05/21 (23.81 %) 1.85 s
Generate movie 06/21 (28.57 %) 1.76 s
Generate movie 07/21 (33.33 %) 1.65 s
Generate movie 08/21 (38.10 %) 1.54 s
Generate movie 09/21 (42.86 %) 1.46 s
Generate movie 10/21 (47.62 %) 1.34 s
Generate movie 11/21 (52.38 %) 1.21 s
Generate movie 12/21 (57.14 %) 1.08 s
Generate movie 13/21 (61.90 %) 947.22 ms
Generate movie 14/21 (66.67 %) 831.54 ms
Generate movie 15/21 (71.43 %) 720.33 ms
Generate movie 16/21 (76.19 %) 612.20 ms
Generate movie 17/21 (80.95 %) 489.99 ms
Generate movie 18/21 (85.71 %) 358.92 ms
Generate movie 19/21 (90.48 %) 238.43 ms
Generate movie 20/21 (95.24 %) 125.66 ms
Generate movie 21/21 (100.00 %) 0.00 µs

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

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

Gallery generated by Sphinx-Gallery