.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/LinearizedElasticity/Elas9.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_LinearizedElasticity_Elas9.py: Elas9 ===== Wave propagation. .. GENERATED FROM PYTHON SOURCE LINES 12-134 .. image-sg:: /examples/LinearizedElasticity/images/sphx_glr_Elas9_001.gif :alt: Elas9 :srcset: /examples/LinearizedElasticity/images/sphx_glr_Elas9_001.gif :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 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.88 s Generate movie 02/21 (9.52 %) 2.70 s Generate movie 03/21 (14.29 %) 2.55 s Generate movie 04/21 (19.05 %) 2.43 s Generate movie 05/21 (23.81 %) 2.29 s Generate movie 06/21 (28.57 %) 2.12 s Generate movie 07/21 (33.33 %) 1.97 s Generate movie 08/21 (38.10 %) 1.83 s Generate movie 09/21 (42.86 %) 1.68 s Generate movie 10/21 (47.62 %) 1.55 s Generate movie 11/21 (52.38 %) 1.41 s Generate movie 12/21 (57.14 %) 1.28 s Generate movie 13/21 (61.90 %) 1.14 s Generate movie 14/21 (66.67 %) 999.46 ms Generate movie 15/21 (71.43 %) 861.26 ms Generate movie 16/21 (76.19 %) 729.37 ms Generate movie 17/21 (80.95 %) 580.60 ms Generate movie 18/21 (85.71 %) 433.33 ms Generate movie 19/21 (90.48 %) 289.09 ms Generate movie 20/21 (95.24 %) 144.52 ms Generate movie 21/21 (100.00 %) 0.00 µs | .. code-block:: Python :lineno-start: 12 # TODO: Compare results with analytical values. import matplotlib.pyplot as plt from EasyFEA import Folder, Display, Models, Tic, ElemType, Simulations, PyVista from EasyFEA.Geoms import Domain, Circle, Line if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- # outputs folder = Folder.Results_Dir() plotModel = False plotIter = False makeMovie = True result = "speed_norm" # Define geometric parameters a = 1 meshSize = a / 50 diam = a / 10 r = diam / 2 # Time parameters tMax = 1e-6 Nt = 20 dt = tMax / Nt # Load parameters load = 1e-3 f0 = 2 a0 = 1 t0 = dt * 4 # ---------------------------------------------- # Mesh # ---------------------------------------------- # Define the domain and create the mesh domain = Domain((-a / 2, -a / 2), (a / 2, a / 2), meshSize) circle = Circle((0, 0), diam, meshSize, isFilled=True) line = Line((0, 0), (diam / 4, 0)) mesh = domain.Mesh_2D([circle], ElemType.TRI6, cracks=[line]) # Plot the model if specified if plotModel: Display.Plot_Tags(mesh) plt.show() # Get nodes for boundary conditions and loading nodesBorders = mesh.Nodes_Tags(["L0", "L1", "L2", "L3"]) nodesLoad = mesh.Nodes_Point((0, 0)) # ---------------------------------------------- # Simulation # ---------------------------------------------- # Define material properties material = Models.Elastic.Isotropic( 2, E=210000e6, v=0.3, planeStress=False, thickness=1 ) lmbda = material.get_lambda() mu = material.get_mu() # Create the simulation object simu = Simulations.Elastic(mesh, material) simu.Set_Rayleigh_Damping_Coefs(1e-10, 1e-10) simu.Solver_Set_Hyperbolic_Algorithm(beta=1 / 4, gamma=1 / 2, dt=dt) # Plot the result at the initial iteration if specified if plotIter: ax = Display.Plot_Result(simu, result, nodeValues=True, title=result) # Create a timer object tic = Tic() # Time loop t = 0 while t <= tMax: simu.Bc_Init() # Set displacement boundary conditions simu.add_dirichlet(nodesBorders, [0, 0], ["x", "y"], description="[0,0]") # Set Neumann boundary conditions (loading) at t = t0 if t == t0: simu.add_neumann(nodesLoad, [load], ["x"]) # Solve the simulation simu.Solve() # Save the iteration results simu.Save_Iter() # Print the progress print(f"{t / tMax * 100:.3f} %", end="\r") # Update the plot at each iteration if specified if plotIter: ax = Display.Plot_Result(simu, result, nodeValues=True, ax=ax, title=result) plt.pause(1e-12) t += dt # ---------------------------------------------- # Results # ---------------------------------------------- if makeMovie: PyVista.Movie_simu( simu, f"{result}", folder, f"{result}.gif", ) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 18.926 seconds) .. _sphx_glr_download_examples_LinearizedElasticity_Elas9.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Elas9.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Elas9.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Elas9.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_