MAPDL 3D Beam ExampleΒΆ

This is a simple example that loads an archive file containing a beam and then runs a modal analysis using the simplified modal_analysis method.

First, start by launching MAPDL as a service.

from ansys.mapdl.reader import examples
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()

# load a beam stored as an example archive file and mesh it
mapdl.cdread('db', examples.hexarchivefile)
mapdl.esel('s', 'ELEM', vmin=5, vmax=20)
mapdl.cm('ELEM_COMP', 'ELEM')
mapdl.nsel('s', 'NODE', vmin=5, vmax=20)
mapdl.cm('NODE_COMP', 'NODE')

# boundary conditions
mapdl.allsel()

# dummy steel properties
mapdl.prep7()
mapdl.mp('EX', 1, 200E9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp('DENS', 1, 7800)  # Density in kg/m3
mapdl.mp('NUXY', 1, 0.3)  # Poissons Ratio
mapdl.emodif('ALL', 'MAT', 1)

# fix one end of the beam
mapdl.nsel('S', 'LOC', 'Z')
mapdl.d('all', 'all')
mapdl.allsel()

mapdl.mxpand(elcalc='YES')
mapdl.modal_analysis(nmode=6)

Out:

'*****  ANSYS SOLVE    COMMAND  *****\n\n *** NOTE ***                            CP =      87.655   TIME= 04:18:33\n There is no title defined for this analysis.                            \n\n *** SELECTION OF ELEMENT TECHNOLOGIES FOR APPLICABLE ELEMENTS ***\n                ---GIVE SUGGESTIONS ONLY---\n\n ELEMENT TYPE         1 IS SOLID186. KEYOPT(2) IS ALREADY SET AS SUGGESTED.\n\n\n\n *** ANSYS - ENGINEERING ANALYSIS SYSTEM  RELEASE 2021 R2          21.2BETA ***\n Ansys Mechanical Enterprise                       \n 00000000  VERSION=LINUX x64     04:18:33  AUG 26, 2021 CP=     87.655\n\n                                                                               \n\n\n\n ** WARNING: PRE-RELEASE VERSION OF ANSYS 21.2BETA\n  ANSYS,INC TESTING IS NOT COMPLETE - CHECK RESULTS CAREFULLY **\n\n                       S O L U T I O N   O P T I O N S\n\n   PROBLEM DIMENSIONALITY. . . . . . . . . . . . .3-D                  \n   DEGREES OF FREEDOM. . . . . . UX   UY   UZ  \n   ANALYSIS TYPE . . . . . . . . . . . . . . . . .MODAL                \n      EXTRACTION METHOD. . . . . . . . . . . . . .BLOCK LANCZOS\n   NUMBER OF MODES TO EXTRACT. . . . . . . . . . .     6\n   GLOBALLY ASSEMBLED MATRIX . . . . . . . . . . .SYMMETRIC  \n   NUMBER OF MODES TO EXPAND . . . . . . . . . . .ALL\n   ELEMENT RESULTS CALCULATION . . . . . . . . . .ON \n\n *** NOTE ***                            CP =      87.655   TIME= 04:18:33\n The conditions for direct assembly have been met.  No .emat or .erot    \n files will be produced.                                                 \n\n                      L O A D   S T E P   O P T I O N S\n\n   LOAD STEP NUMBER. . . . . . . . . . . . . . . .     1\n   THERMAL STRAINS INCLUDED IN THE LOAD VECTOR . .   YES\n   PRINT OUTPUT CONTROLS . . . . . . . . . . . . .NO PRINTOUT\n   DATABASE OUTPUT CONTROLS. . . . . . . . . . . .ALL DATA WRITTEN\n\n\n\n                         ***********  PRECISE MASS SUMMARY  ***********\n\n   TOTAL RIGID BODY MASS MATRIX ABOUT ORIGIN\n               Translational mass               |   Coupled translational/rotational mass\n         39000.        0.0000        0.0000     |     0.0000        97500.       -19500.    \n         0.0000        39000.        0.0000     |    -97500.        0.0000        19500.    \n         0.0000        0.0000        39000.     |     19500.       -19500.        0.0000    \n     ------------------------------------------ | ------------------------------------------\n                                                |         Rotational mass (inertia)\n                                                |    0.33800E+06   -9750.0       -48750.    \n                                                |    -9750.0       0.33800E+06   -48750.    \n                                                |    -48750.       -48750.        26000.    \n\n   TOTAL MASS =  39000.    \n     The mass principal axes coincide with the global Cartesian axes\n\n   CENTER OF MASS (X,Y,Z)=   0.50000       0.50000        2.5000    \n\n   TOTAL INERTIA ABOUT CENTER OF MASS\n         84500.      -0.92371E-11  -0.79876E-10\n       -0.92371E-11    84500.      -0.32069E-10\n       -0.79876E-10  -0.32069E-10    6500.0    \n     The inertia principal axes coincide with the global Cartesian axes\n\n\n  *** MASS SUMMARY BY ELEMENT TYPE ***\n\n  TYPE      MASS\n     1   39000.0    \n\n Range of element maximum matrix coefficients in global coordinates\n Maximum = 9.116809117E+10 at element 32.                                \n Minimum = 9.116809117E+10 at element 4.                                 \n\n   *** ELEMENT MATRIX FORMULATION TIMES\n     TYPE    NUMBER   ENAME      TOTAL CP  AVE CP\n\n        1        40  SOLID186      0.016   0.000390\n Time at end of element matrix formulation CP = 87.677742.               \n\n  BLOCK LANCZOS CALCULATION OF UP TO     6 EIGENVECTORS.\n  NUMBER OF EQUATIONS              =          900\n  MAXIMUM WAVEFRONT                =          174\n  MAXIMUM MODES STORED             =            6\n  MINIMUM EIGENVALUE               =  0.00000E+00\n  MAXIMUM EIGENVALUE               =  0.10000E+31\n\n  Memory allocated for solver              =     2.263 MB\n  Memory required for in-core solution     =     2.159 MB\n  Memory required for out-of-core solution =     1.369 MB\n\n *** NOTE ***                            CP =      87.724   TIME= 04:18:33\n The Sparse Matrix Solver used by the Block Lanczos eigensolver is       \n currently running in the in-core memory mode.  This memory mode uses    \n the most amount of memory in order to avoid using the hard drive as     \n much as possible, which most often results in the fastest solution      \n time.  This mode is recommended if enough physical memory is present    \n to accommodate all of the solver data.                                  \n\n *** ANSYS - ENGINEERING ANALYSIS SYSTEM  RELEASE 2021 R2          21.2BETA ***\n Ansys Mechanical Enterprise                       \n 00000000  VERSION=LINUX x64     04:18:33  AUG 26, 2021 CP=     87.792\n\n                                                                               \n\n\n\n ** WARNING: PRE-RELEASE VERSION OF ANSYS 21.2BETA\n  ANSYS,INC TESTING IS NOT COMPLETE - CHECK RESULTS CAREFULLY **\n\n *** FREQUENCIES FROM BLOCK LANCZOS ITERATION ***\n\n  MODE    FREQUENCY (HERTZ)      \n\n\n    1     32.13951614478    \n    2     32.13951614483    \n    3     145.4783895431    \n    4     173.4557943042    \n    5     173.4557943042    \n    6     254.8511237205    \n\n\n *** ANSYS BINARY FILE STATISTICS\n  BUFFER SIZE USED= 16384\n        0.750 MB WRITTEN ON ASSEMBLED MATRIX FILE: file.full\n        0.062 MB WRITTEN ON MODAL MATRIX FILE: file.mode\n        0.312 MB WRITTEN ON RESULTS FILE: file.rst'

View the results using the pyansys result object

result = mapdl.result
print(result)

Out:

PyMAPDL Result
Units       : User Defined
Version     : 21.2
Cyclic      : False
Result Sets : 6
Nodes       : 321
Elements    : 40


Available Results:
EMS : Miscellaneous summable items (normally includes face pressures)
ENF : Nodal forces
ENS : Nodal stresses
ENG : Element energies and volume
EEL : Nodal elastic strains
ETH : Nodal thermal strains (includes swelling strains)
EUL : Element euler angles
EPT : Nodal temperatures
NSL : Nodal displacements
RF  : Nodal reaction forces

Access nodal displacement values

nnum, disp = result.nodal_displacement(0)

# print the nodes 50 - 59
for i in range(49, 59):
    print(nnum[i], disp[i])

Out:

50 [-0.00111018  0.00212727  0.00132799]
51 [-0.00134529  0.00259955  0.00142809]
52 [-0.00159593  0.00310205  0.00151419]
53 [-0.00185973  0.00363011  0.00158671]
54 [-0.00213448  0.0041793   0.00164654]
55 [-0.00241804  0.00474535  0.0016944 ]
56 [-0.00270851  0.0053244   0.00173145]
57 [-0.00300408  0.00591281  0.00175865]
58 [-0.00330322  0.00650749  0.00177741]
59 [-0.00360454  0.00710562  0.00178894]

Plot a modal result

result.plot_nodal_displacement(0, show_edges=True)
mapdl 3d beam

Out:

[(6.295554957734411, 6.295554957734411, 8.29555495773441),
 (0.5, 0.5, 2.5),
 (0.0, 0.0, 1.0)]

Animate a modal result result.animate_nodal_solution(0, show_edges=True, loop=False, displacement_factor=10,

# movie_filename='demo.gif')

Total running time of the script: ( 0 minutes 0.961 seconds)

Gallery generated by Sphinx-Gallery