.. 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 11-129 .. 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 0/20 Generate movie 1/20 (5.00 %) 3.74 s Generate movie 2/20 (10.00 %) 3.48 s Generate movie 3/20 (15.00 %) 3.29 s Generate movie 4/20 (20.00 %) 3.10 s Generate movie 5/20 (25.00 %) 2.90 s Generate movie 6/20 (30.00 %) 2.70 s Generate movie 7/20 (35.00 %) 2.52 s Generate movie 8/20 (40.00 %) 2.32 s Generate movie 9/20 (45.00 %) 2.12 s Generate movie 10/20 (50.00 %) 1.95 s Generate movie 11/20 (55.00 %) 1.67 s Generate movie 12/20 (60.00 %) 1.54 s Generate movie 13/20 (65.00 %) 1.35 s Generate movie 14/20 (70.00 %) 1.16 s Generate movie 15/20 (75.00 %) 966.52 ms Generate movie 16/20 (80.00 %) 775.28 ms Generate movie 17/20 (85.00 %) 584.56 ms Generate movie 18/20 (90.00 %) 391.32 ms Generate movie 19/20 (95.00 %) 194.36 ms Generate movie 20/20 (100.00 %) 0.00 µs | .. code-block:: Python :lineno-start: 11 # TODO: Compare results with analytical values. from EasyFEA import Folder, Display, Models, Tic, plt, ElemType, Simulations, PyVista from EasyFEA.Geoms import Domain, Circle, Line if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- # outputs folder = Folder.Join(Folder.RESULTS_DIR, "LinearizedElasticity", "Dynamic2") 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, isHollow=False) 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.ElasIsot(2, E=210000e6, v=0.3, planeStress=False, thickness=1) lmbda = material.get_lambda() mu = material.get_mu() # Create the simulation object simu = Simulations.ElasticSimu(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 7.301 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 `_