From ba016ebed9291b11f86fa71a490e0e8841f9047c Mon Sep 17 00:00:00 2001 From: Pernelle Marone-Hitz Date: Mon, 5 Sep 2022 16:15:54 +0200 Subject: [PATCH 1/6] Adding example on buckling analysis --- .gitignore | 5 +- .../technology_showcase_examples/README.txt | 2 + ...21-example-technology-showcase-buckling.py | 381 ++++++++++++++++++ 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py diff --git a/.gitignore b/.gitignore index 3fa916340d9..99d54eaddec 100755 --- a/.gitignore +++ b/.gitignore @@ -88,4 +88,7 @@ venv/ .vscode/ # Pycharm local settings -.idea/ \ No newline at end of file +.idea/ + +.vs +.gitignore \ No newline at end of file diff --git a/doc/source/examples/technology_showcase_examples/README.txt b/doc/source/examples/technology_showcase_examples/README.txt index ea9f089aa52..08f7287ae1e 100644 --- a/doc/source/examples/technology_showcase_examples/README.txt +++ b/doc/source/examples/technology_showcase_examples/README.txt @@ -20,5 +20,7 @@ this project. +----------------------------+---------------------------------------------------------------------------------------------------------+ | :ref:`tech_demo_20` | Technology showcase demonstration example 20: Dynamic simulation of a printed circuit board assembly | +----------------------------+---------------------------------------------------------------------------------------------------------+ +| :ref:`tech_demo_21` | Technology showcase demonstration example 21: Buckling of a ring-stiffened cylinder | ++----------------------------+---------------------------------------------------------------------------------------------------------+ | :ref:`tech_demo_28` | Technology showcase demonstration example 28: Friction Stir Welding (FSW) Simulation | +----------------------------+---------------------------------------------------------------------------------------------------------+ \ No newline at end of file diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py new file mode 100644 index 00000000000..5d4c7b0c574 --- /dev/null +++ b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri Sep 2 14:24:13 2022 + +@author: pmaroneh +""" + +""".. _ref_buckling_postbuckling_ring_stiffened_cylinder: + +Buckling and post-buckling analysis of a ring-stiffened +cylinder using nonlinear stabilization +====================================================== + +This examples shows how to use PyMAPDL to import an existing FE model and to +perform a nonlinear buckling and postbuckling analysis using nonlinear +stabilization. The problem uses a stiffened cylinder subjected to uniform +external pressure to show how to find the nonlinear buckling loads, +achieve convergence at the post-buckling stage, and interpret the results. + +This example is inspired from the model and analysis defined in Chapter 21 of +the Mechanical APDL Technology Showcase Manual. + +Additional Packages Used +------------------------ + +* `Matplotlib `_ is used for plotting purposes. + +""" + +############################################################################### +# Setting up model +# ---------------- +# +# The original FE model is given in the Ansys Mechanical APDL Technology +# Showcase Manual. The .cdb contains a FE model of a ring-stiffened cylinder. +# +# A circular cylinder made of bare 2024-T3 aluminum alloy is stiffened inside +# with five Z-section rings. Its ends are closed with thick aluminum bulkheads. +# A riveted L section exists between the top plate and the top ring and the +# bottom plate and bottom ring. +# The cylinder is subjected to a differential external pressure. The pressure +# causes a local buckling phenomenon characterized by buckling of the skin +# between stiffening rings, leading eventually to collapse. +# +# The finite element model of the ring stiffened cylinder is meshed with +# SHELL281 elements with an element size of 10 mm. The fine mesh is required +# for buckling analysis, and a full 360-degree model is necessary because +# the deformation is no longer axisymmetric after buckling occurs. +# +# All shell elements have uniform thickness. Five sections are created in the +# model with no offsets, so the shell sections are offset to the midplane +# by default. +# +# Starting MAPDL as a service and importing an external model +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +import matplotlib.pyplot as plt + +from ansys.mapdl.core import launch_mapdl +from ansys.mapdl.core.examples import download_tech_demo_data + +# define geometric parameters +bs=95.3 # Ring spacing (mm) +ts=1.034 # Skin thickness (mm) +tw=0.843 # Ring thickness (mm) +r=344*ts # Radius of cylinder (mm) +L=431.8+2*(19-9.5) # Length of cylinder (mm) +pext=0.24 # Differential external pressure (MPa) + +# start MAPDL as a service +mapdl = launch_mapdl() +print(mapdl) + +# enter preprocessor +mapdl.prep7() + +# define material properties for 2024-T3 Alluminum alloy +EX=73000 # Young's Modulus (MPA) +ET=73 # Tangent modulus +mapdl.mp('ex',1,EX) # Young's Modulus (MPA) +mapdl.mp('prxy',1,0.33 ) # Poisson's ratio +EP=EX*ET/(EX-ET) +mapdl.tb('biso',1) +mapdl.tbdata(1,268.9,EP) +# create material plot +mapdl.show('png') +mapdl.tbplot('biso',1) +mapdl.show('close') + +# define shell elements and their sections +mapdl.et(1,181) +# cylinder +mapdl.sectype(1,'shell') +mapdl.secdata(ts,1) +# L +mapdl.sectype(2,'shell') +mapdl.secdata(ts+1.64,1) +# Z shaped ring stiffener +mapdl.sectype(3,'shell') +mapdl.secdata(tw,1) +# Plate at z=0 with thickness=25 mm +mapdl.sectype(4,'shell') +mapdl.secdata(25,1) +# Plate at z=L with thickness=25 mm +mapdl.sectype(5,'shell') +mapdl.secdata(25,1) + + +# read model of stiffened cylinder +# download the cdb file +# ring_mesh_file = download_tech_demo_data("td-21", "ring_stiffened_cylinder_mesh_file.cdb") + +ring_mesh_file = r"D:\PyAnsys\Examples\Buckling_PostBuckling_TD21\ring_stiffened_cylinder_mesh_file.cdb" + +# read in cdb + +mapdl.cdread("db", ring_mesh_file) +mapdl.allsel() +mapdl.eplot(background="w") +mapdl.cmsel("all") + +############################################################################### +# Define static prestress analysis +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Displacement boundary conditions are defined to prevent the six rigid body +# motions. A total of six displacements are therefore applied to three nodes +# located on the top plate at 0, 90, and 270 degrees; the nodes are restricted +# so that all rigid translations and rotations are not possible for the +# cylinder. +# +# Loading consists of a uniformly distributed external differential +# pressure: Pext = 0.24 MPa + +mapdl.csys(1) # activate cylindrical coordinate system + +# Define pressure on plate at z=0 +mapdl.nsel('s','loc','z',0) +mapdl.esln('s',1) +mapdl.sfe('all',2,'pres',1,pext) +mapdl.allsel() + +# Define pressure on the rim of plate at z=0 +mapdl.nsel('s','loc','z',0) +mapdl.nsel('r','loc','x',r-ts/2,760/2) +mapdl.esln('s',1) +mapdl.sfe('all',1,'pres',1,pext) +mapdl.allsel() + +# Define pressure on plate at z=L +mapdl.nsel('s','loc','z',L) +mapdl.esln('s',1) +mapdl.sfe('all',2,'pres',1,pext) +mapdl.allsel() + +# Define pressure on the rim of plate at z=L +mapdl.nsel('s','loc','z',L) +mapdl.nsel('r','loc','x',r-ts/2,760/2) +mapdl.esln('s',1) +mapdl.sfe('all',1,'pres',1,pext) +mapdl.allsel() + +# Define pressure on cylinder +mapdl.nsel('s','loc','x',r-ts/2) +mapdl.esln('s',1) +mapdl.sfe('all',2,'pres',1,pext) +mapdl.allsel() + +# Define displacement BSs to avoid rigid body motion +mapdl.csys(0) # activate cartesian coordinate system +mapdl.nsel('s','loc','x',r-ts/2) +mapdl.nsel('r','loc','y',0) +mapdl.nsel('r','loc','z',0) +mapdl.d('all','ux',0) +mapdl.d('all','uy',0) +mapdl.d('all','uz',0) +mapdl.allsel() +# +mapdl.nsel('s','loc','x',0) +mapdl.nsel('r','loc','y',r-ts/2) +mapdl.nsel('r','loc','z',0) +mapdl.d('all','uz',0) +mapdl.allsel() +# +mapdl.nsel('s','loc','x',0) +mapdl.nsel('r','loc','y',-(r-ts/2)) +mapdl.nsel('r','loc','z',0) +mapdl.d('all','uy',0) +mapdl.d('all','uz',0) +mapdl.allsel() +# + +# Print DOF constraints +print(mapdl.dlist()) + +# Solve static prestress analysis +mapdl.slashsolu() +mapdl.pstres('on') +mapdl.antype('STATIC') +output = mapdl.solve() +print(output) + +# Plot total deformation +mapdl.post1() +mapdl.set('last') +mapdl.post_processing.plot_nodal_displacement('NORM', + smooth_shading=True) +#%% +############################################################################### +# Run linear buckling analysis +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# This preliminary analysis predicts the theoretical buckling pressure of the +# ideal linear elastic structure (perfect cylinder) and the buckled mode shapes +# used in the next step to generate the imperfections. +# It is also an efficient way to check the completeness and +# correctness of modeling. +# To run the linear buckling analysis, a static solution with prestress effects +# must be obtained, followed by the eigenvalue buckling solution using the +# Block Lanczos method and mode expansion. + +# Define and solve linear buckling analysis +mapdl.slashsolu() +mapdl.outres('all','all') +mapdl.antype('BUCKLE') +mapdl.bucopt('lanb','10') +mapdl.mxpand(10) +output = mapdl.solve() +print(output) + +# Plot total deformation of first and 10th mode +mapdl.post1() +mapdl.set(1,1) +mapdl.post_processing.plot_nodal_displacement('NORM', + smooth_shading=True) +mapdl.set(1,10) +mapdl.post_processing.plot_nodal_displacement('NORM', + smooth_shading=True) +#%% +############################################################################### +# Generate imperfections +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# If a structure is perfectly symmetric, nonsymmetric buckling does not occur +# numerically, and a nonlinear buckling analysis fails because +# nonsymmetric buckling responses cannot be triggered. In this problem, +# the geometry, elements, and pressure are all axisymmetric. +# It is not possible, therefore, to simulate nonaxisymmetric buckling with +# the initial model. To overcome this problem, small geometric imperfections +# (similar to those caused by manufacturing a real structure) must be +# introduced to trigger the buckling responses. +# Because the radius of the cylinder is 355.69 mm and the maximum +# displacement of a mode shape is 1 mm, a factor of 0.1 is applied when +# updating the geometry with mode shapes. The factor assumes the manufacturing +# tolerance of the radius to be on the order of 0.1. +mapdl.finish() +mapdl.filname('buckling') # change filename +mapdl.prep7() +for i in range(1,11): + mapdl.upgeom(0.1,1,i,'file','rst') # Add imperfections as a tenth of each + # mode shape +mapdl.finish() +#%% +############################################################################### +# Run nonlinear static analysis on geometry with imperfections +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# The nonlinear buckling analysis is a static analysis performed after adding +# imperfections with large deflection active (NLGEOM,ON), extended to a point +# where the stiffened cylinder can reach its limit load. +# To perform the analysis, the load must be allowed to increase using very +# small time increments so that the expected critical buckling load can +# be predicted accurately. +# Note - as this is a buckling analysis, divergence is expected. + +mapdl.slashsolu() +mapdl.antype('STATIC') +mapdl.nlgeom('on') +mapdl.pred('on') +mapdl.time(1) +mapdl.nsubst(100,10000,10) +mapdl.rescontrol('define','all',1) +mapdl.outres('all','all') +mapdl.ncnv(2) # Do not terminate the program execution if the solution diverges +output = mapdl.solve() +print(output) +mapdl.finish() + +#%% +############################################################################### +# Post-buckling analysis +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# An unconverged solution of the nonlinear static analysis could mean that +# buckling has occurred. In this example, the change in time (or load) +# increment, and displacement value, occurs between substeps 10 and 11, +# which corresponds to TIME = 0.51781 and TIME = 0.53806 and to a pressure +# between 0.124 MPa and 0.129 MPa. It is therefore very likely that buckling +# occurred at this time; to be sure, the analysis is continued. The goal is to +# verify the assessment made at this stage by obtaining the load-displacement +# behavior over a larger range. Because the post-buckling state is unstable, +# special techniques are necessary to compensate, in this case, nonlinear +# stabilization is used. + +mapdl.slashsolu() # Restart analysis with stabilization +mapdl.antype('static','restart',1,10) +mapdl.nsubst(100,50000,10) +mapdl.rescontrol('define','last') +mapdl.stabilize('constant','energy',0.000144) # Use energy option +output = mapdl.solve() +print(output) +mapdl.finish() + +#%% +############################################################################### +# Postprocess buckling analysis in POST1 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +mapdl.post1() +mapdl.set('last') +mapdl.post_processing.plot_nodal_displacement('NORM', + smooth_shading=True) +mapdl.post_processing.plot_nodal_eqv_stress() +mapdl.finish() +#%% +############################################################################### +# Postprocess buckling analysis in POST26 +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +mapdl.post26() + + +mapdl.numvar(100) # allow storage for 100 variables +mapdl.enersol(13,'sene') # store stiffness energy +mapdl.enersol(14,'sten') # store artificial stabilization energy + +# time history plot of stiffness and stabilization energies +mapdl.show('png') +mapdl.plvar(13,14) +mapdl.show('close') + +# pressure versus axial shortening for some nodes under the upper ring +mapdl.nsol(2,67319,'U','Z','UZ1') +mapdl.prod(ir=3, ia=2, ib='', ic='', name='strain1', facta='', factb='', factc=-1/431.8) +mapdl.prod(ir=12, ia=1, ib='', ic='', name='Load', facta='', factb='', factc=0.24) +mapdl.xvar(3) +mapdl.show('png') +mapdl.xrange(0.01) +mapdl.yrange(0.24) +mapdl.axlab('X','Axial Shortening') +mapdl.aylab('Y','Applied Pressure ') +mapdl.plvar(12) +mapdl.show('close') +mapdl.xvar(3) +mapdl.show('png') +mapdl.xrange(0.002) +mapdl.yrange(1) +mapdl.axlab('X','Axial Shortening') +mapdl.aylab('Y','Time') +mapdl.plvar(1) +mapdl.show('close') + +# pressure versus radial displacement for the node with max. deformation +mapdl.nsol(6,65269,'U','Y','UY_1') +mapdl.prod(ir=7, ia=6, ib=6, ic='', name='UY2_1') +mapdl.nsol(8,65269,'U','X','UX_1') +mapdl.prod(ir=9, ia=8, ib=8, ic='', name='UX2_1') +mapdl.add(10,7,9,'sum') +mapdl.sqrt(ir=11, ia=10, name='Urad') +mapdl.xvar(11) +mapdl.show('png') +mapdl.xrange(4) +mapdl.yrange(0.24) +mapdl.axlab('X','Radial Displacement') +mapdl.aylab('Y','Applied Pressure') +mapdl.plvar(12) +mapdl.show('close') +mapdl.finish() + +#%% +############################################################################### +# Exit MAPDL +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# + +#mapdl.exit() \ No newline at end of file From e6349f35e6e032dc766f66473820fac1fe475e77 Mon Sep 17 00:00:00 2001 From: Pernelle Marone-Hitz Date: Mon, 26 Sep 2022 17:20:15 +0200 Subject: [PATCH 2/6] download cdb from example repo --- .../21-example-technology-showcase-buckling.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py index 5d4c7b0c574..2b70627f4c9 100644 --- a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py +++ b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py @@ -71,6 +71,9 @@ mapdl = launch_mapdl() print(mapdl) +mapdl.filname('buckling') # change filename +# mapdl.nerr(nmerr=200, nmabt=10000, abort=-1, ifkey=0, num=0) + # enter preprocessor mapdl.prep7() @@ -108,12 +111,9 @@ # read model of stiffened cylinder # download the cdb file -# ring_mesh_file = download_tech_demo_data("td-21", "ring_stiffened_cylinder_mesh_file.cdb") - -ring_mesh_file = r"D:\PyAnsys\Examples\Buckling_PostBuckling_TD21\ring_stiffened_cylinder_mesh_file.cdb" +ring_mesh_file = download_tech_demo_data("td-21", "ring_stiffened_cylinder_mesh_file.cdb") # read in cdb - mapdl.cdread("db", ring_mesh_file) mapdl.allsel() mapdl.eplot(background="w") @@ -251,10 +251,9 @@ # updating the geometry with mode shapes. The factor assumes the manufacturing # tolerance of the radius to be on the order of 0.1. mapdl.finish() -mapdl.filname('buckling') # change filename mapdl.prep7() for i in range(1,11): - mapdl.upgeom(0.1,1,i,'file','rst') # Add imperfections as a tenth of each + mapdl.upgeom(0.1,1,i,'buckling','rst') # Add imperfections as a tenth of each # mode shape mapdl.finish() #%% @@ -301,7 +300,7 @@ mapdl.antype('static','restart',1,10) mapdl.nsubst(100,50000,10) mapdl.rescontrol('define','last') -mapdl.stabilize('constant','energy',0.000144) # Use energy option +mapdl.stabilize('constant','energy',0.000143) # Use energy option output = mapdl.solve() print(output) mapdl.finish() From 41151960424ffd6546efa635602759b3a28dfad1 Mon Sep 17 00:00:00 2001 From: Pernelle Marone-Hitz Date: Mon, 26 Sep 2022 17:33:05 +0200 Subject: [PATCH 3/6] Correct style check --- .../techdemo-21/21-example-technology-showcase-buckling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py index 2b70627f4c9..697b7e0b58f 100644 --- a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py +++ b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py @@ -377,4 +377,4 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -#mapdl.exit() \ No newline at end of file +mapdl.exit() \ No newline at end of file From de720c41a03003766f9cd5c118f1e9741237851f Mon Sep 17 00:00:00 2001 From: Pernelle Marone-Hitz Date: Wed, 5 Oct 2022 11:39:27 +0200 Subject: [PATCH 4/6] Exit MAPDL properly --- .../techdemo-21/21-example-technology-showcase-buckling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py index 697b7e0b58f..b88d25faf61 100644 --- a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py +++ b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py @@ -375,6 +375,6 @@ ############################################################################### # Exit MAPDL # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# +# Exit MAPDL instance mapdl.exit() \ No newline at end of file From 7747d26d8289da7653826d5bcc4e6c7a520224a3 Mon Sep 17 00:00:00 2001 From: Pernelle Marone-Hitz Date: Wed, 5 Oct 2022 15:23:36 +0200 Subject: [PATCH 5/6] Litting --- ...21-example-technology-showcase-buckling.py | 350 +++++++++--------- 1 file changed, 172 insertions(+), 178 deletions(-) diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py index b88d25faf61..6c501f9bb22 100644 --- a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py +++ b/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py @@ -12,19 +12,14 @@ ====================================================== This examples shows how to use PyMAPDL to import an existing FE model and to -perform a nonlinear buckling and postbuckling analysis using nonlinear -stabilization. The problem uses a stiffened cylinder subjected to uniform -external pressure to show how to find the nonlinear buckling loads, +perform a nonlinear buckling and postbuckling analysis using nonlinear +stabilization. The problem uses a stiffened cylinder subjected to uniform +external pressure to show how to find the nonlinear buckling loads, achieve convergence at the post-buckling stage, and interpret the results. This example is inspired from the model and analysis defined in Chapter 21 of the Mechanical APDL Technology Showcase Manual. -Additional Packages Used ------------------------- - -* `Matplotlib `_ is used for plotting purposes. - """ ############################################################################### @@ -33,85 +28,86 @@ # # The original FE model is given in the Ansys Mechanical APDL Technology # Showcase Manual. The .cdb contains a FE model of a ring-stiffened cylinder. -# -# A circular cylinder made of bare 2024-T3 aluminum alloy is stiffened inside +# +# A circular cylinder made of bare 2024-T3 aluminum alloy is stiffened inside # with five Z-section rings. Its ends are closed with thick aluminum bulkheads. -# A riveted L section exists between the top plate and the top ring and the +# A riveted L section exists between the top plate and the top ring and the # bottom plate and bottom ring. # The cylinder is subjected to a differential external pressure. The pressure -# causes a local buckling phenomenon characterized by buckling of the skin -# between stiffening rings, leading eventually to collapse. +# causes a local buckling phenomenon characterized by buckling of the skin +# between stiffening rings, leading eventually to collapse. # -# The finite element model of the ring stiffened cylinder is meshed with -# SHELL281 elements with an element size of 10 mm. The fine mesh is required -# for buckling analysis, and a full 360-degree model is necessary because +# The finite element model of the ring stiffened cylinder is meshed with +# SHELL281 elements with an element size of 10 mm. The fine mesh is required +# for buckling analysis, and a full 360-degree model is necessary because # the deformation is no longer axisymmetric after buckling occurs. # # All shell elements have uniform thickness. Five sections are created in the -# model with no offsets, so the shell sections are offset to the midplane +# model with no offsets, so the shell sections are offset to the midplane # by default. # # Starting MAPDL as a service and importing an external model # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # -import matplotlib.pyplot as plt from ansys.mapdl.core import launch_mapdl from ansys.mapdl.core.examples import download_tech_demo_data # define geometric parameters -bs=95.3 # Ring spacing (mm) -ts=1.034 # Skin thickness (mm) -tw=0.843 # Ring thickness (mm) -r=344*ts # Radius of cylinder (mm) -L=431.8+2*(19-9.5) # Length of cylinder (mm) -pext=0.24 # Differential external pressure (MPa) +bs = 95.3 # Ring spacing (mm) +ts = 1.034 # Skin thickness (mm) +tw = 0.843 # Ring thickness (mm) +r = 344 * ts # Radius of cylinder (mm) +L = 431.8 + 2 * (19 - 9.5) # Length of cylinder (mm) +pext = 0.24 # Differential external pressure (MPa) # start MAPDL as a service mapdl = launch_mapdl() print(mapdl) -mapdl.filname('buckling') # change filename +mapdl.filname("buckling") # change filename # mapdl.nerr(nmerr=200, nmabt=10000, abort=-1, ifkey=0, num=0) # enter preprocessor mapdl.prep7() # define material properties for 2024-T3 Alluminum alloy -EX=73000 # Young's Modulus (MPA) -ET=73 # Tangent modulus -mapdl.mp('ex',1,EX) # Young's Modulus (MPA) -mapdl.mp('prxy',1,0.33 ) # Poisson's ratio -EP=EX*ET/(EX-ET) -mapdl.tb('biso',1) -mapdl.tbdata(1,268.9,EP) +EX = 73000 # Young's Modulus (MPA) +ET = 73 # Tangent modulus +mapdl.mp("ex", 1, EX) # Young's Modulus (MPA) +mapdl.mp("prxy", 1, 0.33) # Poisson's ratio +EP = EX * ET / (EX - ET) +mapdl.tb("biso", 1) +mapdl.tbdata(1, 268.9, EP) # create material plot -mapdl.show('png') -mapdl.tbplot('biso',1) -mapdl.show('close') +mapdl.show("png") +mapdl.tbplot("biso", 1) +mapdl.show("close") # define shell elements and their sections -mapdl.et(1,181) +mapdl.et(1, 181) # cylinder -mapdl.sectype(1,'shell') -mapdl.secdata(ts,1) +mapdl.sectype(1, "shell") +mapdl.secdata(ts, 1) # L -mapdl.sectype(2,'shell') -mapdl.secdata(ts+1.64,1) +mapdl.sectype(2, "shell") +mapdl.secdata(ts + 1.64, 1) # Z shaped ring stiffener -mapdl.sectype(3,'shell') -mapdl.secdata(tw,1) +mapdl.sectype(3, "shell") +mapdl.secdata(tw, 1) # Plate at z=0 with thickness=25 mm -mapdl.sectype(4,'shell') -mapdl.secdata(25,1) +mapdl.sectype(4, "shell") +mapdl.secdata(25, 1) # Plate at z=L with thickness=25 mm -mapdl.sectype(5,'shell') -mapdl.secdata(25,1) +mapdl.sectype(5, "shell") +mapdl.secdata(25, 1) # read model of stiffened cylinder # download the cdb file -ring_mesh_file = download_tech_demo_data("td-21", "ring_stiffened_cylinder_mesh_file.cdb") +ring_mesh_file = download_tech_demo_data( + "td-21", "ring_stiffened_cylinder_mesh_file.cdb" +) # read in cdb mapdl.cdread("db", ring_mesh_file) @@ -122,70 +118,70 @@ ############################################################################### # Define static prestress analysis # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Displacement boundary conditions are defined to prevent the six rigid body -# motions. A total of six displacements are therefore applied to three nodes -# located on the top plate at 0, 90, and 270 degrees; the nodes are restricted -# so that all rigid translations and rotations are not possible for the +# Displacement boundary conditions are defined to prevent the six rigid body +# motions. A total of six displacements are therefore applied to three nodes +# located on the top plate at 0, 90, and 270 degrees; the nodes are restricted +# so that all rigid translations and rotations are not possible for the # cylinder. # -# Loading consists of a uniformly distributed external differential +# Loading consists of a uniformly distributed external differential # pressure: Pext = 0.24 MPa -mapdl.csys(1) # activate cylindrical coordinate system +mapdl.csys(1) # activate cylindrical coordinate system # Define pressure on plate at z=0 -mapdl.nsel('s','loc','z',0) -mapdl.esln('s',1) -mapdl.sfe('all',2,'pres',1,pext) +mapdl.nsel("s", "loc", "z", 0) +mapdl.esln("s", 1) +mapdl.sfe("all", 2, "pres", 1, pext) mapdl.allsel() # Define pressure on the rim of plate at z=0 -mapdl.nsel('s','loc','z',0) -mapdl.nsel('r','loc','x',r-ts/2,760/2) -mapdl.esln('s',1) -mapdl.sfe('all',1,'pres',1,pext) +mapdl.nsel("s", "loc", "z", 0) +mapdl.nsel("r", "loc", "x", r - ts / 2, 760 / 2) +mapdl.esln("s", 1) +mapdl.sfe("all", 1, "pres", 1, pext) mapdl.allsel() # Define pressure on plate at z=L -mapdl.nsel('s','loc','z',L) -mapdl.esln('s',1) -mapdl.sfe('all',2,'pres',1,pext) +mapdl.nsel("s", "loc", "z", L) +mapdl.esln("s", 1) +mapdl.sfe("all", 2, "pres", 1, pext) mapdl.allsel() # Define pressure on the rim of plate at z=L -mapdl.nsel('s','loc','z',L) -mapdl.nsel('r','loc','x',r-ts/2,760/2) -mapdl.esln('s',1) -mapdl.sfe('all',1,'pres',1,pext) +mapdl.nsel("s", "loc", "z", L) +mapdl.nsel("r", "loc", "x", r - ts / 2, 760 / 2) +mapdl.esln("s", 1) +mapdl.sfe("all", 1, "pres", 1, pext) mapdl.allsel() # Define pressure on cylinder -mapdl.nsel('s','loc','x',r-ts/2) -mapdl.esln('s',1) -mapdl.sfe('all',2,'pres',1,pext) +mapdl.nsel("s", "loc", "x", r - ts / 2) +mapdl.esln("s", 1) +mapdl.sfe("all", 2, "pres", 1, pext) mapdl.allsel() # Define displacement BSs to avoid rigid body motion -mapdl.csys(0) # activate cartesian coordinate system -mapdl.nsel('s','loc','x',r-ts/2) -mapdl.nsel('r','loc','y',0) -mapdl.nsel('r','loc','z',0) -mapdl.d('all','ux',0) -mapdl.d('all','uy',0) -mapdl.d('all','uz',0) +mapdl.csys(0) # activate cartesian coordinate system +mapdl.nsel("s", "loc", "x", r - ts / 2) +mapdl.nsel("r", "loc", "y", 0) +mapdl.nsel("r", "loc", "z", 0) +mapdl.d("all", "ux", 0) +mapdl.d("all", "uy", 0) +mapdl.d("all", "uz", 0) mapdl.allsel() # -mapdl.nsel('s','loc','x',0) -mapdl.nsel('r','loc','y',r-ts/2) -mapdl.nsel('r','loc','z',0) -mapdl.d('all','uz',0) +mapdl.nsel("s", "loc", "x", 0) +mapdl.nsel("r", "loc", "y", r - ts / 2) +mapdl.nsel("r", "loc", "z", 0) +mapdl.d("all", "uz", 0) mapdl.allsel() # -mapdl.nsel('s','loc','x',0) -mapdl.nsel('r','loc','y',-(r-ts/2)) -mapdl.nsel('r','loc','z',0) -mapdl.d('all','uy',0) -mapdl.d('all','uz',0) +mapdl.nsel("s", "loc", "x", 0) +mapdl.nsel("r", "loc", "y", -(r - ts / 2)) +mapdl.nsel("r", "loc", "z", 0) +mapdl.d("all", "uy", 0) +mapdl.d("all", "uz", 0) mapdl.allsel() # @@ -194,89 +190,86 @@ # Solve static prestress analysis mapdl.slashsolu() -mapdl.pstres('on') -mapdl.antype('STATIC') +mapdl.pstres("on") +mapdl.antype("STATIC") output = mapdl.solve() print(output) # Plot total deformation mapdl.post1() -mapdl.set('last') -mapdl.post_processing.plot_nodal_displacement('NORM', - smooth_shading=True) +mapdl.set("last") +mapdl.post_processing.plot_nodal_displacement("NORM", smooth_shading=True) #%% ############################################################################### # Run linear buckling analysis # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# This preliminary analysis predicts the theoretical buckling pressure of the +# This preliminary analysis predicts the theoretical buckling pressure of the # ideal linear elastic structure (perfect cylinder) and the buckled mode shapes # used in the next step to generate the imperfections. -# It is also an efficient way to check the completeness and +# It is also an efficient way to check the completeness and # correctness of modeling. # To run the linear buckling analysis, a static solution with prestress effects -# must be obtained, followed by the eigenvalue buckling solution using the +# must be obtained, followed by the eigenvalue buckling solution using the # Block Lanczos method and mode expansion. # Define and solve linear buckling analysis mapdl.slashsolu() -mapdl.outres('all','all') -mapdl.antype('BUCKLE') -mapdl.bucopt('lanb','10') +mapdl.outres("all", "all") +mapdl.antype("BUCKLE") +mapdl.bucopt("lanb", "10") mapdl.mxpand(10) output = mapdl.solve() print(output) # Plot total deformation of first and 10th mode mapdl.post1() -mapdl.set(1,1) -mapdl.post_processing.plot_nodal_displacement('NORM', - smooth_shading=True) -mapdl.set(1,10) -mapdl.post_processing.plot_nodal_displacement('NORM', - smooth_shading=True) +mapdl.set(1, 1) +mapdl.post_processing.plot_nodal_displacement("NORM", smooth_shading=True) +mapdl.set(1, 10) +mapdl.post_processing.plot_nodal_displacement("NORM", smooth_shading=True) #%% ############################################################################### # Generate imperfections # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# If a structure is perfectly symmetric, nonsymmetric buckling does not occur -# numerically, and a nonlinear buckling analysis fails because -# nonsymmetric buckling responses cannot be triggered. In this problem, +# If a structure is perfectly symmetric, nonsymmetric buckling does not occur +# numerically, and a nonlinear buckling analysis fails because +# nonsymmetric buckling responses cannot be triggered. In this problem, # the geometry, elements, and pressure are all axisymmetric. -# It is not possible, therefore, to simulate nonaxisymmetric buckling with -# the initial model. To overcome this problem, small geometric imperfections -# (similar to those caused by manufacturing a real structure) must be +# It is not possible, therefore, to simulate nonaxisymmetric buckling with +# the initial model. To overcome this problem, small geometric imperfections +# (similar to those caused by manufacturing a real structure) must be # introduced to trigger the buckling responses. -# Because the radius of the cylinder is 355.69 mm and the maximum -# displacement of a mode shape is 1 mm, a factor of 0.1 is applied when +# Because the radius of the cylinder is 355.69 mm and the maximum +# displacement of a mode shape is 1 mm, a factor of 0.1 is applied when # updating the geometry with mode shapes. The factor assumes the manufacturing -# tolerance of the radius to be on the order of 0.1. +# tolerance of the radius to be on the order of 0.1. mapdl.finish() mapdl.prep7() -for i in range(1,11): - mapdl.upgeom(0.1,1,i,'buckling','rst') # Add imperfections as a tenth of each - # mode shape +for i in range(1, 11): + mapdl.upgeom(0.1, 1, i, "buckling", "rst") # Add imperfections as a tenth of each + # mode shape mapdl.finish() #%% ############################################################################### # Run nonlinear static analysis on geometry with imperfections # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# The nonlinear buckling analysis is a static analysis performed after adding -# imperfections with large deflection active (NLGEOM,ON), extended to a point +# The nonlinear buckling analysis is a static analysis performed after adding +# imperfections with large deflection active (NLGEOM,ON), extended to a point # where the stiffened cylinder can reach its limit load. -# To perform the analysis, the load must be allowed to increase using very -# small time increments so that the expected critical buckling load can +# To perform the analysis, the load must be allowed to increase using very +# small time increments so that the expected critical buckling load can # be predicted accurately. # Note - as this is a buckling analysis, divergence is expected. mapdl.slashsolu() -mapdl.antype('STATIC') -mapdl.nlgeom('on') -mapdl.pred('on') +mapdl.antype("STATIC") +mapdl.nlgeom("on") +mapdl.pred("on") mapdl.time(1) -mapdl.nsubst(100,10000,10) -mapdl.rescontrol('define','all',1) -mapdl.outres('all','all') -mapdl.ncnv(2) # Do not terminate the program execution if the solution diverges +mapdl.nsubst(100, 10000, 10) +mapdl.rescontrol("define", "all", 1) +mapdl.outres("all", "all") +mapdl.ncnv(2) # Do not terminate the program execution if the solution diverges output = mapdl.solve() print(output) mapdl.finish() @@ -285,22 +278,22 @@ ############################################################################### # Post-buckling analysis # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# An unconverged solution of the nonlinear static analysis could mean that -# buckling has occurred. In this example, the change in time (or load) -# increment, and displacement value, occurs between substeps 10 and 11, -# which corresponds to TIME = 0.51781 and TIME = 0.53806 and to a pressure +# An unconverged solution of the nonlinear static analysis could mean that +# buckling has occurred. In this example, the change in time (or load) +# increment, and displacement value, occurs between substeps 10 and 11, +# which corresponds to TIME = 0.51781 and TIME = 0.53806 and to a pressure # between 0.124 MPa and 0.129 MPa. It is therefore very likely that buckling -# occurred at this time; to be sure, the analysis is continued. The goal is to -# verify the assessment made at this stage by obtaining the load-displacement -# behavior over a larger range. Because the post-buckling state is unstable, -# special techniques are necessary to compensate, in this case, nonlinear +# occurred at this time; to be sure, the analysis is continued. The goal is to +# verify the assessment made at this stage by obtaining the load-displacement +# behavior over a larger range. Because the post-buckling state is unstable, +# special techniques are necessary to compensate, in this case, nonlinear # stabilization is used. -mapdl.slashsolu() # Restart analysis with stabilization -mapdl.antype('static','restart',1,10) -mapdl.nsubst(100,50000,10) -mapdl.rescontrol('define','last') -mapdl.stabilize('constant','energy',0.000143) # Use energy option +mapdl.slashsolu() # Restart analysis with stabilization +mapdl.antype("static", "restart", 1, 10) +mapdl.nsubst(100, 50000, 10) +mapdl.rescontrol("define", "last") +mapdl.stabilize("constant", "energy", 0.000143) # Use energy option output = mapdl.solve() print(output) mapdl.finish() @@ -309,66 +302,67 @@ ############################################################################### # Postprocess buckling analysis in POST1 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# +# mapdl.post1() -mapdl.set('last') -mapdl.post_processing.plot_nodal_displacement('NORM', - smooth_shading=True) +mapdl.set("last") +mapdl.post_processing.plot_nodal_displacement("NORM", smooth_shading=True) mapdl.post_processing.plot_nodal_eqv_stress() mapdl.finish() #%% ############################################################################### # Postprocess buckling analysis in POST26 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# +# mapdl.post26() -mapdl.numvar(100) # allow storage for 100 variables -mapdl.enersol(13,'sene') # store stiffness energy -mapdl.enersol(14,'sten') # store artificial stabilization energy +mapdl.numvar(100) # allow storage for 100 variables +mapdl.enersol(13, "sene") # store stiffness energy +mapdl.enersol(14, "sten") # store artificial stabilization energy # time history plot of stiffness and stabilization energies -mapdl.show('png') -mapdl.plvar(13,14) -mapdl.show('close') +mapdl.show("png") +mapdl.plvar(13, 14) +mapdl.show("close") # pressure versus axial shortening for some nodes under the upper ring -mapdl.nsol(2,67319,'U','Z','UZ1') -mapdl.prod(ir=3, ia=2, ib='', ic='', name='strain1', facta='', factb='', factc=-1/431.8) -mapdl.prod(ir=12, ia=1, ib='', ic='', name='Load', facta='', factb='', factc=0.24) +mapdl.nsol(2, 67319, "U", "Z", "UZ1") +mapdl.prod( + ir=3, ia=2, ib="", ic="", name="strain1", facta="", factb="", factc=-1 / 431.8 +) +mapdl.prod(ir=12, ia=1, ib="", ic="", name="Load", facta="", factb="", factc=0.24) mapdl.xvar(3) -mapdl.show('png') -mapdl.xrange(0.01) -mapdl.yrange(0.24) -mapdl.axlab('X','Axial Shortening') -mapdl.aylab('Y','Applied Pressure ') +mapdl.show("png") +mapdl.xrange(0.01) +mapdl.yrange(0.24) +mapdl.axlab("X", "Axial Shortening") +mapdl.aylab("Y", "Applied Pressure ") mapdl.plvar(12) -mapdl.show('close') +mapdl.show("close") mapdl.xvar(3) -mapdl.show('png') -mapdl.xrange(0.002) -mapdl.yrange(1) -mapdl.axlab('X','Axial Shortening') -mapdl.aylab('Y','Time') +mapdl.show("png") +mapdl.xrange(0.002) +mapdl.yrange(1) +mapdl.axlab("X", "Axial Shortening") +mapdl.aylab("Y", "Time") mapdl.plvar(1) -mapdl.show('close') +mapdl.show("close") # pressure versus radial displacement for the node with max. deformation -mapdl.nsol(6,65269,'U','Y','UY_1') -mapdl.prod(ir=7, ia=6, ib=6, ic='', name='UY2_1') -mapdl.nsol(8,65269,'U','X','UX_1') -mapdl.prod(ir=9, ia=8, ib=8, ic='', name='UX2_1') -mapdl.add(10,7,9,'sum') -mapdl.sqrt(ir=11, ia=10, name='Urad') +mapdl.nsol(6, 65269, "U", "Y", "UY_1") +mapdl.prod(ir=7, ia=6, ib=6, ic="", name="UY2_1") +mapdl.nsol(8, 65269, "U", "X", "UX_1") +mapdl.prod(ir=9, ia=8, ib=8, ic="", name="UX2_1") +mapdl.add(10, 7, 9, "sum") +mapdl.sqrt(ir=11, ia=10, name="Urad") mapdl.xvar(11) -mapdl.show('png') -mapdl.xrange(4) -mapdl.yrange(0.24) -mapdl.axlab('X','Radial Displacement') -mapdl.aylab('Y','Applied Pressure') +mapdl.show("png") +mapdl.xrange(4) +mapdl.yrange(0.24) +mapdl.axlab("X", "Radial Displacement") +mapdl.aylab("Y", "Applied Pressure") mapdl.plvar(12) -mapdl.show('close') +mapdl.show("close") mapdl.finish() #%% @@ -377,4 +371,4 @@ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Exit MAPDL instance -mapdl.exit() \ No newline at end of file +mapdl.exit() From 47156d0d52624aa68189b79da5d874d33840338d Mon Sep 17 00:00:00 2001 From: German Date: Fri, 21 Oct 2022 12:31:25 +0200 Subject: [PATCH 6/6] moving techdemo to examples --- .../00-mapdl-examples}/21-example-technology-showcase-buckling.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {doc/source/examples/technology_showcase_examples/techdemo-21 => examples/00-mapdl-examples}/21-example-technology-showcase-buckling.py (100%) diff --git a/doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py b/examples/00-mapdl-examples/21-example-technology-showcase-buckling.py similarity index 100% rename from doc/source/examples/technology_showcase_examples/techdemo-21/21-example-technology-showcase-buckling.py rename to examples/00-mapdl-examples/21-example-technology-showcase-buckling.py