.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/basic/example_08_lsdyna_taylor_bar.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_basic_example_08_lsdyna_taylor_bar.py: .. _ref_example_08_lsdyna_taylor_bar_example: LS-Dyna analysis ---------------- Using supplied files, this example shows how to insert an LS-Dyna analysis into a new Mechanical session and execute a sequence of Python scripting commands that define and solve the analysis. Deformation results are then reported and plastic strain (EPS) animation is exported in the project directory. .. GENERATED FROM PYTHON SOURCE LINES 13-16 Download required files ~~~~~~~~~~~~~~~~~~~~~~~ Download the required files. Print the file path for the geometry file. .. GENERATED FROM PYTHON SOURCE LINES 16-28 .. code-block:: Python import os from PIL import Image from ansys.mechanical.core import launch_mechanical from ansys.mechanical.core.examples import download_file from matplotlib import image as mpimg from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation geometry_path = download_file("example_08_Taylor_Bar.agdb", "pymechanical", "00_basic") print(f"Downloaded the geometry file to: {geometry_path}") .. rst-class:: sphx-glr-script-out .. code-block:: none Downloaded the geometry file to: /home/runner/.local/share/ansys_mechanical_core/examples/example_08_Taylor_Bar.agdb .. GENERATED FROM PYTHON SOURCE LINES 29-34 Launch mechanical ~~~~~~~~~~~~~~~~~ Launch a new Mechanical session in batch, setting ``cleanup_on_exit`` to ``False``. To close this Mechanical session when finished, this example must call the ``mechanical.exit()`` method. .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python mechanical = launch_mechanical(batch=True, cleanup_on_exit=False) print(mechanical) .. rst-class:: sphx-glr-script-out .. code-block:: none Ansys Mechanical [Ansys Mechanical Enterprise] Product Version:241 Software build date: 11/27/2023 10:24:20 .. GENERATED FROM PYTHON SOURCE LINES 39-43 Initialize variable for workflow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set the ``part_file_path`` variable on the server for later use. Make this variable compatible for Windows, Linux, and Docker containers. .. GENERATED FROM PYTHON SOURCE LINES 43-58 .. code-block:: Python project_directory = mechanical.project_directory print(f"project directory = {project_directory}") project_directory = project_directory.replace("\\", "\\\\") mechanical.run_python_script(f"project_directory='{project_directory}'") # Upload the file to the project directory. mechanical.upload(file_name=geometry_path, file_location_destination=project_directory) # Build the path relative to project directory. base_name = os.path.basename(geometry_path) combined_path = os.path.join(project_directory, base_name) part_file_path = combined_path.replace("\\", "\\\\") mechanical.run_python_script(f"part_file_path='{part_file_path}'") .. rst-class:: sphx-glr-script-out .. code-block:: none project directory = /tmp/ANSYS.root.1/AnsysMech65AA/Project_Mech_Files/ Uploading example_08_Taylor_Bar.agdb to dns:///127.0.0.1:10000:/tmp/ANSYS.root.1/AnsysMech65AA/Project_Mech_Files/.: 0%| | 0.00/2.27M [00:00 i=input.k S=input.intfor x=70 NCPU=1 [license/info] Successfully checked out 1 of "dyna_solver_core". [license/info] --> Checkout ID: d0781433be37-root-121-000155 (days left: 351) [license/info] --> Customer ID: 0 [license/info] Successfully started "LSDYNA (Core-based License)". Executing with ANSYS license Scale factor for file size = 70 new file size = 18350080 Use this scale factor on all restarts. Command line options: i=input.k S=input.intfor x=70 NCPU=1 Input file: input.k The native file format : 32-bit small endian Memory size from default : 100000000 on UNIX computers note the following change: ctrl-c interrupts ls-dyna and prompts for a sense switch. type the desired sense switch: sw1., sw2., etc. to continue the execution. ls-dyna will respond as explained in the users manual type response ----- ------------------------------------------------------------ quit ls-dyna terminates. stop ls-dyna terminates. sw1. a restart file is written and ls-dyna terminates. sw2. ls-dyna responds with time and cycle numbers. sw3. a restart file is written and ls-dyna continues calculations. sw4. a plot state is written and ls-dyna continues calculations. sw5. ls-dyna enters interactive graphics phase. swa. ls-dyna flushes all output i/o buffers. swb. a dynain is written and ls-dyna continues calculations. swc. a restart and dynain are written and ls-dyna continues calculations. swd. a restart and dynain are written and ls-dyna terminates. swe. stop dynamic relaxation just as though convergence endtime=time change the termination time lpri toggle implicit lin. alg. solver output on/off. nlpr toggle implicit nonlinear solver output on/off. iter toggle implicit output to d3iter database on/off. prof output timing data to messag and continue. conv force implicit nonlinear convergence for current time step. ttrm terminate implicit time step, reduce time step, retry time step. rtrm terminate implicit at end of current time step. ******** notice ******** notice ******** notice ******** * * * This is the LS-DYNA Finite Element code. * * * * Neither LST nor the authors assume any responsibility for * * the validity, accuracy, or applicability of any results * * obtained from this system. Users must verify their own * * results. * * * * LST endeavors to make the LS-DYNA code as complete, * * accurate and easy to use as possible. * * Suggestions and comments are welcomed. Please report any * * errors encountered in either the documentation or results * * immediately to LST through your site focus. * * * * Copyright (C) 1990-2021 * * by Livermore Software Technology, LLC * * All rights reserved * * * ******** notice ******** notice ******** notice ******** Beginning of keyword reader 05/06/24 08:55:20 Memory required to process keyword : 319296 Additional dynamic memory required : 573821 input of data is completed initial kinetic energy = 0.68292406E+05 Memory required to begin solution : 320K Additional dynamically allocated memory: 787K Total: 1107K initialization completed 1 t 0.0000E+00 dt 1.98E-08 flush i/o buffers 05/06/24 08:55:20 1 t 0.0000E+00 dt 1.98E-08 write d3plot file 05/06/24 08:55:20 cpu time per zone cycle............ 384 nanoseconds average cpu time per zone cycle.... 415 nanoseconds average clock time per zone cycle.. 473 nanoseconds estimated total cpu time = 3 sec ( 0 hrs 0 mins) estimated cpu time to complete = 3 sec ( 0 hrs 0 mins) estimated total clock time = 6 sec ( 0 hrs 0 mins) estimated clock time to complete = 3 sec ( 0 hrs 0 mins) termination time = 3.000E-05 termination cycle = 10000000 77 t 1.4949E-06 dt 1.98E-08 write d3plot file 05/06/24 08:55:20 153 t 2.9937E-06 dt 1.97E-08 write d3plot file 05/06/24 08:55:20 229 t 4.4954E-06 dt 1.99E-08 write d3plot file 05/06/24 08:55:20 304 t 5.9808E-06 dt 2.00E-08 write d3plot file 05/06/24 08:55:21 380 t 7.4942E-06 dt 1.98E-08 write d3plot file 05/06/24 08:55:21 461 t 8.9899E-06 dt 1.59E-08 write d3plot file 05/06/24 08:55:21 564 t 1.0494E-05 dt 1.36E-08 write d3plot file 05/06/24 08:55:21 689 t 1.1990E-05 dt 1.07E-08 write d3plot file 05/06/24 08:55:21 836 t 1.3497E-05 dt 9.66E-09 write d3plot file 05/06/24 08:55:22 1003 t 1.4998E-05 dt 8.72E-09 write d3plot file 05/06/24 08:55:22 1190 t 1.6499E-05 dt 7.94E-09 write d3plot file 05/06/24 08:55:22 1392 t 1.7994E-05 dt 7.34E-09 write d3plot file 05/06/24 08:55:22 1604 t 1.9498E-05 dt 6.63E-09 write d3plot file 05/06/24 08:55:23 1827 t 2.0996E-05 dt 6.76E-09 write d3plot file 05/06/24 08:55:23 2058 t 2.2500E-05 dt 6.30E-09 write d3plot file 05/06/24 08:55:24 2289 t 2.3999E-05 dt 6.27E-09 write d3plot file 05/06/24 08:55:24 2524 t 2.5494E-05 dt 6.30E-09 write d3plot file 05/06/24 08:55:24 2762 t 2.6996E-05 dt 6.32E-09 write d3plot file 05/06/24 08:55:25 2992 t 2.8499E-05 dt 6.71E-09 write d3plot file 05/06/24 08:55:25 3225 t 2.9998E-05 dt 6.33E-09 write d3plot file 05/06/24 08:55:25 *** termination time reached *** 3225 t 3.0004E-05 dt 6.33E-09 write d3dump01 file 05/06/24 08:55:25 3225 t 3.0004E-05 dt 6.33E-09 write d3plot file 05/06/24 08:55:25 N o r m a l t e r m i n a t i o n 05/06/24 08:55:25 Memory required to complete solution : 320K Additional dynamically allocated memory: 789K Total: 1108K T i m i n g i n f o r m a t i o n CPU(seconds) %CPU Clock(seconds) %Clock ---------------------------------------------------------------- Keyword Processing ... 2.8470E-02 0.52 2.8471E-02 0.33 KW Reading ......... 1.7928E-02 0.33 1.7929E-02 0.21 KW Writing ......... 2.0490E-03 0.04 2.0490E-03 0.02 Initialization ....... 6.6242E-02 1.21 3.2500E+00 37.53 Init Proc Phase 1 .. 8.6113E-03 0.16 9.4010E-03 0.11 Init Proc Phase 2 .. 2.5032E-03 0.05 3.0450E-03 0.04 Init solver .......... 5.5133E-05 0.00 5.5000E-05 0.00 Element processing ... 4.5183E+00 82.55 4.5183E+00 52.17 Solids ............. 4.1459E+00 75.74 4.1448E+00 47.86 Shells ............. 8.4246E-03 0.15 9.5810E-03 0.11 ISO Shells ......... 3.0643E-03 0.06 3.8380E-03 0.04 E Other ............ 9.0520E-03 0.17 9.3320E-03 0.11 Binary databases ..... 2.1857E-02 0.40 2.2283E-02 0.26 ASCII database ....... 1.5361E-01 2.81 1.5362E-01 1.77 Contact algorithm .... 8.2139E-03 0.15 8.3330E-03 0.10 Rigid Bodies ......... 3.9138E-03 0.07 3.9220E-03 0.05 Time step size ....... 3.6418E-03 0.07 3.6130E-03 0.04 Rigid wall ........... 3.0121E-01 5.50 3.0013E-01 3.47 Group force file ..... 3.7060E-03 0.07 4.7540E-03 0.05 Others ............... 9.1253E-03 0.17 9.0910E-03 0.10 Misc. 1 .............. 2.5270E-01 4.62 2.5670E-01 2.96 Scale Masses ....... 2.3131E-03 0.04 2.3500E-03 0.03 Force Constraints .. 2.3677E-03 0.04 2.3320E-03 0.03 Force to Accel ..... 3.9283E-02 0.72 3.8965E-02 0.45 Update RB nodes .... 2.5501E-03 0.05 2.5750E-03 0.03 Misc. 2 .............. 6.8562E-02 1.25 6.7539E-02 0.78 Misc. 3 .............. 1.0502E-02 0.19 1.0443E-02 0.12 Misc. 4 .............. 2.3502E-02 0.43 2.3501E-02 0.27 Timestep Init ...... 1.3791E-02 0.25 1.3495E-02 0.16 Apply Loads ........ 4.8953E-03 0.09 5.0420E-03 0.06 ---------------------------------------------------------------- T o t a l s 5.4736E+00 100.00 8.6608E+00 100.00 Problem time = 3.0004E-05 Problem cycle = 3225 Total CPU time = 5 seconds ( 0 hours 0 minutes 5 seconds) CPU time per zone cycle = 350.319 nanoseconds Clock time per zone cycle= 350.544 nanoseconds Number of CPU's 1 NLQ used/max 112/ 112 Start time 05/06/2024 08:55:20 End time 05/06/2024 08:55:25 Elapsed time 5 seconds for 3225 cycles using 1 SMP thread ( 0 hour 0 minute 5 seconds) N o r m a l t e r m i n a t i o n 05/06/24 08:55:25 Printed output to console .. GENERATED FROM PYTHON SOURCE LINES 269-271 Get image and display ~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 271-300 .. code-block:: Python def get_image_path(image_name): return os.path.join(result_image_dir_server, image_name) def display_image(path): print(f"Printing {path} using matplotlib") image1 = mpimg.imread(path) plt.figure(figsize=(15, 15)) plt.axis("off") plt.imshow(image1) plt.show() image_name = "totaldeformation.png" image_path_server = get_image_path(image_name) if image_path_server != "": current_working_directory = os.getcwd() local_file_path_list = mechanical.download( image_path_server, target_dir=current_working_directory ) image_local_path = local_file_path_list[0] print(f"Local image path : {image_local_path}") display_image(image_local_path) .. image-sg:: /examples/basic/images/sphx_glr_example_08_lsdyna_taylor_bar_001.png :alt: example 08 lsdyna taylor bar :srcset: /examples/basic/images/sphx_glr_example_08_lsdyna_taylor_bar_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading dns:///127.0.0.1:10000:/tmp/ANSYS.root.1/AnsysMech65AA/Project_Mech_Files/ExplicitDynamics/totaldeformation.png to /home/runner/work/pymechanical-examples/pymechanical-examples/examples/basic/totaldeformation.png: 0%| | 0.00/103k [00:00
.. rst-class:: sphx-glr-script-out .. code-block:: none Downloading dns:///127.0.0.1:10000:/tmp/ANSYS.root.1/AnsysMech65AA/Project_Mech_Files/ExplicitDynamics/taylor_bar.gif to /home/runner/work/pymechanical-examples/pymechanical-examples/examples/basic/taylor_bar.gif: 0%| | 0.00/10.1M [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_08_lsdyna_taylor_bar.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_