.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "verif-manual/vm-016.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_verif-manual_vm-016.py: .. _ref_vm16: Bending of a Solid Beam (Plane Elements) ---------------------------------------- Problem description: - A beam of length :math:`l` and height :math:`h` is built-in at one end and loaded at the free end with: * Case 1: a moment :math:`M`. * Case 2: a shear force :math:`F`. For each case, determine the deflection :math:`\delta` at the free end and the bending stress :math:`\sigma_{Bend}` a distance d from the wall at the outside fiber. Reference: - Formulas for Stress and Strain, R. J. Roark, 4th Edition, McGraw-Hill Book Co., Inc., New York, NY, 1965, pp. 104, 106. Analysis type(s): - Static Analysis ``ANTYPE=0`` Element type(s): - 2-D Structural Solid Elements (PLANE42) - 2-D 4 Node structural elements(PLANE182) .. image:: ../_static/vm16_setup.png :width: 400 :alt: VM16 Bending of a Solid Beam with Plane Elements Problem Sketch Material properties: - :math:`E = 30 \cdot 10^6 psi` - :math:`\mu = 0.0` Geometric properties: - :math:`l = 10 in` - :math:`h = 2.0 in` - :math:`d = 1.0 in` Loading: - Case 1, :math:`M = 2000 in-lb` - Case 2, :math:`F = 300 lb` Analysis Assumptions and Modeling Notes: - The stiffness matrix formed in the first load step is also used in the second load step (automatically determined by Mechanical APDL). The end moment is represented by equal and opposite forces separated by a distance h. The bending stress is obtained from face stresses on element 1. .. GENERATED FROM PYTHON SOURCE LINES 72-96 .. code-block:: Python # sphinx_gallery_thumbnail_path = '_static/vm16_setup.png' # Importing the `launch_mapdl` function from the `ansys.mapdl.core` module from ansys.mapdl.core import launch_mapdl import pandas as pd # Launch MAPDL with specified options mapdl = launch_mapdl(loglevel="WARNING", print_com=True, remove_temp_dir_on_exit=True) # Clear the existing database mapdl.clear() # Run the FINISH command to exists normally from a processor mapdl.finish() # Run a /VERIFY command to verify the installation mapdl.run("/VERIFY,VM16") # Set the ANSYS version and reference verification manual mapdl.com("ANSYS MEDIA REL. 2022R2 (05/13/2022) REF. VERIF. MANUAL: REL. 2022R2") # Set the analysis title mapdl.title("VM16 BENDING OF A SOLID BEAM (PLANE ELEMENTS)") .. rst-class:: sphx-glr-script-out .. code-block:: none TITLE= VM16 BENDING OF A SOLID BEAM (PLANE ELEMENTS) .. GENERATED FROM PYTHON SOURCE LINES 97-100 Case 1: Solve Using PLANE42 Element Model. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter the model creation prep7 preprocessor .. GENERATED FROM PYTHON SOURCE LINES 100-102 .. code-block:: Python mapdl.prep7(mute=True) .. GENERATED FROM PYTHON SOURCE LINES 103-107 Define element type and properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use 2-D Structural Solid (PLANE42) and include Surface solution for both faces, via Keyopt(6)=2. .. GENERATED FROM PYTHON SOURCE LINES 107-112 .. code-block:: Python mapdl.et( 1, "PLANE42", "", "", "", "", "", 2 ) # PLANE42 WITH SURFACE PRINTOUT FOR FACES 1 AND 3 .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 113-117 Define material ~~~~~~~~~~~~~~~ Set up the material and its type (a single material), Young's modulus of 30e6 and Poisson's ratio of 0.0 is specified. .. GENERATED FROM PYTHON SOURCE LINES 117-121 .. code-block:: Python mapdl.mp("EX", 1, 30e6) # Elastic modulus mapdl.mp("NUXY", 1, 0.0) # Poisson's ratio .. rst-class:: sphx-glr-script-out .. code-block:: none MATERIAL 1 NUXY = 0.000000 .. GENERATED FROM PYTHON SOURCE LINES 122-126 Define geometry ~~~~~~~~~~~~~~~ Set up the nodes and elements. This creates a mesh just like in the problem setup. .. GENERATED FROM PYTHON SOURCE LINES 126-147 .. code-block:: Python mapdl.n(1) mapdl.n(6, 10) # Generate additional nodes mapdl.fill() # Generates nodes from an existing pattern mapdl.ngen(2, 10, 1, 6, 1, "", 2) # Define elements mapdl.e(1, 2, 12, 11) # Generate additional elements from an existing pattern mapdl.egen(5, 1, 1) # select all entities mapdl.allsel() # element plot mapdl.eplot(background="w") .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /verif-manual/images/sphx_glr_vm-016_001.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pymapdl-examples/pymapdl-examples/doc/source/verif-manual/images/sphx_glr_vm-016_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 148-152 Define boundary conditions and loadings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix all degrees of freedom (dof) at nodes 10 & 11. For load case 1, apply end moment and then exit prep7 processor. .. GENERATED FROM PYTHON SOURCE LINES 152-161 .. code-block:: Python # Set boundary conditions for case 1 (end moment) mapdl.d(1, "ALL", "", "", 11, 10) # Displacement constraint mapdl.f(6, "FX", 1000) # Applied force mapdl.f(16, "FX", -1000) # Applied force # Finish the pre-processing processor mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 162-165 Solve ~~~~~ Enter solution mode and solve the system for the 1st load case. .. GENERATED FROM PYTHON SOURCE LINES 165-176 .. code-block:: Python mapdl.slashsolu() # Set analysis type to static mapdl.antype("STATIC") # start solve for 1st load case mapdl.solve() # exists solution processor mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none FINISH SOLUTION PROCESSING ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 177-180 Post-processing ~~~~~~~~~~~~~~~ Enter post-processing. Compute deflection and stress components for load case 1. .. GENERATED FROM PYTHON SOURCE LINES 180-202 .. code-block:: Python mapdl.post1() # Set "last" load case to be read from result file for post-processing mapdl.set("LAST") # Get displacement at node 16 in the Y-direction u1 = mapdl.get("U1", "NODE", 16, "U", "Y") mapdl.graphics("POWER") # Activates the graphics mode for power graphics mapdl.eshape(1) # Display element shape mapdl.view(1, 1, 1, 1) # Set the viewing options # for graphics displays mapdl.show(option="REV", fname="png") mapdl.plnsol("S", "X") # Plot bending stress along the X-axis # Get maximum bending stress for case 1 bend_stress1 = mapdl.get("BEND_STRESS1", "PLNSOL", 0, "MAX") mapdl.show("close") # exists solution processor for case 1 mapdl.finish() .. image-sg:: /verif-manual/images/sphx_glr_vm-016_002.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EXIT THE MAPDL POST1 DATABASE PROCESSOR ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 203-206 Solve ~~~~~ Enter solution mode and solve the system for the 2nd load case. .. GENERATED FROM PYTHON SOURCE LINES 206-208 .. code-block:: Python mapdl.slashsolu() .. rst-class:: sphx-glr-script-out .. code-block:: none ***** MAPDL SOLUTION ROUTINE ***** .. GENERATED FROM PYTHON SOURCE LINES 209-212 Define boundary conditions and loadings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For load case 2, apply end load and then solve for 2nd load case. .. GENERATED FROM PYTHON SOURCE LINES 212-221 .. code-block:: Python mapdl.f(6, "FX", "", "", 16, 10) # Applied force in the X-direction mapdl.f(6, "FY", 150, "", 16, 10) # Applied force in the Y-direction # start solve for 2nd load case mapdl.solve() # exists solution processor for case 2 mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none FINISH SOLUTION PROCESSING ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 222-225 Post-processing ~~~~~~~~~~~~~~~ Enter post-processing. Compute deflection and stress components for load case 2. .. GENERATED FROM PYTHON SOURCE LINES 225-245 .. code-block:: Python mapdl.post1() # Set "last" load case to be read from result file for post-processing mapdl.set("LAST") # Retrieves the displacement "U2" of node 16 in the Y direction u2 = mapdl.get("U2", "NODE", 16, "U", "Y") mapdl.graphics("POWER") # Activates the graphics mode for power graphics mapdl.eshape(1) # Display element shape mapdl.view(1, 1, 1, 1) # Set the viewing options # for graphics displays mapdl.show(option="REV", fname="png") mapdl.plnsol("S", "X") # Plot bending stress along the X-axis # Retrieves the maximum bending stress from the plane stress plot bend_stress2 = mapdl.get("BEND_STRESS2", "PLNSOL", 0, "MAX") mapdl.show("close") .. image-sg:: /verif-manual/images/sphx_glr_vm-016_003.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 246-248 Verify the results. ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 248-284 .. code-block:: Python # Set target values target_def = [0.00500, 0.00500] target_strss = [3000, 4050] # Fill result values res_def = [u1, u2] res_strss = [bend_stress1, bend_stress2] title = f""" ------------------- VM16 RESULTS COMPARISON --------------------- PLANE42 ======= """ print(title) col_headers = ["TARGET", "Mechanical APDL", "RATIO"] row_headers = ["Deflection (in)", "Bending Stress (psi)"] for lc in range(len(res_def)): data = [ [target_def[lc], res_def[lc], abs(target_def[lc] / res_def[lc])], [target_strss[lc], abs(res_strss[lc]), abs(target_strss[lc] / res_strss[lc])], ] title = f""" RESULTS FOR CASE {lc+1:1d}: ------------------- """ print(title) print(pd.DataFrame(data, row_headers, col_headers)) .. rst-class:: sphx-glr-script-out .. code-block:: none ------------------- VM16 RESULTS COMPARISON --------------------- PLANE42 ======= RESULTS FOR CASE 1: ------------------- TARGET Mechanical APDL RATIO Deflection (in) 0.005 0.005 1.0 Bending Stress (psi) 3000.000 3000.000 1.0 RESULTS FOR CASE 2: ------------------- TARGET Mechanical APDL RATIO Deflection (in) 0.005 0.00505 0.990099 Bending Stress (psi) 4050.000 4050.00000 1.000000 .. GENERATED FROM PYTHON SOURCE LINES 285-287 Finish the post-processing processor. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 287-289 .. code-block:: Python mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none EXIT THE MAPDL POST1 DATABASE PROCESSOR ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 290-292 Clears the database without restarting. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 292-294 .. code-block:: Python mapdl.run("/CLEAR,NOSTART") .. rst-class:: sphx-glr-script-out .. code-block:: none CLEAR MAPDL DATABASE AND RESTART Ansys Mechanical Enterprise Academic Student .. GENERATED FROM PYTHON SOURCE LINES 295-298 Case 2: Solve Using PLANE182 Element Model ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Switches to the preprocessor (PREP7) .. GENERATED FROM PYTHON SOURCE LINES 298-300 .. code-block:: Python mapdl.prep7() .. rst-class:: sphx-glr-script-out .. code-block:: none *****MAPDL VERIFICATION RUN ONLY***** DO NOT USE RESULTS FOR PRODUCTION ***** MAPDL ANALYSIS DEFINITION (PREP7) ***** .. GENERATED FROM PYTHON SOURCE LINES 301-305 Define element type and properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use 2-D 4 Node structural elements (PLANE182) and include simplified enhanced strain formulation, via Keyopt(1)=3. .. GENERATED FROM PYTHON SOURCE LINES 305-311 .. code-block:: Python # Defines an element type as PLANE182 mapdl.et(1, "PLANE182") # Sets a key option for the element type mapdl.keyopt(1, 1, 3) .. rst-class:: sphx-glr-script-out .. code-block:: none ELEMENT TYPE 1 IS PLANE182 2-D 4-NODE PLANE STRS SOLID KEYOPT( 1- 6)= 3 0 0 0 0 0 KEYOPT( 7-12)= 0 0 0 0 0 0 KEYOPT(13-18)= 0 0 0 0 0 0 CURRENT NODAL DOF SET IS UX UY TWO-DIMENSIONAL MODEL .. GENERATED FROM PYTHON SOURCE LINES 312-316 Define material ~~~~~~~~~~~~~~~ Set up the material and its type (a single material), Young's modulus of 30e6 and Poisson's ratio of 0.0 is specified. .. GENERATED FROM PYTHON SOURCE LINES 316-320 .. code-block:: Python mapdl.mp("EX", 1, 30e6) mapdl.mp("NUXY", 1, 0.0) .. rst-class:: sphx-glr-script-out .. code-block:: none MATERIAL 1 NUXY = 0.000000 .. GENERATED FROM PYTHON SOURCE LINES 321-325 Define geometry ~~~~~~~~~~~~~~~ Set up the nodes and elements. This creates a mesh just like in the problem setup. .. GENERATED FROM PYTHON SOURCE LINES 325-347 .. code-block:: Python # Defines nodes mapdl.n(1) mapdl.n(6, 10) # Generate additional nodes mapdl.fill() # Generates additional nodes from an existing pattern mapdl.ngen(2, 10, 1, 6, 1, "", 2) # Defines elements mapdl.e(1, 2, 12, 11) # Generates additional elements from an existing pattern mapdl.egen(5, 1, 1) # select all entities mapdl.allsel() # element plot mapdl.eplot(background="w") .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /verif-manual/images/sphx_glr_vm-016_004.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_004.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pymapdl-examples/pymapdl-examples/doc/source/verif-manual/images/sphx_glr_vm-016_004.vtksz .. GENERATED FROM PYTHON SOURCE LINES 348-352 Define boundary conditions and loadings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix all degrees of freedom (dof) at nodes 10 & 11. For load case 1, apply end moment and then exit prep7 processor. .. GENERATED FROM PYTHON SOURCE LINES 352-361 .. code-block:: Python mapdl.d(1, "ALL", "", "", 11, 10) # Applies nodal forces mapdl.f(6, "FX", 1000) mapdl.f(16, "FX", -1000) # exists solution processor mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 362-365 Solve ~~~~~ Enter solution mode and solve the system for the 1st load case. .. GENERATED FROM PYTHON SOURCE LINES 365-376 .. code-block:: Python mapdl.slashsolu() # Set analysis type to static mapdl.antype("STATIC") # start solve for 1st load case mapdl.solve() # exists solution processor mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none FINISH SOLUTION PROCESSING ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 377-380 Post-processing ~~~~~~~~~~~~~~~ Enter post-processing. Compute deflection and stress components for load case 1. .. GENERATED FROM PYTHON SOURCE LINES 380-403 .. code-block:: Python mapdl.post1() # Sets the LAST result as the active result set mapdl.set("LAST") # Retrieves the displacement "U1" of node 16 in the Y direction u1 = mapdl.get("U1", "NODE", 16, "U", "Y") mapdl.graphics("POWER") # Activates the graphics mode for power graphics mapdl.eshape(1) # Display element shape mapdl.view(1, 1, 1, 1) # Set the viewing options # for graphics displays mapdl.show(option="REV", fname="png") mapdl.plnsol("S", "X") # Plot bending stress along the X-axis # Retrieves the maximum bending stress from the plane stress plot bend_stress1 = mapdl.get("BEND_STRESS1", "PLNSOL", 0, "MAX") mapdl.show("close") # exists solution processor for case 1 mapdl.finish() .. image-sg:: /verif-manual/images/sphx_glr_vm-016_005.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EXIT THE MAPDL POST1 DATABASE PROCESSOR ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 404-407 Solve ~~~~~ Enter solution mode and solve the system for the 2nd load case. .. GENERATED FROM PYTHON SOURCE LINES 407-409 .. code-block:: Python mapdl.slashsolu() .. rst-class:: sphx-glr-script-out .. code-block:: none ***** MAPDL SOLUTION ROUTINE ***** .. GENERATED FROM PYTHON SOURCE LINES 410-413 Define boundary conditions and loadings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For load case 2, apply end load and then solve for 2nd load case. .. GENERATED FROM PYTHON SOURCE LINES 413-422 .. code-block:: Python mapdl.f(6, "FX", "", "", 16, 10) mapdl.f(6, "FY", 150, "", 16, 10) # start solve for 2nd load case mapdl.solve() # exists solution processor for case 2 mapdl.finish() .. rst-class:: sphx-glr-script-out .. code-block:: none FINISH SOLUTION PROCESSING ***** ROUTINE COMPLETED ***** CP = 0.000 .. GENERATED FROM PYTHON SOURCE LINES 423-426 Post-processing ~~~~~~~~~~~~~~~ Enter post-processing. Compute deflection and stress components for load case 2. .. GENERATED FROM PYTHON SOURCE LINES 426-446 .. code-block:: Python mapdl.post1() # Sets the LAST result as the active result set mapdl.set("LAST") # Retrieves the displacement "U2" of node 16 in the Y direction u2 = mapdl.get("U2", "NODE", 16, "U", "Y") mapdl.graphics("POWER") # Activates the graphics mode for power graphics mapdl.eshape(1) # Display element shape mapdl.view(1, 1, 1, 1) # Set the viewing options # for graphics displays mapdl.show(option="REV", fname="png") mapdl.plnsol("S", "X") # Plot bending stress along the X-axis # Retrieves the maximum bending stress from the plane stress plot bend_stress2 = mapdl.get("BEND_STRESS2", "PLNSOL", 0, "MAX") mapdl.show("close") .. image-sg:: /verif-manual/images/sphx_glr_vm-016_006.png :alt: vm 016 :srcset: /verif-manual/images/sphx_glr_vm-016_006.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 447-449 Verify the results. ~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 449-484 .. code-block:: Python # Set target values target_def = [0.00500, 0.00500] target_strss = [3000, 4050] # Fill result values res_def = [u1, u2] res_strss = [bend_stress1, bend_stress2] title = f""" PLANE182 ======== """ print(title) col_headers = ["TARGET", "Mechanical APDL", "RATIO"] row_headers = ["Deflection (in)", "Bending Stress (psi)"] for lc in range(len(res_def)): data = [ [target_def[lc], res_def[lc], abs(target_def[lc] / res_def[lc])], [target_strss[lc], abs(res_strss[lc]), abs(target_strss[lc] / res_strss[lc])], ] title = f""" RESULTS FOR CASE {lc+1:1d}: ------------------- """ print(title) print(pd.DataFrame(data, row_headers, col_headers)) .. rst-class:: sphx-glr-script-out .. code-block:: none PLANE182 ======== RESULTS FOR CASE 1: ------------------- TARGET Mechanical APDL RATIO Deflection (in) 0.005 0.005 1.0 Bending Stress (psi) 3000.000 3000.000 1.0 RESULTS FOR CASE 2: ------------------- TARGET Mechanical APDL RATIO Deflection (in) 0.005 0.00505 0.990099 Bending Stress (psi) 4050.000 4050.00000 1.000000 .. GENERATED FROM PYTHON SOURCE LINES 485-487 Finish the post-processing processor. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 487-491 .. code-block:: Python mapdl.finish() # Exit MAPDL session mapdl.exit() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.190 seconds) .. _sphx_glr_download_verif-manual_vm-016.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: vm-016.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: vm-016.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_